From a23c55c7605f8fccacab2f9dde73c9f8060688cf Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Wed, 11 May 2022 15:51:54 -0500 Subject: [PATCH 1/2] Added a check to prevent doubling coding contract rewards --- src/Terminal/Terminal.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts index 5369a5907..db9daa67b 100644 --- a/src/Terminal/Terminal.ts +++ b/src/Terminal/Terminal.ts @@ -284,7 +284,7 @@ export class Terminal implements ITerminal { `Security decreased on '${server.hostname}' from ${numeralWrapper.formatSecurity( oldSec, )} to ${numeralWrapper.formatSecurity(newSec)} (min: ${numeralWrapper.formatSecurity(server.minDifficulty)})` + - ` and Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`, + ` and Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`, ); } @@ -330,8 +330,7 @@ export class Terminal implements ITerminal { this.print("Time to hack: " + (!isHacknet ? convertTimeMsToTimeElapsedString(hackingTime, true) : "N/A")); } this.print( - `Total money available on server: ${ - currServ instanceof Server ? numeralWrapper.formatMoney(currServ.moneyAvailable) : "N/A" + `Total money available on server: ${currServ instanceof Server ? numeralWrapper.formatMoney(currServ.moneyAvailable) : "N/A" }`, ); if (currServ instanceof Server) { @@ -463,6 +462,12 @@ export class Terminal implements ITerminal { this.contractOpen = true; const res = await contract.prompt(); + //Check if the contract still exists by the time the promise is fullfilled + if (serv.getContract(contractName) == null) { + this.contractOpen = false; + return this.error("Contract no longer exists (Was it solved by a script?)"); + } + switch (res) { case CodingContractResult.Success: if (contract.reward !== null) { From 831b2262de5622315290ce650979e896908b5394 Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Wed, 11 May 2022 16:06:05 -0500 Subject: [PATCH 2/2] Reran format and lint --- src/Terminal/Terminal.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts index db9daa67b..8f3cf13cb 100644 --- a/src/Terminal/Terminal.ts +++ b/src/Terminal/Terminal.ts @@ -284,7 +284,7 @@ export class Terminal implements ITerminal { `Security decreased on '${server.hostname}' from ${numeralWrapper.formatSecurity( oldSec, )} to ${numeralWrapper.formatSecurity(newSec)} (min: ${numeralWrapper.formatSecurity(server.minDifficulty)})` + - ` and Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`, + ` and Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`, ); } @@ -330,7 +330,8 @@ export class Terminal implements ITerminal { this.print("Time to hack: " + (!isHacknet ? convertTimeMsToTimeElapsedString(hackingTime, true) : "N/A")); } this.print( - `Total money available on server: ${currServ instanceof Server ? numeralWrapper.formatMoney(currServ.moneyAvailable) : "N/A" + `Total money available on server: ${ + currServ instanceof Server ? numeralWrapper.formatMoney(currServ.moneyAvailable) : "N/A" }`, ); if (currServ instanceof Server) {