diff --git a/css/menupages.css b/css/menupages.css index 79a3c49dc..6914844b0 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -160,6 +160,19 @@ padding: 10px; } +#hacknet-nodes-purchase-button { + display: block; +} + +#hacknet-nodes-money-multipliers-div { + display: inline-block; + width: 80%; +} + +#hacknet-nodes-multipliers { + float: right; +} + .hacknet-node { margin: 6px; padding: 6px; diff --git a/css/styles.css b/css/styles.css index 53a3e59a6..55017956a 100644 --- a/css/styles.css +++ b/css/styles.css @@ -89,8 +89,8 @@ tr:focus { text-decoration: none; background-color: #555; color: #FFFFFF; - padding: 6px; - margin: 6px; + padding: 5px; + margin: 5px; border: 1px solid #333333; width: 50%; } diff --git a/index.html b/index.html index edc5b9f20..abcb57a0a 100644 --- a/index.html +++ b/index.html @@ -179,7 +179,16 @@ in order to increase its computing power and thereby increase the profit you earn from it.

Purchase Hacknet Node -

+
" +

+ + x1 + x5 + x10 + x100 + MAX + +
diff --git a/src/Constants.js b/src/Constants.js index 1ccee80b7..e0723c1c9 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -19,10 +19,10 @@ CONSTANTS = { /* Hacknet Node constants */ HacknetNodeMoneyGainPerLevel: 1, - HacknetNodePurchaseNextMult: 1.30, //Multiplier when purchasing an additional hacknet node + HacknetNodePurchaseNextMult: 1.33, //Multiplier when purchasing an additional hacknet node HacknetNodeUpgradeLevelMult: 1.06, //Multiplier for cost when upgrading level - HacknetNodeUpgradeRamMult: 1.20, //Multiplier for cost when upgrading RAM - HacknetNodeUpgradeCoreMult: 1.40, //Multiplier for cost when buying another core + HacknetNodeUpgradeRamMult: 1.23, //Multiplier for cost when upgrading RAM + HacknetNodeUpgradeCoreMult: 1.43, //Multiplier for cost when buying another core HacknetNodeMaxLevel: 200, HacknetNodeMaxRam: 64, diff --git a/src/HacknetNode.js b/src/HacknetNode.js index 096a1855b..35769d680 100644 --- a/src/HacknetNode.js +++ b/src/HacknetNode.js @@ -16,9 +16,8 @@ HacknetNode.prototype.updateMoneyGainRate = function() { //How much extra $/s is gained per level var gainPerLevel = CONSTANTS.HacknetNodeMoneyGainPerLevel; - //Each CPU core doubles the speed. Every 1GB of ram adds 15% increase this.moneyGainRatePerSecond = (this.level * gainPerLevel) * - Math.pow(1.07, this.ram-1) * + Math.pow(1.06, this.ram-1) * ((this.numCores + 1) / 2) * Player.hacknet_node_money_mult; if (isNaN(this.moneyGainRatePerSecond)) { this.moneyGainRatePerSecond = 0; @@ -28,19 +27,28 @@ HacknetNode.prototype.updateMoneyGainRate = function() { updateTotalHacknetProduction(); } -HacknetNode.prototype.calculateLevelUpgradeCost = function() { - //Upgrade cost = Base cost * multiplier ^ level +HacknetNode.prototype.calculateLevelUpgradeCost = function(levels=1) { + if (levels < 1) {return 0;} var mult = CONSTANTS.HacknetNodeUpgradeLevelMult; - return CONSTANTS.BaseCostForHacknetNode / 2 * Math.pow(mult, this.level) * Player.hacknet_node_level_cost_mult; + var totalMultiplier = 0; //Summed + var currLevel = this.level; + for (var i = 0; i < levels; ++i) { + totalMultiplier += Math.pow(mult, currLevel); + ++currLevel; + } + return CONSTANTS.BaseCostForHacknetNode / 2 * totalMultiplier * Player.hacknet_node_level_cost_mult; } -HacknetNode.prototype.purchaseLevelUpgrade = function() { - var cost = this.calculateLevelUpgradeCost(); +HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) { + var cost = this.calculateLevelUpgradeCost(levels); if (isNaN(cost)) {throw new Error("Cost is NaN"); return;} if (cost > Player.money) {return;} Player.loseMoney(cost); - if (this.level >= CONSTANTS.HacknetNodeMaxLevel) {return;} - ++this.level; + if (this.level + levels >= CONSTANTS.HacknetNodeMaxLevel) { + this.level = CONSTANTS.HacknetNodeMaxLevel; + return; + } + this.level += levels; this.updateMoneyGainRate(); } @@ -48,11 +56,10 @@ HacknetNode.prototype.calculateRamUpgradeCost = function() { var numUpgrades = Math.log2(this.ram); //Calculate cost - //Base cost of RAM is 50k per 1GB...but lets have this increase by 10% for every time - //the RAM has been upgraded - var cost = this.ram * CONSTANTS.BaseCostFor1GBOfRamHacknetNode; + //Base cost of RAM is 50k per 1GB, increased by some multiplier for each time RAM is upgraded + var baseCost = this.ram * CONSTANTS.BaseCostFor1GBOfRamHacknetNode; var mult = Math.pow(CONSTANTS.HacknetNodeUpgradeRamMult, numUpgrades); - return cost * mult * Player.hacknet_node_ram_cost_mult; + return baseCost * mult * Player.hacknet_node_ram_cost_mult; } HacknetNode.prototype.purchaseRamUpgrade = function() { @@ -141,6 +148,10 @@ getCostOfNextHacknetNode = function() { return CONSTANTS.BaseCostForHacknetNode * Math.pow(mult, numOwned) * Player.hacknet_node_purchase_cost_mult; } +selectHacknetNodePurchaseMultiplier = function() { + +} + //Creates Hacknet Node DOM elements when the page is opened displayHacknetNodesContent = function() { //Update Hacknet Nodes button @@ -151,6 +162,13 @@ displayHacknetNodesContent = function() { return false; }); + //Handle Purchase multiplier buttons + var mult1x = clearEventListeners("hacknet-nodes-1x-multiplier"); + var mult5x = clearEventListenrs("hacknet-nodes-1x-multiplier"); + if (Player.hacknetNodes.length == 0) { + + } + //Remove all old hacknet Node DOM elements var hacknetNodesList = document.getElementById("hacknet-nodes-list"); while (hacknetNodesList.firstChild) { diff --git a/src/Script.js b/src/Script.js index a515da6df..0421a4ef7 100644 --- a/src/Script.js +++ b/src/Script.js @@ -21,11 +21,11 @@ function scriptEditorInit() { var start = this.selectionStart; var end = this.selectionEnd; - // set textarea value to: text before caret + tab + text after caret + //Set textarea value to: text before caret + four spaces + text after caret spaces = " "; this.value = this.value.substring(0, start) + spaces + this.value.substring(end); - // put caret at right position again + //Put caret at after the four spaces this.selectionStart = this.selectionEnd = start + spaces.length; } }