Server security increases slightly when hacked

This commit is contained in:
Daniel Xie 2017-05-31 11:45:30 -05:00
parent e70f499f13
commit 07d9dc6db8
4 changed files with 19 additions and 4 deletions

@ -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,

@ -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;}

@ -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);

@ -292,6 +292,8 @@ var Terminal = {
Player.gainHackingExp(expGainedOnSuccess)
Player.getCurrentServer().fortify(CONSTANTS.ServerFortifyAmount);
post("Hack successful! Gained $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " hacking EXP");
} else { //Failure
//Player only gains 25% exp for failure? TODO Can change this later to balance
@ -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));