This commit is contained in:
2026-04-20 00:30:12 +03:00
parent f820f4e80f
commit 9c1a05927a
3 changed files with 17 additions and 4 deletions

View File

@@ -99,6 +99,7 @@
wood: res.wood,
stone: res.stone,
iron: res.iron,
storage: res.storage || res.storage_capacity || 0,
population: res.population,
points: town.getPoints?.() ?? 0,
god: town.god?.() ?? null,

View File

@@ -42,6 +42,7 @@ def get_towns():
'wood': d.get('wood', 0),
'stone': d.get('stone', 0),
'iron': d.get('iron', 0),
'storage': d.get('storage', 0),
'population': d.get('population', 0),
},
'buildings': d.get('buildings', {}),

View File

@@ -463,11 +463,22 @@ function renderTownDetails() {
document.getElementById('td-name').textContent = t.town_name;
const cap = t.resources.storage || 1;
const getCol = (amt) => {
const pct = amt / cap;
if (pct >= 0.95) return 'color: #ff4a4a;'; // Red
if (pct >= 0.85) return 'color: #ffa500;'; // Orange
return 'color: #fff;';
};
const capFmt = t.resources.storage ? fmt(t.resources.storage) : '?';
document.getElementById('td-resources').innerHTML = `
<div>${RES_ICONS.wood} Ξύλο: <strong>${fmt(t.resources.wood)}</strong></div>
<div>${RES_ICONS.stone} Πέτρα: <strong>${fmt(t.resources.stone)}</strong></div>
<div>${RES_ICONS.iron} Ασήμι: <strong>${fmt(t.resources.iron)}</strong></div>
<div>${RES_ICONS.pop} Πληθυσμός: <strong>${t.resources.population}</strong></div>
<div style="font-size:0.75rem; color:#aaa; margin-bottom: 4px;">Χωρητικότητα: <strong style="color:#eee">${capFmt}</strong></div>
<div>${RES_ICONS.wood} Ξύλο: <strong style="${getCol(t.resources.wood)}">${fmt(t.resources.wood)}</strong></div>
<div>${RES_ICONS.stone} Πέτρα: <strong style="${getCol(t.resources.stone)}">${fmt(t.resources.stone)}</strong></div>
<div>${RES_ICONS.iron} Ασήμι: <strong style="${getCol(t.resources.iron)}">${fmt(t.resources.iron)}</strong></div>
<div style="margin-top: 6px;">${RES_ICONS.pop} Πληθυσμός: <strong style="color:#fff">${t.resources.population}</strong></div>
`;
const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας';