Fix GH Issue #621: workForFaction() now properly accounts for disabled/enabled logs

This commit is contained in:
danielyxie 2019-07-04 18:07:48 -07:00 committed by danielyxie
parent 6d9e6e6466
commit 7a49a5b3e8
3 changed files with 75036 additions and 10 deletions

75020
dist/engine.bundle.js vendored

File diff suppressed because one or more lines are too long

@ -222,7 +222,9 @@ export let CONSTANTS: IMap<any> = {
LatestUpdate: LatestUpdate:
` `
v0.47.2 v0.47.2
* Added tail() Netscript function
* Added 'Solarized Dark' theme to CodeMirror editor * Added 'Solarized Dark' theme to CodeMirror editor
* Bug fix: Stock Market UI should no longer crash for certain locale settings * Bug fix: Stock Market UI should no longer crash for certain locale settings
* Bug fix: workForFaction() function now properly accounts for disabled logs
` `
} }

@ -3047,8 +3047,8 @@ function NetscriptFunctions(workerScript) {
if (Player.isWorking) { if (Player.isWorking) {
var txt = Player.singularityStopWork(); var txt = Player.singularityStopWork();
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) { if (workerScript.shouldLog("workForFaction")) {
workerScript.scriptRef.log(txt); workerScript.log(txt);
} }
} }
@ -3079,34 +3079,40 @@ function NetscriptFunctions(workerScript) {
case "hacking contracts": case "hacking contracts":
case "hackingcontracts": case "hackingcontracts":
if (!hackAvailable.includes(fac.name)) { if (!hackAvailable.includes(fac.name)) {
workerScript.scriptRef.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed"); workerScript.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed");
return false; return false;
} }
Player.startFactionHackWork(fac); Player.startFactionHackWork(fac);
workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name); if (workerScript.shouldLog("workForFaction")) {
workerScript.log("Started carrying out hacking contracts for " + fac.name);
}
return true; return true;
case "field": case "field":
case "fieldwork": case "fieldwork":
case "field work": case "field work":
if (!fdWkAvailable.includes(fac.name)) { if (!fdWkAvailable.includes(fac.name)) {
workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed"); workerScript.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed");
return false; return false;
} }
Player.startFactionFieldWork(fac); Player.startFactionFieldWork(fac);
workerScript.scriptRef.log("Started carrying out field missions for " + fac.name); if (workerScript.shouldLog("workForFaction")) {
workerScript.log("Started carrying out field missions for " + fac.name);
}
return true; return true;
case "security": case "security":
case "securitywork": case "securitywork":
case "security work": case "security work":
if (!scWkAvailable.includes(fac.name)) { if (!scWkAvailable.includes(fac.name)) {
workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed"); workerScript.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed");
return false; return false;
} }
Player.startFactionSecurityWork(fac); Player.startFactionSecurityWork(fac);
workerScript.scriptRef.log("Started serving as security details for " + fac.name); if (workerScript.shouldLog("workForFaction")) {
workerScript.log("Started serving as security details for " + fac.name);
}
return true; return true;
default: default:
workerScript.scriptRef.log("ERROR: Invalid work type passed into workForFaction(): " + type); workerScript.log("ERROR: Invalid work type passed into workForFaction(): " + type);
} }
return true; return true;
}, },