diff --git a/src/components/ControllerPage.vue b/src/components/ControllerPage.vue index 6668490..6b14d27 100644 --- a/src/components/ControllerPage.vue +++ b/src/components/ControllerPage.vue @@ -78,6 +78,20 @@ + +
+
+
SET FINITO
+
+
{{ state.sp.nomi[setFinito.vincitore] }}
+
{{ state.sp.punt.home }} – {{ state.sp.punt.guest }}
+
+
+ +
+
+
+
@@ -209,6 +223,8 @@ export default { visuStriscia: true, modalitaPartita: "3/5", sp: { + strisce: [], + setFinito: null, striscia: { home: [0], guest: [0] }, servHome: true, punt: { home: 0, guest: 0 }, @@ -227,6 +243,9 @@ export default { isPunteggioZeroZero() { return this.state.sp.punt.home === 0 && this.state.sp.punt.guest === 0 }, + setFinito() { + return this.state.sp.setFinito + }, cambiValid() { let hasComplete = false let allValid = true @@ -905,4 +924,21 @@ export default { padding: 8px 0; font-weight: 600; } + +/* Fine set */ +.set-finito-info { + text-align: center; + padding: 16px 0; +} +.set-vincitore { + font-size: 22px; + font-weight: 800; + color: #fdd835; + text-transform: uppercase; + margin-bottom: 8px; +} +.set-score { + font-size: 36px; + font-weight: 900; +} diff --git a/src/components/DisplayPage.vue b/src/components/DisplayPage.vue index baba1fe..40b9058 100644 --- a/src/components/DisplayPage.vue +++ b/src/components/DisplayPage.vue @@ -112,6 +112,15 @@ {{ wsConnected ? '' : 'Disconnesso' }}
+ + +
+
+
PARTITA FINITA
+
{{ state.sp.nomi[state.sp.partitaFinita.vincitore] }}
+
{{ state.sp.set.home }} – {{ state.sp.set.guest }}
+
+
@@ -132,6 +141,9 @@ export default { visuStriscia: true, modalitaPartita: "3/5", sp: { + strisce: [], + setFinito: null, + partitaFinita: null, striscia: { home: [0], guest: [0] }, servHome: true, punt: { home: 0, guest: 0 }, @@ -436,4 +448,38 @@ export default { overflow: hidden; box-sizing: border-box; } + +/* Fine partita */ +.partita-finita-overlay { + position: fixed; + inset: 0; + background: rgba(0, 0, 0, 0.88); + display: flex; + align-items: center; + justify-content: center; + z-index: 500; +} +.partita-finita-box { + text-align: center; + color: #fff; +} +.partita-finita-label { + font-size: 5vw; + font-weight: 700; + letter-spacing: 0.1em; + color: #aaa; + margin-bottom: 0.3em; +} +.partita-finita-vincitore { + font-size: 14vw; + font-weight: 900; + color: #fdd835; + text-transform: uppercase; + line-height: 1; + margin-bottom: 0.2em; +} +.partita-finita-set { + font-size: 8vw; + font-weight: 700; +} diff --git a/src/gameState.js b/src/gameState.js index 2065620..f47e3cb 100644 --- a/src/gameState.js +++ b/src/gameState.js @@ -10,6 +10,9 @@ export function createInitialState() { visuStriscia: true, modalitaPartita: "3/5", sp: { + strisce: [], + setFinito: null, + partitaFinita: null, striscia: { home: [0], guest: [" "] }, servHome: true, punt: { home: 0, guest: 0 }, @@ -24,6 +27,13 @@ export function createInitialState() { } } +export function checkVittoriaPartita(state) { + const setsToWin = state.modalitaPartita === "2/3" ? 2 : 3 + if (state.sp.set.home >= setsToWin) return "home" + if (state.sp.set.guest >= setsToWin) return "guest" + return null +} + export function checkVittoria(state) { const puntHome = state.sp.punt.home const puntGuest = state.sp.punt.guest @@ -58,7 +68,7 @@ export function applyAction(state, action) { switch (action.type) { case "incPunt": { const team = action.team - if (checkVittoria(s)) break + if (s.sp.setFinito !== null || s.sp.partitaFinita !== null) break s.sp.storicoServizio.push({ servHome: s.sp.servHome, @@ -80,10 +90,17 @@ export function applyAction(state, action) { } s.sp.servHome = team === "home" + + if (checkVittoria(s)) { + s.sp.setFinito = { vincitore: team } + } break } case "decPunt": { + if (s.sp.setFinito !== null) { + s.sp.setFinito = null + } if (s.sp.storicoServizio.length > 0) { const tmpHome = s.sp.striscia.home.pop() s.sp.striscia.guest.pop() @@ -105,6 +122,35 @@ export function applyAction(state, action) { break } + case "confermaSet": { + if (!s.sp.setFinito) break + const vincitore = s.sp.setFinito.vincitore + + s.sp.strisce.push({ + home: [...s.sp.striscia.home], + guest: [...s.sp.striscia.guest], + vincitore, + punt: { ...s.sp.punt }, + }) + + s.sp.set[vincitore]++ + + s.sp.punt.home = 0 + s.sp.punt.guest = 0 + s.sp.storicoServizio = [] + s.sp.setFinito = null + + const vincitorePartita = checkVittoriaPartita(s) + if (vincitorePartita) { + s.sp.partitaFinita = { vincitore: vincitorePartita } + } else { + s.sp.striscia = s.sp.servHome + ? { home: [0], guest: [" "] } + : { home: [" "], guest: [0] } + } + break + } + case "incSet": { const team = action.team if (s.sp.set[team] === 2) { @@ -139,6 +185,9 @@ export function applyAction(state, action) { ? { home: [0], guest: [" "] } : { home: [" "], guest: [0] } s.sp.storicoServizio = [] + s.sp.strisce = [] + s.sp.setFinito = null + s.sp.partitaFinita = null break }