From cd0ecb961f8ab466f3e878d49327809ca522bd08 Mon Sep 17 00:00:00 2001 From: Desobediente Civil Date: Tue, 25 Jul 2017 03:01:24 -0300 Subject: [PATCH 1/2] Account for negative money This should guarantee that in the event the balance becomes negative, there will be no scrolling bars. --- css/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/styles.css b/css/styles.css index fdbdc3b48..e469d331a 100644 --- a/css/styles.css +++ b/css/styles.css @@ -326,7 +326,7 @@ a:link, a:visited { /*margin: 50% auto;*/ padding: 5px; border: 2px solid var(--my-highlight-color); - width: 18%; + width: 19%; overflow: auto; /* Enable scroll if needed */ background-color: #444; /* Fallback color */ z-index: 1; From 53d514d28ea18bc2483d657d6bf6decabe16998c Mon Sep 17 00:00:00 2001 From: danielyxie Date: Sat, 29 Jul 2017 11:25:40 -0500 Subject: [PATCH 2/2] Decimal.js support for player's money. Buffed early game servers. --- css/menupages.css | 4 + index.html | 1 + src/CompanyJobApplication.js | 2 +- src/Constants.js | 9 +- src/DarkWeb.js | 14 +- src/Faction.js | 28 +-- src/HacknetNode.js | 30 +-- src/Infiltration.js | 352 +++++++++++++++---------------- src/Location.js | 8 +- src/NetscriptEvaluator.js | 6 +- src/NetscriptFunctions.js | 10 +- src/NetscriptWorker.js | 2 +- src/Player.js | 16 +- src/Prestige.js | 4 +- src/SaveObject.js | 43 +--- src/Server.js | 14 +- src/ServerPurchases.js | 4 +- src/StockMarket.js | 168 +++++++-------- src/Terminal.js | 2 +- src/engine.js | 4 +- utils/PurchaseAugmentationBox.js | 52 ++--- 21 files changed, 381 insertions(+), 392 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index 23011b8c8..480d69c34 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -462,6 +462,10 @@ div.faction-clear { text-decoration: none; } +#augmentations-list li p { + width: 95%; +} + .installed-augmentation { /* TODO */ } diff --git a/index.html b/index.html index be43ffc65..fd161dc78 100644 --- a/index.html +++ b/index.html @@ -28,6 +28,7 @@ + diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js index d32ce9f03..255148296 100644 --- a/src/CompanyJobApplication.js +++ b/src/CompanyJobApplication.js @@ -105,7 +105,7 @@ function getJobRequirementText(company, pos, tooltiptext=false) { reqText += (reqDexterity.toString() + " dexterity
"); reqText += (reqAgility.toString() + " agility
"); reqText += (reqCharisma.toString() + " charisma
"); - reqText += (reqRep.toString() + " and reputation"); + reqText += (reqRep.toString() + " reputation"); } else { reqText = "(Requires "; if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");} diff --git a/src/Constants.js b/src/Constants.js index 3f4e67479..05eb6a334 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ 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 //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 */ BaseCostFor1GBOfRamHome: 30000, - BaseCostFor1GBOfRamServer: 60000, //1 GB of RAM + BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM BaseCostFor1GBOfRamHacknetNode: 30000, BaseCostForHacknetNode: 1000, @@ -678,6 +678,11 @@ CONSTANTS = { "World Stock Exchange account and TIX API Access
", LatestUpdate: + "v0.26.3
" + + "-Added support for large numbers using Decimal.js. Right now it only applies for the player's money
" + + "-Purchasing servers with the Netscript function purchaseServer() is no longer 2x as expensive as doing manually, " + + "it now costs the same
" + + "-Early game servers have more starting money
" + "v0.26.2
" + "-Major rebalancing and randomization of the amount of money that servers start with
" + "-Significantly lowered hacking exp gain from hacking servers. The exp gain for higher-level servers was lowered more than " + diff --git a/src/DarkWeb.js b/src/DarkWeb.js index 25c574dd7..09403e071 100644 --- a/src/DarkWeb.js +++ b/src/DarkWeb.js @@ -79,7 +79,7 @@ listAllDarkwebItems = function() { buyDarkwebItem = function(itemName) { if (itemName.toLowerCase() == Programs.BruteSSHProgram.toLowerCase()) { var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.BruteSSHProgram); 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()) { var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.FTPCrackProgram); 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()) { var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram); 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()) { var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.HTTPWormProgram); 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()) { var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.SQLInjectProgram); 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()) { var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.DeepscanV1); 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()) { var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program); - if (price > 0 && Player.money >= price) { + if (price > 0 && Player.money.gt(price)) { Player.loseMoney(price); Player.getHomeComputer().programs.push(Programs.DeepscanV2); post("You have purchased the DeepscanV2.exe program. The new program " + diff --git a/src/Faction.js b/src/Faction.js index af23322f3..45a7e0c9a 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -350,7 +350,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { var illuminatiFac = Factions["Illuminati"]; if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited && numAugmentations >= 30 && - this.money >= 150000000000 && + this.money.gte(150000000000) && this.hacking_skill >= 1500 && this.strength >= 1200 && this.defense >= 1200 && this.dexterity >= 1200 && this.agility >= 1200) { @@ -361,7 +361,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { var daedalusFac = Factions["Daedalus"]; if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited && numAugmentations >= 30 && - this.money >= 100000000000 && + this.money.gte(100000000000) && (this.hacking_skill >= 2500 || (this.strength >= 1500 && this.defense >= 1500 && this.dexterity >= 1500 && this.agility >= 1500))) { @@ -372,7 +372,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { var covenantFac = Factions["The Covenant"]; if (!covenantFac.isBanned && !covenantFac.isMember && !covenantFac.alreadyInvited && numAugmentations >= 30 && - this.money >= 75000000000 && + this.money.gte(75000000000) && this.hacking_skill >= 850 && this.strength >= 850 && this.defense >= 850 && @@ -494,42 +494,42 @@ PlayerObject.prototype.checkForFactionInvitations = function() { //Chongqing var chongqingFac = Factions["Chongqing"]; 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); } //Sector-12 var sector12Fac = Factions["Sector-12"]; 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); } //New Tokyo var newtokyoFac = Factions["New Tokyo"]; 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); } //Aevum var aevumFac = Factions["Aevum"]; 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); } //Ishima var ishimaFac = Factions["Ishima"]; 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); } //Volhaven var volhavenFac = Factions["Volhaven"]; 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); } @@ -559,7 +559,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 && this.dexterity >= 200 && this.agility >= 200 && (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) { invitedFactions.push(thesyndicateFac); } @@ -570,7 +570,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { (this.companyPosition.positionName == CompanyPositions.CTO.positionName || this.companyPosition.positionName == CompanyPositions.CFO.positionName || this.companyPosition.positionName == CompanyPositions.CEO.positionName) && - this.money >= 15000000 && this.karma <= -22) { + this.money.gte(15000000) && this.karma <= -22) { invitedFactions.push(silhouetteFac); } @@ -587,7 +587,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { var slumsnakesFac = Factions["Slum Snakes"]; if (!slumsnakesFac.isBanned && !slumsnakesFac.isMember && !slumsnakesFac.alreadyInvited && 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); } @@ -610,7 +610,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() { //Tian Di Hui var tiandihuiFac = Factions["Tian Di Hui"]; 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.Ishima)) { invitedFactions.push(tiandihuiFac); @@ -759,7 +759,7 @@ displayFactionContent = function(factionName) { var donateAmountVal = document.getElementById("faction-donate-input").value; if (isPositiveNumber(donateAmountVal)) { var numMoneyDonate = Number(donateAmountVal); - if (Player.money < numMoneyDonate) { + if (Player.money.lt(numMoneyDonate)) { dialogBoxCreate("You cannot afford to donate this much money!"); return; } diff --git a/src/HacknetNode.js b/src/HacknetNode.js index 70e3d00ff..e5d28825d 100644 --- a/src/HacknetNode.js +++ b/src/HacknetNode.js @@ -83,7 +83,7 @@ HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) { var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level); return this.purchaseLevelUpgrade(diff); } - if (cost > Player.money) {return false;} + if (Player.money.lt(cost)) {return false;} Player.loseMoney(cost); this.level += levels; this.updateMoneyGainRate(); @@ -113,7 +113,7 @@ HacknetNode.prototype.getRamUpgradeCost = function() { HacknetNode.prototype.purchaseRamUpgrade = function() { var cost = this.calculateRamUpgradeCost(); 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;} Player.loseMoney(cost); this.ram *= 2; //Ram is always doubled @@ -140,7 +140,7 @@ HacknetNode.prototype.getCoreUpgradeCost = function() { HacknetNode.prototype.purchaseCoreUpgrade = function() { var cost = this.calculateCoreUpgradeCost(); 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;} Player.loseMoney(cost); ++this.cores; @@ -179,7 +179,7 @@ purchaseHacknet = function() { var cost = getCostOfNextHacknetNode(); 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!"); return false; } @@ -243,23 +243,23 @@ updateHacknetNodesMultiplierButtons = function() { //Calculate the maximum number of times the Player can afford to upgrade //a Hacknet Node's level" getMaxNumberLevelUpgrades = function(nodeObj) { - if (nodeObj.calculateLevelUpgradeCost(1) > Player.money) {return 0;} + if (Player.money.lt(nodeObj.calculateLevelUpgradeCost(1))) {return 0;} var min = 1; var max = CONSTANTS.HacknetNodeMaxLevel-1; var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level; - if (nodeObj.calculateLevelUpgradeCost(levelsToMax) < Player.money) { + if (Player.money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) { return levelsToMax; } while (min <= max) { var curr = (min + max) / 2 | 0; if (curr != CONSTANTS.HacknetNodeMaxLevel && - nodeObj.calculateLevelUpgradeCost(curr) < Player.money && - nodeObj.calculateLevelUpgradeCost(curr+1) > Player.money) { + Player.money.gt(nodeObj.calculateLevelUpgradeCost(curr)) && + Player.money.lt(nodeObj.calculateLevelUpgradeCost(curr+1))) { return Math.min(levelsToMax, curr); - } else if (nodeObj.calculateLevelUpgradeCost(curr) > Player.money) { + } else if (Player.money.lt(nodeObj.calculateLevelUpgradeCost(curr))) { max = curr - 1; - } else if (nodeObj.calculateLevelUpgradeCost(curr) < Player.money) { + } else if (Player.money.gt(nodeObj.calculateLevelUpgradeCost(curr))) { min = curr + 1; } else { return Math.min(levelsToMax, curr); @@ -299,7 +299,7 @@ updateHacknetNodesContent = function() { var cost = getCostOfNextHacknetNode(); var purchaseButton = document.getElementById("hacknet-nodes-purchase-button"); purchaseButton.innerHTML = "Purchase Hacknet Node - $" + formatNumber(cost, 2); - if (cost > Player.money) { + if (Player.money.lt(cost)) { purchaseButton.setAttribute("class", "a-link-button-inactive"); } else { purchaseButton.setAttribute("class", "a-link-button"); @@ -307,7 +307,7 @@ updateHacknetNodesContent = function() { //Update player's money var moneyElem = document.getElementById("hacknet-nodes-money"); - moneyElem.innerHTML = "Money: $" + formatNumber(Player.money, 2) + "
" + + moneyElem.innerHTML = "Money: $" + formatNumber(Player.money.toNumber(), 2) + "
" + "Total production from all Hacknet Nodes: $" + formatNumber(Player.totalHacknetNodeProduction, 2) + " / second"; //Update information in each owned hacknet node @@ -413,7 +413,7 @@ updateHacknetNodeDomElement = function(nodeObj) { var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier); upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier + " - $" + formatNumber(upgradeLevelCost, 2); - if (upgradeLevelCost > Player.money ) { + if (Player.money.lt(upgradeLevelCost)) { upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); } else { upgradeLevelButton.setAttribute("class", "a-link-button"); @@ -429,7 +429,7 @@ updateHacknetNodeDomElement = function(nodeObj) { } else { var upgradeRamCost = nodeObj.calculateRamUpgradeCost(); 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"); } else { upgradeRamButton.setAttribute("class", "a-link-button"); @@ -445,7 +445,7 @@ updateHacknetNodeDomElement = function(nodeObj) { } else { var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost(); 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"); } else { upgradeCoreButton.setAttribute("class", "a-link-button"); diff --git a/src/Infiltration.js b/src/Infiltration.js index 0e91f8216..058a145de 100644 --- a/src/Infiltration.js +++ b/src/Infiltration.js @@ -1,10 +1,10 @@ -/* Infiltration.js +/* Infiltration.js * * Kill * Knockout (nonlethal) * Stealth Knockout (nonlethal) * Assassinate - * + * * Hack Security * Destroy Security * Sneak past Security @@ -12,7 +12,7 @@ * Pick the locked door * * Bribe security - * + * * 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.baseValue = val; //Base value of company secrets this.secretsStolen = []; //Numbers representing value of stolen secrets - + this.hackingExpGained = 0; this.strExpGained = 0; this.defExpGained = 0; @@ -83,7 +83,7 @@ function endInfiltration(inst, success) { if (success) { infiltrationBoxCreate(inst); } - + clearEventListeners("infiltration-kill"); clearEventListeners("infiltration-knockout"); clearEventListeners("infiltration-stealthknockout"); @@ -94,14 +94,14 @@ function endInfiltration(inst, success) { clearEventListeners("infiltration-pickdoor"); clearEventListeners("infiltration-bribe"); clearEventListeners("infiltration-escape"); - + Engine.loadWorldContent(); } function nextInfiltrationLevel(inst) { ++inst.clearanceLevel; updateInfiltrationLevelText(inst); - + //Buttons var killButton = clearEventListeners("infiltration-kill"); var knockoutButton = clearEventListeners("infiltration-knockout"); @@ -113,7 +113,7 @@ function nextInfiltrationLevel(inst) { var pickdoorButton = clearEventListeners("infiltration-pickdoor"); var bribeButton = clearEventListeners("infiltration-bribe"); var escapeButton = clearEventListeners("infiltration-escape"); - + killButton.style.display = "none"; knockoutButton.style.display = "none"; stealthKnockoutButton.style.display = "none"; @@ -124,7 +124,7 @@ function nextInfiltrationLevel(inst) { pickdoorButton.style.display = "none"; bribeButton.style.display = "none"; escapeButton.style.display = "none"; - + var rand = getRandomInt(0, 5); //This needs to change if more scenarios are added var scenario = null; switch (rand) { @@ -149,8 +149,8 @@ function nextInfiltrationLevel(inst) { killButton.addEventListener("click", function() { var res = attemptInfiltrationKill(inst); if (res[0]) { - writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " + - "rest of the facility's security. The facility's security " + + writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " + + "rest of the facility's security. The facility's security " + "level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); Player.karma -= 1; endInfiltrationLevel(inst); @@ -158,8 +158,8 @@ function nextInfiltrationLevel(inst) { } else { 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 " + - "and raise the alarm! You take " + dmgTaken + " damage and " + - "the facility's security level increases by " + + "and raise the alarm! 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); @@ -177,8 +177,8 @@ function nextInfiltrationLevel(inst) { endInfiltrationLevel(inst); return false; } else { - 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 " + + 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 " + "has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); } updateInfiltrationButtons(inst, scenario); @@ -194,8 +194,8 @@ function nextInfiltrationLevel(inst) { killButton.addEventListener("click", function() { var res = attemptInfiltrationKill(inst); if (res[0]) { - writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " + - "rest of the facility's security. The facility's security " + + writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " + + "rest of the facility's security. The facility's security " + "level has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); Player.karma -= 3; endInfiltrationLevel(inst); @@ -203,8 +203,8 @@ function nextInfiltrationLevel(inst) { } else { var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense)); writeInfiltrationStatusText("You FAILED to kill the security guard. The guard fights back " + - "and raises the alarm! You take " + dmgTaken + " damage and " + - "the facility's security level has increased by " + + "and raises the alarm! You take " + dmgTaken + " damage and " + + "the facility's security level has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); if (Player.takeDamage(dmgTaken)) { endInfiltration(inst, false); @@ -224,8 +224,8 @@ function nextInfiltrationLevel(inst) { endInfiltrationLevel(inst); return false; } else { - 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 " + + 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 " + "has increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); } updateInfiltrationButtons(inst, scenario); @@ -236,39 +236,18 @@ function nextInfiltrationLevel(inst) { escapeButton.style.display = "block"; break; } - + knockoutButton.addEventListener("click", function() { var res = attemptInfiltrationKnockout(inst); 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."); writeInfiltrationStatusText("The facility's security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); endInfiltrationLevel(inst); return false; } else { var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense)); - 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 " + + 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)) { @@ -279,7 +258,28 @@ function nextInfiltrationLevel(inst) { 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 " + + "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() { var res = attemptInfiltrationHack(inst); if (res[0]) { @@ -288,14 +288,14 @@ function nextInfiltrationLevel(inst) { endInfiltrationLevel(inst); return false; } 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() + "%"); } updateInfiltrationButtons(inst, scenario); updateInfiltrationLevelText(inst); return false; }); - + destroySecurityButton.addEventListener("click", function() { var res = attemptInfiltrationDestroySecurity(inst); if (res[0]) { @@ -304,14 +304,14 @@ function nextInfiltrationLevel(inst) { endInfiltrationLevel(inst); return false; } 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() + "%"); } updateInfiltrationButtons(inst, scenario); updateInfiltrationLevelText(inst); return false; }); - + sneakButton.addEventListener("click", function() { var res = attemptInfiltrationSneak(inst); if (res[0]) { @@ -319,14 +319,14 @@ function nextInfiltrationLevel(inst) { endInfiltrationLevel(inst); return false; } 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() + "%"); } updateInfiltrationButtons(inst, scenario); updateInfiltrationLevelText(inst); return false; }); - + pickdoorButton.addEventListener("click", function() { var res = attemptInfiltrationPickLockedDoor(inst); if (res[0]) { @@ -335,47 +335,47 @@ function nextInfiltrationLevel(inst) { endInfiltrationLevel(inst); return false; } 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() + "%"); } updateInfiltrationButtons(inst, scenario); updateInfiltrationLevelText(inst); return false; }); - + bribeButton.addEventListener("click", function() { var bribeAmt = CONSTANTS.InfiltrationBribeBaseAmount * inst.clearanceLevel; - if (Player.money < bribeAmt) { - writeInfiltrationStatusText("You do not have enough money to bribe the guard. " + + if (Player.money.lt(bribeAmt)) { + writeInfiltrationStatusText("You do not have enough money to bribe the guard. " + "You need $" + bribeAmt); return false; } var res = attemptInfiltrationBribe(inst); 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); Player.loseMoney(bribeAmt); endInfiltrationLevel(inst); return false; } else { - writeInfiltrationStatusText("You FAILED to bribe a guard! The guard is alerting " + - "other security guards about your presence! The facility's " + + writeInfiltrationStatusText("You FAILED to bribe a guard! The guard is alerting " + + "other security guards about your presence! The facility's " + "security level increased by " + formatNumber((res[1]*100)-100, 2).toString() + "%"); } updateInfiltrationButtons(inst, scenario); updateInfiltrationLevelText(inst); return false; }); - + escapeButton.addEventListener("click", function() { var res = attemptInfiltrationEscape(inst); 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!"); endInfiltration(inst, true); return false; } 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() + "%"); if (Player.takeDamage(1)) { endInfiltration(inst, false); @@ -385,10 +385,10 @@ function nextInfiltrationLevel(inst) { updateInfiltrationLevelText(inst); return false; }); - + updateInfiltrationButtons(inst, scenario); writeInfiltrationStatusText(""); - writeInfiltrationStatusText("You are now on clearance level " + inst.clearanceLevel + ".
" + + writeInfiltrationStatusText("You are now on clearance level " + inst.clearanceLevel + ".
" + scenario); } @@ -401,16 +401,16 @@ function endInfiltrationLevel(inst) { var secretMoneyValue = baseSecretValue * CONSTANTS.InfiltrationMoneyValue; inst.secretsStolen.push(baseSecretValue); dialogBoxCreate("You found and stole a set of classified documents from the company. " + - "These classified secrets could probably be sold for money ($" + - formatNumber(secretMoneyValue, 2) + "), or they " + + "These classified secrets could probably be sold for money ($" + + formatNumber(secretMoneyValue, 2) + "), or they " + "could be given to factions for reputation (" + formatNumber(secretValue, 3) + " rep)"); } - + //Increase security level based on difficulty inst.securityLevel *= (1 + (inst.difficulty / 100)); writeInfiltrationStatusText("You move on to the facility's next clearance level. This " + "clearance level has " + inst.difficulty + "% higher security"); - + //If this is max level, force endInfiltration if (inst.clearanceLevel >= inst.maxClearanceLevel) { endInfiltration(inst, true); @@ -436,17 +436,17 @@ function updateInfiltrationLevelText(inst) { totalValue += inst.secretsStolen[i]; totalMoneyValue += inst.secretsStolen[i] * CONSTANTS.InfiltrationMoneyValue; } - document.getElementById("infiltration-level-text").innerHTML = - "Facility name: " + inst.companyName + "
" + - "Clearance Level: " + inst.clearanceLevel + "
" + - "Security Level: " + formatNumber(inst.securityLevel, 3) + "

" + - "Total reputation value of secrets stolen: " + formatNumber(totalValue, 3) + "
" + + document.getElementById("infiltration-level-text").innerHTML = + "Facility name: " + inst.companyName + "
" + + "Clearance Level: " + inst.clearanceLevel + "
" + + "Security Level: " + formatNumber(inst.securityLevel, 3) + "

" + + "Total reputation value of secrets stolen: " + formatNumber(totalValue, 3) + "
" + "Total monetary value of secrets stolen: $" + formatNumber(totalMoneyValue, 2) + "

" + "Hack exp gained: " + formatNumber(inst.hackingExpGained, 3) + "
" + "Str exp gained: " + formatNumber(inst.strExpGained, 3) + "
" + "Def exp gained: " + formatNumber(inst.defExpGained, 3) + "
" + - "Dex exp gained: " + formatNumber(inst.dexExpGained, 3) + "
" + - "Agi exp gained: " + formatNumber(inst.agiExpGained, 3) + "
" + + "Dex exp gained: " + formatNumber(inst.dexExpGained, 3) + "
" + + "Agi exp gained: " + formatNumber(inst.agiExpGained, 3) + "
" + "Cha exp gained: " + formatNumber(inst.chaExpGained, 3); } @@ -461,109 +461,109 @@ function updateInfiltrationButtons(inst, scenario) { var lockpickChance = getInfiltrationPickLockedDoorChance(inst); var bribeChance = getInfiltrationBribeChance(inst); var escapeChance = getInfiltrationEscapeChance(inst); - - document.getElementById("infiltration-escape").innerHTML = "Escape" + - "" + - "Attempt to escape the facility with the classified secrets and " + - "documents you have stolen. You have a " + - formatNumber(escapeChance*100, 2) + "% chance of success. If you fail, " + + + document.getElementById("infiltration-escape").innerHTML = "Escape" + + "" + + "Attempt to escape the facility with the classified secrets and " + + "documents you have stolen. You have a " + + formatNumber(escapeChance*100, 2) + "% chance of success. If you fail, " + "the security level will increase by 5%."; - + switch(scenario) { case InfiltrationScenarios.TechOrLockedDoor: - document.getElementById("infiltration-pickdoor").innerHTML = "Lockpick" + - "" + - "Attempt to pick the locked door. You have a " + - formatNumber(lockpickChance*100, 2) + "% chance of success. " + + document.getElementById("infiltration-pickdoor").innerHTML = "Lockpick" + + "" + + "Attempt to pick the locked door. You have a " + + formatNumber(lockpickChance*100, 2) + "% chance of success. " + "If you succeed, the security level will increased by 1%. If you fail, the " + "security level will increase by 3%."; case InfiltrationScenarios.TechOnly: - document.getElementById("infiltration-hacksecurity").innerHTML = "Hack" + - "" + - "Attempt to hack and disable the security system. You have a " + + document.getElementById("infiltration-hacksecurity").innerHTML = "Hack" + + "" + + "Attempt to hack and disable the security system. You have a " + 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%."; - - document.getElementById("infiltration-destroysecurity").innerHTML = "Destroy security" + - "" + - "Attempt to violently destroy the security system. You have a " + - formatNumber(destroySecurityChance*100, 2) + "% chance of success. " + + + document.getElementById("infiltration-destroysecurity").innerHTML = "Destroy security" + + "" + + "Attempt to violently destroy the security system. You have a " + + formatNumber(destroySecurityChance*100, 2) + "% chance of success. " + "If you succeed, the security level will increase by 5%. If you fail, the " + "security level will increase by 10%. "; - - document.getElementById("infiltration-sneak").innerHTML = "Sneak" + - "" + - "Attempt to sneak past the security system. You have a " + - formatNumber(sneakChance*100, 2) + "% chance of success. " + + + document.getElementById("infiltration-sneak").innerHTML = "Sneak" + + "" + + "Attempt to sneak past the security system. You have a " + + formatNumber(sneakChance*100, 2) + "% chance of success. " + "If you fail, the security level will increase by 8%. "; break; case InfiltrationScenarios.Bots: document.getElementById("infiltration-kill").innerHTML = "Destroy bots" + - "" + - "Attempt to destroy the security bots through combat. You have a " + - formatNumber(killChance*100, 2) + "% chance of success. " + - "If you succeed, the security level will increase by 5%. If you fail, " + + "" + + "Attempt to destroy the security bots through combat. 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 increase by 10%. "; - - document.getElementById("infiltration-assassinate").innerHTML = "Assassinate bots" + - "" + + + document.getElementById("infiltration-assassinate").innerHTML = "Assassinate bots" + + "" + "Attempt to stealthily destroy the security bots through assassination. You have a " + formatNumber(assassinateChance*100, 2) + "% chance of success. " + "If you fail, the security level will increase by 10%. "; - - document.getElementById("infiltration-hacksecurity").innerHTML = "Hack bots" + - "" + + + document.getElementById("infiltration-hacksecurity").innerHTML = "Hack bots" + + "" + "Attempt to disable the security bots by hacking them. You have a " + - formatNumber(hackChance*100, 2) + "% chance of success. " + - "If you succeed, the security level will increase by 1%. If you fail, " + + formatNumber(hackChance*100, 2) + "% chance of success. " + + "If you succeed, the security level will increase by 1%. If you fail, " + "the security level will increase by 5%. "; - - document.getElementById("infiltration-sneak").innerHTML = "Sneak" + - "" + - "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%. "; - break; - - case InfiltrationScenarios.Guards: - default: - document.getElementById("infiltration-kill").innerHTML = "Kill" + - "" + - "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%. "; - - document.getElementById("infiltration-knockout").innerHTML = "Knockout" + + + document.getElementById("infiltration-sneak").innerHTML = "Sneak" + "" + - "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%. "; - - document.getElementById("infiltration-stealthknockout").innerHTML = "Stealth Knockout" + - "" + - "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%. "; - - document.getElementById("infiltration-assassinate").innerHTML = "Assassinate" + - "" + - "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%. "; - - document.getElementById("infiltration-sneak").innerHTML = "Sneak" + - "" + - "Attempt to sneak past the security guard. You have a " + + "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%. "; - - document.getElementById("infiltration-bribe").innerHTML = "Bribe" + - "" + - "Attempt to bribe the security guard. You have a " + - formatNumber(bribeChance*100, 2) + "% chance of success. " + + break; + + case InfiltrationScenarios.Guards: + default: + document.getElementById("infiltration-kill").innerHTML = "Kill" + + "" + + "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%. "; + + document.getElementById("infiltration-knockout").innerHTML = "Knockout" + + "" + + "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%. "; + + document.getElementById("infiltration-stealthknockout").innerHTML = "Stealth Knockout" + + "" + + "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%. "; + + document.getElementById("infiltration-assassinate").innerHTML = "Assassinate" + + "" + + "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%. "; + + document.getElementById("infiltration-sneak").innerHTML = "Sneak" + + "" + + "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%. "; + + document.getElementById("infiltration-bribe").innerHTML = "Bribe" + + "" + + "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%. "; break; } @@ -589,14 +589,14 @@ function attemptInfiltrationKill(inst) { function getInfiltrationKillChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, + return Math.min(0.95, (Player.strength + - Player.dexterity + + Player.dexterity + Player.agility) / (1.5 * lvl)); } -//Knockout +//Knockout //Success: 3%, Failure: 10% function attemptInfiltrationKnockout(inst) { var chance = getInfiltrationKnockoutChance(inst); @@ -616,8 +616,8 @@ function attemptInfiltrationKnockout(inst) { function getInfiltrationKnockoutChance(inst) { var lvl = inst.securityLevel; return Math.min(0.95, - (Player.strength + - Player.dexterity + + (Player.strength + + Player.dexterity + Player.agility) / (1.75 * lvl)); } @@ -639,8 +639,8 @@ function attemptInfiltrationStealthKnockout(inst) { function getInfiltrationStealthKnockoutChance(inst) { var lvl = inst.securityLevel; return Math.min(0.95, - (0.5 * Player.strength + - 2 * Player.dexterity + + (0.5 * Player.strength + + 2 * Player.dexterity + 2 * Player.agility) / (3 * lvl)); } @@ -655,13 +655,13 @@ function attemptInfiltrationAssassinate(inst) { return [true, 1]; } else { inst.securityLevel *= 1.05; - return [false, 1.05]; + return [false, 1.05]; } } function getInfiltrationAssassinateChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, + return Math.min(0.95, (Player.dexterity + 0.5 * Player.agility) / (2 * lvl)); } @@ -682,14 +682,14 @@ function attemptInfiltrationDestroySecurity(inst) { inst.securityLevel *= 1.1; return [false, 1.1]; } - + } function getInfiltrationDestroySecurityChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, - (Player.strength + - Player.dexterity + + return Math.min(0.95, + (Player.strength + + Player.dexterity + Player.agility) / (2 * lvl)); } @@ -706,12 +706,12 @@ function attemptInfiltrationHack(inst) { inst.securityLevel *= 1.05; return [false, 1.05]; } - + } function getInfiltrationHackChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, + return Math.min(0.95, (Player.hacking_skill) / lvl); } @@ -730,7 +730,7 @@ function attemptInfiltrationSneak(inst) { function getInfiltrationSneakChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, + return Math.min(0.95, (Player.agility + 0.5 * Player.dexterity) / (2 * lvl)); } @@ -742,7 +742,7 @@ function attemptInfiltrationPickLockedDoor(inst) { inst.gainDexterityExp(inst.securityLevel / 250) * Player.dexterity_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.01; - return [true, 1.01]; + return [true, 1.01]; } else { inst.securityLevel *= 1.03; return [false, 1.03]; @@ -751,7 +751,7 @@ function attemptInfiltrationPickLockedDoor(inst) { function getInfiltrationPickLockedDoorChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, + return Math.min(0.95, (Player.dexterity) / lvl); } @@ -770,7 +770,7 @@ function attemptInfiltrationBribe(inst) { function getInfiltrationBribeChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, + return Math.min(0.95, (Player.charisma) / lvl); } @@ -790,7 +790,7 @@ function attemptInfiltrationEscape(inst) { function getInfiltrationEscapeChance(inst) { var lvl = inst.securityLevel; - return Math.min(0.95, - (2 * Player.agility + + return Math.min(0.95, + (2 * Player.agility + Player.dexterity) / lvl); } diff --git a/src/Location.js b/src/Location.js index ca73b4be1..c936e29e9 100644 --- a/src/Location.js +++ b/src/Location.js @@ -988,7 +988,7 @@ displayLocationContent = function() { slumsDescText.style.display = "block"; slumsShoplift.style.display = "block"; slumsShoplift.innerHTML = "Shoplift (" + (shopliftChance*100).toFixed(3) + "% chance of success)"; - slumsShoplift.innerHTML += ' Attempt to shoplift from a low-end retailers '; + slumsShoplift.innerHTML += ' Attempt to shoplift from a low-end retailer '; slumsMug.style.display = "block"; slumsMug.innerHTML = "Mug someone (" + (mugChance*100).toFixed(3) + "% chance of success)"; slumsMug.innerHTML += ' Attempt to mug a random person on the street '; @@ -1764,11 +1764,11 @@ initLocationButtons = function() { } travelToCity = function(destCityName, cost) { - if (cost > Player.money) { + if (Player.money.lt(cost)) { dialogBoxCreate("You cannot afford to travel to " + destCityName); return; } - Player.money -= cost; + Player.loseMoney(cost); Player.city = destCityName; dialogBoxCreate("You are now in " + destCityName + "!"); @@ -1776,7 +1776,7 @@ travelToCity = function(destCityName, cost) { } purchaseTorRouter = function() { - if (CONSTANTS.TorRouterCost > Player.money) { + if (Player.money.lt(CONSTANTS.TorRouterCost)) { dialogBoxCreate("You cannot afford to purchase the Tor router"); return; } diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 3462cafa2..e86bd79e4 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -107,8 +107,12 @@ function evaluate(exp, workerScript) { if (exp.computed){ var p = evaluate(exp.property, workerScript); p.then(function(index) { + if (index >= object.length) { + return reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays")); + } resolve(object[index]); }).catch(function(e) { + console.log("here"); reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression")); }); } else { @@ -647,7 +651,7 @@ function scriptCalculateExpGain(server) { if (server.baseDifficulty == null) { 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 diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 160694ef4..ed7bbecd0 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -459,8 +459,8 @@ function NetscriptFunctions(workerScript) { } if (server.hostname == "home") { //Return player's money - workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money, 2)); - return Player.money; + workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money.toNumber(), 2)); + return Player.money.toNumber(); } workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname); return server.moneyAvailable; @@ -592,7 +592,7 @@ function NetscriptFunctions(workerScript) { shares = Math.round(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 " + symbol + ". Need $" + formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString()); @@ -666,8 +666,8 @@ function NetscriptFunctions(workerScript) { return ""; } - var cost = 2 * ram * CONSTANTS.BaseCostFor1GBOfRamServer; - if (cost > Player.money) { + var cost = ram * CONSTANTS.BaseCostFor1GBOfRamServer; + if (Player.money.lt(cost)) { workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + formatNumber(cost, 2)); return ""; } diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index f90703b0d..3877efeb1 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -46,7 +46,7 @@ function runScriptsLoop() { if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) { try { var ast = acorn.parse(workerScripts[i].code); - //console.log(ast); + console.log(ast); } catch (e) { console.log("Error parsing script: " + workerScripts[i].name); dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":
" + e); diff --git a/src/Player.js b/src/Player.js index 41e494079..f7613cba4 100644 --- a/src/Player.js +++ b/src/Player.js @@ -62,9 +62,9 @@ function PlayerObject() { this.faction_rep_mult = 1; //Money - this.money = 1000; - this.total_money = 0; //Total money ever earned in this "simulation" - this.lifetime_money = 0; //Total money ever earned + this.money = new Decimal(1000); + this.total_money = new Decimal(0); //Total money ever earned in this "simulation" + this.lifetime_money = new Decimal(0); //Total money ever earned //IP Address of Starting (home) computer this.homeComputer = ""; @@ -269,7 +269,7 @@ PlayerObject.prototype.calculateExpGain = function() { if (s.baseDifficulty == null) { 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 @@ -298,16 +298,16 @@ PlayerObject.prototype.gainMoney = function(money) { if (isNaN(money)) { console.log("ERR: NaN passed into Player.gainMoney()"); return; } - this.money += money; - this.total_money += money; - this.lifetime_money += money; + this.money = this.money.plus(money); + this.total_money = this.total_money.plus(money); + this.lifetime_money = this.lifetime_money.plus(money); } PlayerObject.prototype.loseMoney = function(money) { if (isNaN(money)) { console.log("ERR: NaN passed into Player.loseMoney()"); return; } - this.money -= money; + this.money = this.money.minus(money); } PlayerObject.prototype.gainHackingExp = function(exp) { diff --git a/src/Prestige.js b/src/Prestige.js index 26a4eb8d5..e4684f027 100644 --- a/src/Prestige.js +++ b/src/Prestige.js @@ -61,7 +61,7 @@ function prestigeAugmentation() { Player.agility_exp = 0; Player.charisma_exp = 0; - Player.money = 1000; + Player.money = new Decimal(1000); Player.city = Locations.Sector12; Player.location = ""; @@ -144,7 +144,7 @@ function prestigeAugmentation() { } if (augmentationExists(AugmentationNames.CashRoot) && Augmentations[AugmentationNames.CashRoot].owned) { - Player.money = 1000000; + Player.money = new Decimal(1000000); homeComp.programs.push(Programs.BruteSSHProgram); } Player.currentServer = homeComp.ip; diff --git a/src/SaveObject.js b/src/SaveObject.js index 4f0694dba..1b86814ef 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -112,24 +112,12 @@ loadGame = function(saveObj) { if (saveObj.hasOwnProperty("VersionSave")) { try { 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 (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(); } } catch(e) { @@ -204,25 +192,12 @@ loadImportedGame = function(saveObj, saveString) { if (tempSaveObj.hasOwnProperty("VersionSave")) { try { var ver = JSON.parse(tempSaveObj.VersionSave, Reviver); - if (ver != CONSTANTS.Version) { - createNewUpdateText(); + if (CONSTANTS.Version == "0.26.3") { + 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 (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(); } } catch(e) { diff --git a/src/Server.js b/src/Server.js index 79e77f0d4..74389394f 100644 --- a/src/Server.js +++ b/src/Server.js @@ -422,19 +422,19 @@ initForeignServers = function() { //"Low level" targets var FoodNStuffServer = new Server(); 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); AddToAllServers(FoodNStuffServer); var SigmaCosmeticsServer = new Server(); 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); AddToAllServers(SigmaCosmeticsServer); var JoesGunsServer = new Server(); 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); AddToAllServers(JoesGunsServer); @@ -446,13 +446,13 @@ initForeignServers = function() { var NectarNightclubServer = new Server(); 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); AddToAllServers(NectarNightclubServer); var NeoNightclubServer = new Server(); 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); AddToAllServers(NeoNightclubServer); @@ -464,13 +464,13 @@ initForeignServers = function() { var HongFangTeaHouseServer = new Server(); 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); AddToAllServers(HongFangTeaHouseServer); var HaraKiriSushiBarServer = new Server(); 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); AddToAllServers(HaraKiriSushiBarServer); diff --git a/src/ServerPurchases.js b/src/ServerPurchases.js index e3a1e0d9d..51c9eef14 100644 --- a/src/ServerPurchases.js +++ b/src/ServerPurchases.js @@ -4,7 +4,7 @@ */ purchaseServer = function(ram, cost) { //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!"); return; } @@ -44,7 +44,7 @@ purchaseServer = function(ram, 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"); return; } diff --git a/src/StockMarket.js b/src/StockMarket.js index 42ad9538d..7e76b43ad 100644 --- a/src/StockMarket.js +++ b/src/StockMarket.js @@ -3,7 +3,7 @@ function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { this.symbol = symbol; this.name = name; this.price = initPrice; - + this.playerShares = 0; this.playerAvgPx = 0; this.mv = mv; @@ -46,7 +46,7 @@ function initStockSymbols() { StockSymbols[Locations.AevumNetLinkTechnologies] = "NTLK"; StockSymbols[Locations.IshimaOmegaSoftware] = "OMGA"; StockSymbols[Locations.Sector12FoodNStuff] = "FNS"; - + //Stocks for other companies StockSymbols["Sigma Cosmetics"] = "SGC"; StockSymbols["Joes Guns"] = "JGN"; @@ -62,143 +62,143 @@ function initStockMarket() { delete StockMarket[stk]; } } - + var ecorp = Locations.AevumECorp; var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.5, true, 16, getRandomInt(20000, 25000)); StockMarket[ecorp] = ecorpStk; - + var megacorp = Locations.Sector12MegaCorp; var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.5, true, 16, getRandomInt(25000, 33000)); StockMarket[megacorp] = megacorpStk; - + var blade = Locations.Sector12BladeIndustries; var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, getRandomInt(15000, 22000)); StockMarket[blade] = bladeStk; - + var clarke = Locations.AevumClarkeIncorporated; var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, getRandomInt(15000, 20000)); StockMarket[clarke] = clarkeStk; - + var omnitek = Locations.VolhavenOmniTekIncorporated; var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, getRandomInt(35000, 40000)); StockMarket[omnitek] = omnitekStk; - + var foursigma = Locations.Sector12FourSigma; var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.1, true, 18, getRandomInt(60000, 70000)); StockMarket[foursigma] = foursigmaStk; - + var kuaigong = Locations.ChongqingKuaiGongInternational; var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, getRandomInt(20000, 24000)); StockMarket[kuaigong] = kuaigongStk; - + var fulcrum = Locations.AevumFulcrumTechnologies; var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 17, getRandomInt(30000, 35000)); StockMarket[fulcrum] = fulcrumStk; - + var storm = Locations.IshimaStormTechnologies; var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, getRandomInt(21000, 24000)); StockMarket[storm] = stormStk; - + var defcomm = Locations.NewTokyoDefComm; var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, getRandomInt(10000, 15000)); StockMarket[defcomm] = defcommStk; - + var helios = Locations.VolhavenHeliosLabs; var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, getRandomInt(12000, 16000)); StockMarket[helios] = heliosStk; - + var vitalife = Locations.NewTokyoVitaLife; var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, getRandomInt(10000, 12000)); StockMarket[vitalife] = vitalifeStk; - + var icarus = Locations.Sector12IcarusMicrosystems; var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, getRandomInt(16000, 20000)); StockMarket[icarus] = icarusStk; - + var universalenergy = Locations.Sector12UniversalEnergy; var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, getRandomInt(20000, 25000)); StockMarket[universalenergy] = universalenergyStk; - + var galactic = Locations.AevumGalacticCybersystems; var galacticStk = new Stock(galactic, StockSymbols[galactic], 0.6, true, 5, getRandomInt(8000, 10000)); StockMarket[galactic] = galacticStk; - + var aerocorp = Locations.AevumAeroCorp; var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, getRandomInt(10000, 15000)); StockMarket[aerocorp] = aerocorpStk; - + var omnia = Locations.VolhavenOmniaCybersystems; var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, getRandomInt(9000, 12000)); StockMarket[omnia] = omniaStk; - + var solaris = Locations.ChongqingSolarisSpaceSystems; var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, getRandomInt(18000, 24000)); StockMarket[solaris] = solarisStk; - + var globalpharm = Locations.NewTokyoGlobalPharmaceuticals; var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, getRandomInt(18000, 24000)); StockMarket[globalpharm] = globalpharmStk; - + var nova = Locations.IshimaNovaMedical; var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, getRandomInt(18000, 24000)); StockMarket[nova] = novaStk; - + var watchdog = Locations.AevumWatchdogSecurity; var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 1, true, 1.5, getRandomInt(5000, 7500)); StockMarket[watchdog] = watchdogStk; - + var lexocorp = Locations.VolhavenLexoCorp; var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, getRandomInt(5000, 7500)); StockMarket[lexocorp] = lexocorpStk; - + var rho = Locations.AevumRhoConstruction; var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, getRandomInt(3000, 6000)); StockMarket[rho] = rhoStk; - + var alpha = Locations.Sector12AlphaEnterprises; var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, getRandomInt(5000, 7500)); StockMarket[alpha] = alphaStk; - + var syscore = Locations.VolhavenSysCoreSecurities; var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, getRandomInt(4000, 7000)) StockMarket[syscore] = syscoreStk; - + var computek = Locations.VolhavenCompuTek; var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, getRandomInt(2000, 5000)); StockMarket[computek] = computekStk; - + var netlink = Locations.AevumNetLinkTechnologies; var netlinkStk = new Stock(netlink, StockSymbols[netlink], 1, true, 1, getRandomInt(2000, 4000)); StockMarket[netlink] = netlinkStk; - + var omega = Locations.IshimaOmegaSoftware; var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, getRandomInt(3000, 6000)); StockMarket[omega] = omegaStk; - + var fns = Locations.Sector12FoodNStuff; var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, getRandomInt(1000, 4000)); StockMarket[fns] = fnsStk; - + var sigmacosm = "Sigma Cosmetics"; var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, getRandomInt(2000, 3000)); StockMarket[sigmacosm] = sigmacosmStk; - + var joesguns = "Joes Guns"; var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, getRandomInt(500, 1000)); StockMarket[joesguns] = joesgunsStk; - + var catalyst = "Catalyst Ventures"; var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, getRandomInt(1000, 1500)); StockMarket[catalyst] = catalystStk; - + var taiyang = "Taiyang Digital"; var taiyangStk = new Stock(taiyang, StockSymbols[taiyang], 0.75, true, 12, getRandomInt(25000, 30000)); StockMarket[taiyang] = taiyangStk; - + var microdyne = "Microdyne Technologies"; var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, getRandomInt(20000, 25000)); StockMarket[microdyne] = microdyneStk; - + var titanlabs = "Titan Laboratories"; var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, getRandomInt(15000, 20000)); StockMarket[titanlabs] = titanlabsStk; @@ -240,22 +240,22 @@ function buyStock(stock, shares) { return false; } shares = Math.round(shares); - + var totalPrice = stock.price * shares; - if (Player.money < totalPrice + CONSTANTS.StockMarketCommission) { - dialogBoxCreate("You do not have enough money to purchase this. You need $" + + if (Player.money.lt(totalPrice + CONSTANTS.StockMarketCommission)) { + dialogBoxCreate("You do not have enough money to purchase this. You need $" + formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString() + "."); return false; } - + var origTotal = stock.playerShares * stock.playerAvgPx; Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission); var newTotal = origTotal + totalPrice; - stock.playerShares += shares; + stock.playerShares += shares; stock.playerAvgPx = newTotal / stock.playerShares; updateStockPlayerPosition(stock); - dialogBoxCreate("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + - formatNumber(stock.price, 2) + " per share. You also paid $" + + dialogBoxCreate("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + + formatNumber(stock.price, 2) + " per share. You also paid $" + formatNumber(CONSTANTS.StockMarketCommission, 2) + " in commission fees."); return true; } @@ -277,8 +277,8 @@ function sellStock(stock, shares) { stock.playerAvgPx = 0; } updateStockPlayerPosition(stock); - dialogBoxCreate("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + - formatNumber(stock.price, 2) + " per share. After commissions, you gained " + + dialogBoxCreate("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" + + formatNumber(stock.price, 2) + " per share. After commissions, you gained " + "a total of $" + formatNumber(gains, 2)); return true; } @@ -290,7 +290,7 @@ function updateStockPrices() { var stock = StockMarket[name]; var av = (v * stock.mv) / 100; if (isNaN(av)) {av = .02;} - + var chc = 50; if (stock.b) { chc = (chc + stock.otlkMag)/100; @@ -299,7 +299,7 @@ function updateStockPrices() { chc = (chc - stock.otlkMag)/100; if (isNaN(chc)) {chc = 0.5;} } - + var c = Math.random(); if (c < chc) { stock.price *= (1 + av); @@ -309,10 +309,10 @@ function updateStockPrices() { } else { stock.price /= (1 + av); if (Engine.currentPage == Engine.Page.StockMarket) { - updateStockTicker(stock, false); + updateStockTicker(stock, false); } } - + var otlkMagChange = stock.otlkMag * av; if (stock.otlkMag <= 0.1) { otlkMagChange = 1; @@ -334,11 +334,11 @@ var stockMarketContentCreated = false; function displayStockMarketContent() { if (Player.hasWseAccount == null) {Player.hasWseAccount = false;} if (Player.hasTixApiAccess == null) {Player.hasTixApiAccess = false;} - + //Purchase WSE Account button var wseAccountButton = clearEventListeners("stock-market-buy-account"); 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"); } else { wseAccountButton.setAttribute("class", "a-link-button-inactive"); @@ -351,12 +351,12 @@ function displayStockMarketContent() { displayStockMarketContent(); return false; }); - + //Purchase TIX API Access account 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(); - if (!Player.hasTixApiAccess && Player.money >= CONSTANTS.TIXAPICost) { + if (!Player.hasTixApiAccess && Player.money.gte(CONSTANTS.TIXAPICost)) { tixApiAccessButton.setAttribute("class", "a-link-button"); } else { tixApiAccessButton.setAttribute("class", "a-link-button-inactive"); @@ -367,10 +367,10 @@ function displayStockMarketContent() { displayStockMarketContent(); return false; }); - + var stockList = document.getElementById("stock-market-list"); if (stockList == null) {return;} - + if (!Player.hasWseAccount) { stockMarketContentCreated = false; while (stockList.firstChild) { @@ -378,16 +378,16 @@ function displayStockMarketContent() { } return; } - + if (!stockMarketContentCreated && Player.hasWseAccount) { console.log("Creating Stock Market UI"); document.getElementById("stock-market-commission").innerHTML = - "Commission Fees: Every transaction you make has a $" + - formatNumber(CONSTANTS.StockMarketCommission, 2) + " commission fee.

" + - "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 " + + "Commission Fees: Every transaction you make has a $" + + formatNumber(CONSTANTS.StockMarketCommission, 2) + " commission fee.

" + + "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 " + "Augmentations!"; - + var hdrLi = document.createElement("li"); var hdrName = document.createElement("p"); var hdrSym = document.createElement("p"); @@ -430,12 +430,12 @@ function displayStockMarketContent() { hdrLi.appendChild(hdrShares); hdrLi.appendChild(hdrReturn); stockList.appendChild(hdrLi); - + for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { (function() { var stock = StockMarket[name]; - + var li = document.createElement("li"); var stkName = document.createElement("p"); var stkSym = document.createElement("p"); @@ -446,7 +446,7 @@ function displayStockMarketContent() { var avgPriceTxt = document.createElement("p"); var sharesTxt = document.createElement("p"); var returnTxt = document.createElement("p"); - + var tickerId = "stock-market-ticker-" + stock.symbol; stkName.setAttribute("id", tickerId + "-name"); stkSym.setAttribute("id", tickerId + "-sym"); @@ -457,21 +457,21 @@ function displayStockMarketContent() { stkSym.style.width = "4%"; stkPrice.style.display = "inline-block"; stkPrice.style.width = "9%"; - + li.setAttribute("display", "inline-block"); - + qtyInput.setAttribute("type", "text"); qtyInput.setAttribute("id", tickerId + "-qty-input"); qtyInput.setAttribute("class", "stock-market-qty-input"); - qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + - " || (4734 && event.keyCode<40) " + " || (event.keyCode==46) )"); qtyInput.style.width = "3%"; qtyInput.style.display = "inline-block"; - + buyButton.innerHTML = "Buy"; buyButton.setAttribute("class", "stock-market-buy-sell-button"); buyButton.style.width = "3%"; @@ -492,7 +492,7 @@ function displayStockMarketContent() { if (isNaN(shares)) {return false;} sellStock(stock, shares); }); - + avgPriceTxt.setAttribute("id", tickerId + "-avgprice"); avgPriceTxt.style.display = "inline-block"; avgPriceTxt.style.width = "8%"; @@ -505,7 +505,7 @@ function displayStockMarketContent() { returnTxt.style.display = "inline-block"; returnTxt.style.width = "6%"; returnTxt.style.color = "white"; - + li.appendChild(stkName); li.appendChild(stkSym); li.appendChild(stkPrice); @@ -518,11 +518,11 @@ function displayStockMarketContent() { stockList.appendChild(li); }()); //Immediate invocation }//End if - + } stockMarketContentCreated = true; } - + if (Player.hasWseAccount) { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { @@ -540,7 +540,7 @@ function updateStockTicker(stock, increase) { stkName = document.getElementById(tickerId + "-name"); stkSym = document.getElementById(tickerId + "-sym"); stkPrice = document.getElementById(tickerId + "-price"); - + if (stkName == null || stkSym == null || stkPrice == null) { console.log("ERROR, couldn't find elements with tickerId " + tickerId); return; @@ -548,19 +548,19 @@ function updateStockTicker(stock, increase) { stkName.innerText = stock.name; stkSym.innerText = stock.symbol; stkPrice.innerText = "$" + formatNumber(stock.price, 2).toString(); - + var returnTxt = document.getElementById(tickerId + "-return"); var totalCost = stock.playerShares * stock.playerAvgPx; var gains = (stock.price - stock.playerAvgPx) * stock.playerShares; var percentageGains = gains / totalCost; if (totalCost > 0) { - returnTxt.innerText = "$" + formatNumber(gains, 2) + " (" + + returnTxt.innerText = "$" + formatNumber(gains, 2) + " (" + formatNumber(percentageGains * 100, 2) + "%)"; } else { returnTxt.innerText = "N/A"; } - - + + if (increase) { stkName.style.color = "#66ff33"; stkSym.style.color = "#66ff33"; @@ -577,10 +577,10 @@ function updateStockPlayerPosition(stock) { var avgPriceTxt = document.getElementById(tickerId + "-avgprice"); var sharesTxt = document.getElementById(tickerId + "-shares"); 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"); return; } avgPriceTxt.innerText = "$" + formatNumber(stock.playerAvgPx, 2); sharesTxt.innerText = stock.playerShares.toString(); -} \ No newline at end of file +} diff --git a/src/Terminal.js b/src/Terminal.js index 0e10e0737..c27fa0ac4 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -1388,7 +1388,7 @@ var Terminal = { break; case Programs.Flight: 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("----------HACKING PATH----------"); post("Hacking skill: " + Player.hacking_skill + " / 2500"); diff --git a/src/engine.js b/src/engine.js index 385d841c0..f0f716660 100644 --- a/src/engine.js +++ b/src/engine.js @@ -368,7 +368,7 @@ var Engine = { if (Player.hp == null) {Player.hp = Player.max_hp;} document.getElementById("character-overview-text").innerHTML = ("Hp: " + Player.hp + " / " + Player.max_hp + "
" + - "Money: $" + formatNumber(Player.money, 2) + "
" + + "Money: $" + formatNumber(Player.money.toNumber(), 2) + "
" + "Hack: " + (Player.hacking_skill).toLocaleString() + "
" + "Str: " + (Player.strength).toLocaleString() + "
" + "Def: " + (Player.defense).toLocaleString() + "
" + @@ -389,7 +389,7 @@ var Engine = { 'Current City: ' + Player.city + '

' + 'Employer: ' + Player.companyName + '
' + 'Job Title: ' + companyPosition + '

' + - 'Money: $' + formatNumber(Player.money, 2)+ '


' + + 'Money: $' + formatNumber(Player.money.toNumber(), 2)+ '


' + 'Stats

' + 'Hacking Level: ' + (Player.hacking_skill).toLocaleString() + " (" + formatNumber(Player.hacking_exp, 4) + ' experience)
' + diff --git a/utils/PurchaseAugmentationBox.js b/utils/PurchaseAugmentationBox.js index 81186eacc..faab88db9 100644 --- a/utils/PurchaseAugmentationBox.js +++ b/utils/PurchaseAugmentationBox.js @@ -1,7 +1,7 @@ /* Pop up Purchase Augmentation Box */ function purchaseAugmentationBoxInit() { var cancelButton = document.getElementById("purchase-augmentation-box-cancel"); - + //Close Dialog box cancelButton.addEventListener("click", function() { purchaseAugmentationBoxClose(); @@ -30,14 +30,14 @@ purchaseAugmentationBoxSetText = function(txt) { purchaseAugmentationBoxCreate = function(aug, fac) { document.getElementById("purchase-augmentation-box-aug-name").innerHTML = aug.name; document.getElementById("purchase-augmentation-box-aug-info").innerHTML = aug.info; - purchaseAugmentationBoxSetText("
Would you like to purchase the " + aug.name + " Augmentation for $" + + purchaseAugmentationBoxSetText("
Would you like to purchase the " + aug.name + " Augmentation for $" + formatNumber(aug.baseCost * fac.augmentationPriceMult, 2) + "?"); - + //Clear old event listeners from Confirm button var newConfirmButton = clearEventListeners("purchase-augmentation-box-confirm"); - + newConfirmButton.addEventListener("click", function() { - + //TODO Requirements for specific augmentations (e.g Embedded Netburner Module b4 its upgrades) if (aug.name == AugmentationNames.Targeting2 && Augmentations[AugmentationNames.Targeting1].owned == false) { @@ -48,16 +48,16 @@ purchaseAugmentationBoxCreate = function(aug, fac) { } else if (aug.name == AugmentationNames.CombatRib2 && Augmentations[AugmentationNames.CombatRib1].owned == false) { 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) { 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) { 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) { - dialogBoxCreate("You must first install Bionic Legs before you can upgrade it to Graphene Bionic Legs"); - } else if (aug.name == AugmentationNames.ENMCoreV2 && + dialogBoxCreate("You must first install Bionic Legs before you can upgrade it to Graphene Bionic Legs"); + } else if (aug.name == AugmentationNames.ENMCoreV2 && Augmentations[AugmentationNames.ENMCore].owned == false) { dialogBoxCreate("You must first install Embedded Netburner Module Core Implant before you can upgrade it to V2"); } 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"); } else if ((aug.name == AugmentationNames.ENMCore || aug.name == AugmentationNames.ENMAnalyzeEngine || - aug.name == AugmentationNames.ENMDMA) && + aug.name == AugmentationNames.ENMDMA) && Augmentations[AugmentationNames.ENM].owned == false) { dialogBoxCreate("You must first install the Embedded Netburner Module before installing any upgrades to it"); } else if ((aug.name == AugmentationNames.PCDNIOptimizer || - aug.name == AugmentationNames.PCDNINeuralNetwork) && + aug.name == AugmentationNames.PCDNINeuralNetwork) && Augmentations[AugmentationNames.PCDNI].owned == false) { 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) { 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) { 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); if (aug.name == AugmentationNames.NeuroFluxGovernor) { queuedAugmentation.level = getNextNeurofluxLevel(); } Player.queuedAugmentations.push(queuedAugmentation); - + Player.loseMoney((aug.baseCost * fac.augmentationPriceMult)); - dialogBoxCreate("You purchased " + aug.name + ". It's enhancements will not take " + - "effect until they are installed. To install your augmentations, go to the " + - "'Augmentations' tab on the left-hand navigation menu. Purchasing additional " + + dialogBoxCreate("You purchased " + aug.name + ". It's enhancements will not take " + + "effect until they are installed. To install your augmentations, go to the " + + "'Augmentations' tab on the left-hand navigation menu. Purchasing additional " + "augmentations will now be more expensive."); - + //If you just purchased Neuroflux Governor, recalculate the cost if (aug.name == AugmentationNames.NeuroFluxGovernor) { var nextLevel = getNextNeurofluxLevel(); --nextLevel; var mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); aug.setRequirements(500 * mult, 750000 * mult); - + for (var i = 0; i < Player.queuedAugmentations.length-1; ++i) { aug.baseCost *= CONSTANTS.MultipleAugMultiplier; } } - + for (var name in Augmentations) { if (Augmentations.hasOwnProperty(name)) { Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier; } } - + displayFactionAugmentations(fac.name); } else { dialogBoxCreate("You don't have enough money to purchase this Augmentation!"); } purchaseAugmentationBoxClose(); - + return false; }); - + purchaseAugmentationBoxOpen(); } @@ -141,4 +141,4 @@ function getNextNeurofluxLevel() { } } return nextLevel; -} \ No newline at end of file +}