@@ -326,6 +348,23 @@ const BUILDING_NAMES_GR = {
wall: "Τείχος"
};
+const UNIT_NAMES_GR = {
+ sword: "Ξιφομάχος", slinger: "Σφενδονήτης", archer: "Τοξότης", hoplite: "Οπλίτης",
+ rider: "Ιππέας", chariot: "Άρμα", catapult: "Καταπέλτης",
+ big_transporter: "Μεταφορικό", small_transporter: "Γρήγ. Μεταφορικό", bireme: "Διήρης",
+ attack_ship: "Πλοίο Φάρος", trireme: "Τριήρης", colonize_ship: "Αποικιακό",
+ medusa: "Μέδουσα", zyklop: "Κύκλωπας", harpy: "Άρπυια", pegasus: "Πήγασος",
+ minotaur: "Μινώταυρος", manticore: "Μαντιχώρας", cerberus: "Κέρβερος",
+ hydra: "Ύδρα", sea_monster: "Τέρας Θάλασσας", militia: "Εθνοφρουρά"
+};
+
+const RES_ICONS = {
+ wood: '
',
+ stone: '
',
+ iron: '
',
+ pop: '
'
+};
+
// ================================================================
// Polling
// ================================================================
@@ -335,6 +374,12 @@ async function fetchTowns() {
towns = await res.json();
renderTowns();
updateConnectionStatus(true);
+
+ if (selectedTownId) {
+ renderBuildQueuePreview();
+ renderBuildingDropdown();
+ renderTownDetails();
+ }
} catch (e) {
updateConnectionStatus(false);
}
@@ -405,9 +450,44 @@ function selectTown(id) {
document.getElementById('no-town-selected').style.display = 'none';
document.getElementById('command-form-wrap').style.display = 'block';
+ document.getElementById('town-details-panel').style.display = 'block';
renderBuildQueuePreview();
renderBuildingDropdown();
+ renderTownDetails();
+}
+
+function renderTownDetails() {
+ const t = getSelectedTown();
+ if(!t) return;
+
+ document.getElementById('td-name').textContent = t.town_name;
+
+ document.getElementById('td-resources').innerHTML = `
+
${RES_ICONS.wood} Ξύλο: ${fmt(t.resources.wood)}
+
${RES_ICONS.stone} Πέτρα: ${fmt(t.resources.stone)}
+
${RES_ICONS.iron} Ασήμι: ${fmt(t.resources.iron)}
+
${RES_ICONS.pop} Πληθυσμός: ${t.resources.population}
+ `;
+
+ const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας';
+ document.getElementById('td-general').innerHTML = `
+
Πόντοι: ${t.points}
+
Θεός: ${godName}
+
Παίκτης: ${t.player}
+ `;
+
+ const unitsObj = t.units || {};
+ let unitsHtml = '';
+ for(const [unitKey, count] of Object.entries(unitsObj)) {
+ if(count > 0 && unitKey !== 'militia') {
+ const name = UNIT_NAMES_GR[unitKey] || unitKey;
+ unitsHtml += `
${name}: ${count}
`;
+ }
+ }
+ if(unitsHtml === '') unitsHtml = '
Κανένα στράτευμα
';
+
+ document.getElementById('td-units').innerHTML = unitsHtml;
}
function renderBuildingDropdown() {