|
|
|
@@ -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 |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|