nice changes

This commit is contained in:
2026-04-20 00:41:01 +03:00
parent 9c1a05927a
commit 291b909c6f
3 changed files with 53 additions and 3 deletions

View File

@@ -506,14 +506,29 @@ function renderBuildingDropdown() {
if (!town) return;
const bSelect = document.getElementById('building-select');
const bLevels = town.buildings || {};
const bData = town.build_data || {};
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];
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) {
extraText = ' (Λείπουν πόροι/πληθ.)';
}
}
}
const option = document.createElement('option');
option.value = key;
option.textContent = `${nameGr} [Επίπεδο ${level}]`;
option.textContent = `${nameGr} [Επίπεδο ${level}]${extraText}`;
bSelect.appendChild(option);
}
}
@@ -556,7 +571,23 @@ async function sendCommand() {
let payload = {};
if (type === 'build') {
payload = { building_id: document.getElementById('building-select').value };
const bid = document.getElementById('building-select').value;
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})`);
}
}
payload = { building_id: bid };
} else {
payload = {
unit_id: document.getElementById('unit-select').value,