nice changes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user