Update generateEquipment() to return true when it adds item

This commit is contained in:
Dev 2024-02-03 20:29:31 +00:00
parent 3c371a6c16
commit 714386c793

View File

@ -305,8 +305,9 @@ export class BotInventoryGenerator
/** /**
* Add a piece of equipment with mods to inventory from the provided pools * Add a piece of equipment with mods to inventory from the provided pools
* @param settings Values to adjust how item is chosen and added to bot * @param settings Values to adjust how item is chosen and added to bot
* @returns true when item added
*/ */
protected generateEquipment(settings: IGenerateEquipmentProperties): void protected generateEquipment(settings: IGenerateEquipmentProperties): boolean
{ {
const spawnChance = const spawnChance =
([EquipmentSlots.POCKETS, EquipmentSlots.SECURED_CONTAINER] as string[]).includes( ([EquipmentSlots.POCKETS, EquipmentSlots.SECURED_CONTAINER] as string[]).includes(
@ -323,7 +324,7 @@ export class BotInventoryGenerator
), ),
); );
return; return false;
} }
const shouldSpawn = this.randomUtil.getChance100(spawnChance); const shouldSpawn = this.randomUtil.getChance100(spawnChance);
@ -338,7 +339,7 @@ export class BotInventoryGenerator
{ {
if (Object.values(settings.rootEquipmentPool).length === 0) if (Object.values(settings.rootEquipmentPool).length === 0)
{ {
return; return false;
} }
const chosenItemTpl = this.weightedRandomHelper.getWeightedValue<string>(settings.rootEquipmentPool); const chosenItemTpl = this.weightedRandomHelper.getWeightedValue<string>(settings.rootEquipmentPool);
@ -367,7 +368,7 @@ export class BotInventoryGenerator
// Tried x different items that failed, stop // Tried x different items that failed, stop
if (attempts > maxAttempts) if (attempts > maxAttempts)
{ {
return; return false;
} }
// Remove picked item // Remove picked item
@ -422,7 +423,11 @@ export class BotInventoryGenerator
// No slots, push root item only // No slots, push root item only
settings.inventory.items.push(item); settings.inventory.items.push(item);
} }
return true;
} }
return false;
} }
/** /**