From 828d45001f201fcae9b836d0d854d6a3173bfd3f Mon Sep 17 00:00:00 2001 From: cialloo Date: Mon, 6 Oct 2025 18:37:45 +0800 Subject: [PATCH] Refactor server statistics calculations to remove dependency on a2sData structure --- src/App.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index e4133af..a5db6ba 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -42,14 +42,14 @@ function App() { // Calculate server statistics const onlineServers = servers.filter(s => s.status === 'online') - const totalPlayers = onlineServers.reduce((sum, s) => sum + (s.a2sData ? (s.a2sData.playerCount - s.a2sData.botCount) : 0), 0) - const totalSlots = onlineServers.reduce((sum, s) => sum + (s.a2sData?.maxPlayers || 0), 0) + const totalPlayers = onlineServers.reduce((sum, s) => sum + (s.playerCount - s.botCount), 0) + const totalSlots = onlineServers.reduce((sum, s) => sum + s.maxPlayers, 0) // Get most popular server (highest player count) const mostPopularServer = onlineServers.length > 0 ? onlineServers.reduce((prev, current) => { - const prevPlayers = (prev.a2sData?.playerCount || 0) - (prev.a2sData?.botCount || 0) - const currentPlayers = (current.a2sData?.playerCount || 0) - (current.a2sData?.botCount || 0) + const prevPlayers = prev.playerCount - prev.botCount + const currentPlayers = current.playerCount - current.botCount return currentPlayers > prevPlayers ? current : prev }) : null