Merge pull request #100 from danielyxie/dev

Dev v0.26.3
This commit is contained in:
danielyxie 2017-07-29 11:27:31 -05:00 committed by GitHub
commit 4857fe5e41
22 changed files with 382 additions and 393 deletions

@ -462,6 +462,10 @@ div.faction-clear {
text-decoration: none; text-decoration: none;
} }
#augmentations-list li p {
width: 95%;
}
.installed-augmentation { .installed-augmentation {
/* TODO */ /* TODO */
} }

@ -326,7 +326,7 @@ a:link, a:visited {
/*margin: 50% auto;*/ /*margin: 50% auto;*/
padding: 5px; padding: 5px;
border: 2px solid var(--my-highlight-color); border: 2px solid var(--my-highlight-color);
width: 18%; width: 19%;
overflow: auto; /* Enable scroll if needed */ overflow: auto; /* Enable scroll if needed */
background-color: #444; /* Fallback color */ background-color: #444; /* Fallback color */
z-index: 1; z-index: 1;

@ -28,6 +28,7 @@
<script src="utils/GameOptions.js"></script> <script src="utils/GameOptions.js"></script>
<script src="utils/LogBox.js"></script> <script src="utils/LogBox.js"></script>
<script src="utils/InfiltrationBox.js"></script> <script src="utils/InfiltrationBox.js"></script>
<script src="utils/decimal.js"></script>
<!-- Netscript --> <!-- Netscript -->
<script src="src/NetscriptWorker.js"></script> <script src="src/NetscriptWorker.js"></script>

@ -105,7 +105,7 @@ function getJobRequirementText(company, pos, tooltiptext=false) {
reqText += (reqDexterity.toString() + " dexterity<br>"); reqText += (reqDexterity.toString() + " dexterity<br>");
reqText += (reqAgility.toString() + " agility<br>"); reqText += (reqAgility.toString() + " agility<br>");
reqText += (reqCharisma.toString() + " charisma<br>"); reqText += (reqCharisma.toString() + " charisma<br>");
reqText += (reqRep.toString() + " and reputation"); reqText += (reqRep.toString() + " reputation");
} else { } else {
reqText = "(Requires "; reqText = "(Requires ";
if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");} if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");}

