返回提交历史
Modified
src/services/serversideVendorsService.ts
+12
-1
XFEstudio/SpaceNinjaServer
chore: handle vendor per-item count limits (#2084)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2084 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
ce59086f
代码差异
1 个文件
+12
-1
@@ -270,11 +270,22 @@ const generateVendorManifest = (vendorInfo: IGeneratableVendorInfo): IVendorMani
270
270
manifest.items.length != manifest.numItems.minValue) &&
271
271
!manifest.isOneBinPerCycle
272
272
) {
273
const remainingItemCapacity: Record<string, number> = {};
274
for (const item of manifest.items) {
275
remainingItemCapacity[item.storeItem] = 1 + item.duplicates;
276
}
277
for (const offer of info.ItemManifest) {
278
remainingItemCapacity[offer.StoreItem] -= 1;
279
}
273
280
const numItemsTarget = rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue);
274
281
while (info.ItemManifest.length + offersToAdd.length < numItemsTarget) {
275
282
// TODO: Consider per-bin item limits
276
283
// TODO: Consider item probability weightings
277
offersToAdd.push(rng.randomElement(manifest.items)!);
284
const item = rng.randomElement(manifest.items)!;
285
if (remainingItemCapacity[item.storeItem] != 0) {
286
remainingItemCapacity[item.storeItem] -= 1;
287
offersToAdd.push(item);
288
}
278
289
}
279
290
} else {
280
291
let binThisCycle;