Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fb4177056f | |||
| 303c548ab8 | |||
| 43e49c4c66 |
+2
-5
@@ -1,12 +1,9 @@
|
||||
services:
|
||||
segnapunti:
|
||||
image: santantonio.sytes.net/attilio/segnapunti:1.0.0
|
||||
build: .
|
||||
container_name: segnapunti
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- segnapunti-state:/app/.segnapunti
|
||||
- ./.segnapunti:/app/.segnapunti
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
segnapunti-state:
|
||||
|
||||
@@ -224,7 +224,7 @@ export default {
|
||||
visuStriscia: true,
|
||||
modalitaPartita: "3/5",
|
||||
sp: {
|
||||
striscia: [{ serv: 'home', r: [] }],
|
||||
striscia: [{ serv: 'h', ris: '' }],
|
||||
servHome: true,
|
||||
punt: { home: 0, guest: 0 },
|
||||
set: { home: 0, guest: 0 },
|
||||
|
||||
@@ -132,7 +132,7 @@ export default {
|
||||
visuStriscia: true,
|
||||
modalitaPartita: "3/5",
|
||||
sp: {
|
||||
striscia: [{ serv: 'home', r: [] }],
|
||||
striscia: [{ serv: 'h', ris: '' }],
|
||||
servHome: true,
|
||||
punt: { home: 0, guest: 0 },
|
||||
set: { home: 0, guest: 0 },
|
||||
@@ -197,8 +197,8 @@ export default {
|
||||
if (!currentSet) return { home: [], guest: [] }
|
||||
let h = 0, g = 0
|
||||
const home = [], guest = []
|
||||
for (const scorer of currentSet.r) {
|
||||
if (scorer === 'home') { h++; home.push(h); guest.push(' ') }
|
||||
for (const scorer of currentSet.ris) {
|
||||
if (scorer === 'h') { h++; home.push(h); guest.push(' ') }
|
||||
else { g++; guest.push(g); home.push(' ') }
|
||||
}
|
||||
return { home, guest }
|
||||
|
||||
+16
-12
@@ -5,7 +5,7 @@ export function createInitialState() {
|
||||
visuStriscia: true,
|
||||
modalitaPartita: "3/5",
|
||||
sp: {
|
||||
striscia: [{ serv: 'home', r: [] }],
|
||||
striscia: [{ serv: 'h', ris: '' }],
|
||||
servHome: true,
|
||||
punt: { home: 0, guest: 0 },
|
||||
set: { home: 0, guest: 0 },
|
||||
@@ -43,7 +43,7 @@ export function applyAction(state, action) {
|
||||
|
||||
const cambioPalla = (team === "home") !== s.sp.servHome
|
||||
s.sp.punt[team]++
|
||||
s.sp.striscia.at(-1).r.push(team)
|
||||
s.sp.striscia.at(-1).ris += team === 'home' ? 'h' : 'g'
|
||||
|
||||
if (cambioPalla) {
|
||||
s.sp.form[team].push(s.sp.form[team].shift())
|
||||
@@ -55,18 +55,22 @@ export function applyAction(state, action) {
|
||||
|
||||
case "decPunt": {
|
||||
const currentSet = s.sp.striscia.at(-1)
|
||||
if (currentSet.r.length === 0) break
|
||||
if (currentSet.ris.length === 0) break
|
||||
|
||||
const lastScorer = currentSet.r[currentSet.r.length - 1]
|
||||
const prevServer = currentSet.r.length >= 2
|
||||
? currentSet.r[currentSet.r.length - 2]
|
||||
const lastScorerShort = currentSet.ris.at(-1)
|
||||
const prevServerShort = currentSet.ris.length >= 2
|
||||
? currentSet.ris.at(-2)
|
||||
: currentSet.serv
|
||||
|
||||
const wasCambioPalla = lastScorer !== prevServer
|
||||
const wasCambioPalla = lastScorerShort !== prevServerShort
|
||||
|
||||
currentSet.ris = currentSet.ris.slice(0, -1)
|
||||
|
||||
const lastScorer = lastScorerShort === 'h' ? 'home' : 'guest'
|
||||
const prevServer = prevServerShort === 'h' ? 'home' : 'guest'
|
||||
|
||||
currentSet.r.pop()
|
||||
s.sp.punt[lastScorer]--
|
||||
s.sp.servHome = prevServer === 'home'
|
||||
s.sp.servHome = prevServerShort === 'h'
|
||||
|
||||
if (wasCambioPalla) {
|
||||
s.sp.form[lastScorer].unshift(s.sp.form[lastScorer].pop())
|
||||
@@ -91,7 +95,7 @@ export function applyAction(state, action) {
|
||||
s.sp.punt.home = 0
|
||||
s.sp.punt.guest = 0
|
||||
s.sp.servHome = team === 'home'
|
||||
s.sp.striscia.push({ serv: team, r: [] })
|
||||
s.sp.striscia.push({ serv: team === 'home' ? 'h' : 'g', ris: '' })
|
||||
s.sp.form = {
|
||||
home: ["1", "2", "3", "4", "5", "6"],
|
||||
guest: ["1", "2", "3", "4", "5", "6"],
|
||||
@@ -102,7 +106,7 @@ export function applyAction(state, action) {
|
||||
case "cambiaPalla": {
|
||||
if (s.sp.punt.home === 0 && s.sp.punt.guest === 0) {
|
||||
s.sp.servHome = !s.sp.servHome
|
||||
s.sp.striscia.at(-1).serv = s.sp.servHome ? 'home' : 'guest'
|
||||
s.sp.striscia.at(-1).serv = s.sp.servHome ? 'h' : 'g'
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -117,7 +121,7 @@ export function applyAction(state, action) {
|
||||
home: ["1", "2", "3", "4", "5", "6"],
|
||||
guest: ["1", "2", "3", "4", "5", "6"],
|
||||
}
|
||||
s.sp.striscia = [{ serv: s.sp.servHome ? 'home' : 'guest', r: [] }]
|
||||
s.sp.striscia = [{ serv: s.sp.servHome ? 'h' : 'g', ris: '' }]
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ describe('Game Logic (gameState.js)', () => {
|
||||
|
||||
it('dovrebbe avere la striscia iniziale con un set vuoto', () => {
|
||||
expect(state.sp.striscia).toHaveLength(1)
|
||||
expect(state.sp.striscia[0].serv).toBe('home')
|
||||
expect(state.sp.striscia[0].r).toEqual([])
|
||||
expect(state.sp.striscia[0].serv).toBe('h')
|
||||
expect(state.sp.striscia[0].ris).toBe('')
|
||||
})
|
||||
|
||||
it('dovrebbe avere modalità 3/5 di default', () => {
|
||||
@@ -113,19 +113,19 @@ describe('Game Logic (gameState.js)', () => {
|
||||
|
||||
it('dovrebbe aggiornare la striscia per punto Home', () => {
|
||||
const s = applyAction(state, { type: 'incPunt', team: 'home' })
|
||||
expect(s.sp.striscia.at(-1).r).toEqual(['home'])
|
||||
expect(s.sp.striscia.at(-1).ris).toBe('h')
|
||||
})
|
||||
|
||||
it('dovrebbe aggiornare la striscia per punto Guest', () => {
|
||||
const s = applyAction(state, { type: 'incPunt', team: 'guest' })
|
||||
expect(s.sp.striscia.at(-1).r).toEqual(['guest'])
|
||||
expect(s.sp.striscia.at(-1).ris).toBe('g')
|
||||
})
|
||||
|
||||
it('dovrebbe registrare scorer nella striscia', () => {
|
||||
let s = applyAction(state, { type: 'incPunt', team: 'home' })
|
||||
s = applyAction(s, { type: 'incPunt', team: 'guest' })
|
||||
s = applyAction(s, { type: 'incPunt', team: 'home' })
|
||||
expect(s.sp.striscia.at(-1).r).toEqual(['home', 'guest', 'home'])
|
||||
expect(s.sp.striscia.at(-1).ris).toBe('hgh')
|
||||
})
|
||||
|
||||
it('non dovrebbe incrementare i punti dopo vittoria', () => {
|
||||
@@ -180,7 +180,7 @@ describe('Game Logic (gameState.js)', () => {
|
||||
it('dovrebbe ripristinare la striscia', () => {
|
||||
const s1 = applyAction(state, { type: 'incPunt', team: 'home' })
|
||||
const s2 = applyAction(s1, { type: 'decPunt' })
|
||||
expect(s2.sp.striscia.at(-1).r).toEqual([])
|
||||
expect(s2.sp.striscia.at(-1).ris).toBe('')
|
||||
})
|
||||
|
||||
it('dovrebbe gestire undo multipli in sequenza', () => {
|
||||
@@ -248,14 +248,14 @@ describe('Game Logic (gameState.js)', () => {
|
||||
it('dovrebbe aggiungere un nuovo set vuoto alla striscia', () => {
|
||||
const s = applyAction(state, { type: 'nuovoSet', team: 'home' })
|
||||
expect(s.sp.striscia).toHaveLength(2)
|
||||
expect(s.sp.striscia.at(-1).r).toEqual([])
|
||||
expect(s.sp.striscia.at(-1).serv).toBe('home')
|
||||
expect(s.sp.striscia.at(-1).ris).toBe('')
|
||||
expect(s.sp.striscia.at(-1).serv).toBe('h')
|
||||
})
|
||||
|
||||
it('dovrebbe conservare il set precedente nella striscia', () => {
|
||||
state.sp.striscia[0].r = ['home', 'guest', 'home']
|
||||
state.sp.striscia[0].ris = 'hgh'
|
||||
const s = applyAction(state, { type: 'nuovoSet', team: 'home' })
|
||||
expect(s.sp.striscia[0].r).toEqual(['home', 'guest', 'home'])
|
||||
expect(s.sp.striscia[0].ris).toBe('hgh')
|
||||
})
|
||||
|
||||
it('dovrebbe resettare le formazioni', () => {
|
||||
@@ -661,10 +661,10 @@ describe('Game Logic (gameState.js)', () => {
|
||||
})
|
||||
|
||||
it('dovrebbe resettare la striscia a un set vuoto', () => {
|
||||
state.sp.striscia = [{ serv: 'home', r: ['home', 'guest', 'home'] }, { serv: 'home', r: ['guest'] }]
|
||||
state.sp.striscia = [{ serv: 'h', ris: 'hgh' }, { serv: 'h', ris: 'g' }]
|
||||
const s = applyAction(state, { type: 'resetta' })
|
||||
expect(s.sp.striscia).toHaveLength(1)
|
||||
expect(s.sp.striscia[0].r).toEqual([])
|
||||
expect(s.sp.striscia[0].ris).toBe('')
|
||||
})
|
||||
|
||||
it('dovrebbe impostare visuForm a false', () => {
|
||||
|
||||
Reference in New Issue
Block a user