diff --git a/src/Constants.js b/src/Constants.js index 1220bdd43..74948b37f 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -62,8 +62,10 @@ CONSTANTS = { ScriptHNUpgRamRamCost: 0.6, ScriptHNUpgCoreRamCost: 0.8, - //Server growth rate - ServerGrowthRate: 1.0018, + //Server constants + ServerGrowthRate: 1.0018, //Growth rate + ServerFortifyAmount: 0.001, //Amount by which server's security increases when its hacked + ServerWeakenAmount: 0.1, //Amount by which server's security decreases when weakened //Maximum number of log entries for a script MaxLogCapacity: 40, diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index a26353e96..c3d851455 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -288,6 +288,7 @@ function evaluate(exp, workerScript) { workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); + server.fortify(CONSTANTS.ServerFortifyAmount); resolve("Hack success"); } else { if (env.stopFlag) {reject(workerScript); return;} diff --git a/src/Server.js b/src/Server.js index aff18b744..e5ada5f7d 100644 --- a/src/Server.js +++ b/src/Server.js @@ -108,6 +108,17 @@ Server.prototype.getScript = function(scriptName) { return null; } +//Strengthens a server's security level (difficulty) by the specified amount +Server.prototype.fortify = function(amt) { + this.hackDifficulty += amt; + if (this.hackDifficulty > 99) {this.hackDifficulty = 99;} +} + +Server.prototype.weaken = function(amt) { + this.hackDifficulty -= amt; + if (this.hackDifficulty < 1) {this.hackDifficulty = 1;} +} + //Functions for loading and saving a Server Server.prototype.toJSON = function() { return Generic_toJSON("Server", this); diff --git a/src/Terminal.js b/src/Terminal.js index b96a39363..6d9d92889 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -291,6 +291,8 @@ var Terminal = { Player.gainMoney(moneyGained); Player.gainHackingExp(expGainedOnSuccess) + + Player.getCurrentServer().fortify(CONSTANTS.ServerFortifyAmount); post("Hack successful! Gained $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " hacking EXP"); } else { //Failure @@ -317,8 +319,7 @@ var Terminal = { else {rootAccess = "NO";} post("Root Access: " + rootAccess); post("Required hacking skill: " + Player.getCurrentServer().requiredHackingSkill); - //TODO Make these actual estimates by adding a random offset to result? - //TODO Change the text to sound better + post("Estimated server security level(1-100): " + formatNumber(addOffset(Player.getCurrentServer().hackDifficulty, 5), 0)); post("Estimated chance to hack: " + formatNumber(addOffset(Player.calculateHackingChance() * 100, 5), 2) + "%"); post("Estimated time to hack: " + formatNumber(addOffset(Player.calculateHackingTime(), 5), 3) + " seconds"); post("Estimated total money available on server: $" + formatNumber(addOffset(Player.getCurrentServer().moneyAvailable, 5), 2));