@ -1,5 +1,5 @@
CONSTANTS = { CONSTANTS = {
Version: "0.26.2", Version: "0.26.3",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -11,7 +11,7 @@ CONSTANTS = {
/* Base costs */ /* Base costs */
BaseCostFor1GBOfRamHome: 30000, BaseCostFor1GBOfRamHome: 30000,
BaseCostFor1GBOfRamServer: 60000, //1 GB of RAM BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM
BaseCostFor1GBOfRamHacknetNode: 30000, BaseCostFor1GBOfRamHacknetNode: 30000,
BaseCostForHacknetNode: 1000, BaseCostForHacknetNode: 1000,
@ -678,6 +678,11 @@ CONSTANTS = {
"World Stock Exchange account and TIX API Access<br>", "World Stock Exchange account and TIX API Access<br>",
LatestUpdate: LatestUpdate:
"v0.26.3<br>" +
"-Added support for large numbers using Decimal.js. Right now it only applies for the player's money<br>" +
"-Purchasing servers with the Netscript function purchaseServer() is no longer 2x as expensive as doing manually, " +
"it now costs the same<br>" +
"-Early game servers have more starting money<br>" +
"v0.26.2<br>" + "v0.26.2<br>" +
"-Major rebalancing and randomization of the amount of money that servers start with<br>" + "-Major rebalancing and randomization of the amount of money that servers start with<br>" +
"-Significantly lowered hacking exp gain from hacking servers. The exp gain for higher-level servers was lowered more than " + "-Significantly lowered hacking exp gain from hacking servers. The exp gain for higher-level servers was lowered more than " +

@ -79,7 +79,7 @@ listAllDarkwebItems = function() {
buyDarkwebItem = function(itemName) { buyDarkwebItem = function(itemName) {
if (itemName.toLowerCase() == Programs.BruteSSHProgram.toLowerCase()) { if (itemName.toLowerCase() == Programs.BruteSSHProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram); var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram); Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);
post("You have purchased the BruteSSH.exe program. The new program " + post("You have purchased the BruteSSH.exe program. The new program " +
@ -89,7 +89,7 @@ buyDarkwebItem = function(itemName) {
} }
} else if (itemName.toLowerCase() == Programs.FTPCrackProgram.toLowerCase()) { } else if (itemName.toLowerCase() == Programs.FTPCrackProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram); var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram); Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);
post("You have purchased the FTPCrack.exe program. The new program " + post("You have purchased the FTPCrack.exe program. The new program " +
@ -99,7 +99,7 @@ buyDarkwebItem = function(itemName) {
} }
} else if (itemName.toLowerCase() == Programs.RelaySMTPProgram.toLowerCase()) { } else if (itemName.toLowerCase() == Programs.RelaySMTPProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram); var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram); Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);
post("You have purchased the relaySMTP.exe program. The new program " + post("You have purchased the relaySMTP.exe program. The new program " +
@ -109,7 +109,7 @@ buyDarkwebItem = function(itemName) {
} }
} else if (itemName.toLowerCase() == Programs.HTTPWormProgram.toLowerCase()) { } else if (itemName.toLowerCase() == Programs.HTTPWormProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram); var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram); Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);
post("You have purchased the HTTPWorm.exe program. The new program " + post("You have purchased the HTTPWorm.exe program. The new program " +
@ -119,7 +119,7 @@ buyDarkwebItem = function(itemName) {
} }
} else if (itemName.toLowerCase() == Programs.SQLInjectProgram.toLowerCase()) { } else if (itemName.toLowerCase() == Programs.SQLInjectProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram); var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram); Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);
post("You have purchased the SQLInject.exe program. The new program " + post("You have purchased the SQLInject.exe program. The new program " +
@ -129,7 +129,7 @@ buyDarkwebItem = function(itemName) {
} }
} else if (itemName.toLowerCase() == Programs.DeepscanV1.toLowerCase()) { } else if (itemName.toLowerCase() == Programs.DeepscanV1.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program); var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV1); Player.getHomeComputer().programs.push(Programs.DeepscanV1);
post("You have purchased the DeepscanV1.exe program. The new program " + post("You have purchased the DeepscanV1.exe program. The new program " +
@ -139,7 +139,7 @@ buyDarkwebItem = function(itemName) {
} }
} else if (itemName.toLowerCase() == Programs.DeepscanV2.toLowerCase()) { } else if (itemName.toLowerCase() == Programs.DeepscanV2.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program); var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money.gt(price)) {
Player.loseMoney(price); Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV2); Player.getHomeComputer().programs.push(Programs.DeepscanV2);
post("You have purchased the DeepscanV2.exe program. The new program " + post("You have purchased the DeepscanV2.exe program. The new program " +

@ -350,7 +350,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
var illuminatiFac = Factions["Illuminati"]; var illuminatiFac = Factions["Illuminati"];
if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited && if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited &&
numAugmentations >= 30 && numAugmentations >= 30 &&
this.money >= 150000000000 && this.money.gte(150000000000) &&
this.hacking_skill >= 1500 && this.hacking_skill >= 1500 &&
this.strength >= 1200 && this.defense >= 1200 && this.strength >= 1200 && this.defense >= 1200 &&
this.dexterity >= 1200 && this.agility >= 1200) { this.dexterity >= 1200 && this.agility >= 1200) {
@ -361,7 +361,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
var daedalusFac = Factions["Daedalus"]; var daedalusFac = Factions["Daedalus"];
if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited && if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited &&
numAugmentations >= 30 && numAugmentations >= 30 &&
this.money >= 100000000000 && this.money.gte(100000000000) &&
(this.hacking_skill >= 2500 || (this.hacking_skill >= 2500 ||
(this.strength >= 1500 && this.defense >= 1500 && (this.strength >= 1500 && this.defense >= 1500 &&
this.dexterity >= 1500 && this.agility >= 1500))) { this.dexterity >= 1500 && this.agility >= 1500))) {
@ -372,7 +372,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
var covenantFac = Factions["The Covenant"]; var covenantFac = Factions["The Covenant"];
if (!covenantFac.isBanned && !covenantFac.isMember && !covenantFac.alreadyInvited && if (!covenantFac.isBanned && !covenantFac.isMember && !covenantFac.alreadyInvited &&
numAugmentations >= 30 && numAugmentations >= 30 &&
this.money >= 75000000000 && this.money.gte(75000000000) &&
this.hacking_skill >= 850 && this.hacking_skill >= 850 &&
this.strength >= 850 && this.strength >= 850 &&
this.defense >= 850 && this.defense >= 850 &&
@ -494,42 +494,42 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Chongqing //Chongqing
var chongqingFac = Factions["Chongqing"]; var chongqingFac = Factions["Chongqing"];
if (!chongqingFac.isBanned && !chongqingFac.isMember && !chongqingFac.alreadyInvited && if (!chongqingFac.isBanned && !chongqingFac.isMember && !chongqingFac.alreadyInvited &&
this.money >= 20000000 && this.city == Locations.Chongqing) { this.money.gte(20000000) && this.city == Locations.Chongqing) {
invitedFactions.push(chongqingFac); invitedFactions.push(chongqingFac);
} }
//Sector-12 //Sector-12
var sector12Fac = Factions["Sector-12"]; var sector12Fac = Factions["Sector-12"];
if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited && if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited &&
this.money >= 15000000 && this.city == Locations.Sector12) { this.money.gte(15000000) && this.city == Locations.Sector12) {
invitedFactions.push(sector12Fac); invitedFactions.push(sector12Fac);
} }
//New Tokyo //New Tokyo
var newtokyoFac = Factions["New Tokyo"]; var newtokyoFac = Factions["New Tokyo"];
if (!newtokyoFac.isBanned && !newtokyoFac.isMember && !newtokyoFac.alreadyInvited && if (!newtokyoFac.isBanned && !newtokyoFac.isMember && !newtokyoFac.alreadyInvited &&
this.money >= 20000000 && this.city == Locations.NewTokyo) { this.money.gte(20000000) && this.city == Locations.NewTokyo) {
invitedFactions.push(newtokyoFac); invitedFactions.push(newtokyoFac);
} }
//Aevum //Aevum
var aevumFac = Factions["Aevum"]; var aevumFac = Factions["Aevum"];
if (!aevumFac.isBanned && !aevumFac.isMember && !aevumFac.alreadyInvited && if (!aevumFac.isBanned && !aevumFac.isMember && !aevumFac.alreadyInvited &&
this.money >= 40000000 && this.city == Locations.Aevum) { this.money.gte(40000000) && this.city == Locations.Aevum) {
invitedFactions.push(aevumFac); invitedFactions.push(aevumFac);
} }
//Ishima //Ishima
var ishimaFac = Factions["Ishima"]; var ishimaFac = Factions["Ishima"];
if (!ishimaFac.isBanned && !ishimaFac.isMember && !ishimaFac.alreadyInvited && if (!ishimaFac.isBanned && !ishimaFac.isMember && !ishimaFac.alreadyInvited &&
this.money >= 30000000 && this.city == Locations.Ishima) { this.money.gte(30000000) && this.city == Locations.Ishima) {
invitedFactions.push(ishimaFac); invitedFactions.push(ishimaFac);
} }
//Volhaven //Volhaven
var volhavenFac = Factions["Volhaven"]; var volhavenFac = Factions["Volhaven"];
if (!volhavenFac.isBanned && !volhavenFac.isMember && !volhavenFac.alreadyInvited && if (!volhavenFac.isBanned && !volhavenFac.isMember && !volhavenFac.alreadyInvited &&
this.money >= 50000000 && this.city == Locations.Volhaven) { this.money.gte(50000000) && this.city == Locations.Volhaven) {
invitedFactions.push(volhavenFac); invitedFactions.push(volhavenFac);
} }
@ -559,7 +559,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 && this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
this.dexterity >= 200 && this.agility >= 200 && this.dexterity >= 200 && this.agility >= 200 &&
(this.city == Locations.Aevum || this.city == Locations.Sector12) && (this.city == Locations.Aevum || this.city == Locations.Sector12) &&
this.money >= 10000000 && this.karma <= -90 && this.money.gte(10000000) && this.karma <= -90 &&
this.companyName != Locations.Sector12CIA && this.companyName != Locations.Sector12NSA) { this.companyName != Locations.Sector12CIA && this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thesyndicateFac); invitedFactions.push(thesyndicateFac);
} }
@ -570,7 +570,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
(this.companyPosition.positionName == CompanyPositions.CTO.positionName || (this.companyPosition.positionName == CompanyPositions.CTO.positionName ||
this.companyPosition.positionName == CompanyPositions.CFO.positionName || this.companyPosition.positionName == CompanyPositions.CFO.positionName ||
this.companyPosition.positionName == CompanyPositions.CEO.positionName) && this.companyPosition.positionName == CompanyPositions.CEO.positionName) &&
this.money >= 15000000 && this.karma <= -22) { this.money.gte(15000000) && this.karma <= -22) {
invitedFactions.push(silhouetteFac); invitedFactions.push(silhouetteFac);
} }
@ -587,7 +587,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
var slumsnakesFac = Factions["Slum Snakes"]; var slumsnakesFac = Factions["Slum Snakes"];
if (!slumsnakesFac.isBanned && !slumsnakesFac.isMember && !slumsnakesFac.alreadyInvited && if (!slumsnakesFac.isBanned && !slumsnakesFac.isMember && !slumsnakesFac.alreadyInvited &&
this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 && this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 &&
this.agility >= 30 && this.karma <= -9 && this.money >= 1000000) { this.agility >= 30 && this.karma <= -9 && this.money.gte(1000000)) {
invitedFactions.push(slumsnakesFac); invitedFactions.push(slumsnakesFac);
} }
@ -610,7 +610,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Tian Di Hui //Tian Di Hui
var tiandihuiFac = Factions["Tian Di Hui"]; var tiandihuiFac = Factions["Tian Di Hui"];
if (!tiandihuiFac.isBanned && !tiandihuiFac.isMember && !tiandihuiFac.alreadyInvited && if (!tiandihuiFac.isBanned && !tiandihuiFac.isMember && !tiandihuiFac.alreadyInvited &&
this.money >= 1000000 && this.hacking_skill >= 50 && this.money.gte(1000000) && this.hacking_skill >= 50 &&
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo || (this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
this.city == Locations.Ishima)) { this.city == Locations.Ishima)) {
invitedFactions.push(tiandihuiFac); invitedFactions.push(tiandihuiFac);
@ -759,7 +759,7 @@ displayFactionContent = function(factionName) {
var donateAmountVal = document.getElementById("faction-donate-input").value; var donateAmountVal = document.getElementById("faction-donate-input").value;
if (isPositiveNumber(donateAmountVal)) { if (isPositiveNumber(donateAmountVal)) {
var numMoneyDonate = Number(donateAmountVal); var numMoneyDonate = Number(donateAmountVal);
if (Player.money < numMoneyDonate) { if (Player.money.lt(numMoneyDonate)) {
dialogBoxCreate("You cannot afford to donate this much money!"); dialogBoxCreate("You cannot afford to donate this much money!");
return; return;
} }

@ -83,7 +83,7 @@ HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level); var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level);
return this.purchaseLevelUpgrade(diff); return this.purchaseLevelUpgrade(diff);
} }
if (cost > Player.money) {return false;} if (Player.money.lt(cost)) {return false;}
Player.loseMoney(cost); Player.loseMoney(cost);
this.level += levels; this.level += levels;
this.updateMoneyGainRate(); this.updateMoneyGainRate();
@ -113,7 +113,7 @@ HacknetNode.prototype.getRamUpgradeCost = function() {
HacknetNode.prototype.purchaseRamUpgrade = function() { HacknetNode.prototype.purchaseRamUpgrade = function() {
var cost = this.calculateRamUpgradeCost(); var cost = this.calculateRamUpgradeCost();
if (isNaN(cost)) {return false;} if (isNaN(cost)) {return false;}
if (cost > Player.money) {return false;} if (Player.money.lt(cost)) {return false;}
if (this.ram >= CONSTANTS.HacknetNodeMaxRam) {return false;} if (this.ram >= CONSTANTS.HacknetNodeMaxRam) {return false;}
Player.loseMoney(cost); Player.loseMoney(cost);
this.ram *= 2; //Ram is always doubled this.ram *= 2; //Ram is always doubled
@ -140,7 +140,7 @@ HacknetNode.prototype.getCoreUpgradeCost = function() {
HacknetNode.prototype.purchaseCoreUpgrade = function() { HacknetNode.prototype.purchaseCoreUpgrade = function() {
var cost = this.calculateCoreUpgradeCost(); var cost = this.calculateCoreUpgradeCost();
if (isNaN(cost)) {return false;} if (isNaN(cost)) {return false;}
if (cost > Player.money) {return false;} if (Player.money.lt(cost)) {return false;}
if (this.cores >= CONSTANTS.HacknetNodeMaxCores) {return false;} if (this.cores >= CONSTANTS.HacknetNodeMaxCores) {return false;}
Player.loseMoney(cost); Player.loseMoney(cost);
++this.cores; ++this.cores;
@ -179,7 +179,7 @@ purchaseHacknet = function() {
var cost = getCostOfNextHacknetNode(); var cost = getCostOfNextHacknetNode();
if (isNaN(cost)) {throw new Error("Cost is NaN"); return;} if (isNaN(cost)) {throw new Error("Cost is NaN"); return;}
if (cost > Player.money) { if (Player.money.lt(cost)) {
//dialogBoxCreate("You cannot afford to purchase a Hacknet Node!"); //dialogBoxCreate("You cannot afford to purchase a Hacknet Node!");
return false; return false;
} }
@ -243,23 +243,23 @@ updateHacknetNodesMultiplierButtons = function() {
//Calculate the maximum number of times the Player can afford to upgrade //Calculate the maximum number of times the Player can afford to upgrade
//a Hacknet Node's level" //a Hacknet Node's level"
getMaxNumberLevelUpgrades = function(nodeObj) { getMaxNumberLevelUpgrades = function(nodeObj) {
if (nodeObj.calculateLevelUpgradeCost(1) > Player.money) {return 0;} if (Player.money.lt(nodeObj.calculateLevelUpgradeCost(1))) {return 0;}
var min = 1; var min = 1;
var max = CONSTANTS.HacknetNodeMaxLevel-1; var max = CONSTANTS.HacknetNodeMaxLevel-1;
var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level; var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level;
if (nodeObj.calculateLevelUpgradeCost(levelsToMax) < Player.money) { if (Player.money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) {
return levelsToMax; return levelsToMax;
} }
while (min <= max) { while (min <= max) {
var curr = (min + max) / 2 | 0; var curr = (min + max) / 2 | 0;
if (curr != CONSTANTS.HacknetNodeMaxLevel && if (curr != CONSTANTS.HacknetNodeMaxLevel &&
nodeObj.calculateLevelUpgradeCost(curr) < Player.money && Player.money.gt(nodeObj.calculateLevelUpgradeCost(curr)) &&
nodeObj.calculateLevelUpgradeCost(curr+1) > Player.money) { Player.money.lt(nodeObj.calculateLevelUpgradeCost(curr+1))) {
return Math.min(levelsToMax, curr); return Math.min(levelsToMax, curr);
} else if (nodeObj.calculateLevelUpgradeCost(curr) > Player.money) { } else if (Player.money.lt(nodeObj.calculateLevelUpgradeCost(curr))) {
max = curr - 1; max = curr - 1;
} else if (nodeObj.calculateLevelUpgradeCost(curr) < Player.money) { } else if (Player.money.gt(nodeObj.calculateLevelUpgradeCost(curr))) {
min = curr + 1; min = curr + 1;
} else { } else {
return Math.min(levelsToMax, curr); return Math.min(levelsToMax, curr);
@ -299,7 +299,7 @@ updateHacknetNodesContent = function() {
var cost = getCostOfNextHacknetNode(); var cost = getCostOfNextHacknetNode();
var purchaseButton = document.getElementById("hacknet-nodes-purchase-button"); var purchaseButton = document.getElementById("hacknet-nodes-purchase-button");
purchaseButton.innerHTML = "Purchase Hacknet Node - $" + formatNumber(cost, 2); purchaseButton.innerHTML = "Purchase Hacknet Node - $" + formatNumber(cost, 2);
if (cost > Player.money) { if (Player.money.lt(cost)) {
purchaseButton.setAttribute("class", "a-link-button-inactive"); purchaseButton.setAttribute("class", "a-link-button-inactive");
} else { } else {
purchaseButton.setAttribute("class", "a-link-button"); purchaseButton.setAttribute("class", "a-link-button");
@ -307,7 +307,7 @@ updateHacknetNodesContent = function() {
//Update player's money //Update player's money
var moneyElem = document.getElementById("hacknet-nodes-money"); var moneyElem = document.getElementById("hacknet-nodes-money");
moneyElem.innerHTML = "Money: $" + formatNumber(Player.money, 2) + "<br>" + moneyElem.innerHTML = "Money: $" + formatNumber(Player.money.toNumber(), 2) + "<br>" +
"Total production from all Hacknet Nodes: $" + formatNumber(Player.totalHacknetNodeProduction, 2) + " / second"; "Total production from all Hacknet Nodes: $" + formatNumber(Player.totalHacknetNodeProduction, 2) + " / second";
//Update information in each owned hacknet node //Update information in each owned hacknet node
@ -413,7 +413,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier); var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier);
upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier + upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier +
" - $" + formatNumber(upgradeLevelCost, 2); " - $" + formatNumber(upgradeLevelCost, 2);
if (upgradeLevelCost > Player.money ) { if (Player.money.lt(upgradeLevelCost)) {
upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
} else { } else {
upgradeLevelButton.setAttribute("class", "a-link-button"); upgradeLevelButton.setAttribute("class", "a-link-button");
@ -429,7 +429,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
} else { } else {
var upgradeRamCost = nodeObj.calculateRamUpgradeCost(); var upgradeRamCost = nodeObj.calculateRamUpgradeCost();
upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM -$" + formatNumber(upgradeRamCost, 2); upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM -$" + formatNumber(upgradeRamCost, 2);
if (upgradeRamCost > Player.money) { if (Player.money.lt(upgradeRamCost)) {
upgradeRamButton.setAttribute("class", "a-link-button-inactive"); upgradeRamButton.setAttribute("class", "a-link-button-inactive");
} else { } else {
upgradeRamButton.setAttribute("class", "a-link-button"); upgradeRamButton.setAttribute("class", "a-link-button");
@ -445,7 +445,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
} else { } else {
var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost(); var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost();
upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + formatNumber(upgradeCoreCost, 2); upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + formatNumber(upgradeCoreCost, 2);
if (upgradeCoreCost > Player.money) { if (Player.money.lt(upgradeCoreCost)) {
upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
} else { } else {
upgradeCoreButton.setAttribute("class", "a-link-button"); upgradeCoreButton.setAttribute("class", "a-link-button");

@ -1,10 +1,10 @@
/* Infiltration.js /* Infiltration.js
* *
* Kill * Kill
* Knockout (nonlethal) * Knockout (nonlethal)
* Stealth Knockout (nonlethal) * Stealth Knockout (nonlethal)
* Assassinate * Assassinate
* *
* Hack Security * Hack Security
* Destroy Security * Destroy Security
* Sneak past Security * Sneak past Security
@ -12,7 +12,7 @@
* Pick the locked door * Pick the locked door
* *
* Bribe security * Bribe security
* *
* Escape * Escape
*/ */
@ -32,7 +32,7 @@ function InfiltrationInstance(companyName, startLevel, val, maxClearance, diff)
this.difficulty = diff; //Affects how much security level increases. Represents a percentage this.difficulty = diff; //Affects how much security level increases. Represents a percentage
this.baseValue = val; //Base value of company secrets this.baseValue = val; //Base value of company secrets
this.secretsStolen = []; //Numbers representing value of stolen secrets this.secretsStolen = []; //Numbers representing value of stolen secrets
this.hackingExpGained = 0; this.hackingExpGained = 0;
this.strExpGained = 0; this.strExpGained = 0;
this.defExpGained = 0; this.defExpGained = 0;
@ -83,7 +83,7 @@ function endInfiltration(inst, success) {
if (success) { if (success) {
infiltrationBoxCreate(inst); infiltrationBoxCreate(inst);
} }
clearEventListeners("infiltration-kill"); clearEventListeners("infiltration-kill");
clearEventListeners("infiltration-knockout"); clearEventListeners("infiltration-knockout");
clearEventListeners("infiltration-stealthknockout"); clearEventListeners("infiltration-stealthknockout");
@ -94,14 +94,14 @@ function endInfiltration(inst, success) {
clearEventListeners("infiltration-pickdoor"); clearEventListeners("infiltration-pickdoor");
clearEventListeners("infiltration-bribe"); clearEventListeners("infiltration-bribe");
clearEventListeners("infiltration-escape"); clearEventListeners("infiltration-escape");
Engine.loadWorldContent(); Engine.loadWorldContent();
} }
function nextInfiltrationLevel(inst) { function nextInfiltrationLevel(inst) {
++inst.clearanceLevel; ++inst.clearanceLevel;
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
//Buttons //Buttons
var killButton = clearEventListeners("infiltration-kill"); var killButton = clearEventListeners("infiltration-kill");
var knockoutButton = clearEventListeners("infiltration-knockout"); var knockoutButton = clearEventListeners("infiltration-knockout");
@ -113,7 +113,7 @@ function nextInfiltrationLevel(inst) {
var pickdoorButton = clearEventListeners("infiltration-pickdoor"); var pickdoorButton = clearEventListeners("infiltration-pickdoor");
var bribeButton = clearEventListeners("infiltration-bribe"); var bribeButton = clearEventListeners("infiltration-bribe");
var escapeButton = clearEventListeners("infiltration-escape"); var escapeButton = clearEventListeners("infiltration-escape");
killButton.style.display = "none"; killButton.style.display = "none";
knockoutButton.style.display = "none"; knockoutButton.style.display = "none";
stealthKnockoutButton.style.display = "none"; stealthKnockoutButton.style.display = "none";
@ -124,7 +124,7 @@ function nextInfiltrationLevel(inst) {
pickdoorButton.style.display = "none"; pickdoorButton.style.display = "none";
bribeButton.style.display = "none"; bribeButton.style.display = "none";
escapeButton.style.display = "none"; escapeButton.style.display = "none";
var rand = getRandomInt(0, 5); //This needs to change if more scenarios are added var rand = getRandomInt(0, 5); //This needs to change if more scenarios are added
var scenario = null; var scenario = null;
switch (rand) { switch (rand) {
@ -149,8 +149,8 @@ function nextInfiltrationLevel(inst) {
killButton.addEventListener("click", function() { killButton.addEventListener("click", function() {
var res = attemptInfiltrationKill(inst); var res = attemptInfiltrationKill(inst);
if (res[0]) { if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " + writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " +
"rest of the facility's security. The facility's security " + "rest of the facility's security. The facility's security " +
"level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
Player.karma -= 1; Player.karma -= 1;
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
@ -158,8 +158,8 @@ function nextInfiltrationLevel(inst) {
} else { } else {
var dmgTaken = Math.max(1, Math.round(1.5 * inst.securityLevel / Player.defense)); var dmgTaken = Math.max(1, Math.round(1.5 * inst.securityLevel / Player.defense));
writeInfiltrationStatusText("You FAILED to kill the security bots. The bots fight back " + writeInfiltrationStatusText("You FAILED to kill the security bots. The bots fight back " +
"and raise the alarm! You take " + dmgTaken + " damage and " + "and raise the alarm! You take " + dmgTaken + " damage and " +
"the facility's security level increases by " + "the facility's security level increases by " +
formatNumber((res[1]*100)-100, 2).toString() + "%"); formatNumber((res[1]*100)-100, 2).toString() + "%");
if (Player.takeDamage(dmgTaken)) { if (Player.takeDamage(dmgTaken)) {
endInfiltration(inst, false); endInfiltration(inst, false);
@ -177,8 +177,8 @@ function nextInfiltrationLevel(inst) {
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to assassinate the security bots. The bots have not detected " + writeInfiltrationStatusText("You FAILED to assassinate the security bots. The bots have not detected " +
"you but are now more alert for an intruder. The facility's security level " + "you but are now more alert for an intruder. The facility's security level " +
"has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
@ -194,8 +194,8 @@ function nextInfiltrationLevel(inst) {
killButton.addEventListener("click", function() { killButton.addEventListener("click", function() {
var res = attemptInfiltrationKill(inst); var res = attemptInfiltrationKill(inst);
if (res[0]) { if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " + writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " +
"rest of the facility's security. The facility's security " + "rest of the facility's security. The facility's security " +
"level has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "level has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
Player.karma -= 3; Player.karma -= 3;
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
@ -203,8 +203,8 @@ function nextInfiltrationLevel(inst) {
} else { } else {
var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense)); var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));
writeInfiltrationStatusText("You FAILED to kill the security guard. The guard fights back " + writeInfiltrationStatusText("You FAILED to kill the security guard. The guard fights back " +
"and raises the alarm! You take " + dmgTaken + " damage and " + "and raises the alarm! You take " + dmgTaken + " damage and " +
"the facility's security level has increased by " + "the facility's security level has increased by " +
formatNumber((res[1]*100)-100, 2).toString() + "%"); formatNumber((res[1]*100)-100, 2).toString() + "%");
if (Player.takeDamage(dmgTaken)) { if (Player.takeDamage(dmgTaken)) {
endInfiltration(inst, false); endInfiltration(inst, false);
@ -224,8 +224,8 @@ function nextInfiltrationLevel(inst) {
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to assassinate the security guard. The guard has not detected " + writeInfiltrationStatusText("You FAILED to assassinate the security guard. The guard has not detected " +
"you but is now more alert for an intruder. The facility's security level " + "you but is now more alert for an intruder. The facility's security level " +
"has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
@ -236,39 +236,18 @@ function nextInfiltrationLevel(inst) {
escapeButton.style.display = "block"; escapeButton.style.display = "block";
break; break;
} }
knockoutButton.addEventListener("click", function() { knockoutButton.addEventListener("click", function() {
var res = attemptInfiltrationKnockout(inst); var res = attemptInfiltrationKnockout(inst);
if (res[0]) { if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard! " + writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard! " +
"Unfortunately you made a lot of noise and alerted other security."); "Unfortunately you made a lot of noise and alerted other security.");
writeInfiltrationStatusText("The facility's security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); writeInfiltrationStatusText("The facility's security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense)); var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));
writeInfiltrationStatusText("You FAILED to knockout the security guard. The guard " + writeInfiltrationStatusText("You FAILED to knockout the security guard. The guard " +
"raises the alarm and fights back! You take " + dmgTaken + " damage and " +
"the facility's security level increases by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
if (Player.takeDamage(dmgTaken)) {
endInfiltration(inst, false);
}
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
return false;
});
stealthKnockoutButton.addEventListener("click", function() {
var res = attemptInfiltrationStealthKnockout(inst);
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard without making " +
"any noise!");
endInfiltrationLevel(inst);
return false;
} else {
var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));
writeInfiltrationStatusText("You FAILED to stealthily knockout the security guard. The guard " +
"raises the alarm and fights back! You take " + dmgTaken + " damage and " + "raises the alarm and fights back! You take " + dmgTaken + " damage and " +
"the facility's security level increases by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "the facility's security level increases by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
if (Player.takeDamage(dmgTaken)) { if (Player.takeDamage(dmgTaken)) {
@ -279,7 +258,28 @@ function nextInfiltrationLevel(inst) {
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
stealthKnockoutButton.addEventListener("click", function() {
var res = attemptInfiltrationStealthKnockout(inst);
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard without making " +
"any noise!");
endInfiltrationLevel(inst);
return false;
} else {
var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));
writeInfiltrationStatusText("You FAILED to stealthily knockout the security guard. The guard " +
"raises the alarm and fights back! You take " + dmgTaken + " damage and " +
"the facility's security level increases by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
if (Player.takeDamage(dmgTaken)) {
endInfiltration(inst, false);
}
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
return false;
});
hackSecurityButton.addEventListener("click", function() { hackSecurityButton.addEventListener("click", function() {
var res = attemptInfiltrationHack(inst); var res = attemptInfiltrationHack(inst);
if (res[0]) { if (res[0]) {
@ -288,14 +288,14 @@ function nextInfiltrationLevel(inst) {
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to hack the security system. The facility's " + writeInfiltrationStatusText("You FAILED to hack the security system. The facility's " +
"security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
destroySecurityButton.addEventListener("click", function() { destroySecurityButton.addEventListener("click", function() {
var res = attemptInfiltrationDestroySecurity(inst); var res = attemptInfiltrationDestroySecurity(inst);
if (res[0]) { if (res[0]) {
@ -304,14 +304,14 @@ function nextInfiltrationLevel(inst) {
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to destroy the security system. The facility's " + writeInfiltrationStatusText("You FAILED to destroy the security system. The facility's " +
"security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
sneakButton.addEventListener("click", function() { sneakButton.addEventListener("click", function() {
var res = attemptInfiltrationSneak(inst); var res = attemptInfiltrationSneak(inst);
if (res[0]) { if (res[0]) {
@ -319,14 +319,14 @@ function nextInfiltrationLevel(inst) {
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED and were detected while trying to sneak past security! The facility's " + writeInfiltrationStatusText("You FAILED and were detected while trying to sneak past security! The facility's " +
"security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
pickdoorButton.addEventListener("click", function() { pickdoorButton.addEventListener("click", function() {
var res = attemptInfiltrationPickLockedDoor(inst); var res = attemptInfiltrationPickLockedDoor(inst);
if (res[0]) { if (res[0]) {
@ -335,47 +335,47 @@ function nextInfiltrationLevel(inst) {
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to pick the locked door. The facility's security level " + writeInfiltrationStatusText("You FAILED to pick the locked door. The facility's security level " +
"increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
bribeButton.addEventListener("click", function() { bribeButton.addEventListener("click", function() {
var bribeAmt = CONSTANTS.InfiltrationBribeBaseAmount * inst.clearanceLevel; var bribeAmt = CONSTANTS.InfiltrationBribeBaseAmount * inst.clearanceLevel;
if (Player.money < bribeAmt) { if (Player.money.lt(bribeAmt)) {
writeInfiltrationStatusText("You do not have enough money to bribe the guard. " + writeInfiltrationStatusText("You do not have enough money to bribe the guard. " +
"You need $" + bribeAmt); "You need $" + bribeAmt);
return false; return false;
} }
var res = attemptInfiltrationBribe(inst); var res = attemptInfiltrationBribe(inst);
if (res[0]) { if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY bribed a guard to let you through " + writeInfiltrationStatusText("You SUCCESSFULLY bribed a guard to let you through " +
"to the next clearance level for $" + bribeAmt); "to the next clearance level for $" + bribeAmt);
Player.loseMoney(bribeAmt); Player.loseMoney(bribeAmt);
endInfiltrationLevel(inst); endInfiltrationLevel(inst);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to bribe a guard! The guard is alerting " + writeInfiltrationStatusText("You FAILED to bribe a guard! The guard is alerting " +
"other security guards about your presence! The facility's " + "other security guards about your presence! The facility's " +
"security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
} }
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
escapeButton.addEventListener("click", function() { escapeButton.addEventListener("click", function() {
var res = attemptInfiltrationEscape(inst); var res = attemptInfiltrationEscape(inst);
if (res[0]) { if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY escape from the facility with the stolen classified " + writeInfiltrationStatusText("You SUCCESSFULLY escape from the facility with the stolen classified " +
"documents and company secrets!"); "documents and company secrets!");
endInfiltration(inst, true); endInfiltration(inst, true);
return false; return false;
} else { } else {
writeInfiltrationStatusText("You FAILED to escape from the facility. You took 1 damage. The facility's " + writeInfiltrationStatusText("You FAILED to escape from the facility. You took 1 damage. The facility's " +
"security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); "security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%");
if (Player.takeDamage(1)) { if (Player.takeDamage(1)) {
endInfiltration(inst, false); endInfiltration(inst, false);
@ -385,10 +385,10 @@ function nextInfiltrationLevel(inst) {
updateInfiltrationLevelText(inst); updateInfiltrationLevelText(inst);
return false; return false;
}); });
updateInfiltrationButtons(inst, scenario); updateInfiltrationButtons(inst, scenario);
writeInfiltrationStatusText(""); writeInfiltrationStatusText("");
writeInfiltrationStatusText("You are now on clearance level " + inst.clearanceLevel + ".<br>" + writeInfiltrationStatusText("You are now on clearance level " + inst.clearanceLevel + ".<br>" +
scenario); scenario);
} }
@ -401,16 +401,16 @@ function endInfiltrationLevel(inst) {
var secretMoneyValue = baseSecretValue * CONSTANTS.InfiltrationMoneyValue; var secretMoneyValue = baseSecretValue * CONSTANTS.InfiltrationMoneyValue;
inst.secretsStolen.push(baseSecretValue); inst.secretsStolen.push(baseSecretValue);
dialogBoxCreate("You found and stole a set of classified documents from the company. " + dialogBoxCreate("You found and stole a set of classified documents from the company. " +
"These classified secrets could probably be sold for money ($" + "These classified secrets could probably be sold for money ($" +
formatNumber(secretMoneyValue, 2) + "), or they " + formatNumber(secretMoneyValue, 2) + "), or they " +
"could be given to factions for reputation (" + formatNumber(secretValue, 3) + " rep)"); "could be given to factions for reputation (" + formatNumber(secretValue, 3) + " rep)");
} }
//Increase security level based on difficulty //Increase security level based on difficulty
inst.securityLevel *= (1 + (inst.difficulty / 100)); inst.securityLevel *= (1 + (inst.difficulty / 100));
writeInfiltrationStatusText("You move on to the facility's next clearance level. This " + writeInfiltrationStatusText("You move on to the facility's next clearance level. This " +
"clearance level has " + inst.difficulty + "% higher security"); "clearance level has " + inst.difficulty + "% higher security");
//If this is max level, force endInfiltration //If this is max level, force endInfiltration
if (inst.clearanceLevel >= inst.maxClearanceLevel) { if (inst.clearanceLevel >= inst.maxClearanceLevel) {
endInfiltration(inst, true); endInfiltration(inst, true);
@ -436,17 +436,17 @@ function updateInfiltrationLevelText(inst) {
totalValue += inst.secretsStolen[i]; totalValue += inst.secretsStolen[i];
totalMoneyValue += inst.secretsStolen[i] * CONSTANTS.InfiltrationMoneyValue; totalMoneyValue += inst.secretsStolen[i] * CONSTANTS.InfiltrationMoneyValue;
} }
document.getElementById("infiltration-level-text").innerHTML = document.getElementById("infiltration-level-text").innerHTML =
"Facility name: " + inst.companyName + "<br>" + "Facility name: " + inst.companyName + "<br>" +
"Clearance Level: " + inst.clearanceLevel + "<br>" + "Clearance Level: " + inst.clearanceLevel + "<br>" +
"Security Level: " + formatNumber(inst.securityLevel, 3) + "<br><br>" + "Security Level: " + formatNumber(inst.securityLevel, 3) + "<br><br>" +
"Total reputation value of secrets stolen: " + formatNumber(totalValue, 3) + "<br>" + "Total reputation value of secrets stolen: " + formatNumber(totalValue, 3) + "<br>" +
"Total monetary value of secrets stolen: $" + formatNumber(totalMoneyValue, 2) + "<br><br>" + "Total monetary value of secrets stolen: $" + formatNumber(totalMoneyValue, 2) + "<br><br>" +
"Hack exp gained: " + formatNumber(inst.hackingExpGained, 3) + "<br>" + "Hack exp gained: " + formatNumber(inst.hackingExpGained, 3) + "<br>" +
"Str exp gained: " + formatNumber(inst.strExpGained, 3) + "<br>" + "Str exp gained: " + formatNumber(inst.strExpGained, 3) + "<br>" +
"Def exp gained: " + formatNumber(inst.defExpGained, 3) + "<br>" + "Def exp gained: " + formatNumber(inst.defExpGained, 3) + "<br>" +
"Dex exp gained: " + formatNumber(inst.dexExpGained, 3) + "<br>" + "Dex exp gained: " + formatNumber(inst.dexExpGained, 3) + "<br>" +
"Agi exp gained: " + formatNumber(inst.agiExpGained, 3) + "<br>" + "Agi exp gained: " + formatNumber(inst.agiExpGained, 3) + "<br>" +
"Cha exp gained: " + formatNumber(inst.chaExpGained, 3); "Cha exp gained: " + formatNumber(inst.chaExpGained, 3);
} }
@ -461,109 +461,109 @@ function updateInfiltrationButtons(inst, scenario) {
var lockpickChance = getInfiltrationPickLockedDoorChance(inst); var lockpickChance = getInfiltrationPickLockedDoorChance(inst);
var bribeChance = getInfiltrationBribeChance(inst); var bribeChance = getInfiltrationBribeChance(inst);
var escapeChance = getInfiltrationEscapeChance(inst); var escapeChance = getInfiltrationEscapeChance(inst);
document.getElementById("infiltration-escape").innerHTML = "Escape" + document.getElementById("infiltration-escape").innerHTML = "Escape" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to escape the facility with the classified secrets and " + "Attempt to escape the facility with the classified secrets and " +
"documents you have stolen. You have a " + "documents you have stolen. You have a " +
formatNumber(escapeChance*100, 2) + "% chance of success. If you fail, " + formatNumber(escapeChance*100, 2) + "% chance of success. If you fail, " +
"the security level will increase by 5%.</span>"; "the security level will increase by 5%.</span>";
switch(scenario) { switch(scenario) {
case InfiltrationScenarios.TechOrLockedDoor: case InfiltrationScenarios.TechOrLockedDoor:
document.getElementById("infiltration-pickdoor").innerHTML = "Lockpick" + document.getElementById("infiltration-pickdoor").innerHTML = "Lockpick" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to pick the locked door. You have a " + "Attempt to pick the locked door. You have a " +
formatNumber(lockpickChance*100, 2) + "% chance of success. " + formatNumber(lockpickChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increased by 1%. If you fail, the " + "If you succeed, the security level will increased by 1%. If you fail, the " +
"security level will increase by 3%.</span>"; "security level will increase by 3%.</span>";
case InfiltrationScenarios.TechOnly: case InfiltrationScenarios.TechOnly:
document.getElementById("infiltration-hacksecurity").innerHTML = "Hack" + document.getElementById("infiltration-hacksecurity").innerHTML = "Hack" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to hack and disable the security system. You have a " + "Attempt to hack and disable the security system. You have a " +
formatNumber(hackChance*100, 2) + "% chance of success. " + formatNumber(hackChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 3%. If you fail, " + "If you succeed, the security level will increase by 3%. If you fail, " +
"the security level will increase by 5%.</span>"; "the security level will increase by 5%.</span>";
document.getElementById("infiltration-destroysecurity").innerHTML = "Destroy security" + document.getElementById("infiltration-destroysecurity").innerHTML = "Destroy security" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to violently destroy the security system. You have a " + "Attempt to violently destroy the security system. You have a " +
formatNumber(destroySecurityChance*100, 2) + "% chance of success. " + formatNumber(destroySecurityChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, the " + "If you succeed, the security level will increase by 5%. If you fail, the " +
"security level will increase by 10%. </span>"; "security level will increase by 10%. </span>";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" + document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to sneak past the security system. You have a " + "Attempt to sneak past the security system. You have a " +
formatNumber(sneakChance*100, 2) + "% chance of success. " + formatNumber(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. </span>"; "If you fail, the security level will increase by 8%. </span>";
break; break;
case InfiltrationScenarios.Bots: case InfiltrationScenarios.Bots:
document.getElementById("infiltration-kill").innerHTML = "Destroy bots" + document.getElementById("infiltration-kill").innerHTML = "Destroy bots" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to destroy the security bots through combat. You have a " + "Attempt to destroy the security bots through combat. You have a " +
formatNumber(killChance*100, 2) + "% chance of success. " + formatNumber(killChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, " + "If you succeed, the security level will increase by 5%. If you fail, " +
"the security level will increase by 10%. </span>"; "the security level will increase by 10%. </span>";
document.getElementById("infiltration-assassinate").innerHTML = "Assassinate bots" + document.getElementById("infiltration-assassinate").innerHTML = "Assassinate bots" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to stealthily destroy the security bots through assassination. You have a " + "Attempt to stealthily destroy the security bots through assassination. You have a " +
formatNumber(assassinateChance*100, 2) + "% chance of success. " + formatNumber(assassinateChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 10%. </span>"; "If you fail, the security level will increase by 10%. </span>";
document.getElementById("infiltration-hacksecurity").innerHTML = "Hack bots" + document.getElementById("infiltration-hacksecurity").innerHTML = "Hack bots" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to disable the security bots by hacking them. You have a " + "Attempt to disable the security bots by hacking them. You have a " +
formatNumber(hackChance*100, 2) + "% chance of success. " + formatNumber(hackChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 1%. If you fail, " + "If you succeed, the security level will increase by 1%. If you fail, " +
"the security level will increase by 5%. </span>"; "the security level will increase by 5%. </span>";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" + document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"<span class='tooltiptext'>" +
"Attempt to sneak past the security bots. You have a " +
formatNumber(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. </span>";
break;
case InfiltrationScenarios.Guards:
default:
document.getElementById("infiltration-kill").innerHTML = "Kill" +
"<span class='tooltiptext'>" +
"Attempt to kill the security guard. You have a " +
formatNumber(killChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, " +
"the security level will decrease by 10%. </span>";
document.getElementById("infiltration-knockout").innerHTML = "Knockout" +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"Attempt to knockout the security guard. You have a " + "Attempt to sneak past the security bots. You have a " +
formatNumber(knockoutChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 3%. If you fail, the " +
"security level will increase by 10%. </span>";
document.getElementById("infiltration-stealthknockout").innerHTML = "Stealth Knockout" +
"<span class='tooltiptext'>" +
"Attempt to stealthily knockout the security guard. You have a " +
formatNumber(stealthKnockoutChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 10%. </span>";
document.getElementById("infiltration-assassinate").innerHTML = "Assassinate" +
"<span class='tooltiptext'>" +
"Attempt to assassinate the security guard. You have a " +
formatNumber(assassinateChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 5%. </span>";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"<span class='tooltiptext'>" +
"Attempt to sneak past the security guard. You have a " +
formatNumber(sneakChance*100, 2) + "% chance of success. " + formatNumber(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. </span>"; "If you fail, the security level will increase by 8%. </span>";
break;
document.getElementById("infiltration-bribe").innerHTML = "Bribe" +
"<span class='tooltiptext'>" + case InfiltrationScenarios.Guards:
"Attempt to bribe the security guard. You have a " + default:
formatNumber(bribeChance*100, 2) + "% chance of success. " + document.getElementById("infiltration-kill").innerHTML = "Kill" +
"<span class='tooltiptext'>" +
"Attempt to kill the security guard. You have a " +
formatNumber(killChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, " +
"the security level will decrease by 10%. </span>";
document.getElementById("infiltration-knockout").innerHTML = "Knockout" +
"<span class='tooltiptext'>" +
"Attempt to knockout the security guard. You have a " +
formatNumber(knockoutChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 3%. If you fail, the " +
"security level will increase by 10%. </span>";
document.getElementById("infiltration-stealthknockout").innerHTML = "Stealth Knockout" +
"<span class='tooltiptext'>" +
"Attempt to stealthily knockout the security guard. You have a " +
formatNumber(stealthKnockoutChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 10%. </span>";
document.getElementById("infiltration-assassinate").innerHTML = "Assassinate" +
"<span class='tooltiptext'>" +
"Attempt to assassinate the security guard. You have a " +
formatNumber(assassinateChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 5%. </span>";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"<span class='tooltiptext'>" +
"Attempt to sneak past the security guard. You have a " +
formatNumber(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. </span>";
document.getElementById("infiltration-bribe").innerHTML = "Bribe" +
"<span class='tooltiptext'>" +
"Attempt to bribe the security guard. You have a " +
formatNumber(bribeChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 15%. </span>"; "If you fail, the security level will increase by 15%. </span>";
break; break;
} }
@ -589,14 +589,14 @@ function attemptInfiltrationKill(inst) {
function getInfiltrationKillChance(inst) { function getInfiltrationKillChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.strength + (Player.strength +
Player.dexterity + Player.dexterity +
Player.agility) / (1.5 * lvl)); Player.agility) / (1.5 * lvl));
} }
//Knockout //Knockout
//Success: 3%, Failure: 10% //Success: 3%, Failure: 10%
function attemptInfiltrationKnockout(inst) { function attemptInfiltrationKnockout(inst) {
var chance = getInfiltrationKnockoutChance(inst); var chance = getInfiltrationKnockoutChance(inst);
@ -616,8 +616,8 @@ function attemptInfiltrationKnockout(inst) {
function getInfiltrationKnockoutChance(inst) { function getInfiltrationKnockoutChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.strength + (Player.strength +
Player.dexterity + Player.dexterity +
Player.agility) / (1.75 * lvl)); Player.agility) / (1.75 * lvl));
} }
@ -639,8 +639,8 @@ function attemptInfiltrationStealthKnockout(inst) {
function getInfiltrationStealthKnockoutChance(inst) { function getInfiltrationStealthKnockoutChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(0.5 * Player.strength + (0.5 * Player.strength +
2 * Player.dexterity + 2 * Player.dexterity +
2 * Player.agility) / (3 * lvl)); 2 * Player.agility) / (3 * lvl));
} }
@ -655,13 +655,13 @@ function attemptInfiltrationAssassinate(inst) {
return [true, 1]; return [true, 1];
} else { } else {
inst.securityLevel *= 1.05; inst.securityLevel *= 1.05;
return [false, 1.05]; return [false, 1.05];
} }
} }
function getInfiltrationAssassinateChance(inst) { function getInfiltrationAssassinateChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.dexterity + (Player.dexterity +
0.5 * Player.agility) / (2 * lvl)); 0.5 * Player.agility) / (2 * lvl));
} }
@ -682,14 +682,14 @@ function attemptInfiltrationDestroySecurity(inst) {
inst.securityLevel *= 1.1; inst.securityLevel *= 1.1;
return [false, 1.1]; return [false, 1.1];
} }
} }
function getInfiltrationDestroySecurityChance(inst) { function getInfiltrationDestroySecurityChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.strength + (Player.strength +
Player.dexterity + Player.dexterity +
Player.agility) / (2 * lvl)); Player.agility) / (2 * lvl));
} }
@ -706,12 +706,12 @@ function attemptInfiltrationHack(inst) {
inst.securityLevel *= 1.05; inst.securityLevel *= 1.05;
return [false, 1.05]; return [false, 1.05];
} }
} }
function getInfiltrationHackChance(inst) { function getInfiltrationHackChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.hacking_skill) / lvl); (Player.hacking_skill) / lvl);
} }
@ -730,7 +730,7 @@ function attemptInfiltrationSneak(inst) {
function getInfiltrationSneakChance(inst) { function getInfiltrationSneakChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.agility + (Player.agility +
0.5 * Player.dexterity) / (2 * lvl)); 0.5 * Player.dexterity) / (2 * lvl));
} }
@ -742,7 +742,7 @@ function attemptInfiltrationPickLockedDoor(inst) {
inst.gainDexterityExp(inst.securityLevel / 250) * Player.dexterity_exp_mult; inst.gainDexterityExp(inst.securityLevel / 250) * Player.dexterity_exp_mult;
if (Math.random() <= chance) { if (Math.random() <= chance) {
inst.securityLevel *= 1.01; inst.securityLevel *= 1.01;
return [true, 1.01]; return [true, 1.01];
} else { } else {
inst.securityLevel *= 1.03; inst.securityLevel *= 1.03;
return [false, 1.03]; return [false, 1.03];
@ -751,7 +751,7 @@ function attemptInfiltrationPickLockedDoor(inst) {
function getInfiltrationPickLockedDoorChance(inst) { function getInfiltrationPickLockedDoorChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.dexterity) / lvl); (Player.dexterity) / lvl);
} }
@ -770,7 +770,7 @@ function attemptInfiltrationBribe(inst) {
function getInfiltrationBribeChance(inst) { function getInfiltrationBribeChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(Player.charisma) / lvl); (Player.charisma) / lvl);
} }
@ -790,7 +790,7 @@ function attemptInfiltrationEscape(inst) {
function getInfiltrationEscapeChance(inst) { function getInfiltrationEscapeChance(inst) {
var lvl = inst.securityLevel; var lvl = inst.securityLevel;
return Math.min(0.95, return Math.min(0.95,
(2 * Player.agility + (2 * Player.agility +
Player.dexterity) / lvl); Player.dexterity) / lvl);
} }

@ -988,7 +988,7 @@ displayLocationContent = function() {
slumsDescText.style.display = "block"; slumsDescText.style.display = "block";
slumsShoplift.style.display = "block"; slumsShoplift.style.display = "block";
slumsShoplift.innerHTML = "Shoplift (" + (shopliftChance*100).toFixed(3) + "% chance of success)"; slumsShoplift.innerHTML = "Shoplift (" + (shopliftChance*100).toFixed(3) + "% chance of success)";
slumsShoplift.innerHTML += '<span class="tooltiptext"> Attempt to shoplift from a low-end retailers </span>'; slumsShoplift.innerHTML += '<span class="tooltiptext"> Attempt to shoplift from a low-end retailer </span>';
slumsMug.style.display = "block"; slumsMug.style.display = "block";
slumsMug.innerHTML = "Mug someone (" + (mugChance*100).toFixed(3) + "% chance of success)"; slumsMug.innerHTML = "Mug someone (" + (mugChance*100).toFixed(3) + "% chance of success)";
slumsMug.innerHTML += '<span class="tooltiptext"> Attempt to mug a random person on the street </span>'; slumsMug.innerHTML += '<span class="tooltiptext"> Attempt to mug a random person on the street </span>';
@ -1764,11 +1764,11 @@ initLocationButtons = function() {
} }
travelToCity = function(destCityName, cost) { travelToCity = function(destCityName, cost) {
if (cost > Player.money) { if (Player.money.lt(cost)) {
dialogBoxCreate("You cannot afford to travel to " + destCityName); dialogBoxCreate("You cannot afford to travel to " + destCityName);
return; return;
} }
Player.money -= cost; Player.loseMoney(cost);
Player.city = destCityName; Player.city = destCityName;
dialogBoxCreate("You are now in " + destCityName + "!"); dialogBoxCreate("You are now in " + destCityName + "!");
@ -1776,7 +1776,7 @@ travelToCity = function(destCityName, cost) {
} }
purchaseTorRouter = function() { purchaseTorRouter = function() {
if (CONSTANTS.TorRouterCost > Player.money) { if (Player.money.lt(CONSTANTS.TorRouterCost)) {
dialogBoxCreate("You cannot afford to purchase the Tor router"); dialogBoxCreate("You cannot afford to purchase the Tor router");
return; return;
} }

@ -107,8 +107,12 @@ function evaluate(exp, workerScript) {
if (exp.computed){ if (exp.computed){
var p = evaluate(exp.property, workerScript); var p = evaluate(exp.property, workerScript);
p.then(function(index) { p.then(function(index) {
if (index >= object.length) {
return reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays"));
}
resolve(object[index]); resolve(object[index]);
}).catch(function(e) { }).catch(function(e) {
console.log("here");
reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression")); reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression"));
}); });
} else { } else {
@ -647,7 +651,7 @@ function scriptCalculateExpGain(server) {
if (server.baseDifficulty == null) { if (server.baseDifficulty == null) {
server.baseDifficulty = server.hackDifficulty; server.baseDifficulty = server.hackDifficulty;
} }
return (server.baseDifficulty * Player.hacking_exp_mult * 0.3 + 2); return (server.baseDifficulty * Player.hacking_exp_mult * 0.3 + 3);
} }
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument //The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument

@ -459,8 +459,8 @@ function NetscriptFunctions(workerScript) {
} }
if (server.hostname == "home") { if (server.hostname == "home") {
//Return player's money //Return player's money
workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money, 2)); workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money.toNumber(), 2));
return Player.money; return Player.money.toNumber();
} }
workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname); workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname);
return server.moneyAvailable; return server.moneyAvailable;
@ -592,7 +592,7 @@ function NetscriptFunctions(workerScript) {
shares = Math.round(shares); shares = Math.round(shares);
var totalPrice = stock.price * shares; var totalPrice = stock.price * shares;
if (Player.money < totalPrice + CONSTANTS.StockMarketCommission) { if (Player.money.lt(totalPrice + CONSTANTS.StockMarketCommission)) {
workerScript.scriptRef.log("Not enough money to purchase " + formatNumber(shares, 0) + " shares of " + workerScript.scriptRef.log("Not enough money to purchase " + formatNumber(shares, 0) + " shares of " +
symbol + ". Need $" + symbol + ". Need $" +
formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString()); formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString());
@ -666,8 +666,8 @@ function NetscriptFunctions(workerScript) {
return ""; return "";
} }
var cost = 2 * ram * CONSTANTS.BaseCostFor1GBOfRamServer; var cost = ram * CONSTANTS.BaseCostFor1GBOfRamServer;
if (cost > Player.money) { if (Player.money.lt(cost)) {
workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + formatNumber(cost, 2)); workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + formatNumber(cost, 2));
return ""; return "";
} }

@ -46,7 +46,7 @@ function runScriptsLoop() {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) { if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
try { try {
var ast = acorn.parse(workerScripts[i].code); var ast = acorn.parse(workerScripts[i].code);
//console.log(ast); console.log(ast);
} catch (e) { } catch (e) {
console.log("Error parsing script: " + workerScripts[i].name); console.log("Error parsing script: " + workerScripts[i].name);
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e); dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);

@ -62,9 +62,9 @@ function PlayerObject() {
this.faction_rep_mult = 1; this.faction_rep_mult = 1;
//Money //Money
this.money = 1000; this.money = new Decimal(1000);
this.total_money = 0; //Total money ever earned in this "simulation" this.total_money = new Decimal(0); //Total money ever earned in this "simulation"
this.lifetime_money = 0; //Total money ever earned this.lifetime_money = new Decimal(0); //Total money ever earned
//IP Address of Starting (home) computer //IP Address of Starting (home) computer
this.homeComputer = ""; this.homeComputer = "";
@ -269,7 +269,7 @@ PlayerObject.prototype.calculateExpGain = function() {
if (s.baseDifficulty == null) { if (s.baseDifficulty == null) {
s.baseDifficulty = s.hackDifficulty; s.baseDifficulty = s.hackDifficulty;
} }
return (s.baseDifficulty * this.hacking_exp_mult * 0.3 + 2); return (s.baseDifficulty * this.hacking_exp_mult * 0.3 + 3);
} }
//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 //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
@ -298,16 +298,16 @@ PlayerObject.prototype.gainMoney = function(money) {
if (isNaN(money)) { if (isNaN(money)) {
console.log("ERR: NaN passed into Player.gainMoney()"); return; console.log("ERR: NaN passed into Player.gainMoney()"); return;
} }
this.money += money; this.money = this.money.plus(money);
this.total_money += money; this.total_money = this.total_money.plus(money);
this.lifetime_money += money; this.lifetime_money = this.lifetime_money.plus(money);
} }
PlayerObject.prototype.loseMoney = function(money) { PlayerObject.prototype.loseMoney = function(money) {
if (isNaN(money)) { if (isNaN(money)) {
console.log("ERR: NaN passed into Player.loseMoney()"); return; console.log("ERR: NaN passed into Player.loseMoney()"); return;
} }
this.money -= money; this.money = this.money.minus(money);
} }
PlayerObject.prototype.gainHackingExp = function(exp) { PlayerObject.prototype.gainHackingExp = function(exp) {

@ -61,7 +61,7 @@ function prestigeAugmentation() {
Player.agility_exp = 0; Player.agility_exp = 0;
Player.charisma_exp = 0; Player.charisma_exp = 0;
Player.money = 1000; Player.money = new Decimal(1000);
Player.city = Locations.Sector12; Player.city = Locations.Sector12;
Player.location = ""; Player.location = "";
@ -144,7 +144,7 @@ function prestigeAugmentation() {
} }
if (augmentationExists(AugmentationNames.CashRoot) && if (augmentationExists(AugmentationNames.CashRoot) &&
Augmentations[AugmentationNames.CashRoot].owned) { Augmentations[AugmentationNames.CashRoot].owned) {
Player.money = 1000000; Player.money = new Decimal(1000000);
homeComp.programs.push(Programs.BruteSSHProgram); homeComp.programs.push(Programs.BruteSSHProgram);
} }
Player.currentServer = homeComp.ip; Player.currentServer = homeComp.ip;

@ -112,24 +112,12 @@ loadGame = function(saveObj) {
if (saveObj.hasOwnProperty("VersionSave")) { if (saveObj.hasOwnProperty("VersionSave")) {
try { try {
var ver = JSON.parse(saveObj.VersionSave, Reviver); var ver = JSON.parse(saveObj.VersionSave, Reviver);
if (CONSTANTS.Version == "0.26.3") {
Player.money = new Decimal(Player.money);
Player.total_money = new Decimal(Player.total_money);
Player.lifetime_money = new Decimal(Player.lifetime_money);
}
if (ver != CONSTANTS.Version) { if (ver != CONSTANTS.Version) {
if (CONSTANTS.Version == "0.21.0" || CONSTANTS.Version == "0.22.0" ||
CONSTANTS.Version == "0.22.1") {
dialogBoxCreate("All scripts automatically killed for the sake of compatibility " +
"with new version. If the game is still broken, try the following: " +
"Options -> Soft Reset -> Save Game -> Reload page. If that STILL " +
"doesn't work contact the dev");
//This is the big update that might break games. Kill all running scripts
for (var ip in AllServers) {
if (AllServers.hasOwnProperty(ip)) {
AllServers[ip].runningScripts = [];
AllServers[ip].runningScripts.length = 0;
}
}
}
if (CONSTANTS.Version == "0.23.0") {
Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver);
}
createNewUpdateText(); createNewUpdateText();
} }
} catch(e) { } catch(e) {
@ -204,25 +192,12 @@ loadImportedGame = function(saveObj, saveString) {
if (tempSaveObj.hasOwnProperty("VersionSave")) { if (tempSaveObj.hasOwnProperty("VersionSave")) {
try { try {
var ver = JSON.parse(tempSaveObj.VersionSave, Reviver); var ver = JSON.parse(tempSaveObj.VersionSave, Reviver);
if (ver != CONSTANTS.Version) { if (CONSTANTS.Version == "0.26.3") {
createNewUpdateText(); tempPlayer.money = new Decimal(tempPlayer.money);
tempPlayer.total_money = new Decimal(tempPlayer.total_money);
tempPlayer.lifetime_money = new Decimal(tempPlayer.lifetime_money);
} }
if (ver != CONSTANTS.Version) { if (ver != CONSTANTS.Version) {
if (CONSTANTS.Version == "0.21.0" || CONSTANTS.Version == "0.22.0" ||
CONSTANTS.Version == "0.22.1") {
console.log("here");
//This is the big update that might break games. Kill all running scripts
for (var ip in tempAllServers) {
if (tempAllServers.hasOwnProperty(ip)) {
tempAllServers[ip].runningScripts = [];
tempAllServers[ip].runningScripts.length = 0;
}
}
}
if (CONSTANTS.Version == "0.23.0") {
tempAugmentations = JSON.parse(saveObj.AugmentationsSave, Reviver);
}
createNewUpdateText(); createNewUpdateText();
} }
} catch(e) { } catch(e) {

@ -422,19 +422,19 @@ initForeignServers = function() {
//"Low level" targets //"Low level" targets
var FoodNStuffServer = new Server(); var FoodNStuffServer = new Server();
FoodNStuffServer.init(createRandomIp(), "foodnstuff", "Food N Stuff Supermarket", true, false, false, false, 4); FoodNStuffServer.init(createRandomIp(), "foodnstuff", "Food N Stuff Supermarket", true, false, false, false, 4);
FoodNStuffServer.setHackingParameters(1, 1000000, 10, 5); FoodNStuffServer.setHackingParameters(1, 2000000, 10, 5);
FoodNStuffServer.setPortProperties(0); FoodNStuffServer.setPortProperties(0);
AddToAllServers(FoodNStuffServer); AddToAllServers(FoodNStuffServer);
var SigmaCosmeticsServer = new Server(); var SigmaCosmeticsServer = new Server();
SigmaCosmeticsServer.init(createRandomIp(), "sigma-cosmetics", "Sigma Cosmetics", true, false, false, false, 4); SigmaCosmeticsServer.init(createRandomIp(), "sigma-cosmetics", "Sigma Cosmetics", true, false, false, false, 4);
SigmaCosmeticsServer.setHackingParameters(5, 1300000, 10, 10); SigmaCosmeticsServer.setHackingParameters(5, 2300000, 10, 10);
SigmaCosmeticsServer.setPortProperties(0); SigmaCosmeticsServer.setPortProperties(0);
AddToAllServers(SigmaCosmeticsServer); AddToAllServers(SigmaCosmeticsServer);
var JoesGunsServer = new Server(); var JoesGunsServer = new Server();
JoesGunsServer.init(createRandomIp(), "joesguns", "Joe's Guns", true, false, false, false, 4); JoesGunsServer.init(createRandomIp(), "joesguns", "Joe's Guns", true, false, false, false, 4);
JoesGunsServer.setHackingParameters(10, 1750000, 20, 20); JoesGunsServer.setHackingParameters(10, 2500000, 20, 20);
JoesGunsServer.setPortProperties(0); JoesGunsServer.setPortProperties(0);
AddToAllServers(JoesGunsServer); AddToAllServers(JoesGunsServer);
@ -446,13 +446,13 @@ initForeignServers = function() {
var NectarNightclubServer = new Server(); var NectarNightclubServer = new Server();
NectarNightclubServer.init(createRandomIp(), "nectar-net", "Nectar Nightclub Network", true, false, false, false, 4); NectarNightclubServer.init(createRandomIp(), "nectar-net", "Nectar Nightclub Network", true, false, false, false, 4);
NectarNightclubServer.setHackingParameters(20, 2000000, 20, 25); NectarNightclubServer.setHackingParameters(20, 2750000, 20, 25);
NectarNightclubServer.setPortProperties(0); NectarNightclubServer.setPortProperties(0);
AddToAllServers(NectarNightclubServer); AddToAllServers(NectarNightclubServer);
var NeoNightclubServer = new Server(); var NeoNightclubServer = new Server();
NeoNightclubServer.init(createRandomIp(), "neo-net", "Neo Nightclub Network", true, false, false, false, 4); NeoNightclubServer.init(createRandomIp(), "neo-net", "Neo Nightclub Network", true, false, false, false, 4);
NeoNightclubServer.setHackingParameters(50, 4500000, 25, 25); NeoNightclubServer.setHackingParameters(50, 5000000, 25, 25);
NeoNightclubServer.setPortProperties(1); NeoNightclubServer.setPortProperties(1);
AddToAllServers(NeoNightclubServer); AddToAllServers(NeoNightclubServer);
@ -464,13 +464,13 @@ initForeignServers = function() {
var HongFangTeaHouseServer = new Server(); var HongFangTeaHouseServer = new Server();
HongFangTeaHouseServer.init(createRandomIp(), "hong-fang-tea", "HongFang Teahouse", true, false, false, false, 4); HongFangTeaHouseServer.init(createRandomIp(), "hong-fang-tea", "HongFang Teahouse", true, false, false, false, 4);
HongFangTeaHouseServer.setHackingParameters(30, 2500000, 15, 15); HongFangTeaHouseServer.setHackingParameters(30, 3000000, 15, 15);
HongFangTeaHouseServer.setPortProperties(0); HongFangTeaHouseServer.setPortProperties(0);
AddToAllServers(HongFangTeaHouseServer); AddToAllServers(HongFangTeaHouseServer);
var HaraKiriSushiBarServer = new Server(); var HaraKiriSushiBarServer = new Server();
HaraKiriSushiBarServer.init(createRandomIp(), "harakiri-sushi", "HaraKiri Sushi Bar Network", true, false, false, false, 4); HaraKiriSushiBarServer.init(createRandomIp(), "harakiri-sushi", "HaraKiri Sushi Bar Network", true, false, false, false, 4);
HaraKiriSushiBarServer.setHackingParameters(40, 3500000, 15, 40); HaraKiriSushiBarServer.setHackingParameters(40, 4000000, 15, 40);
HaraKiriSushiBarServer.setPortProperties(0); HaraKiriSushiBarServer.setPortProperties(0);
AddToAllServers(HaraKiriSushiBarServer); AddToAllServers(HaraKiriSushiBarServer);

@ -4,7 +4,7 @@
*/ */
purchaseServer = function(ram, cost) { purchaseServer = function(ram, cost) {
//Check if player has enough money //Check if player has enough money
if (cost > Player.money) { if (Player.money.lt(cost)) {
dialogBoxCreate("You don't have enough money to purchase this server!"); dialogBoxCreate("You don't have enough money to purchase this server!");
return; return;
} }
@ -44,7 +44,7 @@ purchaseServer = function(ram, cost) {
purchaseRamForHomeComputer = function(cost) { purchaseRamForHomeComputer = function(cost) {
if (cost > Player.money) { if (Player.money.lt(cost)) {
dialogBoxCreate("You do not have enough money to purchase additional RAM for your home computer"); dialogBoxCreate("You do not have enough money to purchase additional RAM for your home computer");
return; return;
} }

@ -3,7 +3,7 @@ function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {
this.symbol = symbol; this.symbol = symbol;
this.name = name; this.name = name;
this.price = initPrice; this.price = initPrice;
this.playerShares = 0; this.playerShares = 0;
this.playerAvgPx = 0; this.playerAvgPx = 0;
this.mv = mv; this.mv = mv;
@ -46,7 +46,7 @@ function initStockSymbols() {
StockSymbols[Locations.AevumNetLinkTechnologies] = "NTLK"; StockSymbols[Locations.AevumNetLinkTechnologies] = "NTLK";
StockSymbols[Locations.IshimaOmegaSoftware] = "OMGA"; StockSymbols[Locations.IshimaOmegaSoftware] = "OMGA";
StockSymbols[Locations.Sector12FoodNStuff] = "FNS"; StockSymbols[Locations.Sector12FoodNStuff] = "FNS";
//Stocks for other companies //Stocks for other companies
StockSymbols["Sigma Cosmetics"] = "SGC"; StockSymbols["Sigma Cosmetics"] = "SGC";
StockSymbols["Joes Guns"] = "JGN"; StockSymbols["Joes Guns"] = "JGN";
@ -62,143 +62,143 @@ function initStockMarket() {
delete StockMarket[stk]; delete StockMarket[stk];
} }
} }
var ecorp = Locations.AevumECorp; var ecorp = Locations.AevumECorp;
var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.5, true, 16, getRandomInt(20000, 25000)); var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.5, true, 16, getRandomInt(20000, 25000));
StockMarket[ecorp] = ecorpStk; StockMarket[ecorp] = ecorpStk;
var megacorp = Locations.Sector12MegaCorp; var megacorp = Locations.Sector12MegaCorp;
var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.5, true, 16, getRandomInt(25000, 33000)); var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.5, true, 16, getRandomInt(25000, 33000));
StockMarket[megacorp] = megacorpStk; StockMarket[megacorp] = megacorpStk;
var blade = Locations.Sector12BladeIndustries; var blade = Locations.Sector12BladeIndustries;
var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, getRandomInt(15000, 22000)); var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, getRandomInt(15000, 22000));
StockMarket[blade] = bladeStk; StockMarket[blade] = bladeStk;
var clarke = Locations.AevumClarkeIncorporated; var clarke = Locations.AevumClarkeIncorporated;
var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, getRandomInt(15000, 20000)); var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, getRandomInt(15000, 20000));
StockMarket[clarke] = clarkeStk; StockMarket[clarke] = clarkeStk;
var omnitek = Locations.VolhavenOmniTekIncorporated; var omnitek = Locations.VolhavenOmniTekIncorporated;
var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, getRandomInt(35000, 40000)); var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, getRandomInt(35000, 40000));
StockMarket[omnitek] = omnitekStk; StockMarket[omnitek] = omnitekStk;
var foursigma = Locations.Sector12FourSigma; var foursigma = Locations.Sector12FourSigma;
var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.1, true, 18, getRandomInt(60000, 70000)); var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.1, true, 18, getRandomInt(60000, 70000));
StockMarket[foursigma] = foursigmaStk; StockMarket[foursigma] = foursigmaStk;
var kuaigong = Locations.ChongqingKuaiGongInternational; var kuaigong = Locations.ChongqingKuaiGongInternational;
var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, getRandomInt(20000, 24000)); var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, getRandomInt(20000, 24000));
StockMarket[kuaigong] = kuaigongStk; StockMarket[kuaigong] = kuaigongStk;
var fulcrum = Locations.AevumFulcrumTechnologies; var fulcrum = Locations.AevumFulcrumTechnologies;
var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 17, getRandomInt(30000, 35000)); var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 17, getRandomInt(30000, 35000));
StockMarket[fulcrum] = fulcrumStk; StockMarket[fulcrum] = fulcrumStk;
var storm = Locations.IshimaStormTechnologies; var storm = Locations.IshimaStormTechnologies;
var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, getRandomInt(21000, 24000)); var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, getRandomInt(21000, 24000));
StockMarket[storm] = stormStk; StockMarket[storm] = stormStk;
var defcomm = Locations.NewTokyoDefComm; var defcomm = Locations.NewTokyoDefComm;
var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, getRandomInt(10000, 15000)); var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, getRandomInt(10000, 15000));
StockMarket[defcomm] = defcommStk; StockMarket[defcomm] = defcommStk;
var helios = Locations.VolhavenHeliosLabs; var helios = Locations.VolhavenHeliosLabs;
var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, getRandomInt(12000, 16000)); var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, getRandomInt(12000, 16000));
StockMarket[helios] = heliosStk; StockMarket[helios] = heliosStk;
var vitalife = Locations.NewTokyoVitaLife; var vitalife = Locations.NewTokyoVitaLife;
var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, getRandomInt(10000, 12000)); var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, getRandomInt(10000, 12000));
StockMarket[vitalife] = vitalifeStk; StockMarket[vitalife] = vitalifeStk;
var icarus = Locations.Sector12IcarusMicrosystems; var icarus = Locations.Sector12IcarusMicrosystems;
var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, getRandomInt(16000, 20000)); var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, getRandomInt(16000, 20000));
StockMarket[icarus] = icarusStk; StockMarket[icarus] = icarusStk;
var universalenergy = Locations.Sector12UniversalEnergy; var universalenergy = Locations.Sector12UniversalEnergy;
var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, getRandomInt(20000, 25000)); var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, getRandomInt(20000, 25000));
StockMarket[universalenergy] = universalenergyStk; StockMarket[universalenergy] = universalenergyStk;
var galactic = Locations.AevumGalacticCybersystems; var galactic = Locations.AevumGalacticCybersystems;
var galacticStk = new Stock(galactic, StockSymbols[galactic], 0.6, true, 5, getRandomInt(8000, 10000)); var galacticStk = new Stock(galactic, StockSymbols[galactic], 0.6, true, 5, getRandomInt(8000, 10000));
StockMarket[galactic] = galacticStk; StockMarket[galactic] = galacticStk;
var aerocorp = Locations.AevumAeroCorp; var aerocorp = Locations.AevumAeroCorp;
var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, getRandomInt(10000, 15000)); var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, getRandomInt(10000, 15000));
StockMarket[aerocorp] = aerocorpStk; StockMarket[aerocorp] = aerocorpStk;
var omnia = Locations.VolhavenOmniaCybersystems; var omnia = Locations.VolhavenOmniaCybersystems;
var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, getRandomInt(9000, 12000)); var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, getRandomInt(9000, 12000));
StockMarket[omnia] = omniaStk; StockMarket[omnia] = omniaStk;
var solaris = Locations.ChongqingSolarisSpaceSystems; var solaris = Locations.ChongqingSolarisSpaceSystems;
var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, getRandomInt(18000, 24000)); var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, getRandomInt(18000, 24000));
StockMarket[solaris] = solarisStk; StockMarket[solaris] = solarisStk;
var globalpharm = Locations.NewTokyoGlobalPharmaceuticals; var globalpharm = Locations.NewTokyoGlobalPharmaceuticals;
var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, getRandomInt(18000, 24000)); var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, getRandomInt(18000, 24000));
StockMarket[globalpharm] = globalpharmStk; StockMarket[globalpharm] = globalpharmStk;
var nova = Locations.IshimaNovaMedical; var nova = Locations.IshimaNovaMedical;
var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, getRandomInt(18000, 24000)); var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, getRandomInt(18000, 24000));
StockMarket[nova] = novaStk; StockMarket[nova] = novaStk;
var watchdog = Locations.AevumWatchdogSecurity; var watchdog = Locations.AevumWatchdogSecurity;
var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 1, true, 1.5, getRandomInt(5000, 7500)); var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 1, true, 1.5, getRandomInt(5000, 7500));
StockMarket[watchdog] = watchdogStk; StockMarket[watchdog] = watchdogStk;
var lexocorp = Locations.VolhavenLexoCorp; var lexocorp = Locations.VolhavenLexoCorp;
var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, getRandomInt(5000, 7500)); var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, getRandomInt(5000, 7500));
StockMarket[lexocorp] = lexocorpStk; StockMarket[lexocorp] = lexocorpStk;
var rho = Locations.AevumRhoConstruction; var rho = Locations.AevumRhoConstruction;
var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, getRandomInt(3000, 6000)); var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, getRandomInt(3000, 6000));
StockMarket[rho] = rhoStk; StockMarket[rho] = rhoStk;
var alpha = Locations.Sector12AlphaEnterprises; var alpha = Locations.Sector12AlphaEnterprises;
var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, getRandomInt(5000, 7500)); var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, getRandomInt(5000, 7500));
StockMarket[alpha] = alphaStk; StockMarket[alpha] = alphaStk;
var syscore = Locations.VolhavenSysCoreSecurities; var syscore = Locations.VolhavenSysCoreSecurities;
var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, getRandomInt(4000, 7000)) var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, getRandomInt(4000, 7000))
StockMarket[syscore] = syscoreStk; StockMarket[syscore] = syscoreStk;
var computek = Locations.VolhavenCompuTek; var computek = Locations.VolhavenCompuTek;
var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, getRandomInt(2000, 5000)); var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, getRandomInt(2000, 5000));
StockMarket[computek] = computekStk; StockMarket[computek] = computekStk;
var netlink = Locations.AevumNetLinkTechnologies; var netlink = Locations.AevumNetLinkTechnologies;
var netlinkStk = new Stock(netlink, StockSymbols[netlink], 1, true, 1, getRandomInt(2000, 4000)); var netlinkStk = new Stock(netlink, StockSymbols[netlink], 1, true, 1, getRandomInt(2000, 4000));
StockMarket[netlink] = netlinkStk; StockMarket[netlink] = netlinkStk;
var omega = Locations.IshimaOmegaSoftware; var omega = Locations.IshimaOmegaSoftware;
var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, getRandomInt(3000, 6000)); var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, getRandomInt(3000, 6000));
StockMarket[omega] = omegaStk; StockMarket[omega] = omegaStk;
var fns = Locations.Sector12FoodNStuff; var fns = Locations.Sector12FoodNStuff;
var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, getRandomInt(1000, 4000)); var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, getRandomInt(1000, 4000));
StockMarket[fns] = fnsStk; StockMarket[fns] = fnsStk;
var sigmacosm = "Sigma Cosmetics"; var sigmacosm = "Sigma Cosmetics";
var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, getRandomInt(2000, 3000)); var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, getRandomInt(2000, 3000));
StockMarket[sigmacosm] = sigmacosmStk; StockMarket[sigmacosm] = sigmacosmStk;
var joesguns = "Joes Guns"; var joesguns = "Joes Guns";
var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, getRandomInt(500, 1000)); var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, getRandomInt(500, 1000));
StockMarket[joesguns] = joesgunsStk; StockMarket[joesguns] = joesgunsStk;
var catalyst = "Catalyst Ventures"; var catalyst = "Catalyst Ventures";
var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, getRandomInt(1000, 1500)); var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, getRandomInt(1000, 1500));
StockMarket[catalyst] = catalystStk; StockMarket[catalyst] = catalystStk;
var taiyang = "Taiyang Digital"; var taiyang = "Taiyang Digital";
var taiyangStk = new Stock(taiyang, StockSymbols[taiyang], 0.75, true, 12, getRandomInt(25000, 30000)); var taiyangStk = new Stock(taiyang, StockSymbols[taiyang], 0.75, true, 12, getRandomInt(25000, 30000));
StockMarket[taiyang] = taiyangStk; StockMarket[taiyang] = taiyangStk;
var microdyne = "Microdyne Technologies"; var microdyne = "Microdyne Technologies";
var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, getRandomInt(20000, 25000)); var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, getRandomInt(20000, 25000));
StockMarket[microdyne] = microdyneStk; StockMarket[microdyne] = microdyneStk;
var titanlabs = "Titan Laboratories"; var titanlabs = "Titan Laboratories";
var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, getRandomInt(15000, 20000)); var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, getRandomInt(15000, 20000));
StockMarket[titanlabs] = titanlabsStk; StockMarket[titanlabs] = titanlabsStk;
@ -240,22 +240,22 @@ function buyStock(stock, shares) {
return false; return false;
} }
shares = Math.round(shares); shares = Math.round(shares);
var totalPrice = stock.price * shares; var totalPrice = stock.price * shares;
if (Player.money < totalPrice + CONSTANTS.StockMarketCommission) { if (Player.money.lt(totalPrice + CONSTANTS.StockMarketCommission)) {
dialogBoxCreate("You do not have enough money to purchase this. You need $" + dialogBoxCreate("You do not have enough money to purchase this. You need $" +
formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString() + "."); formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString() + ".");
return false; return false;
} }
var origTotal = stock.playerShares * stock.playerAvgPx; var origTotal = stock.playerShares * stock.playerAvgPx;
Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission); Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission);
var newTotal = origTotal + totalPrice; var newTotal = origTotal + totalPrice;
stock.playerShares += shares; stock.playerShares += shares;
stock.playerAvgPx = newTotal / stock.playerShares; stock.playerAvgPx = newTotal / stock.playerShares;
updateStockPlayerPosition(stock); updateStockPlayerPosition(stock);
dialogBoxCreate("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + dialogBoxCreate("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
formatNumber(stock.price, 2) + " per share. You also paid $" + formatNumber(stock.price, 2) + " per share. You also paid $" +
formatNumber(CONSTANTS.StockMarketCommission, 2) + " in commission fees."); formatNumber(CONSTANTS.StockMarketCommission, 2) + " in commission fees.");
return true; return true;
} }
@ -277,8 +277,8 @@ function sellStock(stock, shares) {
stock.playerAvgPx = 0; stock.playerAvgPx = 0;
} }
updateStockPlayerPosition(stock); updateStockPlayerPosition(stock);
dialogBoxCreate("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + dialogBoxCreate("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
formatNumber(stock.price, 2) + " per share. After commissions, you gained " + formatNumber(stock.price, 2) + " per share. After commissions, you gained " +
"a total of $" + formatNumber(gains, 2)); "a total of $" + formatNumber(gains, 2));
return true; return true;
} }
@ -290,7 +290,7 @@ function updateStockPrices() {
var stock = StockMarket[name]; var stock = StockMarket[name];
var av = (v * stock.mv) / 100; var av = (v * stock.mv) / 100;
if (isNaN(av)) {av = .02;} if (isNaN(av)) {av = .02;}
var chc = 50; var chc = 50;
if (stock.b) { if (stock.b) {
chc = (chc + stock.otlkMag)/100; chc = (chc + stock.otlkMag)/100;
@ -299,7 +299,7 @@ function updateStockPrices() {
chc = (chc - stock.otlkMag)/100; chc = (chc - stock.otlkMag)/100;
if (isNaN(chc)) {chc = 0.5;} if (isNaN(chc)) {chc = 0.5;}
} }
var c = Math.random(); var c = Math.random();
if (c < chc) { if (c < chc) {
stock.price *= (1 + av); stock.price *= (1 + av);
@ -309,10 +309,10 @@ function updateStockPrices() {
} else { } else {
stock.price /= (1 + av); stock.price /= (1 + av);
if (Engine.currentPage == Engine.Page.StockMarket) { if (Engine.currentPage == Engine.Page.StockMarket) {
updateStockTicker(stock, false); updateStockTicker(stock, false);
} }
} }
var otlkMagChange = stock.otlkMag * av; var otlkMagChange = stock.otlkMag * av;
if (stock.otlkMag <= 0.1) { if (stock.otlkMag <= 0.1) {
otlkMagChange = 1; otlkMagChange = 1;
@ -334,11 +334,11 @@ var stockMarketContentCreated = false;
function displayStockMarketContent() { function displayStockMarketContent() {
if (Player.hasWseAccount == null) {Player.hasWseAccount = false;} if (Player.hasWseAccount == null) {Player.hasWseAccount = false;}
if (Player.hasTixApiAccess == null) {Player.hasTixApiAccess = false;} if (Player.hasTixApiAccess == null) {Player.hasTixApiAccess = false;}
//Purchase WSE Account button //Purchase WSE Account button
var wseAccountButton = clearEventListeners("stock-market-buy-account"); var wseAccountButton = clearEventListeners("stock-market-buy-account");
wseAccountButton.innerText = "Buy WSE Account - $" + formatNumber(CONSTANTS.WSEAccountCost, 2).toString(); wseAccountButton.innerText = "Buy WSE Account - $" + formatNumber(CONSTANTS.WSEAccountCost, 2).toString();
if (!Player.hasWseAccount && Player.money >= CONSTANTS.WSEAccountCost) { if (!Player.hasWseAccount && Player.money.gte(CONSTANTS.WSEAccountCost)) {
wseAccountButton.setAttribute("class", "a-link-button"); wseAccountButton.setAttribute("class", "a-link-button");
} else { } else {
wseAccountButton.setAttribute("class", "a-link-button-inactive"); wseAccountButton.setAttribute("class", "a-link-button-inactive");
@ -351,12 +351,12 @@ function displayStockMarketContent() {
displayStockMarketContent(); displayStockMarketContent();
return false; return false;
}); });
//Purchase TIX API Access account //Purchase TIX API Access account
var tixApiAccessButton = clearEventListeners("stock-market-buy-tix-api"); var tixApiAccessButton = clearEventListeners("stock-market-buy-tix-api");
tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" + tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" +
formatNumber(CONSTANTS.TIXAPICost, 2).toString(); formatNumber(CONSTANTS.TIXAPICost, 2).toString();
if (!Player.hasTixApiAccess && Player.money >= CONSTANTS.TIXAPICost) { if (!Player.hasTixApiAccess && Player.money.gte(CONSTANTS.TIXAPICost)) {
tixApiAccessButton.setAttribute("class", "a-link-button"); tixApiAccessButton.setAttribute("class", "a-link-button");
} else { } else {
tixApiAccessButton.setAttribute("class", "a-link-button-inactive"); tixApiAccessButton.setAttribute("class", "a-link-button-inactive");
@ -367,10 +367,10 @@ function displayStockMarketContent() {
displayStockMarketContent(); displayStockMarketContent();
return false; return false;
}); });
var stockList = document.getElementById("stock-market-list"); var stockList = document.getElementById("stock-market-list");
if (stockList == null) {return;} if (stockList == null) {return;}
if (!Player.hasWseAccount) { if (!Player.hasWseAccount) {
stockMarketContentCreated = false; stockMarketContentCreated = false;
while (stockList.firstChild) { while (stockList.firstChild) {
@ -378,16 +378,16 @@ function displayStockMarketContent() {
} }
return; return;
} }
if (!stockMarketContentCreated && Player.hasWseAccount) { if (!stockMarketContentCreated && Player.hasWseAccount) {
console.log("Creating Stock Market UI"); console.log("Creating Stock Market UI");
document.getElementById("stock-market-commission").innerHTML = document.getElementById("stock-market-commission").innerHTML =
"Commission Fees: Every transaction you make has a $" + "Commission Fees: Every transaction you make has a $" +
formatNumber(CONSTANTS.StockMarketCommission, 2) + " commission fee.<br><br>" + formatNumber(CONSTANTS.StockMarketCommission, 2) + " commission fee.<br><br>" +
"WARNING: When you reset after installing Augmentations, the Stock Market is reset. " + "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " +
"This means all your positions are lost, so make sure to sell your stocks before installing " + "This means all your positions are lost, so make sure to sell your stocks before installing " +
"Augmentations!"; "Augmentations!";
var hdrLi = document.createElement("li"); var hdrLi = document.createElement("li");
var hdrName = document.createElement("p"); var hdrName = document.createElement("p");
var hdrSym = document.createElement("p"); var hdrSym = document.createElement("p");
@ -430,12 +430,12 @@ function displayStockMarketContent() {
hdrLi.appendChild(hdrShares); hdrLi.appendChild(hdrShares);
hdrLi.appendChild(hdrReturn); hdrLi.appendChild(hdrReturn);
stockList.appendChild(hdrLi); stockList.appendChild(hdrLi);
for (var name in StockMarket) { for (var name in StockMarket) {
if (StockMarket.hasOwnProperty(name)) { if (StockMarket.hasOwnProperty(name)) {
(function() { (function() {
var stock = StockMarket[name]; var stock = StockMarket[name];
var li = document.createElement("li"); var li = document.createElement("li");
var stkName = document.createElement("p"); var stkName = document.createElement("p");
var stkSym = document.createElement("p"); var stkSym = document.createElement("p");
@ -446,7 +446,7 @@ function displayStockMarketContent() {
var avgPriceTxt = document.createElement("p"); var avgPriceTxt = document.createElement("p");
var sharesTxt = document.createElement("p"); var sharesTxt = document.createElement("p");
var returnTxt = document.createElement("p"); var returnTxt = document.createElement("p");
var tickerId = "stock-market-ticker-" + stock.symbol; var tickerId = "stock-market-ticker-" + stock.symbol;
stkName.setAttribute("id", tickerId + "-name"); stkName.setAttribute("id", tickerId + "-name");
stkSym.setAttribute("id", tickerId + "-sym"); stkSym.setAttribute("id", tickerId + "-sym");
@ -457,21 +457,21 @@ function displayStockMarketContent() {
stkSym.style.width = "4%"; stkSym.style.width = "4%";
stkPrice.style.display = "inline-block"; stkPrice.style.display = "inline-block";
stkPrice.style.width = "9%"; stkPrice.style.width = "9%";
li.setAttribute("display", "inline-block"); li.setAttribute("display", "inline-block");
qtyInput.setAttribute("type", "text"); qtyInput.setAttribute("type", "text");
qtyInput.setAttribute("id", tickerId + "-qty-input"); qtyInput.setAttribute("id", tickerId + "-qty-input");
qtyInput.setAttribute("class", "stock-market-qty-input"); qtyInput.setAttribute("class", "stock-market-qty-input");
qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " +
" || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) " + " || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) " +
" || (95<event.keyCode && event.keyCode<106) " + " || (95<event.keyCode && event.keyCode<106) " +
" || (event.keyCode==8) || (event.keyCode==9) " + " || (event.keyCode==8) || (event.keyCode==9) " +
" || (event.keyCode>34 && event.keyCode<40) " + " || (event.keyCode>34 && event.keyCode<40) " +
" || (event.keyCode==46) )"); " || (event.keyCode==46) )");
qtyInput.style.width = "3%"; qtyInput.style.width = "3%";
qtyInput.style.display = "inline-block"; qtyInput.style.display = "inline-block";
buyButton.innerHTML = "Buy"; buyButton.innerHTML = "Buy";
buyButton.setAttribute("class", "stock-market-buy-sell-button"); buyButton.setAttribute("class", "stock-market-buy-sell-button");
buyButton.style.width = "3%"; buyButton.style.width = "3%";
@ -492,7 +492,7 @@ function displayStockMarketContent() {
if (isNaN(shares)) {return false;} if (isNaN(shares)) {return false;}
sellStock(stock, shares); sellStock(stock, shares);
}); });
avgPriceTxt.setAttribute("id", tickerId + "-avgprice"); avgPriceTxt.setAttribute("id", tickerId + "-avgprice");
avgPriceTxt.style.display = "inline-block"; avgPriceTxt.style.display = "inline-block";
avgPriceTxt.style.width = "8%"; avgPriceTxt.style.width = "8%";
@ -505,7 +505,7 @@ function displayStockMarketContent() {
returnTxt.style.display = "inline-block"; returnTxt.style.display = "inline-block";
returnTxt.style.width = "6%"; returnTxt.style.width = "6%";
returnTxt.style.color = "white"; returnTxt.style.color = "white";
li.appendChild(stkName); li.appendChild(stkName);
li.appendChild(stkSym); li.appendChild(stkSym);
li.appendChild(stkPrice); li.appendChild(stkPrice);
@ -518,11 +518,11 @@ function displayStockMarketContent() {
stockList.appendChild(li); stockList.appendChild(li);
}()); //Immediate invocation }()); //Immediate invocation
}//End if }//End if
} }
stockMarketContentCreated = true; stockMarketContentCreated = true;
} }
if (Player.hasWseAccount) { if (Player.hasWseAccount) {
for (var name in StockMarket) { for (var name in StockMarket) {
if (StockMarket.hasOwnProperty(name)) { if (StockMarket.hasOwnProperty(name)) {
@ -540,7 +540,7 @@ function updateStockTicker(stock, increase) {
stkName = document.getElementById(tickerId + "-name"); stkName = document.getElementById(tickerId + "-name");
stkSym = document.getElementById(tickerId + "-sym"); stkSym = document.getElementById(tickerId + "-sym");
stkPrice = document.getElementById(tickerId + "-price"); stkPrice = document.getElementById(tickerId + "-price");
if (stkName == null || stkSym == null || stkPrice == null) { if (stkName == null || stkSym == null || stkPrice == null) {
console.log("ERROR, couldn't find elements with tickerId " + tickerId); console.log("ERROR, couldn't find elements with tickerId " + tickerId);
return; return;
@ -548,19 +548,19 @@ function updateStockTicker(stock, increase) {
stkName.innerText = stock.name; stkName.innerText = stock.name;
stkSym.innerText = stock.symbol; stkSym.innerText = stock.symbol;
stkPrice.innerText = "$" + formatNumber(stock.price, 2).toString(); stkPrice.innerText = "$" + formatNumber(stock.price, 2).toString();
var returnTxt = document.getElementById(tickerId + "-return"); var returnTxt = document.getElementById(tickerId + "-return");
var totalCost = stock.playerShares * stock.playerAvgPx; var totalCost = stock.playerShares * stock.playerAvgPx;
var gains = (stock.price - stock.playerAvgPx) * stock.playerShares; var gains = (stock.price - stock.playerAvgPx) * stock.playerShares;
var percentageGains = gains / totalCost; var percentageGains = gains / totalCost;
if (totalCost > 0) { if (totalCost > 0) {
returnTxt.innerText = "$" + formatNumber(gains, 2) + " (" + returnTxt.innerText = "$" + formatNumber(gains, 2) + " (" +
formatNumber(percentageGains * 100, 2) + "%)"; formatNumber(percentageGains * 100, 2) + "%)";
} else { } else {
returnTxt.innerText = "N/A"; returnTxt.innerText = "N/A";
} }
if (increase) { if (increase) {
stkName.style.color = "#66ff33"; stkName.style.color = "#66ff33";
stkSym.style.color = "#66ff33"; stkSym.style.color = "#66ff33";
@ -577,10 +577,10 @@ function updateStockPlayerPosition(stock) {
var avgPriceTxt = document.getElementById(tickerId + "-avgprice"); var avgPriceTxt = document.getElementById(tickerId + "-avgprice");
var sharesTxt = document.getElementById(tickerId + "-shares"); var sharesTxt = document.getElementById(tickerId + "-shares");
if (avgPriceTxt == null || sharesTxt == null) { if (avgPriceTxt == null || sharesTxt == null) {
dialogBoxCreate("Could not find element for player positions for stock " + dialogBoxCreate("Could not find element for player positions for stock " +
stock.symbol + ". This is a bug please contact developer"); stock.symbol + ". This is a bug please contact developer");
return; return;
} }
avgPriceTxt.innerText = "$" + formatNumber(stock.playerAvgPx, 2); avgPriceTxt.innerText = "$" + formatNumber(stock.playerAvgPx, 2);
sharesTxt.innerText = stock.playerShares.toString(); sharesTxt.innerText = stock.playerShares.toString();
} }

@ -1388,7 +1388,7 @@ var Terminal = {
break; break;
case Programs.Flight: case Programs.Flight:
post("Augmentations: " + Player.augmentations.length + " / 30"); post("Augmentations: " + Player.augmentations.length + " / 30");
post("Money: $" + formatNumber(Player.money, 2) + " / $" + formatNumber(100000000000, 2)); post("Money: $" + formatNumber(Player.money.toNumber(), 2) + " / $" + formatNumber(100000000000, 2));
post("One path below must be fulfilled..."); post("One path below must be fulfilled...");
post("----------HACKING PATH----------"); post("----------HACKING PATH----------");
post("Hacking skill: " + Player.hacking_skill + " / 2500"); post("Hacking skill: " + Player.hacking_skill + " / 2500");

@ -368,7 +368,7 @@ var Engine = {
if (Player.hp == null) {Player.hp = Player.max_hp;} if (Player.hp == null) {Player.hp = Player.max_hp;}
document.getElementById("character-overview-text").innerHTML = document.getElementById("character-overview-text").innerHTML =
("Hp: " + Player.hp + " / " + Player.max_hp + "<br>" + ("Hp: " + Player.hp + " / " + Player.max_hp + "<br>" +
"Money: $" + formatNumber(Player.money, 2) + "<br>" + "Money: $" + formatNumber(Player.money.toNumber(), 2) + "<br>" +
"Hack: " + (Player.hacking_skill).toLocaleString() + "<br>" + "Hack: " + (Player.hacking_skill).toLocaleString() + "<br>" +
"Str: " + (Player.strength).toLocaleString() + "<br>" + "Str: " + (Player.strength).toLocaleString() + "<br>" +
"Def: " + (Player.defense).toLocaleString() + "<br>" + "Def: " + (Player.defense).toLocaleString() + "<br>" +
@ -389,7 +389,7 @@ var Engine = {
'Current City: ' + Player.city + '<br><br>' + 'Current City: ' + Player.city + '<br><br>' +
'Employer: ' + Player.companyName + '<br>' + 'Employer: ' + Player.companyName + '<br>' +
'Job Title: ' + companyPosition + '<br><br>' + 'Job Title: ' + companyPosition + '<br><br>' +
'Money: $' + formatNumber(Player.money, 2)+ '<br><br><br>' + 'Money: $' + formatNumber(Player.money.toNumber(), 2)+ '<br><br><br>' +
'<b>Stats</b><br><br>' + '<b>Stats</b><br><br>' +
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() + 'Hacking Level: ' + (Player.hacking_skill).toLocaleString() +
" (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' + " (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' +

@ -1,7 +1,7 @@
/* Pop up Purchase Augmentation Box */ /* Pop up Purchase Augmentation Box */
function purchaseAugmentationBoxInit() { function purchaseAugmentationBoxInit() {
var cancelButton = document.getElementById("purchase-augmentation-box-cancel"); var cancelButton = document.getElementById("purchase-augmentation-box-cancel");
//Close Dialog box //Close Dialog box
cancelButton.addEventListener("click", function() { cancelButton.addEventListener("click", function() {
purchaseAugmentationBoxClose(); purchaseAugmentationBoxClose();
@ -30,14 +30,14 @@ purchaseAugmentationBoxSetText = function(txt) {
purchaseAugmentationBoxCreate = function(aug, fac) { purchaseAugmentationBoxCreate = function(aug, fac) {
document.getElementById("purchase-augmentation-box-aug-name").innerHTML = aug.name; document.getElementById("purchase-augmentation-box-aug-name").innerHTML = aug.name;
document.getElementById("purchase-augmentation-box-aug-info").innerHTML = aug.info; document.getElementById("purchase-augmentation-box-aug-info").innerHTML = aug.info;
purchaseAugmentationBoxSetText("<br>Would you like to purchase the " + aug.name + " Augmentation for $" + purchaseAugmentationBoxSetText("<br>Would you like to purchase the " + aug.name + " Augmentation for $" +
formatNumber(aug.baseCost * fac.augmentationPriceMult, 2) + "?"); formatNumber(aug.baseCost * fac.augmentationPriceMult, 2) + "?");
//Clear old event listeners from Confirm button //Clear old event listeners from Confirm button
var newConfirmButton = clearEventListeners("purchase-augmentation-box-confirm"); var newConfirmButton = clearEventListeners("purchase-augmentation-box-confirm");
newConfirmButton.addEventListener("click", function() { newConfirmButton.addEventListener("click", function() {
//TODO Requirements for specific augmentations (e.g Embedded Netburner Module b4 its upgrades) //TODO Requirements for specific augmentations (e.g Embedded Netburner Module b4 its upgrades)
if (aug.name == AugmentationNames.Targeting2 && if (aug.name == AugmentationNames.Targeting2 &&
Augmentations[AugmentationNames.Targeting1].owned == false) { Augmentations[AugmentationNames.Targeting1].owned == false) {
@ -48,16 +48,16 @@ purchaseAugmentationBoxCreate = function(aug, fac) {
} else if (aug.name == AugmentationNames.CombatRib2 && } else if (aug.name == AugmentationNames.CombatRib2 &&
Augmentations[AugmentationNames.CombatRib1].owned == false) { Augmentations[AugmentationNames.CombatRib1].owned == false) {
dialogBoxCreate("You must first install Combat Rib I before you can upgrade it to Combat Rib II"); dialogBoxCreate("You must first install Combat Rib I before you can upgrade it to Combat Rib II");
} else if (aug.name == AugmentationNames.CombatRib3 && } else if (aug.name == AugmentationNames.CombatRib3 &&
Augmentations[AugmentationNames.CombatRib2].owned == false) { Augmentations[AugmentationNames.CombatRib2].owned == false) {
dialogBoxCreate("You must first install Combat Rib II before you can upgrade it to Combat Rib III"); dialogBoxCreate("You must first install Combat Rib II before you can upgrade it to Combat Rib III");
} else if (aug.name == AugmentationNames.GrapheneBionicSpine && } else if (aug.name == AugmentationNames.GrapheneBionicSpine &&
Augmentations[AugmentationNames.BionicSpine].owned == false) { Augmentations[AugmentationNames.BionicSpine].owned == false) {
dialogBoxCreate("You must first install a Bionic Spine before you can upgrade it to a Graphene Bionic Spine"); dialogBoxCreate("You must first install a Bionic Spine before you can upgrade it to a Graphene Bionic Spine");
} else if (aug.name == AugmentationNames.GrapheneBionicLegs && } else if (aug.name == AugmentationNames.GrapheneBionicLegs &&
Augmentations[AugmentationNames.BionicLegs].owned == false) { Augmentations[AugmentationNames.BionicLegs].owned == false) {
dialogBoxCreate("You must first install Bionic Legs before you can upgrade it to Graphene Bionic Legs"); dialogBoxCreate("You must first install Bionic Legs before you can upgrade it to Graphene Bionic Legs");
} else if (aug.name == AugmentationNames.ENMCoreV2 && } else if (aug.name == AugmentationNames.ENMCoreV2 &&
Augmentations[AugmentationNames.ENMCore].owned == false) { Augmentations[AugmentationNames.ENMCore].owned == false) {
dialogBoxCreate("You must first install Embedded Netburner Module Core Implant before you can upgrade it to V2"); dialogBoxCreate("You must first install Embedded Netburner Module Core Implant before you can upgrade it to V2");
} else if (aug.name == AugmentationNames.ENMCoreV3 && } else if (aug.name == AugmentationNames.ENMCoreV3 &&
@ -65,59 +65,59 @@ purchaseAugmentationBoxCreate = function(aug, fac) {
dialogBoxCreate("You must first install Embedded Netburner Module Core V2 Upgrade before you can upgrade it to V3"); dialogBoxCreate("You must first install Embedded Netburner Module Core V2 Upgrade before you can upgrade it to V3");
} else if ((aug.name == AugmentationNames.ENMCore || } else if ((aug.name == AugmentationNames.ENMCore ||
aug.name == AugmentationNames.ENMAnalyzeEngine || aug.name == AugmentationNames.ENMAnalyzeEngine ||
aug.name == AugmentationNames.ENMDMA) && aug.name == AugmentationNames.ENMDMA) &&
Augmentations[AugmentationNames.ENM].owned == false) { Augmentations[AugmentationNames.ENM].owned == false) {
dialogBoxCreate("You must first install the Embedded Netburner Module before installing any upgrades to it"); dialogBoxCreate("You must first install the Embedded Netburner Module before installing any upgrades to it");
} else if ((aug.name == AugmentationNames.PCDNIOptimizer || } else if ((aug.name == AugmentationNames.PCDNIOptimizer ||
aug.name == AugmentationNames.PCDNINeuralNetwork) && aug.name == AugmentationNames.PCDNINeuralNetwork) &&
Augmentations[AugmentationNames.PCDNI].owned == false) { Augmentations[AugmentationNames.PCDNI].owned == false) {
dialogBoxCreate("You must first install the Pc Direct-Neural Interface before installing this upgrade"); dialogBoxCreate("You must first install the Pc Direct-Neural Interface before installing this upgrade");
} else if (aug.name == AugmentationNames.GrapheneBrachiBlades && } else if (aug.name == AugmentationNames.GrapheneBrachiBlades &&
Augmentations[AugmentationNames.BrachiBlades].owned == false) { Augmentations[AugmentationNames.BrachiBlades].owned == false) {
dialogBoxCreate("You must first install the Brachi Blades augmentation before installing this upgrade"); dialogBoxCreate("You must first install the Brachi Blades augmentation before installing this upgrade");
} else if (aug.name == AugmentationNames.GrapheneBionicArms && } else if (aug.name == AugmentationNames.GrapheneBionicArms &&
Augmentations[AugmentationNames.BionicArms].owned == false) { Augmentations[AugmentationNames.BionicArms].owned == false) {
dialogBoxCreate("You must first install the Bionic Arms augmentation before installing this upgrade"); dialogBoxCreate("You must first install the Bionic Arms augmentation before installing this upgrade");
} else if (Player.money >= (aug.baseCost * fac.augmentationPriceMult)) { } else if (Player.money.gte(aug.baseCost * fac.augmentationPriceMult)) {
var queuedAugmentation = new PlayerOwnedAugmentation(aug.name); var queuedAugmentation = new PlayerOwnedAugmentation(aug.name);
if (aug.name == AugmentationNames.NeuroFluxGovernor) { if (aug.name == AugmentationNames.NeuroFluxGovernor) {
queuedAugmentation.level = getNextNeurofluxLevel(); queuedAugmentation.level = getNextNeurofluxLevel();
} }
Player.queuedAugmentations.push(queuedAugmentation); Player.queuedAugmentations.push(queuedAugmentation);
Player.loseMoney((aug.baseCost * fac.augmentationPriceMult)); Player.loseMoney((aug.baseCost * fac.augmentationPriceMult));
dialogBoxCreate("You purchased " + aug.name + ". It's enhancements will not take " + dialogBoxCreate("You purchased " + aug.name + ". It's enhancements will not take " +
"effect until they are installed. To install your augmentations, go to the " + "effect until they are installed. To install your augmentations, go to the " +
"'Augmentations' tab on the left-hand navigation menu. Purchasing additional " + "'Augmentations' tab on the left-hand navigation menu. Purchasing additional " +
"augmentations will now be more expensive."); "augmentations will now be more expensive.");
//If you just purchased Neuroflux Governor, recalculate the cost //If you just purchased Neuroflux Governor, recalculate the cost
if (aug.name == AugmentationNames.NeuroFluxGovernor) { if (aug.name == AugmentationNames.NeuroFluxGovernor) {
var nextLevel = getNextNeurofluxLevel(); var nextLevel = getNextNeurofluxLevel();
--nextLevel; --nextLevel;
var mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); var mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel);
aug.setRequirements(500 * mult, 750000 * mult); aug.setRequirements(500 * mult, 750000 * mult);
for (var i = 0; i < Player.queuedAugmentations.length-1; ++i) { for (var i = 0; i < Player.queuedAugmentations.length-1; ++i) {
aug.baseCost *= CONSTANTS.MultipleAugMultiplier; aug.baseCost *= CONSTANTS.MultipleAugMultiplier;
} }
} }
for (var name in Augmentations) { for (var name in Augmentations) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier; Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier;
} }
} }
displayFactionAugmentations(fac.name); displayFactionAugmentations(fac.name);
} else { } else {
dialogBoxCreate("You don't have enough money to purchase this Augmentation!"); dialogBoxCreate("You don't have enough money to purchase this Augmentation!");
} }
purchaseAugmentationBoxClose(); purchaseAugmentationBoxClose();
return false; return false;
}); });
purchaseAugmentationBoxOpen(); purchaseAugmentationBoxOpen();
} }
@ -141,4 +141,4 @@ function getNextNeurofluxLevel() {
} }
} }
return nextLevel; return nextLevel;
} }