favor update

This commit is contained in:
2026-05-05 21:54:29 +03:00
parent 2a20ca11b4
commit 1746bfd078
3 changed files with 18 additions and 1 deletions

View File

@@ -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,