Format numbers to look nice, update info that is displayed on Character page

This commit is contained in:
Daniel Xie 2017-05-04 15:50:17 -05:00
parent c862969198
commit 2c53073f21
6 changed files with 133 additions and 90 deletions

@ -4,10 +4,16 @@
/* Character Info */
#character-container {
position: fixed;
height: 100%;
padding-top: 10px;
padding-left: 10px;
margin-left: 10%;
width: 99%;
overflow-y: scroll;
}
#character-info {
overflow-y: scroll;
}

@ -522,7 +522,7 @@ displayFactionContent = function(factionName) {
var faction = Factions[factionName];
document.getElementById("faction-name").innerHTML = factionName;
document.getElementById("faction-info").innerHTML = faction.info;
document.getElementById("faction-reputation").innerHTML = "Reputation: " + faction.playerReputation.toFixed(3);
document.getElementById("faction-reputation").innerHTML = "Reputation: " + formatNumber(faction.playerReputation, 4);
var hackDiv = document.getElementById("faction-hack-div");
var fieldWorkDiv = document.getElementById("faction-fieldwork-div");
@ -749,11 +749,11 @@ displayFactionAugmentations = function(factionName) {
var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult;
if (faction.playerReputation >= req) {
aElem.setAttribute("class", "a-link-button");
pElem.innerHTML = "UNLOCKED - $" + aug.baseCost * faction.augmentationPriceMult;
pElem.innerHTML = "UNLOCKED - $" + formatNumber(aug.baseCost * faction.augmentationPriceMult, 2);
//TODO Event listener for button to purchase augmentation
} else {
aElem.setAttribute("class", "a-link-button-inactive");
pElem.innerHTML = "LOCKED (Requires " + req + " faction reputation)";
pElem.innerHTML = "LOCKED (Requires " + formatNumber(req, 4) + " faction reputation)";
pElem.style.color = "red";
}
aElem.style.display = "inline-block";

@ -144,7 +144,7 @@ updateHacknetNodesContent = function() {
//Set purchase button to inactive if not enough money, and update its price display
var cost = getCostOfNextHacknetNode();
var purchaseButton = document.getElementById("hacknet-nodes-purchase-button");
purchaseButton.innerHTML = "Purchase Hacknet Node - $" + cost.toFixed(2);
purchaseButton.innerHTML = "Purchase Hacknet Node - $" + formatNumber(cost, 2);
if (cost > Player.money) {
purchaseButton.setAttribute("class", "a-link-button-inactive");
} else {
@ -152,7 +152,7 @@ updateHacknetNodesContent = function() {
}
//Update player's money
document.getElementById("hacknet-nodes-money").innerHTML = "Money: $" + Player.money.toFixed(2);
document.getElementById("hacknet-nodes-money").innerHTML = "Money: $" + formatNumber(Player.money, 2);
//Update information in each owned hacknet node
for (var i = 0; i < Player.hacknetNodes.length; ++i) {
@ -228,8 +228,8 @@ updateHacknetNodeDomElement = function(nodeObj) {
var txt = document.getElementById("hacknet-node-text-" + nodeName);
if (txt == null) {throw new Error("Cannot find text element");}
txt.innerHTML = "Node name: " + nodeName + "<br>" +
"Production: $" + nodeObj.totalMoneyGenerated.toFixed(2) +
" ($" + nodeObj.moneyGainRatePerSecond.toFixed(2) + " / second) <br>" +
"Production: $" + formatNumber(nodeObj.totalMoneyGenerated, 2) +
" ($" + formatNumber(nodeObj.moneyGainRatePerSecond, 2) + " / second) <br>" +
"Level: " + nodeObj.level + "<br>" +
"RAM: " + nodeObj.ram + "GB<br>" +
"Cores: " + nodeObj.numCores;
@ -237,7 +237,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
var upgradeLevelButton = document.getElementById("hacknet-node-upgrade-level-" + nodeName);
if (upgradeLevelButton == null) {throw new Error("Cannot find upgrade level button element");}
var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost();
upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level - $" + upgradeLevelCost.toFixed(2);
upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level - $" + formatNumber(upgradeLevelCost, 2);
if (upgradeLevelCost > Player.money) {
upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
} else {
@ -247,7 +247,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
var upgradeRamButton = document.getElementById("hacknet-node-upgrade-ram-" + nodeName);
if (upgradeRamButton == null) {throw new Error("Cannot find upgrade ram button element");}
var upgradeRamCost = nodeObj.calculateRamUpgradeCost();
upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM -$" + upgradeRamCost.toFixed(2);
upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM -$" + formatNumber(upgradeRamCost, 2);
if (upgradeRamCost > Player.money) {
upgradeRamButton.setAttribute("class", "a-link-button-inactive");
} else {
@ -257,7 +257,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
var upgradeCoreButton = document.getElementById("hacknet-node-upgrade-core-" + nodeName);
if (upgradeCoreButton == null) {throw new Error("Cannot find upgrade cores button element");}
var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost();
upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + upgradeCoreCost.toFixed(2);
upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + formatNumber(upgradeCoreCost, 2);
if (upgradeCoreCost > Player.money) {
upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
} else {

@ -384,26 +384,26 @@ PlayerObject.prototype.finishWork = function(cancelled) {
txt = "You worked a short shift of " + convertTimeMsToTimeElapsedString(this.timeWorked) + " <br><br> " +
"Since you cancelled your work early, you only gained half of the experience, money, and reputation you earned. <br><br>" +
"You earned a total of: <br>" +
"$" + (this.workMoneyGained / cancMult).toFixed(2) + "<br>" +
(this.workRepGained / cancMult).toFixed(3) + " reputation for the company <br>" +
(this.workHackExpGained / cancMult).toFixed(3) + " hacking exp <br>" +
(this.workStrExpGained / cancMult).toFixed(3) + " strength exp <br>" +
(this.workDefExpGained / cancMult).toFixed(3) + " defense exp <br>" +
(this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp <br>" +
(this.workAgiExpGained / cancMult).toFixed(3) + " agility exp <br>" +
(this.workChaExpGained / cancMult).toFixed(3) + " charisma exp<br>";
"$" + formatNumber(this.workMoneyGained / cancMult, 2) + "<br>" +
formatNumber(this.workRepGained / cancMult, 4) + " reputation for the company <br>" +
formatNumber(this.workHackExpGained / cancMult, 4) + " hacking exp <br>" +
formatNumber(this.workStrExpGained / cancMult, 4) + " strength exp <br>" +
formatNumber(this.workDefExpGained / cancMult, 4) + " defense exp <br>" +
formatNumber(this.workDexExpGained / cancMult, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained / cancMult, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained / cancMult, 4) + " charisma exp<br>";
} else {
txt = "You worked a full shift of 8 hours! <br><br> " +
"You earned a total of: <br>" +
"$" + (this.workMoneyGained / cancMult) + "<br>" +
(this.workRepGained / cancMult).toFixed(3) + " reputation for the company <br>" +
(this.workHackExpGained / cancMult).toFixed(3) + " hacking exp <br>" +
(this.workStrExpGained / cancMult).toFixed(3) + " strength exp <br>" +
(this.workDefExpGained / cancMult).toFixed(3) + " defense exp <br>" +
(this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp <br>" +
(this.workAgiExpGained / cancMult).toFixed(3) + " agility exp <br>" +
(this.workChaExpGained / cancMult).toFixed(3) + " charisma exp <br>";
"$" + formatNumber(this.workMoneyGained / cancMult, 2) + "<br>" +
formatNumber(this.workRepGained / cancMult, 4) + " reputation for the company <br>" +
formatNumber(this.workHackExpGained / cancMult, 4) + " hacking exp <br>" +
formatNumber(this.workStrExpGained / cancMult, 4) + " strength exp <br>" +
formatNumber(this.workDefExpGained / cancMult, 4) + " defense exp <br>" +
formatNumber(this.workDexExpGained / cancMult, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained / cancMult, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained / cancMult, 4) + " charisma exp <br>";
}
dialogBoxCreate(txt);
@ -481,14 +481,14 @@ PlayerObject.prototype.work = function(numCycles) {
" at " + Player.companyName + "<br><br>" +
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"You have earned: <br><br>" +
"$" + this.workMoneyGained.toFixed(2) + " ($" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" +
this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this company <br><br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br><br>" +
this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" +
this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" +
this.workDexExpGained.toFixed(3) + " (" + (this.workDexExpGainRate * cyclesPerSec).toFixed(3) + " / sec) dexterity exp <br>" +
this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br><br> " +
this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br><br>" +
"$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
formatNumber(this.workRepGained, 4) + " (" + formatNumber(this.workRepGainRate * cyclesPerSec, 4) + " / sec) reputation for this company <br><br>" +
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br><br>" +
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br><br> " +
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br><br>" +
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish, <br>" +
@ -509,14 +509,14 @@ PlayerObject.prototype.finishFactionWork = function(cancelled, faction) {
var txt = "You worked for your faction " + faction.name + " for a total of " + convertTimeMsToTimeElapsedString(this.timeWorked) + " <br><br> " +
"You earned a total of: <br>" +
"$" + (this.workMoneyGained).toFixed(2) + "<br>" +
(this.workRepGained).toFixed(3) + " reputation for the faction <br>" +
(this.workHackExpGained).toFixed(3) + " hacking exp <br>" +
(this.workStrExpGained).toFixed(3) + " strength exp <br>" +
(this.workDefExpGained).toFixed(3) + " defense exp <br>" +
(this.workDexExpGained).toFixed(3) + " dexterity exp <br>" +
(this.workAgiExpGained).toFixed(3) + " agility exp <br>" +
(this.workChaExpGained).toFixed(3) + " charisma exp<br>";
"$" + formatNumber(this.workMoneyGained, 2) + "<br>" +
formatNumber(this.workRepGained, 4) + " reputation for the faction <br>" +
formatNumber(this.workHackExpGained, 4) + " hacking exp <br>" +
formatNumber(this.workStrExpGained, 4) + " strength exp <br>" +
formatNumber(this.workDefExpGained, 4) + " defense exp <br>" +
formatNumber(this.workDexExpGained, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained, 4) + " charisma exp<br>";
dialogBoxCreate(txt);
var mainMenu = document.getElementById("mainmenu-container");
@ -644,14 +644,14 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
txt.innerHTML = "You are currently " + this.currentWorkFactionDescription + " for your faction " + faction.name + "." +
"You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"You have earned: <br><br>" +
"$" + this.workMoneyGained + " (" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" +
this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this faction <br><br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br><br>" +
this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" +
this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" +
this.workDexExpGained.toFixed(3) + " (" + (this.workDexExpGainRate * cyclesPerSec).toFixed(3) + " / sec) dexterity exp <br>" +
this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br><br> " +
this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br><br>" +
"$" + formatNumber(this.workMoneyGained, 2) + " (" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
formatNumber(this.workRepGained, 4) + " (" + formatNumber(this.workRepGainRate * cyclesPerSec, 4) + " / sec) reputation for this faction <br><br>" +
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br><br>" +
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br><br> " +
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br><br>" +
"You will automatically finish after working for 20 hours. You can cancel earlier if you wish.<br>" +
"There is no penalty for cancelling earlier.";
@ -878,14 +878,14 @@ PlayerObject.prototype.takeClass = function(numCycles) {
var txt = document.getElementById("work-in-progress-text");
txt.innerHTML = "You have been " + className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + ".<br><br>" +
"This has cost you: <br>" +
"$" + this.workMoneyGained.toFixed(2) + " ($" + (this.workMoneyLossRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" +
"$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyLossRate * cyclesPerSec, 2) + " / sec) <br><br>" +
"You have gained: <br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br>" +
this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" +
this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" +
this.workDexExpGained.toFixed(3) + " (" + (this.workDexExpGainRate * cyclesPerSec).toFixed(3) + " / sec) dexterity exp <br>" +
this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br>" +
this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br>" +
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br>" +
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br>" +
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br>" +
"You may cancel at any time";
}
@ -899,14 +899,14 @@ PlayerObject.prototype.finishClass = function() {
this.updateSkillLevels();
var txt = "After " + this.className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + ", <br>" +
"you spent a total of $" + this.workMoneyGained * -1 + ". <br><br>" +
"you spent a total of $" + formatNumber(this.workMoneyGained * -1, 2) + ". <br><br>" +
"You earned a total of: <br>" +
(this.workHackExpGained).toFixed(3) + " hacking exp <br>" +
(this.workStrExpGained).toFixed(3) + " strength exp <br>" +
(this.workDefExpGained).toFixed(3) + " defense exp <br>" +
(this.workDexExpGained).toFixed(3) + " dexterity exp <br>" +
(this.workAgiExpGained).toFixed(3) + " agility exp <br>" +
(this.workChaExpGained).toFixed(3) + " charisma exp<br>";
formatNumber(this.workHackExpGained, 4) + " hacking exp <br>" +
formatNumber(this.workStrExpGained, 4) + " strength exp <br>" +
formatNumber(this.workDefExpGained, 4) + " defense exp <br>" +
formatNumber(this.workDexExpGained, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained, 4) + " charisma exp<br>";
dialogBoxCreate(txt);

@ -311,24 +311,53 @@ var Engine = {
if (Player.companyPosition != "") {
companyPosition = Player.companyPosition.positionName;
}
Engine.Display.characterInfo.innerHTML = 'Current City: ' + Player.city + '<br><br>' +
'Employer: ' + Player.companyName + '<br><br>' +
'Job Title: ' + companyPosition + '<br><br><br><br>' +
'Money: $' + (Player.money.toFixed(2)).toLocaleString() + '<br><br>' +
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() + '<br><br>' +
'Strength: ' + (Player.strength).toLocaleString() + '<br><br>' +
'Defense: ' + (Player.defense).toLocaleString() + '<br><br>' +
'Dexterity: ' + (Player.dexterity).toLocaleString() + '<br><br>' +
'Agility: ' + (Player.agility).toLocaleString() + '<br><br>' +
'Charisma: ' + (Player.charisma).toLocaleString() + '<br><br>' +
'Servers owned: ' + Player.purchasedServers.length + '<br><br>' +
'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '<br><br>' +
'Hacking experience: ' + (Player.hacking_exp.toFixed(4)).toLocaleString() + '<br><br>' +
'Strength experience: ' + (Player.strength_exp.toFixed(4)).toLocaleString() + '<br><br>' +
'Defense experience: ' + (Player.defense_exp.toFixed(4)).toLocaleString() + '<br><br>' +
'Dexterity experience: ' + (Player.dexterity_exp.toFixed(4)).toLocaleString() + '<br><br>' +
'Agility experience: ' + (Player.agility_exp.toFixed(4)).toLocaleString() + '<br><br>' +
'Charisma experience: ' + (Player.charisma_exp.toFixed(4)).toLocaleString();
Engine.Display.characterInfo.innerHTML =
'<b>General</b><br><br>' +
'Current City: ' + Player.city + '<br><br>' +
'Employer: ' + Player.companyName + '<br>' +
'Job Title: ' + companyPosition + '<br><br>' +
'Money: $' + formatNumber(Player.money, 2)+ '<br><br><br>' +
'<b>Stats</b><br><br>' +
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() +
" (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' +
'Strength: ' + (Player.strength).toLocaleString() +
" (" + formatNumber(Player.strength_exp, 4) + ' experience)<br>' +
'Defense: ' + (Player.defense).toLocaleString() +
" (" + formatNumber(Player.defense_exp, 4) + ' experience)<br>' +
'Dexterity: ' + (Player.dexterity).toLocaleString() +
" (" + formatNumber(Player.dexterity_exp, 4) + ' experience)<br>' +
'Agility: ' + (Player.agility).toLocaleString() +
" (" + formatNumber(Player.agility_exp, 4) + ' experience)<br>' +
'Charisma: ' + (Player.charisma).toLocaleString() +
" (" + formatNumber(Player.charisma_exp, 4) + ' experience)<br><br><br>' +
'<b>Multipliers</b><br><br>' +
'Hacking Chance multiplier: ' + formatNumber(Player.hacking_chance_mult * 100, 2) + '%<br>' +
'Hacking Speed multiplier: ' + formatNumber(Player.hacking_speed_mult * 100, 2) + '%<br>' +
'Hacking money multiplier: ' + formatNumber(Player.hacking_money_mult * 100, 2) + '%<br><br>' +
'Hacking Level multiplier: ' + formatNumber(Player.hacking_mult * 100, 2) + '%<br>' +
'Hacking Experience multiplier: ' + formatNumber(Player.hacking_exp_mult * 100, 2) + '%<br><br>' +
'Strength Level multiplier: ' + formatNumber(Player.strength_mult * 100, 2) + '%<br>' +
'Strength Experience multiplier: ' + formatNumber(Player.strength_exp_mult * 100, 2) + '%<br><br>' +
'Defense Level multiplier: ' + formatNumber(Player.defense_mult * 100, 2) + '%<br>' +
'Defense Experience multiplier: ' + formatNumber(Player.defense_exp_mult * 100, 2) + '%<br><br>' +
'Dexterity Level multiplier: ' + formatNumber(Player.dexterity_mult * 100, 2) + '%<br>' +
'Dexterity Experience multiplier: ' + formatNumber(Player.dexterity_exp_mult * 100, 2) + '%<br><br>' +
'Agility Level multiplier: ' + formatNumber(Player.agility_mult * 100, 2) + '%<br>' +
'Agility Experience multiplier: ' + formatNumber(Player.agility_exp_mult * 100, 2) + '%<br><br>' +
'Charisma Level multiplier: ' + formatNumber(Player.charisma_mult * 100, 2) + '%<br>' +
'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%<br><br>' +
'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%<br>' +
'Hacknet Node purchase cost multiplier: '+ formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%<br>' +
'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%<br>' +
'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%<br>' +
'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%<br><br>' +
'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%<br>' +
'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%<br>' +
'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%<br><br><br>' +
'<b>Misc</b><br><br>' +
'Servers owned: ' + Player.purchasedServers.length + '<br>' +
'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '<br>';
},
/* Display locations in the world*/
@ -436,22 +465,22 @@ var Engine = {
var serverIpHostname = "Server: " + hostname + "(" + workerscript.serverIp + ")";
//Online
var onlineTotalMoneyMade = "Total online production: $" + workerscript.scriptRef.onlineMoneyMade.toFixed(2);
var onlineTotalExpEarned = (Array(26).join(" ") + workerscript.scriptRef.onlineExpGained.toFixed(2) + " exp").replace( / /g, "&nbsp;");
var onlineTotalMoneyMade = "Total online production: $" + formatNumber(workerscript.scriptRef.onlineMoneyMade, 2);
var onlineTotalExpEarned = (Array(26).join(" ") + formatNumber(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, "&nbsp;");
var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
var onlineMpsText = "Online production rate: $" + onlineMps.toFixed(2) + "/second";
var onlineMpsText = "Online production rate: $" + formatNumber(onlineMps, 2) + "/second";
var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime;
var onlineEpsText = (Array(25).join(" ") + onlineEps.toFixed(4) + " exp/second").replace( / /g, "&nbsp;");
var onlineEpsText = (Array(25).join(" ") + formatNumber(onlineEps, 4) + " hacking exp/second").replace( / /g, "&nbsp;");
//Offline
var offlineTotalMoneyMade = "Total offline production: $" + workerscript.scriptRef.offlineMoneyMade.toFixed(2);
var offlineTotalExpEarned = (Array(27).join(" ") + workerscript.scriptRef.offlineExpGained.toFixed(2) + " exp").replace( / /g, "&nbsp;");
var offlineTotalMoneyMade = "Total offline production: $" + formatNumber(workerscript.scriptRef.offlineMoneyMade, 2);
var offlineTotalExpEarned = (Array(27).join(" ") + formatNumber(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, "&nbsp;");
var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime;
var offlineMpsText = "Offline production rate: $" + offlineMps.toFixed(2) + "/second";
var offlineMpsText = "Offline production rate: $" + formatNumber(offlineMps, 2) + "/second";
var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime;
var offlineEpsText = (Array(26).join(" ") + offlineEps.toFixed(4) + " exp/second").replace( / /g, "&nbsp;");
var offlineEpsText = (Array(26).join(" ") + formatNumber(offlineEps, 4) + " hacking exp/second").replace( / /g, "&nbsp;");
itemText.innerHTML = serverIpHostname + "<br>" + onlineTotalMoneyMade + "<br>" + onlineTotalExpEarned + "<br>" +
onlineMpsText + "<br>" + onlineEpsText + "<br>" + offlineTotalMoneyMade + "<br>" + offlineTotalExpEarned + "<br>" +

@ -63,4 +63,12 @@ function isString(str) {
//Returns whether an array contains entirely of string objects
function containsAllStrings(arr) {
return arr.every(isString);
}
//Formats a number with commas and a specific number of decimal digits
function formatNumber(num, numFractionDigits) {
return num.toLocaleString(undefined, {
minimumFractionDigits: numFractionDigits,
maximumFractionDigits: numFractionDigits
});
}