Add errors and only change page when focus changes

This commit is contained in:
theit8514 2021-12-13 16:45:49 -05:00
parent 07d449afc2
commit 2726420709

@ -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 {