mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-11 15:57:33 +01:00
Merge pull request #275 from hydroflame/simpler-home-ram
Simpler home ram
This commit is contained in:
commit
9aa1985d55
@ -1761,16 +1761,8 @@ function initLocationButtons() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
purchaseHomeRam.addEventListener("click", function() {
|
purchaseHomeRam.addEventListener("click", function() {
|
||||||
//Calculate how many times ram has been upgraded (doubled)
|
const cost = Player.getUpgradeHomeRamCost();
|
||||||
var currentRam = Player.getHomeComputer().maxRam;
|
const ram = Player.getHomeComputer().maxRam;
|
||||||
var newRam = currentRam * 2;
|
|
||||||
var numUpgrades = Math.log2(currentRam);
|
|
||||||
|
|
||||||
//Calculate cost
|
|
||||||
//Have cost increase by some percentage each time RAM has been upgraded
|
|
||||||
var cost = currentRam * CONSTANTS.BaseCostFor1GBOfRamHome;
|
|
||||||
var mult = Math.pow(1.58, numUpgrades);
|
|
||||||
cost = cost * mult;
|
|
||||||
|
|
||||||
var yesBtn = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();
|
var yesBtn = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();
|
||||||
yesBtn.innerHTML = "Purchase"; noBtn.innerHTML = "Cancel";
|
yesBtn.innerHTML = "Purchase"; noBtn.innerHTML = "Cancel";
|
||||||
@ -1782,8 +1774,8 @@ function initLocationButtons() {
|
|||||||
yesNoBoxClose();
|
yesNoBoxClose();
|
||||||
});
|
});
|
||||||
yesNoBoxCreate("Would you like to purchase additional RAM for your home computer? <br><br>" +
|
yesNoBoxCreate("Would you like to purchase additional RAM for your home computer? <br><br>" +
|
||||||
"This will upgrade your RAM from " + currentRam + "GB to " + newRam + "GB. <br><br>" +
|
"This will upgrade your RAM from " + ram + "GB to " + ram*2 + "GB. <br><br>" +
|
||||||
"This will cost $" + formatNumber(cost, 2));
|
"This will cost " + numeral(cost).format('$0.000a'));
|
||||||
});
|
});
|
||||||
|
|
||||||
purchaseHomeCores.addEventListener("click", function() {
|
purchaseHomeCores.addEventListener("click", function() {
|
||||||
|
@ -2506,15 +2506,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate how many times ram has been upgraded (doubled)
|
const cost = Player.getUpgradeHomeRamCost();
|
||||||
var currentRam = Player.getHomeComputer().maxRam;
|
|
||||||
var numUpgrades = Math.log2(currentRam);
|
|
||||||
|
|
||||||
//Calculate cost
|
|
||||||
//Have cost increase by some percentage each time RAM has been upgraded
|
|
||||||
var cost = currentRam * CONSTANTS.BaseCostFor1GBOfRamHome;
|
|
||||||
var mult = Math.pow(1.55, numUpgrades);
|
|
||||||
cost = cost * mult;
|
|
||||||
|
|
||||||
if (Player.money.lt(cost)) {
|
if (Player.money.lt(cost)) {
|
||||||
workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money");
|
workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money");
|
||||||
@ -2546,15 +2538,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate how many times ram has been upgraded (doubled)
|
return Player.getUpgradeHomeRamCost();
|
||||||
var currentRam = Player.getHomeComputer().maxRam;
|
|
||||||
var numUpgrades = Math.log2(currentRam);
|
|
||||||
|
|
||||||
//Calculate cost
|
|
||||||
//Have cost increase by some percentage each time RAM has been upgraded
|
|
||||||
var cost = currentRam * CONSTANTS.BaseCostFor1GBOfRamHome;
|
|
||||||
var mult = Math.pow(1.55, numUpgrades);
|
|
||||||
return cost * mult;
|
|
||||||
},
|
},
|
||||||
workForCompany : function() {
|
workForCompany : function() {
|
||||||
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
||||||
|
@ -405,6 +405,19 @@ PlayerObject.prototype.getHomeComputer = function() {
|
|||||||
return AllServers[this.homeComputer];
|
return AllServers[this.homeComputer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerObject.prototype.getUpgradeHomeRamCost = function() {
|
||||||
|
//Calculate how many times ram has been upgraded (doubled)
|
||||||
|
const currentRam = Player.getHomeComputer().maxRam;
|
||||||
|
const numUpgrades = Math.log2(currentRam);
|
||||||
|
|
||||||
|
//Calculate cost
|
||||||
|
//Have cost increase by some percentage each time RAM has been upgraded
|
||||||
|
const mult = Math.pow(1.58, numUpgrades);
|
||||||
|
var cost = currentRam * CONSTANTS.BaseCostFor1GBOfRamHome * mult;
|
||||||
|
cost = cost.toPrecision(5);
|
||||||
|
return cost;
|
||||||
|
}
|
||||||
|
|
||||||
//Calculates skill level based on experience. The same formula will be used for every skill
|
//Calculates skill level based on experience. The same formula will be used for every skill
|
||||||
PlayerObject.prototype.calculateSkill = function(exp) {
|
PlayerObject.prototype.calculateSkill = function(exp) {
|
||||||
return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1);
|
return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user