mirror of
https://github.com/arnaucube/gogame-frontend.git
synced 2026-02-06 19:06:40 +01:00
fix energy building when not enough energy
This commit is contained in:
@@ -12,6 +12,7 @@ function secondsToTime(secs) {
|
|||||||
|
|
||||||
function printNeededResources(r) {
|
function printNeededResources(r) {
|
||||||
let enough = true;
|
let enough = true;
|
||||||
|
let enoughEnergy = true;
|
||||||
let html = "";
|
let html = "";
|
||||||
html += `Requires:`;
|
html += `Requires:`;
|
||||||
if (r.Metal <= planet.Resources.Metal) {
|
if (r.Metal <= planet.Resources.Metal) {
|
||||||
@@ -39,10 +40,11 @@ function printNeededResources(r) {
|
|||||||
html += ` Energy: <b style="color: lime;">` + r.Energy + `</b>`;
|
html += ` Energy: <b style="color: lime;">` + r.Energy + `</b>`;
|
||||||
} else {
|
} else {
|
||||||
enough = false;
|
enough = false;
|
||||||
|
enoughEnergy = true;
|
||||||
html += ` Energy: <b style="color: red;">` + r.Energy + `</b>`;
|
html += ` Energy: <b style="color: red;">` + r.Energy + `</b>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {html, enough};
|
return {html, enough, enoughEnergy};
|
||||||
}
|
}
|
||||||
|
|
||||||
function printResources(r) {
|
function printResources(r) {
|
||||||
@@ -182,7 +184,7 @@ function printBuildings(planet) {
|
|||||||
<br>
|
<br>
|
||||||
Construction time: ` + secondsToTime(t);
|
Construction time: ` + secondsToTime(t);
|
||||||
}
|
}
|
||||||
if (!resrourcesHtml.enough) {
|
if (!resrourcesHtml.enoughEnergy) {
|
||||||
document.getElementById("btnBuildEnergyMine").innerHTML = `<span style="color: red;">not enough resources</span>`;
|
document.getElementById("btnBuildEnergyMine").innerHTML = `<span style="color: red;">not enough resources</span>`;
|
||||||
}
|
}
|
||||||
if (planet.CurrentBuild.Title !== "") {
|
if (planet.CurrentBuild.Title !== "") {
|
||||||
@@ -459,7 +461,7 @@ function buildBuilding(building) {
|
|||||||
axios.post(url + "/buildings", data, config).then(function(res) {
|
axios.post(url + "/buildings", data, config).then(function(res) {
|
||||||
console.log("buildings", res.data);
|
console.log("buildings", res.data);
|
||||||
planet = res.data.planet;
|
planet = res.data.planet;
|
||||||
printResources(planet.Resources);
|
// printResources(planet.Resources);
|
||||||
printBuildings(planet);
|
printBuildings(planet);
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user