bug
This commit is contained in:
@@ -508,6 +508,7 @@ function renderBuildingDropdown() {
|
||||
const bLevels = town.buildings || {};
|
||||
const bData = town.build_data || {};
|
||||
|
||||
const currentVal = bSelect.value;
|
||||
bSelect.innerHTML = '';
|
||||
|
||||
for (const [key, nameGr] of Object.entries(BUILDING_NAMES_GR)) {
|
||||
@@ -516,12 +517,14 @@ function renderBuildingDropdown() {
|
||||
|
||||
if (bData[key]) {
|
||||
const d = bData[key];
|
||||
if (!d.dependencies) {
|
||||
extraText = ' (Απαγορεύεται / Κλειδωμένο)';
|
||||
} else {
|
||||
const r = town.resources;
|
||||
if (r.wood < d.wood || r.stone < d.stone || r.iron < d.iron || r.population < d.pop) {
|
||||
const resMissing = (r.wood < d.wood || r.stone < d.stone || r.iron < d.iron || r.population < d.pop);
|
||||
|
||||
if (d.buildable === false) {
|
||||
if (resMissing) {
|
||||
extraText = ' (Λείπουν πόροι/πληθ.)';
|
||||
} else {
|
||||
extraText = ' (Κλειδωμένο)';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,6 +534,10 @@ function renderBuildingDropdown() {
|
||||
option.textContent = `${nameGr} [Επίπεδο ${level}]${extraText}`;
|
||||
bSelect.appendChild(option);
|
||||
}
|
||||
|
||||
if (currentVal && Array.from(bSelect.options).some(o => o.value === currentVal)) {
|
||||
bSelect.value = currentVal;
|
||||
}
|
||||
}
|
||||
|
||||
function getSelectedTown() {
|
||||
@@ -575,15 +582,15 @@ async function sendCommand() {
|
||||
|
||||
if (town.build_data && town.build_data[bid]) {
|
||||
const d = town.build_data[bid];
|
||||
if (!d.dependencies) {
|
||||
return alert("Αδυναμία: Απαιτούνται άλλα κτίρια πρώτα (Το κτίριο είναι κλειδωμένο).");
|
||||
}
|
||||
const r = town.resources;
|
||||
if (r.wood < d.wood || r.stone < d.stone || r.iron < d.iron) {
|
||||
return alert(`Αδυναμία: Δεν επαρκούν οι πόροι!\n\nΑπαιτεί:\nΞύλο: ${d.wood}\nΠέτρα: ${d.stone}\nΑσήμι: ${d.iron}`);
|
||||
}
|
||||
if (r.population < d.pop) {
|
||||
return alert(`Αδυναμία: Δεν επαρκεί ο πληθυσμός! (Απαιτεί ${d.pop})`);
|
||||
const resMissing = (r.wood < d.wood || r.stone < d.stone || r.iron < d.iron);
|
||||
const popMissing = (r.population < d.pop);
|
||||
|
||||
if (d.buildable === false) {
|
||||
if (popMissing) return alert(`Αδυναμία: Δεν επαρκεί ο πληθυσμός! (Απαιτεί ${d.pop})`);
|
||||
if (resMissing) return alert(`Αδυναμία: Δεν επαρκούν οι πόροι!\n\nΑπαιτεί:\nΞύλο: ${d.wood}\nΠέτρα: ${d.stone}\nΑσήμι: ${d.iron}`);
|
||||
|
||||
return alert("Αδυναμία: Απαιτούνται άλλα κτίρια πρώτα (Το κτίριο είναι κλειδωμένο).");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user