feature/blindtest #6
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 totalTracks = snapshot.submissions.reduce((n, s) => n + s.count, 0)
|
||||||
const myCount =
|
const myCount =
|
||||||
snapshot.submissions.find((s) => s.playerId === playerId)?.count ?? 0
|
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).
|
// Le blindtest exige au moins 3 joueurs connectés (DJ + 2 devineurs).
|
||||||
const connectedCount = snapshot.players.filter((p) => p.connected).length
|
const connectedCount = snapshot.players.filter((p) => p.connected).length
|
||||||
const blindtestAvailable = connectedCount >= 3
|
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 rounds = buildRounds(effectiveType, showQuiz ? count : 0, totalTracks)
|
||||||
const canStart =
|
const canStart = rounds.length > 0
|
||||||
rounds.length > 0 && (!showBlindtest || blindtestAvailable)
|
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
setError(null)
|
setError(null)
|
||||||
|
|
@ -130,7 +133,7 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
<Button
|
<Button
|
||||||
key={t.value}
|
key={t.value}
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
variant={gameType === t.value ? "default" : "secondary"}
|
variant={effectiveType === t.value ? "default" : "secondary"}
|
||||||
disabled={needsThree}
|
disabled={needsThree}
|
||||||
title={needsThree ? "Blindtest : 3 joueurs minimum" : undefined}
|
title={needsThree ? "Blindtest : 3 joueurs minimum" : undefined}
|
||||||
onClick={() => updateSettings({ gameType: t.value })}
|
onClick={() => updateSettings({ gameType: t.value })}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue