diff --git a/static/js/app.js b/static/js/app.js index e29d5b2..935856a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1,4 +1,21 @@ document.addEventListener("DOMContentLoaded", () => { + let buildingNames = {}; + let unitNames = {}; + + // Fetch building names first + fetch("/api/buildings") + .then(res => res.json()) + .then(data => { + buildingNames = data; + }); + + // Fetch unit names + fetch("/api/units") + .then(res => res.json()) + .then(data => { + unitNames = data; + }); + fetch("/api/data") .then(res => res.json()) .then(data => { @@ -51,29 +68,80 @@ document.addEventListener("DOMContentLoaded", () => { item.addEventListener("click", () => { const townId = parseInt(item.dataset.townid); const selectedTown = player.towns.find(t => t.town_id === townId); - showTownDetails(selectedTown); + showTownMenu(selectedTown); }); }); } - // Step 2: Show town data - function showTownDetails(town) { + // Step 2: Show town menu + function showTownMenu(town) { let html = `

${town.town_name}

`; - html += `

Points: ${town.points} | Population: ${town.population}

`; - html += `
Resources
- `; - playerDetails.innerHTML = html; } }); });