diff --git a/bot_modules/02_state.js b/bot_modules/02_state.js index 80ab196..f8af9c4 100644 --- a/bot_modules/02_state.js +++ b/bot_modules/02_state.js @@ -180,6 +180,20 @@ function gatherState() { has_premium = uw.GameDataPremium?.isAdvisorActivated?.('curator') || false; } catch (e) {} + // ---- Favor extraction ----------------------------------------------- + let favor = 0; + let godName = null; + try { + godName = town.god?.() ?? null; + if (godName && uw.ITowns?.player_gods?.attributes) { + favor = uw.ITowns.player_gods.attributes[godName + '_favor'] || 0; + } else if (uw.$ && uw.Game?.townId === town.id) { + // UI fallback for the active town + const uiText = uw.$('.favor_amount').text(); + if (uiText) favor = parseInt(uiText.replace(/[^\d]/g, ''), 10) || 0; + } + } catch (e) { log(`Failed to extract favor: ${e}`); } + return { town_id: town.id, town_name: town.name, @@ -190,8 +204,9 @@ function gatherState() { storage: storageCapacity, market_capacity: marketCapacity, population: res.population, + favor: favor, points: town.getPoints?.() ?? 0, - god: town.god?.() ?? null, + god: godName, buildings, units: unitsObj, buildingOrder: buildQueue, diff --git a/routes/dashboard.py b/routes/dashboard.py index 0b20c67..c0e92a2 100644 --- a/routes/dashboard.py +++ b/routes/dashboard.py @@ -253,6 +253,7 @@ def get_towns(): 'storage': d.get('storage', 0), 'market_capacity': d.get('market_capacity', 0), 'population': d.get('population', 0), + 'favor': d.get('favor', 0), }, 'buildings': d.get('buildings', {}), 'units': d.get('units', {}), diff --git a/static/js/components/townViewer.js b/static/js/components/townViewer.js index 2dda0ba..87f500a 100644 --- a/static/js/components/townViewer.js +++ b/static/js/components/townViewer.js @@ -189,6 +189,7 @@ window.renderTownDetails = function() {