From dcdf03c9ceb6b753da93a79ed3abd51ed05998e6 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 12:55:22 +0200 Subject: [PATCH] avoid duplicate entries in inventory.EvolutionProgress --- src/controllers/api/evolveWeaponController.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/controllers/api/evolveWeaponController.ts b/src/controllers/api/evolveWeaponController.ts index b7339fcf..fea82844 100644 --- a/src/controllers/api/evolveWeaponController.ts +++ b/src/controllers/api/evolveWeaponController.ts @@ -21,11 +21,13 @@ export const evolveWeaponController: RequestHandler = async (req, res) => { item.SkillTree = "0"; inventory.EvolutionProgress ??= []; - inventory.EvolutionProgress.push({ - Progress: 0, - Rank: 1, - ItemType: payload.EvoType - }); + if (!inventory.EvolutionProgress.find(entry => entry.ItemType == payload.EvoType)) { + inventory.EvolutionProgress.push({ + Progress: 0, + Rank: 1, + ItemType: payload.EvoType + }); + } await inventory.save(); res.end();