avoid duplicate entries in inventory.EvolutionProgress

This commit is contained in:
Sainan 2024-06-20 12:55:22 +02:00
parent 3c27f01ad2
commit dcdf03c9ce

View File

@ -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();