favor update
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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', {}),
|
||||
|
||||
@@ -189,6 +189,7 @@ window.renderTownDetails = function() {
|
||||
<div>Παίκτης: <strong style="color:#aaa">${t.player}</strong>${t.has_premium ? ' <span style="color:#c8a44a" title="Premium">★</span>' : ''}</div>
|
||||
${allianceHtml}
|
||||
${bpHtml}
|
||||
${t.god ? `<div>Εύνοια: <strong style="color:#f1c40f">${t.resources?.favor || 0}</strong></div>` : ''}
|
||||
`;
|
||||
|
||||
// ---- Researches ----
|
||||
|
||||
Reference in New Issue
Block a user