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,
|
||||
|
||||
Reference in New Issue
Block a user