fix(web): lobby falls back to quiz UI below 3 players
Default game type stays "mixed", but while fewer than 3 players are connected the lobby renders the quiz config only (Quiz highlighted, Mixed/Blindtest disabled) instead of showing blindtest settings to a lone host. It switches back to the stored type automatically once 3 players are present — no manual click needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a2e3fae858
commit
a2dc687ac0
1 changed files with 9 additions and 6 deletions
|
|
@ -68,16 +68,19 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
|||
const totalTracks = snapshot.submissions.reduce((n, s) => n + s.count, 0)
|
||||
const myCount =
|
||||
snapshot.submissions.find((s) => s.playerId === playerId)?.count ?? 0
|
||||
const showQuiz = gameType === "quiz" || gameType === "mixed"
|
||||
const showBlindtest = gameType === "blindtest" || gameType === "mixed"
|
||||
|
||||
// Le blindtest exige au moins 3 joueurs connectés (DJ + 2 devineurs).
|
||||
const connectedCount = snapshot.players.filter((p) => p.connected).length
|
||||
const blindtestAvailable = connectedCount >= 3
|
||||
// Tant que le blindtest est indisponible, on retombe sur du quiz (sans
|
||||
// toucher au réglage stocké) : repasse en mixte automatiquement à 3 joueurs.
|
||||
const effectiveType: GameType = blindtestAvailable ? gameType : "quiz"
|
||||
const showQuiz = effectiveType === "quiz" || effectiveType === "mixed"
|
||||
const showBlindtest =
|
||||
effectiveType === "blindtest" || effectiveType === "mixed"
|
||||
|
||||
const rounds = buildRounds(gameType, showQuiz ? count : 0, totalTracks)
|
||||
const canStart =
|
||||
rounds.length > 0 && (!showBlindtest || blindtestAvailable)
|
||||
const rounds = buildRounds(effectiveType, showQuiz ? count : 0, totalTracks)
|
||||
const canStart = rounds.length > 0
|
||||
|
||||
async function start() {
|
||||
setError(null)
|
||||
|
|
@ -130,7 +133,7 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
|||
<Button
|
||||
key={t.value}
|
||||
className="flex-1"
|
||||
variant={gameType === t.value ? "default" : "secondary"}
|
||||
variant={effectiveType === t.value ? "default" : "secondary"}
|
||||
disabled={needsThree}
|
||||
title={needsThree ? "Blindtest : 3 joueurs minimum" : undefined}
|
||||
onClick={() => updateSettings({ gameType: t.value })}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue