From ca12bddaf5e1530670f433ffa4bcbda9d6395620 Mon Sep 17 00:00:00 2001 From: TheAimMan <147098375+TheAimMan@users.noreply.github.com> Date: Mon, 30 Oct 2023 03:09:34 -0400 Subject: [PATCH] BUGFIX: Check Corp Research pre-reqs in research api call (#884) --- src/Corporation/Actions.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index 7cb1831fe..9e653a8e2 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -464,7 +464,16 @@ export function Research(researchingDivision: Division, researchName: CorpResear const researchTree = IndustryResearchTrees[researchingDivision.type]; if (researchTree === undefined) throw new Error(`No research tree for industry '${researchingDivision.type}'`); const research = ResearchMap[researchName]; - + const researchNode = researchTree.findNode(researchName); + const researchPreReq = researchNode?.parent?.researchName; + //Check to see if the research request has any pre-reqs that need to be researched first. + if (researchPreReq) { + if (!researchingDivision.researched?.has(researchPreReq)) { + throw new Error( + `Division ${researchingDivision.name} requires ${researchPreReq} before researching ${research.name}`, + ); + } + } if (researchingDivision.researched.has(researchName)) return; if (researchingDivision.researchPoints < research.cost) { throw new Error(`You do not have enough Scientific Research for ${research.name}`);