From ded71427740dc23db63063d0b50c598fe2f75b25 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 22 Feb 2024 13:55:57 +0000 Subject: [PATCH] Comment improvement --- project/src/generators/BotLootGenerator.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/project/src/generators/BotLootGenerator.ts b/project/src/generators/BotLootGenerator.ts index 355f2767..d3eb01d7 100644 --- a/project/src/generators/BotLootGenerator.ts +++ b/project/src/generators/BotLootGenerator.ts @@ -407,18 +407,24 @@ export class BotLootGenerator const addCurrency = this.randomUtil.getChance100(25); if (addCurrency) { + // Create the currency items we want to add to wallet const itemsToAdd = this.createWalletLoot(newRootItemId); - const stashFS2D = this.inventoryHelper.getContainerSlotMap(weightedItemTpl); + + // Get the container grid for the wallet + const containerGrid = this.inventoryHelper.getContainerSlotMap(weightedItemTpl); + + // Check if all the chosen currency items fit into wallet const canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer( - this.jsonUtil.clone(stashFS2D), + this.jsonUtil.clone(containerGrid), // MUST clone grid before passing in as function modifies grid itemsToAdd, ); if (canAddToContainer) { + // Add each currency to wallet for (const itemToAdd of itemsToAdd) { this.inventoryHelper.placeItemInContainer( - stashFS2D, + containerGrid, itemToAdd, itemWithChildrenToAdd[0]._id, );