fix 2
This commit is contained in:
@@ -17,28 +17,16 @@ function gatherState() {
|
||||
const total_points = uw.Game?.player_points ?? 0;
|
||||
const world = uw.Game?.world_id || '';
|
||||
|
||||
let battle_points = { available: 0, used: 0 };
|
||||
// Battle points: att+def = total earned, used = spent, available = att+def-used
|
||||
// Source: ModernBot.user.js line 1635: let available = killpoints.att + killpoints.def - killpoints.used;
|
||||
let battle_points = { att: 0, def: 0, used: 0, available: 0 };
|
||||
try {
|
||||
const pkModels = uw.MM?.getModels?.()?.PlayerKillpoints;
|
||||
if (pkModels && pkModels[player_id]) {
|
||||
const pk = pkModels[player_id];
|
||||
battle_points.used = pk.attributes?.used || 0;
|
||||
if (typeof pk.getUnusedPoints === 'function') {
|
||||
battle_points.available = pk.getUnusedPoints();
|
||||
} else if (pk.attributes?.available !== undefined) {
|
||||
battle_points.available = pk.attributes.available;
|
||||
}
|
||||
}
|
||||
|
||||
// Force sync with the exact UI number if available (e.g. 1986)
|
||||
if (uw.$) {
|
||||
const uiText = uw.$('.nui_battlepoints_container .points').text();
|
||||
if (uiText) {
|
||||
const parsed = parseInt(uiText.replace(/[^\d]/g, ''), 10);
|
||||
if (!isNaN(parsed)) {
|
||||
battle_points.available = parsed;
|
||||
}
|
||||
}
|
||||
const pk = uw.MM?.getModelByNameAndPlayerId?.('PlayerKillpoints')?.attributes;
|
||||
if (pk) {
|
||||
battle_points.att = pk.att || 0;
|
||||
battle_points.def = pk.def || 0;
|
||||
battle_points.used = pk.used || 0;
|
||||
battle_points.available = battle_points.att + battle_points.def - battle_points.used;
|
||||
}
|
||||
} catch (e) { log(`Failed to extract battle_points: ${e}`); }
|
||||
|
||||
|
||||
@@ -178,8 +178,9 @@ window.renderTownDetails = function() {
|
||||
allianceHtml = `<div>Συμμαχία: ID <strong style="color:#aaa">${t.alliance_id}</strong></div>`;
|
||||
}
|
||||
|
||||
let bp = t.battle_points || { available: 0, used: 0 };
|
||||
let bpHtml = `<div>Πόντοι Μάχης: <strong style="color:#2ecc71">${bp.available}</strong> / <span style="color:#aaa">${bp.available + bp.used}</span></div>`;
|
||||
let bp = t.battle_points || { att: 0, def: 0, used: 0, available: 0 };
|
||||
let bpTotal = (bp.att || 0) + (bp.def || 0);
|
||||
let bpHtml = `<div>Πόντοι Μάχης: <strong style="color:#2ecc71">${bp.available}</strong><span style="color:#666;font-size:0.8rem"> / ${bpTotal} (⚔${bp.att||0} 🛡${bp.def||0})</span></div>`;
|
||||
|
||||
document.getElementById('td-general').innerHTML = `
|
||||
<div>Πόντοι: <strong>${t.points}</strong>${t.wonder_points ? ` / Θαύμα: <strong>${t.wonder_points}</strong>` : ''}</div>
|
||||
|
||||
Reference in New Issue
Block a user