From eb6baa5e1550be8e6ba3678745154afaffb568ca Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 6 Jan 2025 01:21:02 +0100 Subject: [PATCH] fix: removing an archon shard doesn't refund it (#729) --- .../api/infestedFoundryController.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/controllers/api/infestedFoundryController.ts b/src/controllers/api/infestedFoundryController.ts index ea35fa4d..04144475 100644 --- a/src/controllers/api/infestedFoundryController.ts +++ b/src/controllers/api/infestedFoundryController.ts @@ -52,14 +52,33 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { const request = getJSONfromString(String(req.body)) as IShardUninstallRequest; const inventory = await getInventory(accountId); const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!; + + // refund shard + const shard = Object.entries(colorToShard).find( + ([color]) => color == suit.ArchonCrystalUpgrades![request.Slot].Color + )![1]; + const miscItemChanges = [ + { + ItemType: shard, + ItemCount: 1 + } + ]; + addMiscItems(inventory, miscItemChanges); + + // remove from suit suit.ArchonCrystalUpgrades![request.Slot] = {}; + + // remove bile const bile = inventory.InfestedFoundry!.Resources!.find( x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile" )!; bile.Count -= 300; + await inventory.save(); + res.json({ InventoryChanges: { + MiscItems: miscItemChanges, InfestedFoundry: inventory.toJSON().InfestedFoundry } });