diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js index 733b1e60a..2cbbd03b6 100644 --- a/src/CompanyJobApplication.js +++ b/src/CompanyJobApplication.js @@ -16,7 +16,25 @@ PlayerObject.prototype.applyForJob = function(entryPosType) { var pos = entryPosType; if (!this.isQualified(company, pos)) { - dialogBoxCreate("Unforunately, you do not qualify for this position"); + var offset = company.jobStatReqOffset; + var reqHacking = pos.requiredHacking > 0 ? pos.requiredHacking+offset : 0; + var reqStrength = pos.requiredStrength > 0 ? pos.requiredStrength+offset : 0; + var reqDefense = pos.requiredDefense > 0 ? pos.requiredDefense+offset : 0; + var reqDexterity = pos.requiredDexterity > 0 ? pos.requiredDexterity+offset : 0; + var reqAgility = pos.requiredDexterity > 0 ? pos.requiredDexterity+offset : 0; + var reqCharisma = pos.requiredCharisma > 0 ? pos.requiredCharisma+offset : 0; + var reqRep = pos.requiredReputation; + var reqText = "(Requires "; + if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");} + if (reqStrength > 0) {reqText += (reqStrength + " strength, ");} + if (reqDefense > 0) {reqText += (reqDefense + " defense, ");} + if (reqDexterity > 0) {reqText += (reqDexterity + " dexterity, ");} + if (reqAgility > 0) {reqText += (reqAgility + " agility, ");} + if (reqCharisma > 0) {reqText += (reqCharisma + " charisma, ");} + if (reqRep > 1) {reqText += (reqRep + " reputation, ");} + reqText = reqText.substring(0, reqText.length - 2); + reqText += ")"; + dialogBoxCreate("Unforunately, you do not qualify for this position", reqText); return; } @@ -56,6 +74,7 @@ PlayerObject.prototype.applyForJob = function(entryPosType) { var reqDexterity = nextPos.requiredDexterity > 0 ? nextPos.requiredDexterity+offset : 0; var reqAgility = nextPos.requiredDexterity > 0 ? nextPos.requiredDexterity+offset : 0; var reqCharisma = nextPos.requiredCharisma > 0 ? nextPos.requiredCharisma+offset : 0; + var reqRep = nextPos.requiredReputation; var reqText = "(Requires "; if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");} if (reqStrength > 0) {reqText += (reqStrength + " strength, ");} @@ -63,6 +82,7 @@ PlayerObject.prototype.applyForJob = function(entryPosType) { if (reqDexterity > 0) {reqText += (reqDexterity + " dexterity, ");} if (reqAgility > 0) {reqText += (reqAgility + " agility, ");} if (reqCharisma > 0) {reqText += (reqCharisma + " charisma, ");} + if (reqRep > 1) {reqText += (reqRep + " reputation, ");} reqText = reqText.substring(0, reqText.length - 2); reqText += ")"; dialogBoxCreate("Unfortunately, you do not qualify for a promotion", reqText); diff --git a/src/Netscript/Evaluator.js b/src/Netscript/Evaluator.js index d92a7b6e0..88bcc8c8c 100644 --- a/src/Netscript/Evaluator.js +++ b/src/Netscript/Evaluator.js @@ -212,12 +212,17 @@ function evaluate(exp, workerScript) { //Calculate the hacking time var hackingTime = scriptCalculateHackingTime(server); //This is in seconds + //No root access or skill level too low if (server.hasAdminRights == false) { - console.log("Cannot hack server " + server.hostname); - resolve("Cannot hack, no admin rights"); - workerScript.scriptRef.log("Cannot hack this server because user does not have root access"); + workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access"); + throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Script crashed because it did not have root access to " + server.hostname); } + if (server.requiredHackingSkill > Player.hacking_skill) { + workerScript.scriptRef.log("Cannot hack this server (" + server.hostaname + ") because user does not have root access"); + throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|Script crashed because player's hacking skill is not high enough to hack " + server.hostname); + } + workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime + " seconds"); var p = new Promise(function(resolve, reject) {