From 8a68633d9c85df8fa984429d7276d113a71850e5 Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Mon, 9 May 2022 14:29:42 -0500 Subject: [PATCH] Throw an error when trying to charge stanek booster fragments --- src/NetscriptFunctions/Stanek.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NetscriptFunctions/Stanek.ts b/src/NetscriptFunctions/Stanek.ts index e80e2f6f3..d3be392d1 100644 --- a/src/NetscriptFunctions/Stanek.ts +++ b/src/NetscriptFunctions/Stanek.ts @@ -5,6 +5,7 @@ import { netscriptDelay } from "../NetscriptEvaluator"; import { staneksGift } from "../CotMG/Helper"; import { Fragments, FragmentById } from "../CotMG/Fragment"; +import { FragmentType } from "../CotMG/FragmentType"; import { Fragment as IFragment, @@ -42,11 +43,19 @@ export function NetscriptStanek( }, chargeFragment: (_ctx: NetscriptContext) => function (_rootX: unknown, _rootY: unknown): Promise { + //Get the fragment object using the given coordinates const rootX = _ctx.helper.number("rootX", _rootX); const rootY = _ctx.helper.number("rootY", _rootY); checkStanekAPIAccess("chargeFragment"); const fragment = staneksGift.findFragment(rootX, rootY); + //Check whether the selected fragment can ge charged if (!fragment) throw _ctx.makeRuntimeErrorMsg(`No fragment with root (${rootX}, ${rootY}).`); + if (fragment.fragment().type == FragmentType.Booster) { + throw _ctx.makeRuntimeErrorMsg( + `The fragment with root (${rootX}, ${rootY}) is a Booster Fragment and thus cannot be charged.`, + ); + } + //Charge the fragment const time = staneksGift.inBonus() ? 200 : 1000; return netscriptDelay(time, workerScript).then(function () { const charge = staneksGift.charge(player, fragment, workerScript.scriptRef.threads);