diff --git a/static/script.js b/static/script.js index b37fbecf..1877c404 100644 --- a/static/script.js +++ b/static/script.js @@ -1173,6 +1173,23 @@ function updateTotalRaresDisplay(data) { } } +async function pollTotalKills() { + try { + const response = await fetch(`${API_BASE}/total-kills/`); + const data = await response.json(); + updateTotalKillsDisplay(data); + } catch (e) { + console.error('Total kills fetch failed:', e); + } +} + +function updateTotalKillsDisplay(data) { + const killsElement = document.getElementById('totalKillsCount'); + if (killsElement && data.total !== undefined) { + killsElement.textContent = data.total.toLocaleString(); + } +} + async function pollServerHealth() { try { const response = await fetch(`${API_BASE}/server-health`); @@ -1248,10 +1265,13 @@ function startPolling() { if (pollID !== null) return; pollLive(); pollTotalRares(); // Initial fetch + pollTotalKills(); // Initial fetch pollServerHealth(); // Initial server health check pollID = setInterval(pollLive, POLL_MS); // Poll total rares every 5 minutes (300,000 ms) setInterval(pollTotalRares, 300000); + // Poll total kills every 5 minutes (300,000 ms) + setInterval(pollTotalKills, 300000); // Poll server health every 30 seconds (30,000 ms) setInterval(pollServerHealth, 30000); } @@ -1324,14 +1344,8 @@ function render(players) { } } - // Calculate and update total kills - const totalKills = players.reduce((sum, p) => sum + (p.total_kills || 0), 0); - const killsElement = document.getElementById('totalKillsCount'); - if (killsElement) { - // Format with commas for readability - const formattedKills = totalKills.toLocaleString(); - killsElement.textContent = formattedKills; - } + // Total kills is now fetched from the /total-kills/ API endpoint + // (see pollTotalKills function) to include ALL characters, not just online ones players.forEach(p => { const { x, y } = worldToPx(p.ew, p.ns);