|
|
|
@@ -56,7 +56,6 @@ function productivityOf(type) { |
|
|
|
|
|
|
|
function costOfBuilding(type) { |
|
|
|
let baseCost = buildings[type].cost |
|
|
|
|
|
|
|
let countCost = baseCost * Math.pow(1.15, belongings[type].count); |
|
|
|
|
|
|
|
return Math.round(countCost); |
|
|
|
@@ -204,6 +203,7 @@ function setup() { |
|
|
|
createButtons(); |
|
|
|
createDisplays(); |
|
|
|
registerListeners(); |
|
|
|
load(); |
|
|
|
unlockAtStart(); |
|
|
|
|
|
|
|
} |
|
|
|
@@ -260,6 +260,10 @@ function initializeData() { |
|
|
|
|
|
|
|
function registerListeners() { |
|
|
|
document.querySelector("#tasty-micro").addEventListener("click", eatMicro); |
|
|
|
|
|
|
|
document.querySelector("#save").addEventListener("click", save); |
|
|
|
|
|
|
|
document.querySelector("#reset").addEventListener("click", reset); |
|
|
|
} |
|
|
|
|
|
|
|
function createButtons() { |
|
|
|
@@ -551,3 +555,33 @@ window.onload = function() { |
|
|
|
|
|
|
|
setTimeout(updateDisplay, 1000/updateRate); |
|
|
|
} |
|
|
|
|
|
|
|
function save() { |
|
|
|
let storage = window.localStorage; |
|
|
|
|
|
|
|
storage.setItem("save-version", "0.0.1"); |
|
|
|
|
|
|
|
storage.setItem("ownedUpgrades", JSON.stringify(ownedUpgrades)); |
|
|
|
|
|
|
|
storage.setItem("resources", JSON.stringify(resources)); |
|
|
|
|
|
|
|
storage.setItem("belongings", JSON.stringify(belongings)); |
|
|
|
} |
|
|
|
|
|
|
|
function load() { |
|
|
|
let storage = window.localStorage; |
|
|
|
|
|
|
|
if (!storage.getItem("save-version")) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ownedUpgrades = JSON.parse(storage.getItem("ownedUpgrades")); |
|
|
|
|
|
|
|
resources = JSON.parse(storage.getItem("resources")); |
|
|
|
|
|
|
|
belongings = JSON.parse(storage.getItem("belongings")); |
|
|
|
} |
|
|
|
|
|
|
|
function reset() { |
|
|
|
window.localStorage.clear(); |
|
|
|
} |