feat(game): add configurable rounds per room

This commit is contained in:
jessy-david-dev
2026-04-11 13:47:05 +02:00
parent d245232497
commit e9f39c572d
8 changed files with 175 additions and 114 deletions
+4 -2
View File
@@ -11,18 +11,20 @@ type Handlers = {
multi: UseMultiGame;
playerName: string;
joinCode: string;
maxPlayers: number;
totalRounds: number;
setScreen: Dispatch<SetStateAction<Screen>>;
setError: Dispatch<SetStateAction<string | null>>;
setLoading: Dispatch<SetStateAction<boolean>>;
};
export function useGameHandlers({
solo, multi, playerName, joinCode, setScreen, setError, setLoading,
solo, multi, playerName, joinCode, maxPlayers, totalRounds, setScreen, setError, setLoading,
}: Handlers) {
async function handleCreateRoom() {
if (!playerName.trim()) { setError("Entre ton pseudo !"); return; }
setLoading(true); setError(null);
const { error: err } = await multi.createRoom(playerName.trim());
const { error: err } = await multi.createRoom(playerName.trim(), maxPlayers, totalRounds);
setLoading(false);
if (err) { setError(err); return; }
setScreen("lobby");