mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
Added functions for purchasing additional RAM for home computer
This commit is contained in:
parent
25b5016fda
commit
66681ccae5
@ -526,6 +526,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Purchase RAM for Home Computer Pop-up Box -->
|
||||||
|
<div id="purchase-ram-for-home-box-container">
|
||||||
|
<p id="purchase-ram-for-home-box-text"> </p>
|
||||||
|
<span id="purchase-ram-for-home-box-confirm"> Purchase </span>
|
||||||
|
<span id="purchase-ram-for-home-box-cancel"> Cancel </span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Travel Pop-up Box -->
|
<!-- Travel Pop-up Box -->
|
||||||
<div id="travel-box-container">
|
<div id="travel-box-container">
|
||||||
<div id="travel-box-content">
|
<div id="travel-box-content">
|
||||||
|
@ -43,7 +43,7 @@ Company.prototype.addPositions = function(positions) {
|
|||||||
|
|
||||||
Company.prototype.hasPosition = function(pos) {
|
Company.prototype.hasPosition = function(pos) {
|
||||||
for (var i = 0; i < this.companyPositions.length; ++i) {
|
for (var i = 0; i < this.companyPositions.length; ++i) {
|
||||||
if (pos.name == this.companyPositions[i]) {
|
if (pos.positionName == this.companyPositions[i]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
//Determines the job that the Player should get (if any) at the current
|
//Determines the job that the Player should get (if any) at the current
|
||||||
//company
|
//company
|
||||||
PlayerObject.prototype.applyForJob = function(entryPosType) {
|
PlayerObject.prototype.applyForJob = function(entryPosType) {
|
||||||
if (Engine.Debug) {
|
|
||||||
console.log("Player.applyForJob() called");
|
|
||||||
}
|
|
||||||
|
|
||||||
var currCompany = "";
|
var currCompany = "";
|
||||||
if (this.companyName != "") {
|
if (this.companyName != "") {
|
||||||
currCompany = Companies[this.companyName];
|
currCompany = Companies[this.companyName];
|
||||||
|
@ -193,7 +193,7 @@ displayLocationContent = function() {
|
|||||||
purchase512gb.style.display = "none";
|
purchase512gb.style.display = "none";
|
||||||
purchase1tb.style.display = "none";
|
purchase1tb.style.display = "none";
|
||||||
purchaseTor.style.display = "none";
|
purchaseTor.style.display = "none";
|
||||||
purchaseHomeRam.stlye.display = "none";
|
purchaseHomeRam.style.display = "none";
|
||||||
|
|
||||||
travelAgencyText.style.display = "none";
|
travelAgencyText.style.display = "none";
|
||||||
travelToAevum.style.display = "none";
|
travelToAevum.style.display = "none";
|
||||||
|
@ -28,12 +28,22 @@ purchaseServer = function(ram, cost) {
|
|||||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
newServ.serversOnNetwork.push(homeComputer.ip);
|
||||||
|
|
||||||
Player.money -= cost;
|
Player.loseMoney(cost);
|
||||||
|
|
||||||
dialogBoxCreate("Server successfully purchased with hostname " + hostname);
|
dialogBoxCreate("Server successfully purchased with hostname " + hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
purchaseRamForHomeComputer = function() {
|
purchaseRamForHomeComputer = function(cost) {
|
||||||
|
if (cost > Player.money) {
|
||||||
|
dialogBoxCreate("You do not have enough money to purchase additional RAM for your home computer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var homeComputer = Player.getHomeComputer();
|
||||||
|
homeComputer.maxRam *= 2;
|
||||||
|
|
||||||
|
Player.loseMoney(cost);
|
||||||
|
|
||||||
|
dialogBoxCreate("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
|
||||||
}
|
}
|
56
utils/PurchaseRamForHomeBox.js
Normal file
56
utils/PurchaseRamForHomeBox.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/* Pop up Purchase Ram for Home Computer Pop-up Box */
|
||||||
|
function purchaseRamForHomeBoxInit() {
|
||||||
|
var cancelButton = document.getElementById("purchase-ram-for-home-box-cancel");
|
||||||
|
|
||||||
|
//Close Dialog box
|
||||||
|
cancelButton.addEventListener("click", function() {
|
||||||
|
purchaseRamForHomeBoxClose();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", purchaseRamForHomeBoxInit, false);
|
||||||
|
|
||||||
|
purchaseRamForHomeBoxClose = function() {
|
||||||
|
var purchaseRamForHomeBox = document.getElementById("purchase-ram-for-home-box-container");
|
||||||
|
purchaseRamForHomeBox.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
purchaseRamForHomeBoxOpen = function() {
|
||||||
|
var purchaseRamForHomeBox = document.getElementById("purchase-ram-for-home-box-container");
|
||||||
|
purchaseRamForHomeBox.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
purchaseRamForHomeBoxSetText = function(txt) {
|
||||||
|
var textElem = document.getElementById("purchase-ram-for-home-box-text");
|
||||||
|
textElem.innerHTML = txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ram argument is in GB
|
||||||
|
purchaseRamForHomeBoxCreate = function() {
|
||||||
|
//Calculate how many times ram has been upgraded (doubled)
|
||||||
|
var currentRam = Player.getHomeComputer().maxRam;
|
||||||
|
var newRam = currentRam * 2;
|
||||||
|
var numUpgrades = Math.log2(currentRam);
|
||||||
|
|
||||||
|
//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 = currentRam * 50000;
|
||||||
|
var mult = Math.pow(1.1, numUpgrades);
|
||||||
|
cost = cost * mult;
|
||||||
|
|
||||||
|
purchaseRamForHomeBoxSetText("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 cost $" + cost);
|
||||||
|
|
||||||
|
//Clear old event listeners from Confirm button
|
||||||
|
var confirmButton = document.getElementById("purchase-ram-for-home-box-confirm");
|
||||||
|
var newConfirmButton = confirmButton.cloneNode(true);
|
||||||
|
confirmButton.parentNode.replaceChild(newConfirmButton, confirmButton);
|
||||||
|
newConfirmButton.addEventListener("click", function() {
|
||||||
|
purchaseRamForHomeBoxClose();
|
||||||
|
purchaseRamForHomeComputer(cost);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user