diff --git a/index.html b/index.html
index 4f1370703..3478e2e04 100644
--- a/index.html
+++ b/index.html
@@ -526,6 +526,13 @@
+
+
diff --git a/src/Company.js b/src/Company.js
index 5480ae8ce..bc75d5a2e 100644
--- a/src/Company.js
+++ b/src/Company.js
@@ -43,7 +43,7 @@ Company.prototype.addPositions = function(positions) {
Company.prototype.hasPosition = function(pos) {
for (var i = 0; i < this.companyPositions.length; ++i) {
- if (pos.name == this.companyPositions[i]) {
+ if (pos.positionName == this.companyPositions[i]) {
return true;
}
}
diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js
index 4f18151b3..733b1e60a 100644
--- a/src/CompanyJobApplication.js
+++ b/src/CompanyJobApplication.js
@@ -2,11 +2,7 @@
//Determines the job that the Player should get (if any) at the current
//company
-PlayerObject.prototype.applyForJob = function(entryPosType) {
- if (Engine.Debug) {
- console.log("Player.applyForJob() called");
- }
-
+PlayerObject.prototype.applyForJob = function(entryPosType) {
var currCompany = "";
if (this.companyName != "") {
currCompany = Companies[this.companyName];
diff --git a/src/Location.js b/src/Location.js
index 3d6e8ba43..cf1aa2b49 100644
--- a/src/Location.js
+++ b/src/Location.js
@@ -193,7 +193,7 @@ displayLocationContent = function() {
purchase512gb.style.display = "none";
purchase1tb.style.display = "none";
purchaseTor.style.display = "none";
- purchaseHomeRam.stlye.display = "none";
+ purchaseHomeRam.style.display = "none";
travelAgencyText.style.display = "none";
travelToAevum.style.display = "none";
diff --git a/src/ServerPurchases.js b/src/ServerPurchases.js
index 4ca49bd37..215fba9a1 100644
--- a/src/ServerPurchases.js
+++ b/src/ServerPurchases.js
@@ -28,12 +28,22 @@ purchaseServer = function(ram, cost) {
homeComputer.serversOnNetwork.push(newServ.ip);
newServ.serversOnNetwork.push(homeComputer.ip);
- Player.money -= cost;
+ Player.loseMoney(cost);
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.");
}
\ No newline at end of file
diff --git a/utils/PurchaseRamForHomeBox.js b/utils/PurchaseRamForHomeBox.js
new file mode 100644
index 000000000..0b549af5d
--- /dev/null
+++ b/utils/PurchaseRamForHomeBox.js
@@ -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?
" +
+ "This will upgrade your RAM from " + currentRam + "GB to " + newRam + "GB.
" +
+ "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;
+ });
+}
\ No newline at end of file