enchance dropdown

This commit is contained in:
2026-04-20 19:02:04 +03:00
parent 9b5656fac5
commit 69d56f621b
2 changed files with 36 additions and 11 deletions

View File

@@ -25,22 +25,44 @@ window.renderBuildingDropdown = function() {
let text = `${nameGr} [Επίπεδο ${level}]`;
if (data && data.dependencies) {
if (data) {
const w = window.fmt(data.wood || 0);
const st = window.fmt(data.stone || 0);
const i = window.fmt(data.iron || 0);
const pop = data.pop || 0;
let t = data.build_time || '';
if (t.startsWith('00:')) t = t.substring(3); // make '00:06:00' cleaner as '06:00'
const popStr = pop > 0 ? ` 🧔:${pop} ` : ' ';
const costStr = `Ξ:${w} Π:${st} Α:${i}${popStr}· ⏱ ${t}`;
// Only show costs if the prerequisites are fulfilled
text += ` — Ξ:${w} Π:${st} Α:${i} · ⏱ ${t}`;
// Figure out the state
const isLocked = (!data.dependencies) || (data.missing_dependencies && data.missing_dependencies.length > 0);
const option = document.createElement('option');
option.value = key;
if (isLocked) {
option.textContent = `${text} — 🔒 Κλειδωμένο (Προϋποθέσεις)`;
option.style.color = '#777777';
} else if (data.can_upgrade === true) {
option.textContent = `${text} — ✅ ${costStr}`;
} else if (data.enough_resources === false) {
option.textContent = `${text} — ❌ ${costStr} (Λείπουν Πόροι)`;
option.style.color = '#aa5555';
} else {
// can_upgrade is false, but resources are fine = Population limit or Queue full
option.textContent = `${text} — ⚠️ ${costStr} (Πληθυσμός / Ουρά)`;
option.style.color = '#aa8855';
}
bSelect.appendChild(option);
} else {
const option = document.createElement('option');
option.value = key;
option.textContent = text;
bSelect.appendChild(option);
}
const option = document.createElement('option');
option.value = key;
option.textContent = text;
bSelect.appendChild(option);
}
if (currentVal && Array.from(bSelect.options).some(o => o.value === currentVal)) {