Add React frontend and clean up legacy HTTP backend

This commit is contained in:
Tim
2026-06-15 22:20:56 +02:00
parent b8e2d15e27
commit beaf142ee4
40 changed files with 8328 additions and 437 deletions
+46
View File
@@ -0,0 +1,46 @@
import { create } from 'zustand';
import type { GameInfo, GameStatusPayload, Hand, MyPlayer } from '../types';
interface GameStore {
games: GameInfo[];
myPlayer: MyPlayer | null;
gameStatus: GameStatusPayload | null;
hand: Hand;
error: string | null;
setGames: (games: GameInfo[]) => void;
setMyPlayer: (player: MyPlayer | null) => void;
setGameStatus: (status: GameStatusPayload) => void;
setHand: (hand: Hand) => void;
setError: (error: string | null) => void;
clearError: () => void;
updatePlayerConnection: (order: number, connected: boolean) => void;
reset: () => void;
}
export const useGameStore = create<GameStore>((set) => ({
games: [],
myPlayer: null,
gameStatus: null,
hand: {},
error: null,
setGames: (games) => set({ games }),
setMyPlayer: (myPlayer) => set({ myPlayer }),
setGameStatus: (gameStatus) => set({ gameStatus }),
setHand: (hand) => set({ hand }),
setError: (error) => set({ error }),
clearError: () => set({ error: null }),
updatePlayerConnection: (order, connected) =>
set((state) => ({
gameStatus: state.gameStatus
? {
...state.gameStatus,
players: state.gameStatus.players.map((p) =>
p.order === order ? { ...p, connected } : p
),
}
: null,
})),
reset: () => set({ myPlayer: null, gameStatus: null, hand: {}, error: null }),
}));