diff --git a/src/components/HomePage/HomePage.js b/src/components/HomePage/HomePage.js index 21677b8..102b54f 100644 --- a/src/components/HomePage/HomePage.js +++ b/src/components/HomePage/HomePage.js @@ -75,6 +75,12 @@ export default { } }, incPunt(team) { + // Controlla se c'è già una condizione di vittoria + if (this.checkVittoria()) { + this.$waveui.notify("Il set è terminato!", "warning"); + return; + } + this.sp.punt[team]++; if (team == 'home') { this.sp.striscia.home.push(this.sp.punt.home) @@ -82,10 +88,31 @@ export default { } else { this.sp.striscia.guest.push(this.sp.punt.guest) this.sp.striscia.home.push(' ') - } + } this.sp.servHome = (team == "home"); this.sp.form[team].push(this.sp.form[team].shift()); }, + checkVittoria() { + const puntHome = this.sp.punt.home; + const puntGuest = this.sp.punt.guest; + const setHome = this.sp.set.home; + const setGuest = this.sp.set.guest; + const totSet = setHome + setGuest; + + // Determina se siamo nel set decisivo (5° set) + const isSetDecisivo = totSet >= 4; + const punteggioVittoria = isSetDecisivo ? 15 : 25; + + // Vittoria con punteggio >= 25 (o 15 per set decisivo) e almeno 2 punti di vantaggio + if (puntHome >= punteggioVittoria && puntHome - puntGuest >= 2) { + return true; // Home ha vinto + } + if (puntGuest >= punteggioVittoria && puntGuest - puntHome >= 2) { + return true; // Guest ha vinto + } + + return false; + }, decPunt() { if (this.sp.striscia.home.length > 1) { var tmpHome = this.sp.striscia.home.pop()