This commit is contained in:
2026-04-20 00:55:07 +03:00
parent 69947c30d2
commit 31ab577c25

View File

@@ -506,30 +506,15 @@ function renderBuildingDropdown() {
if (!town) return;
const bSelect = document.getElementById('building-select');
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)) {
const level = bLevels[key] !== undefined ? bLevels[key] : "?";
let extraText = '';
if (bData[key]) {
const d = bData[key];
const r = town.resources;
const resMissing = (r.wood < d.wood || r.stone < d.stone || r.iron < d.iron || r.population < d.pop);
if (resMissing) {
extraText = ' (Λείπουν πόροι/πληθ.)';
} else if (!d.buildable) {
extraText = ' (Κλειδωμένο / Πλήρες)';
}
}
const option = document.createElement('option');
option.value = key;
option.textContent = `${nameGr} [Επίπεδο ${level}]${extraText}`;
option.textContent = `${nameGr} [Επίπεδο ${level}]`;
bSelect.appendChild(option);
}
@@ -576,23 +561,7 @@ async function sendCommand() {
let payload = {};
if (type === 'build') {
const bid = document.getElementById('building-select').value;
if (town.build_data && town.build_data[bid]) {
const d = town.build_data[bid];
const r = town.resources;
const resMissing = (r.wood < d.wood || r.stone < d.stone || r.iron < d.iron);
const popMissing = (r.population < d.pop);
if (resMissing) return alert(`Αδυναμία: Δεν επαρκούν οι πόροι!\n\nΑπαιτεί:\nΞύλο: ${d.wood}\nΠέτρα: ${d.stone}\nΑσήμι: ${d.iron}`);
if (popMissing) return alert(`Αδυναμία: Δεν επαρκεί ο πληθυσμός! (Απαιτεί ${d.pop})`);
if (!d.buildable) {
return alert("Αδυναμία: Το κτίριο είναι κλειδωμένο (απαιτούνται άλλα κτίρια) ή πλήρως αναβαθμισμένο.");
}
}
payload = { building_id: bid };
payload = { building_id: document.getElementById('building-select').value };
} else {
payload = {
unit_id: document.getElementById('unit-select').value,