This commit is contained in:
2026-04-20 00:46:23 +03:00
parent 291b909c6f
commit 419a1371e1

View File

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