workerscript log takes a function now, hopefully this will increase performance.

This commit is contained in:
Olivier Gagnon
2021-11-26 18:30:58 -05:00
parent fe3aa5a357
commit c05518e162
14 changed files with 376 additions and 316 deletions

View File

@@ -53,20 +53,24 @@ export function NetscriptCodingContract(
const serv = helper.getServer(hostname, "codingcontract.attempt");
if (contract.isSolution(answer)) {
const reward = player.gainCodingContractReward(creward, contract.getDifficulty());
workerScript.log("attempt", `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`);
workerScript.log("attempt", () => `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`);
serv.removeContract(filename);
return returnReward ? reward : true;
} else {
++contract.tries;
if (contract.tries >= contract.getMaxNumTries()) {
workerScript.log("attempt", `Coding Contract attempt '${filename}' failed. Contract is now self-destructing`);
workerScript.log(
"attempt",
() => `Coding Contract attempt '${filename}' failed. Contract is now self-destructing`,
);
serv.removeContract(filename);
} else {
workerScript.log(
"attempt",
`Coding Contract attempt '${filename}' failed. ${
contract.getMaxNumTries() - contract.tries
} attempts remaining.`,
() =>
`Coding Contract attempt '${filename}' failed. ${
contract.getMaxNumTries() - contract.tries
} attempts remaining.`,
);
}