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; if (!town) return;
const bSelect = document.getElementById('building-select'); const bSelect = document.getElementById('building-select');
const bLevels = town.buildings || {}; const bLevels = town.buildings || {};
const bData = town.build_data || {};
const currentVal = bSelect.value; 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)) {
const level = bLevels[key] !== undefined ? bLevels[key] : "?"; 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'); const option = document.createElement('option');
option.value = key; option.value = key;
option.textContent = `${nameGr} [Επίπεδο ${level}]${extraText}`; option.textContent = `${nameGr} [Επίπεδο ${level}]`;
bSelect.appendChild(option); bSelect.appendChild(option);
} }
@@ -576,23 +561,7 @@ async function sendCommand() {
let payload = {}; let payload = {};
if (type === 'build') { if (type === 'build') {
const bid = document.getElementById('building-select').value; payload = { building_id: 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 };
} else { } else {
payload = { payload = {
unit_id: document.getElementById('unit-select').value, unit_id: document.getElementById('unit-select').value,