From 0e2d730ec9a22c9406e5d3c010a1d5a0748172c1 Mon Sep 17 00:00:00 2001 From: Dicken Date: Sun, 28 Jun 2026 19:19:53 +0200 Subject: [PATCH] fix: Hex Wars - Spielliste zeigt current_turn sofort korrekt --- frontend/src/tools/gebietseroberung.jsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/tools/gebietseroberung.jsx b/frontend/src/tools/gebietseroberung.jsx index 2ed5d13..51d0501 100644 --- a/frontend/src/tools/gebietseroberung.jsx +++ b/frontend/src/tools/gebietseroberung.jsx @@ -547,7 +547,14 @@ export default function HexWars({ toast }) { const g = await api(`/tools/gebietseroberung/${activeId}`).catch(() => null); if (!g) return; setGame(g); - if (g.current_turn === myId) toast?.('Du bist dran! ⬡'); + if (g.current_turn === myId) { + toast?.('Du bist dran! ⬡'); + // games-Liste sofort aktualisieren + setGames(prev => prev.map(p => p.id === g.id + ? { ...p, current_turn: g.current_turn, move_count: g.move_count } + : p + )); + } }, 10000); return () => clearInterval(iv); }, [activeId, game, myId]); @@ -555,13 +562,20 @@ export default function HexWars({ toast }) { const handleMove = async (row, col) => { const updated = await api(`/tools/gebietseroberung/${activeId}/move`, { body: { row, col } }); setGame(updated); - loadGames(); // Spielliste aktualisieren damit current_turn stimmt + // Direkt den games-State patchen damit die Liste sofort stimmt (kein Warten auf loadGames) + setGames(prev => prev.map(g => g.id === updated.id + ? { ...g, current_turn: updated.current_turn, move_count: updated.move_count, status: updated.status, winner_id: updated.winner_id } + : g + )); }; const handleScout = async (row, col) => { const updated = await api(`/tools/gebietseroberung/${activeId}/scout`, { body: { row, col } }); setGame(updated); - loadGames(); + setGames(prev => prev.map(g => g.id === updated.id + ? { ...g, current_turn: updated.current_turn, move_count: updated.move_count } + : g + )); }; const handleResign = async () => { @@ -589,7 +603,7 @@ export default function HexWars({ toast }) {
{activeId && ( - + )}

⬡ HEX WARS