forked from OpenWF/SpaceNinjaServer
		
	chore: handle vendor per-item count limits (#2084)
Reviewed-on: OpenWF/SpaceNinjaServer#2084 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									9b0989f1df
								
							
						
					
					
						commit
						ce59086f7d
					
				@ -270,11 +270,22 @@ const generateVendorManifest = (vendorInfo: IGeneratableVendorInfo): IVendorMani
 | 
			
		||||
                manifest.items.length != manifest.numItems.minValue) &&
 | 
			
		||||
            !manifest.isOneBinPerCycle
 | 
			
		||||
        ) {
 | 
			
		||||
            const remainingItemCapacity: Record<string, number> = {};
 | 
			
		||||
            for (const item of manifest.items) {
 | 
			
		||||
                remainingItemCapacity[item.storeItem] = 1 + item.duplicates;
 | 
			
		||||
            }
 | 
			
		||||
            for (const offer of info.ItemManifest) {
 | 
			
		||||
                remainingItemCapacity[offer.StoreItem] -= 1;
 | 
			
		||||
            }
 | 
			
		||||
            const numItemsTarget = rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue);
 | 
			
		||||
            while (info.ItemManifest.length + offersToAdd.length < numItemsTarget) {
 | 
			
		||||
                // TODO: Consider per-bin item limits
 | 
			
		||||
                // TODO: Consider item probability weightings
 | 
			
		||||
                offersToAdd.push(rng.randomElement(manifest.items)!);
 | 
			
		||||
                const item = rng.randomElement(manifest.items)!;
 | 
			
		||||
                if (remainingItemCapacity[item.storeItem] != 0) {
 | 
			
		||||
                    remainingItemCapacity[item.storeItem] -= 1;
 | 
			
		||||
                    offersToAdd.push(item);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            let binThisCycle;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user