返回提交历史
Modified
src/services/serversideVendorsService.ts
+23
-21
XFEstudio/SpaceNinjaServer
fix: simplify logic of fully stocked vendors (#4292)
Closes #4291 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4292 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
57e33c3e
代码差异
1 个文件
+23
-21
@@ -304,18 +304,16 @@ const generateVendorManifest = (
304
304
const cycleIndex = Math.trunc((now - cycleOffset) / cycleDuration);
305
305
const rng = new SRng(mixSeeds(vendorSeed, cycleIndex));
306
306
const offersToAdd: IVendorOffer[] = [];
307
if (manifest.isOneBinPerCycle) {
308
if (fullStock) {
309
for (const rawItem of manifest.items) {
307
if (fullStock) {
308
for (const rawItem of manifest.items) {
309
offersToAdd.push(rawItem);
310
}
311
} else if (manifest.isOneBinPerCycle) {
312
const binThisCycle = cycleIndex % 2; // Note: May want to check the actual number of bins, but this is only used for coda weapons right now.
313
for (const rawItem of manifest.items) {
314
if (rawItem.bin == binThisCycle) {
310
315
offersToAdd.push(rawItem);
311
316
}
312
} else {
313
const binThisCycle = cycleIndex % 2; // Note: May want to check the actual number of bins, but this is only used for coda weapons right now.
314
for (const rawItem of manifest.items) {
315
if (rawItem.bin == binThisCycle) {
316
offersToAdd.push(rawItem);
317
}
318
}
319
317
}
320
318
} else {
321
319
// Compute vendor requirements, subtracting existing offers
@@ -367,17 +365,15 @@ const generateVendorManifest = (
367
365
manifest.numItems &&
368
366
(manifest.numItems.minValue != manifest.numItems.maxValue ||
369
367
manifest.numItems.minValue != numCountedOffers);
370
const numItemsTarget = fullStock
371
? numUncountedOffers + numCountedOffers
372
: manifest.numItems
373
? numUncountedOffers +
374
Math.min(
375
Object.values(remainingItemCapacity).reduce((a, b) => a + b, 0),
376
useRng
377
? rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue)
378
: manifest.numItems.minValue
379
)
380
: manifest.items.length;
368
const numItemsTarget = manifest.numItems
369
? numUncountedOffers +
370
Math.min(
371
Object.values(remainingItemCapacity).reduce((a, b) => a + b, 0),
372
useRng
373
? rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue)
374
: manifest.numItems.minValue
375
)
376
: manifest.items.length;
381
377
let i = 0;
382
378
const rollableOffers = manifest.items.filter(x => x.probability !== undefined) as (Omit<
383
379
IVendorOffer,
@@ -579,4 +575,10 @@ export const selfTestServersideVendors = (): void => {
579
575
if (loid.length != 3) {
580
576
logger.warn(`self test failed for /Lotus/Types/Game/VendorManifests/EntratiLabs/EntratiLabsCommisionsManifest`);
581
577
}
578
579
// This should not produce an infinite loop.
580
getVendorManifestByTypeName(
581
"/Lotus/Types/Game/VendorManifests/Events/RadioLegionIntermission15VendorManifest",
582
true
583
);
582
584
};