From fde2b8cbc110d6f249a8aec6eab89b3037e1b47f Mon Sep 17 00:00:00 2001 From: danielyxie Date: Sat, 7 Jul 2018 19:16:58 -0500 Subject: [PATCH] Infiltration can no longer be done programmatically. HP is reset when prestiging --- dist/engine.bundle.js | 73 +++++++++++++++++++++++++++++----------- src/Infiltration.js | 36 +++++++++++++------- src/Player.js | 9 ++++- utils/InfiltrationBox.js | 6 ++-- 4 files changed, 89 insertions(+), 35 deletions(-) diff --git a/dist/engine.bundle.js b/dist/engine.bundle.js index 01a726bca..b20f02867 100644 --- a/dist/engine.bundle.js +++ b/dist/engine.bundle.js @@ -411,6 +411,10 @@ PlayerObject.prototype.prestigeAugmentation = function() { this.hacknetNodes.length = 0; this.totalHacknetNodeProduction = 0; + + //Re-calculate skills and reset HP + this.updateSkillLevels(); + this.hp = this.max_hp; } PlayerObject.prototype.prestigeSourceFile = function() { @@ -504,6 +508,9 @@ PlayerObject.prototype.prestigeSourceFile = function() { this.playtimeSinceLastAug = 0; this.playtimeSinceLastBitnode = 0; this.scriptProdSinceLastAug = 0; + + this.updateSkillLevels(); + this.hp = this.max_hp; } PlayerObject.prototype.getCurrentServer = function() { @@ -2468,7 +2475,7 @@ PlayerObject.prototype.queueAugmentation = function(name) { return; } } - + this.firstAugPurchased = true; this.queuedAugmentations.push(new _Augmentations__WEBPACK_IMPORTED_MODULE_0__["PlayerOwnedAugmentation"](name)); } @@ -11454,13 +11461,16 @@ function displayFactionContent(factionName) { var donateDivWrapper = Object(_utils_HelperFunctions__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"}); donateDiv.appendChild(donateDivWrapper); var donateRepGain = Object(_utils_HelperFunctions__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", { - innerText:"This donation will result in 0 reputation gain" + innerText:"This donation will result in 0.000 reputation gain" }); var donateAmountInput = Object(_utils_HelperFunctions__WEBPACK_IMPORTED_MODULE_11__["createElement"])("input", { placeholder:"Donation amount", inputListener:()=>{ - var amt = parseFloat(donateAmountInput.value); - if (isNaN(amt) || amt < 0) { + let amt = 0; + if(donateAmountInput.value !== "") { + amt = parseFloat(donateAmountInput.value); + } + if (isNaN(amt)) { donateRepGain.innerText = "Invalid donate amount entered!"; } else { var repGain = amt / 1e6 * _Player__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult; @@ -15586,8 +15596,17 @@ function runScriptsLoop() { var ip = workerScripts[i].serverIp; var name = workerScripts[i].name; - //Free RAM - _Server__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].ramUsed -= workerScripts[i].ramUsage; + //recalculate ram used + _Server__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].ramUsed = 0; + for(let j = 0; j < workerScripts.length; j++) { + if(workerScripts[j].serverIp !== ip) { + continue + } + if(j === i) { // not this one + continue + } + _Server__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].ramUsed += workerScripts[j].ramUsage; + } //Delete script from Active Scripts Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]); @@ -72784,7 +72803,8 @@ function infiltrationBoxCreate(inst) { var sellButton = Object(_HelperFunctions__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("infiltration-box-sell"); setTimeout(function() { - sellButton.addEventListener("click", function() { + sellButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} _src_Player__WEBPACK_IMPORTED_MODULE_3__["Player"].gainMoney(moneyValue); Object(_DialogBox__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You sold the classified information you stole from " + inst.companyName + " for $" + moneyValue + " on the black market!

" + @@ -72802,7 +72822,8 @@ function infiltrationBoxCreate(inst) { var factionButton = Object(_HelperFunctions__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("infiltration-box-faction"); setTimeout(function() { - factionButton.addEventListener("click", function() { + factionButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var facName = selector.options[selector.selectedIndex].value; lastFac = facName; var faction = _src_Faction__WEBPACK_IMPORTED_MODULE_2__["Factions"][facName]; @@ -73005,7 +73026,8 @@ function nextInfiltrationLevel(inst) { case 3: scenario = InfiltrationScenarios.Bots; killButton.style.display = "block"; - killButton.addEventListener("click", function() { + killButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationKill(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " + @@ -73028,7 +73050,8 @@ function nextInfiltrationLevel(inst) { updateInfiltrationLevelText(inst); }); assassinateButton.style.display = "block"; - assassinateButton.addEventListener("click", function() { + assassinateButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationAssassinate(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY assassinated the security bots without being detected!"); @@ -73050,7 +73073,8 @@ function nextInfiltrationLevel(inst) { default: //0, 4-5 scenario = InfiltrationScenarios.Guards; killButton.style.display = "block"; - killButton.addEventListener("click", function() { + killButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationKill(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " + @@ -73076,7 +73100,8 @@ function nextInfiltrationLevel(inst) { knockoutButton.style.display = "block"; stealthKnockoutButton.style.display = "block"; assassinateButton.style.display = "block"; - assassinateButton.addEventListener("click", function() { + assassinateButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationAssassinate(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY assassinated the security guard without being detected!"); @@ -73098,7 +73123,8 @@ function nextInfiltrationLevel(inst) { break; } - knockoutButton.addEventListener("click", function() { + knockoutButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationKnockout(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard! " + @@ -73120,7 +73146,8 @@ function nextInfiltrationLevel(inst) { return false; }); - stealthKnockoutButton.addEventListener("click", function() { + stealthKnockoutButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationStealthKnockout(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard without making " + @@ -73141,7 +73168,8 @@ function nextInfiltrationLevel(inst) { return false; }); - hackSecurityButton.addEventListener("click", function() { + hackSecurityButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationHack(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY hacked and disabled the security system!"); @@ -73157,7 +73185,8 @@ function nextInfiltrationLevel(inst) { return false; }); - destroySecurityButton.addEventListener("click", function() { + destroySecurityButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationDestroySecurity(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY and violently destroy the security system!"); @@ -73173,7 +73202,8 @@ function nextInfiltrationLevel(inst) { return false; }); - sneakButton.addEventListener("click", function() { + sneakButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationSneak(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY sneak past the security undetected!"); @@ -73188,7 +73218,8 @@ function nextInfiltrationLevel(inst) { return false; }); - pickdoorButton.addEventListener("click", function() { + pickdoorButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationPickLockedDoor(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY pick the locked door!"); @@ -73204,7 +73235,8 @@ function nextInfiltrationLevel(inst) { return false; }); - bribeButton.addEventListener("click", function() { + bribeButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var bribeAmt = _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].InfiltrationBribeBaseAmount * inst.clearanceLevel; if (_Player__WEBPACK_IMPORTED_MODULE_3__["Player"].money.lt(bribeAmt)) { writeInfiltrationStatusText("You do not have enough money to bribe the guard. " + @@ -73228,7 +73260,8 @@ function nextInfiltrationLevel(inst) { return false; }); - escapeButton.addEventListener("click", function() { + escapeButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationEscape(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY escape from the facility with the stolen classified " + diff --git a/src/Infiltration.js b/src/Infiltration.js index e3fac6570..1c236e7be 100644 --- a/src/Infiltration.js +++ b/src/Infiltration.js @@ -157,7 +157,8 @@ function nextInfiltrationLevel(inst) { case 3: scenario = InfiltrationScenarios.Bots; killButton.style.display = "block"; - killButton.addEventListener("click", function() { + killButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationKill(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " + @@ -180,7 +181,8 @@ function nextInfiltrationLevel(inst) { updateInfiltrationLevelText(inst); }); assassinateButton.style.display = "block"; - assassinateButton.addEventListener("click", function() { + assassinateButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationAssassinate(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY assassinated the security bots without being detected!"); @@ -202,7 +204,8 @@ function nextInfiltrationLevel(inst) { default: //0, 4-5 scenario = InfiltrationScenarios.Guards; killButton.style.display = "block"; - killButton.addEventListener("click", function() { + killButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationKill(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " + @@ -228,7 +231,8 @@ function nextInfiltrationLevel(inst) { knockoutButton.style.display = "block"; stealthKnockoutButton.style.display = "block"; assassinateButton.style.display = "block"; - assassinateButton.addEventListener("click", function() { + assassinateButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationAssassinate(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY assassinated the security guard without being detected!"); @@ -250,7 +254,8 @@ function nextInfiltrationLevel(inst) { break; } - knockoutButton.addEventListener("click", function() { + knockoutButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationKnockout(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard! " + @@ -272,7 +277,8 @@ function nextInfiltrationLevel(inst) { return false; }); - stealthKnockoutButton.addEventListener("click", function() { + stealthKnockoutButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationStealthKnockout(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard without making " + @@ -293,7 +299,8 @@ function nextInfiltrationLevel(inst) { return false; }); - hackSecurityButton.addEventListener("click", function() { + hackSecurityButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationHack(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY hacked and disabled the security system!"); @@ -309,7 +316,8 @@ function nextInfiltrationLevel(inst) { return false; }); - destroySecurityButton.addEventListener("click", function() { + destroySecurityButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationDestroySecurity(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY and violently destroy the security system!"); @@ -325,7 +333,8 @@ function nextInfiltrationLevel(inst) { return false; }); - sneakButton.addEventListener("click", function() { + sneakButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationSneak(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY sneak past the security undetected!"); @@ -340,7 +349,8 @@ function nextInfiltrationLevel(inst) { return false; }); - pickdoorButton.addEventListener("click", function() { + pickdoorButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationPickLockedDoor(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY pick the locked door!"); @@ -356,7 +366,8 @@ function nextInfiltrationLevel(inst) { return false; }); - bribeButton.addEventListener("click", function() { + bribeButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var bribeAmt = CONSTANTS.InfiltrationBribeBaseAmount * inst.clearanceLevel; if (Player.money.lt(bribeAmt)) { writeInfiltrationStatusText("You do not have enough money to bribe the guard. " + @@ -380,7 +391,8 @@ function nextInfiltrationLevel(inst) { return false; }); - escapeButton.addEventListener("click", function() { + escapeButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var res = attemptInfiltrationEscape(inst); if (res[0]) { writeInfiltrationStatusText("You SUCCESSFULLY escape from the facility with the stolen classified " + diff --git a/src/Player.js b/src/Player.js index acf935823..7e83980f9 100644 --- a/src/Player.js +++ b/src/Player.js @@ -300,6 +300,10 @@ PlayerObject.prototype.prestigeAugmentation = function() { this.hacknetNodes.length = 0; this.totalHacknetNodeProduction = 0; + + //Re-calculate skills and reset HP + this.updateSkillLevels(); + this.hp = this.max_hp; } PlayerObject.prototype.prestigeSourceFile = function() { @@ -393,6 +397,9 @@ PlayerObject.prototype.prestigeSourceFile = function() { this.playtimeSinceLastAug = 0; this.playtimeSinceLastBitnode = 0; this.scriptProdSinceLastAug = 0; + + this.updateSkillLevels(); + this.hp = this.max_hp; } PlayerObject.prototype.getCurrentServer = function() { @@ -2357,7 +2364,7 @@ PlayerObject.prototype.queueAugmentation = function(name) { return; } } - + this.firstAugPurchased = true; this.queuedAugmentations.push(new PlayerOwnedAugmentation(name)); } diff --git a/utils/InfiltrationBox.js b/utils/InfiltrationBox.js index 7858ef06a..ed95ab3cb 100644 --- a/utils/InfiltrationBox.js +++ b/utils/InfiltrationBox.js @@ -81,7 +81,8 @@ function infiltrationBoxCreate(inst) { var sellButton = clearEventListeners("infiltration-box-sell"); setTimeout(function() { - sellButton.addEventListener("click", function() { + sellButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} Player.gainMoney(moneyValue); dialogBoxCreate("You sold the classified information you stole from " + inst.companyName + " for $" + moneyValue + " on the black market!

" + @@ -99,7 +100,8 @@ function infiltrationBoxCreate(inst) { var factionButton = clearEventListeners("infiltration-box-faction"); setTimeout(function() { - factionButton.addEventListener("click", function() { + factionButton.addEventListener("click", function(e) { + if (!e.isTrusted) {return false;} var facName = selector.options[selector.selectedIndex].value; lastFac = facName; var faction = Factions[facName];