返回提交历史
Modified
src/services/serversideVendorsService.ts
+31
-14
XFEstudio/XFESpaceNinjaServer
chore: improve fully stocked vendors logic (#4353)
Closes #4352 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4353 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
d31a8555
代码差异
1 个文件
+31
-14
@@ -304,16 +304,18 @@ 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 (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) {
307
if (manifest.isOneBinPerCycle) {
308
if (fullStock) {
309
for (const rawItem of manifest.items) {
315
310
offersToAdd.push(rawItem);
316
311
}
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
}
317
319
}
318
320
} else {
319
321
// Compute vendor requirements, subtracting existing offers
@@ -365,15 +367,23 @@ const generateVendorManifest = (
365
367
manifest.numItems &&
366
368
(manifest.numItems.minValue != manifest.numItems.maxValue ||
367
369
manifest.numItems.minValue != numCountedOffers);
368
const numItemsTarget = manifest.numItems
370
const numItemsTarget = fullStock
369
371
? numUncountedOffers +
370
Math.min(
372
Math.max(
371
373
Object.values(remainingItemCapacity).reduce((a, b) => a + b, 0),
372
useRng
373
? rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue)
374
: manifest.numItems.minValue
374
numOffersThatNeedToMatchABin == 0
375
? 0
376
: Object.values(missingItemsPerBin).reduce((a, b) => a + b, 0)
375
377
)
376
: manifest.items.length;
378
: manifest.numItems
379
? numUncountedOffers +
380
Math.min(
381
Object.values(remainingItemCapacity).reduce((a, b) => a + b, 0),
382
useRng
383
? rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue)
384
: manifest.numItems.minValue
385
)
386
: manifest.items.length;
377
387
let i = 0;
378
388
const rollableOffers = manifest.items.filter(x => x.probability !== undefined) as (Omit<
379
389
IVendorOffer,
@@ -581,4 +591,11 @@ export const selfTestServersideVendors = (): void => {
581
591
"/Lotus/Types/Game/VendorManifests/Events/RadioLegionIntermission15VendorManifest",
582
592
true
583
593
);
594
// But this shouldn't be crazy. (Note that client may break even if item count is low if items are not generated well.)
595
if (
596
getVendorManifestByTypeName("/Lotus/Types/Game/VendorManifests/Duviri/AcrithisVendorManifest", true)!.VendorInfo
597
.ItemManifest.length > 200
598
) {
599
logger.warn(`self test failed for /Lotus/Types/Game/VendorManifests/Duviri/AcrithisVendorManifest`);
600
}
584
601
};