Browse Source

Only update building names/costs if needed

tags/v0.0.6
Fen Dweller 5 years ago
parent
commit
d531a6a898
No known key found for this signature in database GPG Key ID: E80B35A6F11C3656
1 changed files with 15 additions and 3 deletions
  1. +15
    -3
      gorge.js

+ 15
- 3
gorge.js View File

@@ -269,8 +269,18 @@ function displayBuildings() {

const buildingCost = costOfBuilding(key, count);

name.innerText = value.count + " " + (value.count == 1 ? buildings[key].name : buildings[key].plural);
cost.innerText = render(buildingCost.food) + " food";
const newName = value.count + " " + (value.count == 1 ? buildings[key].name : buildings[key].plural);
if (newName != states.buildings[key].name) {
name.innerText = newName;
states.buildings[key].name = newName;
}
const newCost = render(buildingCost.food) + " food";
if (newCost != states.buildings[key].cost) {
cost.innerText = newCost;
states.buildings[key].cost = newCost;
}


if (canAfford(buildingCost) && available !== true) {
button.classList.remove("building-button-disabled");
@@ -489,7 +499,9 @@ function initializeBuildingStates() {
Object.keys(buildings).forEach(key => {
buildingStates[key] = {
visible: undefined,
available: undefined
available: undefined,
name: undefined,
cost: undefined
}
});



Loading…
Cancel
Save