Yes
No
diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js
index 215b91546..cf6da6302 100644
--- a/src/CompanyJobApplication.js
+++ b/src/CompanyJobApplication.js
@@ -62,6 +62,10 @@ PlayerObject.prototype.applyForJob = function(entryPosType) {
if (currCompany != "") {
if (currCompany.companyName != company.companyName) {
company.playerReputation -= 1000;
+ if (company.playerReputation < 0) {company.playerReputation = 0;}
+ if (Engine.debug) {
+ console.log("Lost reputation for " + company.companyName + ". It is now " + company.playerReputation);
+ }
}
}
diff --git a/src/Constants.js b/src/Constants.js
index a6546af87..3f7a5d8d4 100644
--- a/src/Constants.js
+++ b/src/Constants.js
@@ -19,6 +19,15 @@ CONSTANTS = {
//How much a TOR router costs
TorRouterCost: 2000000,
+ MillisecondsPer20Hours: 72000000,
+ GameCyclesPer20Hours: 72000000 / 200,
+
+ MillisecondsPer8Hours: 28800000,
+ GameCyclesPer8Hours: 28800000 / 200,
+
+ MillisecondsPerHour: 3600000,
+ GameCyclesPerHour: 3600000 / 200,
+
//Text that is displayed when the 'help' command is ran in Terminal
HelpText: "analyze Get statistics and information about current machine
" +
"clear Clear all text on the terminal
" +
diff --git a/src/Netscript/Evaluator.js b/src/Netscript/Evaluator.js
index fbb4017d7..a75f4e218 100644
--- a/src/Netscript/Evaluator.js
+++ b/src/Netscript/Evaluator.js
@@ -244,14 +244,14 @@ function evaluate(exp, workerScript) {
Player.gainMoney(moneyGained);
workerScript.scriptRef.onlineMoneyMade += moneyGained;
- Player.hacking_exp += expGainedOnSuccess;
+ Player.gainHackingExp(expGainedOnSuccess);
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
console.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
workerScript.scriptRef.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
resolve("Hack success");
} else {
//Player only gains 25% exp for failure? TODO Can change this later to balance
- Player.hacking_exp += expGainedOnFailure;
+ Player.gainHackingExp(expGainedOnFailure);
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + " exp");
@@ -544,7 +544,7 @@ function scriptCalculateHackingTime(server) {
//The same as Player's calculateExpGain() function but takes in the server as an argument
function scriptCalculateExpGain(server) {
- return Math.round(server.hackDifficulty * server.requiredHackingSkill * Player.hacking_exp_mult);
+ return Math.round(server.hackDifficulty * Player.hacking_exp_mult);
}
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
@@ -553,5 +553,7 @@ function scriptCalculatePercentMoneyHacked(server) {
var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult;
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
+ if (percentMoneyHacked < 0) {return 0;}
+ if (percentMoneyHacked > 1) {return 1;}
return percentMoneyHacked;
}
\ No newline at end of file
diff --git a/src/Player.js b/src/Player.js
index 87bf5b544..b4d5c94dc 100644
--- a/src/Player.js
+++ b/src/Player.js
@@ -203,6 +203,8 @@ PlayerObject.prototype.calculatePercentMoneyHacked = function() {
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult;
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
+ if (percentMoneyHacked < 0) {return 0;}
+ if (percentMoneyHacked > 1) {return 1;}
return percentMoneyHacked;
}
@@ -212,7 +214,7 @@ PlayerObject.prototype.calculatePercentMoneyHacked = function() {
//
// Note: Keep it at an integer for now,
PlayerObject.prototype.calculateExpGain = function() {
- return Math.round(this.getCurrentServer().hackDifficulty * this.getCurrentServer().requiredHackingSkill * this.hacking_exp_mult);
+ return Math.round(this.getCurrentServer().hackDifficulty * this.hacking_exp_mult);
}
//Hack/Analyze a server. Return the amount of time the hack will take. This lets the Terminal object know how long to disable itself for
@@ -232,27 +234,71 @@ PlayerObject.prototype.analyze = function() {
}
PlayerObject.prototype.gainMoney = function(money) {
+ if (isNaN(money)) {
+ console.log("ERR: NaN passed into Player.gainMoney()"); return;
+ }
this.money += money;
this.total_money += money;
this.lifetime_money += money;
}
+PlayerObject.prototype.gainHackingExp = function(exp) {
+ if (isNaN(exp)) {
+ console.log("ERR: NaN passed into Player.gainHackingExp()"); return;
+ }
+ this.hacking_exp += exp;
+}
+
+PlayerObject.prototype.gainStrengthExp = function(exp) {
+ if (isNaN(exp)) {
+ console.log("ERR: NaN passed into Player.gainStrengthExp()"); return;
+ }
+ this.strength_exp += exp;
+}
+
+PlayerObject.prototype.gainDefenseExp = function(exp) {
+ if (isNaN(exp)) {
+ console.log("ERR: NaN passed into player.gainDefenseExp()"); return;
+ }
+ this.defense_exp += exp;
+}
+
+PlayerObject.prototype.gainDexterityExp = function(exp) {
+ if (isNaN(exp)) {
+ console.log("ERR: NaN passed into Player.gainDexterityExp()"); return;
+ }
+ this.dexterity_exp += exp;
+}
+
+PlayerObject.prototype.gainAgilityExp = function(exp) {
+ if (isNaN(exp)) {
+ console.log("ERR: NaN passed into Player.gainAgilityExp()"); return;
+ }
+ this.agility_exp += exp;
+}
+
+PlayerObject.prototype.gainCharismaExp = function(exp) {
+ if (isNaN(exp)) {
+ console.log("ERR: NaN passed into Player.gainCharismaExp()"); return;
+ }
+ this.charisma_exp += exp;
+}
+
/* Working for Company */
PlayerObject.prototype.finishWork = function(cancelled) {
//Since the work was cancelled early, player only gains half of what they've earned so far
var cancMult = 1;
- if (cancelled) {
- cancMult = 2;
- }
+ if (cancelled) {cancMult = 2;}
+
if (Engine.Debug) {
console.log("Player finishWork() called with " + this.workMoneyGained / cancMult + " $ gained");
}
- this.hacking_exp += (this.workHackExpGained / cancMult);
- this.strength_exp += (this.workStrExpGained / cancMult);
- this.defense_exp += (this.workDefExpGained / cancMult);
- this.dexterity_exp += (this.workDexExpGained / cancMult);
- this.agility_exp += (this.workAgiExpGained / cancMult);
- this.charisma_exp += (this.workChaExpGained / cancMult);
+ this.gainHackingExp(this.workHackExpGained / cancMult);
+ this.gainStrengthExp(this.workStrExpGained / cancMult);
+ this.gainDefenseExp(this.workDefExpGained / cancMult);
+ this.gainDexterityExp(this.workDexExpGained / cancMult);
+ this.gainAgilityExp(this.workAgiExpGained / cancMult);
+ this.gainCharismaExp(this.workChaExpGained / cancMult);
var company = Companies[this.companyName];
company.playerReputation += (this.workRepGained / cancMult);
@@ -279,13 +325,13 @@ PlayerObject.prototype.finishWork = function(cancelled) {
txt = "You worked a full shift of 8 hours!
" +
"You earned a total of:
" +
"$" + (this.workMoneyGained / cancMult) + "
" +
- (this.workRepGained / cancMult) + " reputation for the company
" +
- (this.workHackExpGained / cancMult) + " hacking exp
" +
- (this.workStrExpGained / cancMult) + " strength exp
" +
- (this.workDefExpGained / cancMult) + " defense exp
" +
- (this.workDexExpGained / cancMult) + " dexterity exp
" +
- (this.workAgiExpGained / cancMult) + " agility exp
" +
- (this.workChaExpGained / cancMult) + " charisma exp
";
+ (this.workRepGained / cancMult).toFixed(3) + " reputation for the company
" +
+ (this.workHackExpGained / cancMult).toFixed(3) + " hacking exp
" +
+ (this.workStrExpGained / cancMult).toFixed(3) + " strength exp
" +
+ (this.workDefExpGained / cancMult).toFixed(3) + " defense exp
" +
+ (this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp
" +
+ (this.workAgiExpGained / cancMult).toFixed(3) + " agility exp
" +
+ (this.workChaExpGained / cancMult).toFixed(3) + " charisma exp
";
}
dialogBoxCreate(txt);
@@ -353,8 +399,8 @@ PlayerObject.prototype.work = function(numCycles) {
this.timeWorked += Engine._idleSpeed * numCycles;
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
- if (this.timeWorked >= 28800000) {
- var maxCycles = 144000; //Number of cycles in 8 hours
+ if (this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) {
+ var maxCycles = CONSTANTS.GameCyclesPer8Hours; //Number of cycles in 8 hours
this.workHackExpGained = this.workhackExpGainRate * maxCycles;
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
@@ -515,8 +561,8 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
this.timeWorked += Engine._idleSpeed * numCycles;
//If timeWorked == 20 hours, then finish. You can only work for the faction for 20 hours
- if (this.timeWorked >= 72000000) {
- var maxCycles = 360000; //Number of cycles in 20 hours
+ if (this.timeWorked >= CONSTANTS.MillisecondsPer20Hours) {
+ var maxCycles = CONSTANTS.GameCyclesPer20Hours; //Number of cycles in 20 hours
this.workHackExpGained = this.workhackExpGainRate * maxCycles;
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
diff --git a/src/Server.js b/src/Server.js
index 316c6d5a6..a93f6ec21 100644
--- a/src/Server.js
+++ b/src/Server.js
@@ -396,7 +396,7 @@ initForeignServers = function() {
//"Low level" targets
var FoodNStuffServer = new Server();
FoodNStuffServer.init(createRandomIp(), "foodnstuff", "Food N Stuff Supermarket", true, false, false, false, 2);
- FoodNStuffServer.setHackingParameters(1, 1000000, 10, 20);
+ FoodNStuffServer.setHackingParameters(1, 500000, 10, 20);
FoodNStuffServer.setPortProperties(0);
AddToAllServers(FoodNStuffServer);
@@ -644,7 +644,7 @@ processServerGrowth = function(numCycles) {
//Apply serverGrowth for the calculated number of growth cycles
var serverGrowth = Math.pow(1.0001, numServerGrowthCyclesAdjusted);
- console.log("serverGrowth ratio: " + serverGrowth);
+ //console.log("serverGrowth ratio: " + serverGrowth);
server.moneyAvailable *= serverGrowth;
}
}
diff --git a/src/Terminal.js b/src/Terminal.js
index 30488c905..a5011204b 100644
--- a/src/Terminal.js
+++ b/src/Terminal.js
@@ -112,12 +112,12 @@ var Terminal = {
Player.getCurrentServer().moneyAvailable -= moneyGained;
Player.gainMoney(moneyGained);
- Player.hacking_exp += expGainedOnSuccess;
+ Player.gainHackingExp(expGainedOnSuccess)
post("Hack successful! Gained $" + moneyGained + " and " + expGainedOnSuccess + " hacking EXP");
} else { //Failure
//Player only gains 25% exp for failure? TODO Can change this later to balance
- Player.hacking_exp += expGainedOnFailure;
+ Player.gainHackingExp(expGainedOnFailure)
post("Failed to hack " + Player.getCurrentServer().hostname + ". Gained " + expGainedOnFailure + " hacking EXP");
}
}
diff --git a/src/engine.js b/src/engine.js
index b3234ea8f..ff469efa9 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -645,6 +645,7 @@ var Engine = {
updateHackProgress: function(numCycles = 1) {
var timeElapsedMilli = numCycles * Engine._idleSpeed;
Engine._actionTimeLeft -= (timeElapsedMilli/ 1000); //Substract idle speed (ms)
+ Engine._actionTimeLeft = Math.max(Engine._actionTimeLeft, 0);
//Calculate percent filled
var percent = Math.round((1 - Engine._actionTimeLeft / Engine._totalActionTime) * 100);