|  | @@ -91,7 +91,6 @@ function displayBuildings() { | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | document.querySelector("#building-" + key + " > .building-button-name").innerText = value.count + " " + (value.count == 1 ? buildings[key].name : buildings[key].plural); |  |  | document.querySelector("#building-" + key + " > .building-button-name").innerText = value.count + " " + (value.count == 1 ? buildings[key].name : buildings[key].plural); | 
														
													
														
															
																|  |  | document.querySelector("#building-" + key + " > .building-button-cost").innerText = costOfBuilding(key) + " food"; |  |  | document.querySelector("#building-" + key + " > .building-button-cost").innerText = costOfBuilding(key) + " food"; | 
														
													
														
															
																|  |  | document.querySelector("#building-" + key + " > .building-button-prod").innerText = Math.round(productivityMultiplierOf(key) * buildings[key].prod * 10) / 10 + " food/sec"; |  |  |  | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | if (costOfBuilding(key) > resources.food) { |  |  | if (costOfBuilding(key) > resources.food) { | 
														
													
														
															
																|  |  | button.classList.add("building-button-disabled"); |  |  | button.classList.add("building-button-disabled"); | 
														
													
												
													
														
															
																|  | @@ -184,11 +183,6 @@ function initializeData() { | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | function registerListeners() { |  |  | function registerListeners() { | 
														
													
														
															
																|  |  | document.querySelectorAll(".building-button").forEach(function(button) { |  |  |  | 
														
													
														
															
																|  |  | let id = button.id.replace("building-", ""); |  |  |  | 
														
													
														
															
																|  |  | button.addEventListener("click", function() { buyBuilding(id); }); |  |  |  | 
														
													
														
															
																|  |  | }); |  |  |  | 
														
													
														
															
																|  |  | 
 |  |  |  | 
														
													
														
															
																|  |  | document.querySelector("#tasty-micro").addEventListener("click", eatMicro); |  |  | document.querySelector("#tasty-micro").addEventListener("click", eatMicro); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
												
													
														
															
																|  | @@ -208,13 +202,14 @@ function createBuildings() { | 
														
													
														
															
																|  |  | buttonName.classList.add("building-button-name"); |  |  | buttonName.classList.add("building-button-name"); | 
														
													
														
															
																|  |  | let buttonCost = document.createElement("div"); |  |  | let buttonCost = document.createElement("div"); | 
														
													
														
															
																|  |  | buttonCost.classList.add("building-button-cost"); |  |  | buttonCost.classList.add("building-button-cost"); | 
														
													
														
															
																|  |  | let buttonProd = document.createElement("div"); |  |  |  | 
														
													
														
															
																|  |  | buttonProd.classList.add("building-button-prod"); |  |  |  | 
														
													
														
															
																|  |  | 
 |  |  |  | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | button.appendChild(buttonName); |  |  | button.appendChild(buttonName); | 
														
													
														
															
																|  |  | button.appendChild(buttonCost); |  |  | button.appendChild(buttonCost); | 
														
													
														
															
																|  |  | button.appendChild(buttonProd); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | button.addEventListener("mousemove", function(e) { buildingTooltip(key, e); }); | 
														
													
														
															
																|  |  |  |  |  | button.addEventListener("mouseleave", function() { buildingTooltipRemove(); }); | 
														
													
														
															
																|  |  |  |  |  | button.addEventListener("click", function() { buyBuilding(key); }); | 
														
													
														
															
																|  |  |  |  |  | button.addEventListener("click", function(e) { buildingTooltip(key, e); }); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | container.appendChild(button); |  |  | container.appendChild(button); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
												
													
														
															
																|  | @@ -342,39 +337,57 @@ function renderPrereqs(prereqs) { | 
														
													
														
															
																|  |  | return renderLines(list); |  |  | return renderLines(list); | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | function fillTooltip(type, field, content) { | 
														
													
														
															
																|  |  |  |  |  | let item = document.querySelector("#" + type + "-tooltip-" + field); | 
														
													
														
															
																|  |  |  |  |  | if (typeof(content) === "string") { | 
														
													
														
															
																|  |  |  |  |  | item.innerText = content; | 
														
													
														
															
																|  |  |  |  |  | } else { | 
														
													
														
															
																|  |  |  |  |  | replaceChildren(item, content); | 
														
													
														
															
																|  |  |  |  |  | } | 
														
													
														
															
																|  |  |  |  |  | } | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  | function upgradeTooltip(id, event) { |  |  | function upgradeTooltip(id, event) { | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | let tooltip = document.querySelector("#upgrade-tooltip"); |  |  | let tooltip = document.querySelector("#upgrade-tooltip"); | 
														
													
														
															
																|  |  | 
 |  |  |  | 
														
													
														
															
																|  |  | tooltip.style.setProperty("display", "inline-block"); |  |  | tooltip.style.setProperty("display", "inline-block"); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | let tooltipDesc = document.querySelector("#upgrade-tooltip-desc"); |  |  |  | 
														
													
														
															
																|  |  | 
 |  |  |  | 
														
													
														
															
																|  |  | tooltipDesc.innerText = upgrades[id].desc; |  |  |  | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("upgrade", "desc", upgrades[id].desc); | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("upgrade", "effect", upgrade_types[upgrades[id].effect.type].desc(buildings[upgrades[id].effect.target].name)); | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("upgrade", "cost", renderCost(upgrades[id].cost)); | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("upgrade", "prereqs", renderPrereqs(upgrades[id].prereqs)); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | let tooltipEffect = document.querySelector("#upgrade-tooltip-effect"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | let yOffset = tooltip.parentElement.getBoundingClientRect().y; | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | tooltipEffect.innerText = upgrade_types[upgrades[id].effect.type].desc(buildings[upgrades[id].effect.target].name); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | let yTrans = Math.round(event.clientY - yOffset); | 
														
													
														
															
																|  |  |  |  |  | tooltip.style.setProperty("transform", "translate(-220px, " + yTrans + "px)"); | 
														
													
														
															
																|  |  |  |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | let tooltipCost = document.querySelector("#upgrade-tooltip-cost"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | function upgradeTooltipRemove() { | 
														
													
														
															
																|  |  |  |  |  | let tooltip = document.querySelector("#upgrade-tooltip"); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | replaceChildren(tooltipCost, renderCost(upgrades[id].cost)); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | tooltip.style.setProperty("display", "none"); | 
														
													
														
															
																|  |  |  |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | let tooltipPrereqs = document.querySelector("#upgrade-tooltip-prereqs"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | function buildingTooltip(id, event) { | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | replaceChildren(tooltipPrereqs, renderPrereqs(upgrades[id].prereqs)); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | let tooltip = document.querySelector("#building-tooltip"); | 
														
													
														
															
																|  |  |  |  |  | tooltip.style.setProperty("display", "inline-block"); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("building", "name", buildings[id].name); | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("building", "desc", buildings[id].desc); | 
														
													
														
															
																|  |  |  |  |  | fillTooltip("building", "cost", costOfBuilding(id) + " food"); | 
														
													
														
															
																|  |  | let yOffset = tooltip.parentElement.getBoundingClientRect().y; |  |  | let yOffset = tooltip.parentElement.getBoundingClientRect().y; | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | let yTrans = Math.round(event.clientY - yOffset); |  |  |  | 
														
													
														
															
																|  |  | tooltip.style.setProperty("transform", "translate(-220px, " + yTrans + "px)"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | let xPos = tooltip.parentElement.getBoundingClientRect().x - 450; | 
														
													
														
															
																|  |  |  |  |  | let yPos = event.clientY; | 
														
													
														
															
																|  |  |  |  |  | 
 | 
														
													
														
															
																|  |  |  |  |  | tooltip.style.setProperty("transform", "translate(" + xPos + "px, " + yPos  + "px)") | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | function upgradeTooltipRemove() { |  |  |  | 
														
													
														
															
																|  |  | let tooltip = document.querySelector("#upgrade-tooltip"); |  |  |  | 
														
													
														
															
																|  |  |  |  |  | function buildingTooltipRemove() { | 
														
													
														
															
																|  |  |  |  |  | let tooltip = document.querySelector("#building-tooltip"); | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | tooltip.style.setProperty("display", "none"); |  |  | tooltip.style.setProperty("display", "none"); | 
														
													
														
															
																|  |  | 
 |  |  |  | 
														
													
														
															
																|  |  | } |  |  | } | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | window.onload = function() { |  |  | window.onload = function() { | 
														
													
												
													
														
															
																|  | 
 |