Decimal.js support for player's money. Buffed early game servers.

This commit is contained in:
danielyxie 2017-07-29 11:25:40 -05:00
parent e5322e466b
commit 53d514d28e
21 changed files with 381 additions and 392 deletions

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

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

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

@ -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<br>",
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>" +
"-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 " +

@ -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 " +

@ -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;
}

@ -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) + "<br>" +
moneyElem.innerHTML = "Money: $" + formatNumber(Player.money.toNumber(), 2) + "<br>" +
"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");

@ -345,7 +345,7 @@ function nextInfiltrationLevel(inst) {
bribeButton.addEventListener("click", function() {
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. " +
"You need $" + bribeAmt);
return false;

@ -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 += '<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.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>';
@ -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;
}

@ -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

@ -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 "";
}

@ -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 + ":<br>" + e);

@ -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) {

@ -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;

@ -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) {

@ -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);

@ -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;
}

@ -242,7 +242,7 @@ function buyStock(stock, shares) {
shares = Math.round(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 $" +
formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString() + ".");
return false;
@ -338,7 +338,7 @@ function displayStockMarketContent() {
//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");
@ -356,7 +356,7 @@ function displayStockMarketContent() {
var tixApiAccessButton = clearEventListeners("stock-market-buy-tix-api");
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");

@ -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");

@ -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 + "<br>" +
"Money: $" + formatNumber(Player.money, 2) + "<br>" +
"Money: $" + formatNumber(Player.money.toNumber(), 2) + "<br>" +
"Hack: " + (Player.hacking_skill).toLocaleString() + "<br>" +
"Str: " + (Player.strength).toLocaleString() + "<br>" +
"Def: " + (Player.defense).toLocaleString() + "<br>" +
@ -389,7 +389,7 @@ var Engine = {
'Current City: ' + Player.city + '<br><br>' +
'Employer: ' + Player.companyName + '<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>' +
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() +
" (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' +

@ -78,7 +78,7 @@ purchaseAugmentationBoxCreate = function(aug, fac) {
} 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();