From 2726420709b492c491b8cb34bfeb0880247fc968 Mon Sep 17 00:00:00 2001 From: theit8514 Date: Mon, 13 Dec 2021 16:45:49 -0500 Subject: [PATCH] Add errors and only change page when focus changes --- src/NetscriptFunctions/Singularity.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index cd4574724..103d27a54 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -630,11 +630,18 @@ export function NetscriptSingularity( setFocus: function(focus: boolean): any { helper.updateDynamicRam("setFocus", getRamCost("setFocus")); helper.checkSingularityAccess("setFocus", 1); - if (focus === true) { + if (!player.isWorking) { + throw helper.makeRuntimeErrorMsg("setFocus", "Not currently working"); + } + if (!(player.workType == CONSTANTS.WorkTypeFaction || player.workType == CONSTANTS.WorkTypeCompany || player.workType == CONSTANTS.WorkTypeCompanyPartTime)) { + throw helper.makeRuntimeErrorMsg("setFocus", "Cannot change focus for current job"); + } + if (!player.focus && focus === true) { player.startFocusing(); Router.toWork(); - } else if (focus === false) { + } else if (player.focus && focus === false) { player.stopFocusing(); + Router.toTerminal(); } }, getStats: function (): any {