feat: blocca partita a fine match e mostra dialog dedicato

Aggiunge checkVittoriaPartita per rilevare la vittoria della partita
(2 set in 2/3, 3 set in 3/5). nuovoSet ora registra il set vincente
senza resettare il punteggio quando la partita è finita. Il controller
mostra "PARTITA FINITA" al posto di "SET VINTO" con solo il tasto CHIUDI.
This commit is contained in:
2026-05-13 10:06:38 +02:00
parent 756f78358c
commit a094110be3
3 changed files with 79 additions and 5 deletions
+8
View File
@@ -33,6 +33,11 @@ export function checkVittoria(state) {
return false
}
export function checkVittoriaPartita(state) {
const setsToWin = state.modalitaPartita === "2/3" ? 2 : 3
return state.sp.set.home >= setsToWin || state.sp.set.guest >= setsToWin
}
export function applyAction(state, action) {
const s = structuredClone(state)
@@ -91,7 +96,10 @@ export function applyAction(state, action) {
case "nuovoSet": {
const team = action.team
if (team !== 'home' && team !== 'guest') break
if (checkVittoriaPartita(s)) break
const setsToWin = s.modalitaPartita === "2/3" ? 2 : 3
s.sp.set[team]++
if (s.sp.set[team] >= setsToWin) break
s.sp.punt.home = 0
s.sp.punt.guest = 0
s.sp.servHome = team === 'home'