feat(lobby): allow up to 100 players per room

This commit is contained in:
jessy-david-dev
2026-04-15 19:26:50 +02:00
parent 2dc57915be
commit 6ba0df304f
6 changed files with 34 additions and 4 deletions
+16
View File
@@ -371,6 +371,22 @@ export async function PATCH(
return Response.json({ room });
}
// Hôte change le nombre de joueurs max
case "setMaxPlayers": {
const host = room.players.find((p) => p.id === playerId);
if (!host?.isHost) {
return Response.json(
{ error: "Seul l'hôte peut modifier ce paramètre" },
{ status: 403 },
);
}
if (typeof value === "number") {
room.maxPlayers = Math.min(Math.max(Math.floor(value), 2), 100);
await saveRoom(room);
}
return Response.json({ room });
}
// Hôte change le nombre de manches
case "setTotalRounds": {
const host = room.players.find((p) => p.id === playerId);
+1 -1
View File
@@ -117,7 +117,7 @@ export async function POST(request: NextRequest) {
const clampedMax = Math.min(
Math.max(typeof maxPlayers === "number" ? Math.floor(maxPlayers) : 16, 2),
16,
100,
);
const clampedRounds = Math.min(
Math.max(typeof totalRounds === "number" ? Math.floor(totalRounds) : 3, 1),
+4 -2
View File
@@ -20,6 +20,7 @@ type LobbyScreenProps = {
setGameMode: (v: Room["gameMode"]) => void;
onSetGameMode: (v: Room["gameMode"]) => void;
onSetTotalRounds: (v: number) => void;
onSetMaxPlayers: (v: number) => void;
onSetSearchAllowed: (v: boolean) => void;
onSetTimeLimit: (v: number) => void;
};
@@ -41,6 +42,7 @@ export function LobbyScreen({
setGameMode,
onSetGameMode,
onSetTotalRounds,
onSetMaxPlayers,
onSetSearchAllowed,
onSetTimeLimit,
}: LobbyScreenProps) {
@@ -171,10 +173,10 @@ export function LobbyScreen({
<span className="text-xs text-[#888]">Joueurs max</span>
<select
value={maxPlayers}
onChange={(e) => { setMaxPlayers(Number(e.target.value)); }}
onChange={(e) => { const v = Number(e.target.value); setMaxPlayers(v); onSetMaxPlayers(v); }}
className="w-full min-h-11 px-2 bg-[#0f0f0f] border border-[#2e2e2e] rounded-xl text-sm text-[#f0f0f0] outline-none focus:border-[#7c3aed] cursor-pointer transition-colors"
>
{[2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16].map((n) => (
{[2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 25, 30, 40, 50, 75, 100].map((n) => (
<option key={n} value={n}>
{n} joueurs
</option>
+1
View File
@@ -160,6 +160,7 @@ export function ScreenRouter({
setGameMode={setGameMode}
onSetGameMode={(v) => multi.setGameMode(v)}
onSetTotalRounds={(v) => multi.setTotalRounds(v)}
onSetMaxPlayers={(v) => multi.setMaxPlayers(v)}
onSetSearchAllowed={(v) => multi.setSearchAllowed(v)}
onSetTimeLimit={(v) => multi.setTimeLimit(v)}
/>
+1 -1
View File
@@ -12,7 +12,7 @@ export default function WikiRush() {
const [screen, setScreen] = useState<Screen>("home");
const [playerName, setPlayerName] = useState("");
const [joinCode, setJoinCode] = useState("");
const [maxPlayers, setMaxPlayers] = useState(16);
const [maxPlayers, setMaxPlayers] = useState(100);
const [totalRounds, setTotalRounds] = useState(3);
const [gameMode, setGameMode] = useState<"race" | "all_finish">("race");
const [error, setError] = useState<string | null>(null);