From ee07bd8c0f43e502f40074c8e9edee862c50cc36 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 9 Dec 2024 23:30:22 +0000 Subject: [PATCH] Revert "Better handle cultist rewards not fitting the container (#979)" This reverts commit 8d05bf0069b22968d7e4fcdc4901ae0babd948c3, reversing changes made to d5ce6c4d709f000972ae9f9fdb596eba98184f29. --- .../src/services/CircleOfCultistService.ts | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/project/src/services/CircleOfCultistService.ts b/project/src/services/CircleOfCultistService.ts index 7240c9e6..7f82647e 100644 --- a/project/src/services/CircleOfCultistService.ts +++ b/project/src/services/CircleOfCultistService.ts @@ -124,7 +124,7 @@ export class CircleOfCultistService { } } - let rewards = hasDirectReward + const rewards = hasDirectReward ? this.getDirectRewards(sessionId, directRewardSettings, cultistCircleStashId) : this.getRewardsWithinBudget( this.getCultistCircleRewardPool(sessionId, pmcData, craftingInfo, this.hideoutConfig.cultistCircle), @@ -138,28 +138,27 @@ export class CircleOfCultistService { // Ensure rewards fit into container const containerGrid = this.inventoryHelper.getContainerSlotMap(cultistStashDbItem[1]._id); - let canAddToContainer = false; - while (!canAddToContainer && rewards.length > 0) { - canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer( - this.cloner.clone(containerGrid), // MUST clone grid before passing in as function modifies grid - rewards, - ); + const canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer( + this.cloner.clone(containerGrid), // MUST clone grid before passing in as function modifies grid + rewards, + ); - if (canAddToContainer) { - for (const itemToAdd of rewards) { - this.inventoryHelper.placeItemInContainer( - containerGrid, - itemToAdd, - cultistCircleStashId, - CircleOfCultistService.circleOfCultistSlotId, - ); - // Add item + mods to output and profile inventory - output.profileChanges[sessionId].items.new.push(...itemToAdd); - pmcData.Inventory.items.push(...itemToAdd); - } - } else { - rewards.pop(); + if (canAddToContainer) { + for (const itemToAdd of rewards) { + this.inventoryHelper.placeItemInContainer( + containerGrid, + itemToAdd, + cultistCircleStashId, + CircleOfCultistService.circleOfCultistSlotId, + ); + // Add item + mods to output and profile inventory + output.profileChanges[sessionId].items.new.push(...itemToAdd); + pmcData.Inventory.items.push(...itemToAdd); } + } else { + this.logger.error( + `Unable to fit all: ${rewards.length} reward items into sacrifice grid, nothing will be returned (rewards so valuable cultists stole it)`, + ); } return output;