arnaucube
arnaucube/gogame-old-frontendPublic Self-hosted repository
fix energy building when not enough energy
arnaucube arnaucube@gmail.com
Mon, 22 Jul 2019 19:02:06 +0200
commit

91e2ee9a6077e2fd5fbf983bd208d899c6a431d4

parent

73748aac6c8e6c7d7a8545bb448041f654a86434

1 files changed, 5 insertions(+), 3 deletions(-)

jump to
M buildings.js → buildings.js

@@ -12,6 +12,7 @@ }

function printNeededResources(r) { let enough = true; + let enoughEnergy = true; let html = ""; html += `Requires:`; if (r.Metal <= planet.Resources.Metal) {

@@ -39,10 +40,11 @@ if (r.Energy <= planet.Resources.Energy) {

html += ` Energy: <b style="color: lime;">` + r.Energy + `</b>`; } else { enough = false; + enoughEnergy = true; html += ` Energy: <b style="color: red;">` + r.Energy + `</b>`; } - return {html, enough}; + return {html, enough, enoughEnergy}; } function printResources(r) {

@@ -182,7 +184,7 @@ document.getElementById("energymineResources").innerHTML = resrourcesHtml.html + `

<br> Construction time: ` + secondsToTime(t); } - if (!resrourcesHtml.enough) { + if (!resrourcesHtml.enoughEnergy) { document.getElementById("btnBuildEnergyMine").innerHTML = `<span style="color: red;">not enough resources</span>`; } if (planet.CurrentBuild.Title !== "") {

@@ -459,7 +461,7 @@ }

axios.post(url + "/buildings", data, config).then(function(res) { console.log("buildings", res.data); planet = res.data.planet; - printResources(planet.Resources); + // printResources(planet.Resources); printBuildings(planet); }).catch(function(error) { console.log(error);