Blocca assegnazione punti al raggiungimento della vittoria
Aggiunge controllo che impedisce di assegnare ulteriori punti quando viene raggiunta la condizione di vittoria (25 punti con 2 di vantaggio nei set 1-4, 15 punti con 2 di vantaggio nel set decisivo)
This commit is contained in:
@@ -75,6 +75,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
incPunt(team) {
|
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]++;
|
this.sp.punt[team]++;
|
||||||
if (team == 'home') {
|
if (team == 'home') {
|
||||||
this.sp.striscia.home.push(this.sp.punt.home)
|
this.sp.striscia.home.push(this.sp.punt.home)
|
||||||
@@ -86,6 +92,27 @@ export default {
|
|||||||
this.sp.servHome = (team == "home");
|
this.sp.servHome = (team == "home");
|
||||||
this.sp.form[team].push(this.sp.form[team].shift());
|
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() {
|
decPunt() {
|
||||||
if (this.sp.striscia.home.length > 1) {
|
if (this.sp.striscia.home.length > 1) {
|
||||||
var tmpHome = this.sp.striscia.home.pop()
|
var tmpHome = this.sp.striscia.home.pop()
|
||||||
|
|||||||
Reference in New Issue
Block a user