From 96f0f14a95d49ef8f952ae4be3451c672d321841 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sat, 5 May 2018 23:59:55 -0400 Subject: [PATCH] commitCrime now takes enable/disable log into account --- src/NetscriptFunctions.js | 88 ++++++++++++++++++++++++++++++++------- src/Player.js | 34 ++++++++------- 2 files changed, 93 insertions(+), 29 deletions(-) diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 799ca02df..22528e985 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -74,6 +74,55 @@ var hasCorporationSF=false, //Source-File 3 hasBn11SF=false; //Source-File 11 +var possibleLogs = { + ALL: true, + scan: true, + hack: true, + sleep: true, + disableLog: true, + enableLog: true, + grow: true, + weaken: true, + nuke: true, + brutessh: true, + ftpcrack: true, + relaysmtp: true, + httpworm: true, + sqlinject: true, + spawn: true, + kill: true, + killall: true, + scp: true, + getHackingLevel: true, + getServerMoneyAvailable: true, + getServerSecurityLevel: true, + getServerBaseSecurityLevel: true, + getServerMinSecurityLevel: true, + getServerRequiredHackingLevel: true, + getServerMaxMoney: true, + getServerGrowth: true, + getServerNumPortsRequired: true, + getServerRam: true, + buyStock: true, + sellStock: true, + purchaseServer: true, + deleteServer: true, + universityCourse: true, + gymWorkout: true, + travelToCity: true, + purchaseTor: true, + purchaseProgram: true, + stopAction: true, + upgradeHomeRam: true, + workForCompany: true, + applyToCompany: true, + joinFaction: true, + workForFaction: true, + createProgram: true, + commitCrime: true, + shortStock: true, + sellShort: true, +} var singularitySFLvl=1, wallStreetSFLvl=1; @@ -354,13 +403,23 @@ function NetscriptFunctions(workerScript) { }, disableLog : function(fn) { if (workerScript.checkingRam) {return 0;} + if(possibleLogs[fn]===undefined) { + throw makeRuntimeRejectMsg(workerScript, "Invalid argument to disableLog: "+fn); + } workerScript.disableLogs[fn] = true; - workerScript.scriptRef.log("Disabled logging for " + fn); + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) { + workerScript.scriptRef.log("Disabled logging for " + fn); + } }, enableLog : function(fn) { if (workerScript.checkingRam) {return 0;} + if(possibleLogs[fn]===undefined) { + throw makeRuntimeRejectMsg(workerScript, "Invalid argument to enableLog: "+fn); + } delete workerScript.disableLogs[fn]; - workerScript.scriptRef.log("Enabled logging for " + fn); + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) { + workerScript.scriptRef.log("Enabled logging for " + fn); + } }, nuke : function(ip){ if (workerScript.checkingRam) { @@ -3299,41 +3358,42 @@ function NetscriptFunctions(workerScript) { } crime = crime.toLowerCase(); + let enableCommitCrimeLog = workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null if (crime.includes("shoplift")) { - workerScript.scriptRef.log("Attempting to shoplift..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to shoplift...");} return commitShopliftCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("rob") && crime.includes("store")) { - workerScript.scriptRef.log("Attempting to rob a store..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to rob a store...");} return commitRobStoreCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("mug")) { - workerScript.scriptRef.log("Attempting to mug someone..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to mug someone...");} return commitMugCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("larceny")) { - workerScript.scriptRef.log("Attempting to commit larceny..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit larceny...");} return commitLarcenyCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("drugs")) { - workerScript.scriptRef.log("Attempting to deal drugs..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to deal drugs...");} return commitDealDrugsCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("bond") && crime.includes("forge")) { - workerScript.scriptRef.log("Attempting to forge corporate bonds..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to forge corporate bonds...");} return commitBondForgeryCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("traffick") && crime.includes("arms")) { - workerScript.scriptRef.log("Attempting to traffick illegal arms..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to traffick illegal arms...");} return commitTraffickArmsCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("homicide")) { - workerScript.scriptRef.log("Attempting to commit homicide..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit homicide...");} return commitHomicideCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("grand") && crime.includes("auto")) { - workerScript.scriptRef.log("Attempting to commit grand theft auto..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit grand theft auto...");} return commitGrandTheftAutoCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("kidnap")) { - workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");} return commitKidnapCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("assassinate")) { - workerScript.scriptRef.log("Attempting to assassinate a high-profile target..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");} return commitAssassinationCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}) } else if (crime.includes("heist")) { - workerScript.scriptRef.log("Attempting to pull off a heist..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to pull off a heist...");} return commitHeistCrime(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript}); } else { throw makeRuntimeRejectMsg(workerScript, "Invalid crime passed into commitCrime(): " + crime); diff --git a/src/Player.js b/src/Player.js index a086a5bb0..137817d86 100644 --- a/src/Player.js +++ b/src/Player.js @@ -1582,14 +1582,16 @@ PlayerObject.prototype.finishCrime = function(cancelled) { this.workAgiExpGained *= 2; this.workChaExpGained *= 2; if (this.committingCrimeThruSingFn) { - this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " + - numeral(this.workMoneyGained).format("$0.000a") + ", " + - formatNumber(this.workHackExpGained, 3) + " hack exp, " + - formatNumber(this.workStrExpGained, 3) + " str exp, " + - formatNumber(this.workDefExpGained, 3) + " def exp, " + - formatNumber(this.workDexExpGained, 3) + " dex exp, " + - formatNumber(this.workAgiExpGained, 3) + " agi exp, " + - formatNumber(this.workChaExpGained, 3) + " cha exp."); + if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) { + this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " + + numeral(this.workMoneyGained).format("$0.000a") + ", " + + formatNumber(this.workHackExpGained, 3) + " hack exp, " + + formatNumber(this.workStrExpGained, 3) + " str exp, " + + formatNumber(this.workDefExpGained, 3) + " def exp, " + + formatNumber(this.workDexExpGained, 3) + " dex exp, " + + formatNumber(this.workAgiExpGained, 3) + " agi exp, " + + formatNumber(this.workChaExpGained, 3) + " cha exp."); + } } else { dialogBoxCreate("Crime successful!

" + "You gained:
"+ @@ -1611,13 +1613,15 @@ PlayerObject.prototype.finishCrime = function(cancelled) { this.workAgiExpGained /= 2; this.workChaExpGained /= 2; if (this.committingCrimeThruSingFn) { - this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " + - formatNumber(this.workHackExpGained, 3) + " hack exp, " + - formatNumber(this.workStrExpGained, 3) + " str exp, " + - formatNumber(this.workDefExpGained, 3) + " def exp, " + - formatNumber(this.workDexExpGained, 3) + " dex exp, " + - formatNumber(this.workAgiExpGained, 3) + " agi exp, " + - formatNumber(this.workChaExpGained, 3) + " chaexp."); + if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) { + this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " + + formatNumber(this.workHackExpGained, 3) + " hack exp, " + + formatNumber(this.workStrExpGained, 3) + " str exp, " + + formatNumber(this.workDefExpGained, 3) + " def exp, " + + formatNumber(this.workDexExpGained, 3) + " dex exp, " + + formatNumber(this.workAgiExpGained, 3) + " agi exp, " + + formatNumber(this.workChaExpGained, 3) + " cha exp."); + } } else { dialogBoxCreate("Crime failed!

" + "You gained:
"+