Implementa rotazione regolamentare con cambio palla

- La formazione ruota solo quando si conquista il servizio (cambio palla)
- Aggiunge array servizioPrecedente per tracciare i cambi palla
- Fix decPunt per annullare correttamente la rotazione
- Fix resetta per pulire lo stack dei servizi precedenti
This commit is contained in:
2026-01-25 17:57:22 +01:00
parent 26d647dce7
commit bbe0862241

View File

@@ -24,6 +24,7 @@ export default {
home: ["1", "2", "3", "4", "5", "6"],
guest: ["1", "2", "3", "4", "5", "6"],
},
servizioPrecedente: [], // Stack per tracciare i cambi palla
},
}
},
@@ -66,6 +67,7 @@ export default {
guest: ["1", "2", "3", "4", "5", "6"],
}
this.sp.striscia = { home: [0], guest: [0] }
this.sp.servizioPrecedente = []
},
incSet(team) {
if (this.sp.set[team] == 2) {
@@ -89,8 +91,16 @@ export default {
this.sp.striscia.guest.push(this.sp.punt.guest)
this.sp.striscia.home.push(' ')
}
// Ruota la formazione solo se c'è cambio palla (conquista del servizio)
const cambioPalla = (team == "home" && !this.sp.servHome) || (team == "guest" && this.sp.servHome);
this.sp.servizioPrecedente.push(cambioPalla); // Salva se c'è stato cambio palla
if (cambioPalla) {
this.sp.form[team].push(this.sp.form[team].shift());
}
this.sp.servHome = (team == "home");
this.sp.form[team].push(this.sp.form[team].shift());
},
checkVittoria() {
const puntHome = this.sp.punt.home;
@@ -117,12 +127,20 @@ export default {
if (this.sp.striscia.home.length > 1) {
var tmpHome = this.sp.striscia.home.pop()
var tmpGuest = this.sp.striscia.guest.pop()
var cambioPalla = this.sp.servizioPrecedente.pop() // Recupera se c'era stato cambio palla
if (tmpHome == ' ') {
this.sp.punt.guest--
this.sp.form.guest.unshift(this.sp.form.guest.pop());
// Ruota indietro solo se c'era stato un cambio palla
if (cambioPalla) {
this.sp.form.guest.unshift(this.sp.form.guest.pop());
}
} else {
this.sp.punt.home--
this.sp.form.home.unshift(this.sp.form.home.pop());
// Ruota indietro solo se c'era stato un cambio palla
if (cambioPalla) {
this.sp.form.home.unshift(this.sp.form.home.pop());
}
}
}
},