From f37e6dc668fcde6907797d2cb430416a0a2092d5 Mon Sep 17 00:00:00 2001 From: Sainan Date: Fri, 3 Jan 2025 02:38:46 +0100 Subject: [PATCH] avoid double-starting research --- src/controllers/api/guildTechController.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/controllers/api/guildTechController.ts b/src/controllers/api/guildTechController.ts index 951291c0..ff7f78f3 100644 --- a/src/controllers/api/guildTechController.ts +++ b/src/controllers/api/guildTechController.ts @@ -18,15 +18,17 @@ export const guildTechController: RequestHandler = async (req, res) => { } else if (data.Action == "Start") { const recipe = ExportDojoRecipes.research[data.RecipeType!]; guild.TechProjects ??= []; - guild.TechProjects.push({ - ItemType: data.RecipeType!, - ReqCredits: scaleRequiredCount(recipe.price), - ReqItems: recipe.ingredients.map(x => ({ - ItemType: x.ItemType, - ItemCount: scaleRequiredCount(x.ItemCount) - })), - State: 0 - }); + if (!guild.TechProjects.find(x => x.ItemType == data.RecipeType)) { + guild.TechProjects.push({ + ItemType: data.RecipeType!, + ReqCredits: scaleRequiredCount(recipe.price), + ReqItems: recipe.ingredients.map(x => ({ + ItemType: x.ItemType, + ItemCount: scaleRequiredCount(x.ItemCount) + })), + State: 0 + }); + } await guild.save(); res.end(); } else if (data.Action == "Contribute") {