diff --git a/CHANGELOG.md b/CHANGELOG.md index 97ec86b..24db833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,16 @@ so you can always tell what a deployment is actually serving. ## [Unreleased] +## [0.5.1] - 2026-09-03 + +### Changed +- A team that withdraws during a bracket now shows as a **forfeit** in every match it was in + or would have reached, with its name struck through and a "Forfeit · Team" tag on the match, + instead of quietly becoming a bye. If the opponent isn't known yet, the withdrawn team stays + in its slot and forfeits the moment the opponent arrives; in double elimination it forfeits + its losers-bracket match too. Play continues and the tournament still goes Final on its own. +- Pool match lists mark forfeits as "FF". + ## [0.5.0] - 2026-09-03 ### Fixed diff --git a/docs/ORGANIZER-GUIDE.md b/docs/ORGANIZER-GUIDE.md index 8e54fe5..642dda7 100644 --- a/docs/ORGANIZER-GUIDE.md +++ b/docs/ORGANIZER-GUIDE.md @@ -46,7 +46,7 @@ A keeper link can only do two things: update the running score of the live match - *forfeit remaining* — their unplayed pool games become forfeit wins for the opponents; played games stand. This is the fair default when a team leaves mid-pool. - *void all games* — every game they played or would play is removed from standings, as if they never entered. Use this when a team leaves early and forfeits would distort the pool. -In a bracket the opponent advances automatically either way. +In a bracket the opponent advances by forfeit either way: the bracket shows the withdrawn team struck through with a "Forfeit" tag on each match it was in, including a later match whose opponent wasn't known yet at the time (it forfeits as soon as that opponent arrives). Play carries on and the tournament still finishes on its own. **Rain, injury, net repair.** Pause the court (with an optional reason shown on the board). The queue keeps flowing to the other court; Resume picks up where it left off. diff --git a/engine/tournament.js b/engine/tournament.js index c4ec030..1800530 100644 --- a/engine/tournament.js +++ b/engine/tournament.js @@ -179,6 +179,12 @@ export class Tournament { const next = this.match(matchId); if (!next) return; next[side === 'A' ? 'teamA' : 'teamB'] = teamId; + // a withdrawn team was waiting here: it forfeits to the team that just arrived + if (next.autoForfeit && next.teamA && next.teamB && ['pending', 'on_deck'].includes(next.status)) { + const f = next.autoForfeit; delete next.autoForfeit; + if (this.teams.get(teamId)?.status === 'withdrawn') { next.status = 'void'; return; } // both gone + this.recordResult(next.id, [], { actor: 'system', forfeit: f }); + } } _propagate(m) { @@ -264,10 +270,12 @@ export class Tournament { m.court = null; } } else if (['pending', 'on_deck', 'live'].includes(m.status)) { - // bracket: opponent walks over, if known; otherwise the slot becomes a bye + // bracket: opponent walks over by forfeit. If the opponent isn't known yet, the withdrawn + // team stays in its slot marked autoForfeit and forfeits the moment the opponent arrives, + // so the bracket shows the forfeit rather than a silent bye. const opp = m.teamA === teamId ? m.teamB : m.teamA; if (opp) this.recordResult(m.id, [], { actor, forfeit: teamId }); - else { const side = m.teamA === teamId ? 'A' : 'B'; m[side === 'A' ? 'teamA' : 'teamB'] = null; m.pendingBye = side; } + else m.autoForfeit = teamId; m.court = null; } } diff --git a/package.json b/package.json index ea577c7..39bcf72 100644 --- a/package.json +++ b/package.json @@ -1 +1 @@ -{"name":"courtside","type":"module","version":"0.5.0","scripts":{"test":"node --test test/*.test.js","sim":"node simulate.js","start":"node --disable-warning=ExperimentalWarning server/index.js","dev":"node --disable-warning=ExperimentalWarning --watch server/index.js","demo":"node --disable-warning=ExperimentalWarning scripts/seed-demo.js","smoke":"bash test/smoke.sh"},"description":"Self-hosted volleyball tournament desk: one QR code from check-in to live scores","main":"server/index.js","directories":{"test":"test"},"keywords":[],"author":"","license":"MIT","dependencies":{"qrcode":"^1.5.4","ws":"^8.21.3"},"engines":{"node":">=22.13"},"repository":{"type":"git","url":"https://gitea.cloudfreeiot.com/bkvargyas/courtside.git"}} \ No newline at end of file +{"name":"courtside","type":"module","version":"0.5.1","scripts":{"test":"node --test test/*.test.js","sim":"node simulate.js","start":"node --disable-warning=ExperimentalWarning server/index.js","dev":"node --disable-warning=ExperimentalWarning --watch server/index.js","demo":"node --disable-warning=ExperimentalWarning scripts/seed-demo.js","smoke":"bash test/smoke.sh"},"description":"Self-hosted volleyball tournament desk: one QR code from check-in to live scores","main":"server/index.js","directories":{"test":"test"},"keywords":[],"author":"","license":"MIT","dependencies":{"qrcode":"^1.5.4","ws":"^8.21.3"},"engines":{"node":">=22.13"},"repository":{"type":"git","url":"https://gitea.cloudfreeiot.com/bkvargyas/courtside.git"}} \ No newline at end of file diff --git a/server/public-state.js b/server/public-state.js index c03d5fc..acf2c9d 100644 --- a/server/public-state.js +++ b/server/public-state.js @@ -5,7 +5,7 @@ export function publicState({ t, engine }) { id: m.id, stage: m.stage, round: m.round, slot: m.slot, label: m.label ?? null, status: m.status, court: m.court, a: m.teamA ? { id: m.teamA, name: name(m.teamA) } : null, b: m.teamB ? { id: m.teamB, name: name(m.teamB) } : null, - winner: m.winner, sets: m.sets, live: m.live ?? null, liveSets: m.liveSets ?? null, startedAt: m.startedAt ?? null, feeds: m.feeds, feedsSide: m.feedsSide, loserFeeds: m.loserFeeds ?? null, loserFeedsSide: m.loserFeedsSide ?? null, conditional: !!m.conditional, + winner: m.winner, sets: m.sets, forfeitBy: m.status === 'forfeit' ? m.loser : (m.autoForfeit ?? null), live: m.live ?? null, liveSets: m.liveSets ?? null, startedAt: m.startedAt ?? null, feeds: m.feeds, feedsSide: m.feedsSide, loserFeeds: m.loserFeeds ?? null, loserFeedsSide: m.loserFeedsSide ?? null, conditional: !!m.conditional, }); const board = t.phase === 'live' ? engine.board() : null; const pools = t.pools.map(p => ({ diff --git a/server/public/app.css b/server/public/app.css index 16af683..ca65354 100644 --- a/server/public/app.css +++ b/server/public/app.css @@ -84,7 +84,8 @@ ul.plain,ol.plain{list-style:none;padding:0;margin:8px 0}ol.plain{counter-reset: .brow.won .bn{font-weight:600}.brow.won .bs{color:var(--ink);font-weight:600}.brow.mine{background:var(--sand-soft)} .bm.live{border-color:var(--good);box-shadow:0 0 0 1px var(--good)}.bm.on_deck{border-style:dashed}.bm.mine{border-color:var(--sand);border-width:2px} .btag{position:absolute;left:50%;transform:translateX(-50%);bottom:-9px;white-space:nowrap;font-family:"Barlow Condensed",sans-serif;text-transform:uppercase;letter-spacing:.08em;font-size:10px;padding:0 6px;border-radius:3px;background:var(--bg);border:1px solid var(--line);color:var(--muted);line-height:1.5} -.btag.live{background:var(--good);color:#fff;border-color:var(--good)} +.btag.live{background:var(--good);color:#fff;border-color:var(--good)}.btag.ff{background:var(--sand-soft);color:var(--sand);border-color:var(--sand)} +.brow.wd .bn,.wd{text-decoration:line-through;color:var(--muted)}.brow.wd .bn a{color:var(--muted)} .bm.list .btag{position:static;transform:none;display:inline-block;align-self:flex-start;margin:4px 9px 6px} .blist{margin-top:10px}.blist .rlbl{position:static;text-align:left} .bracketwrap.fit .btree-scroll{overflow:hidden} diff --git a/server/public/board.js b/server/public/board.js index b80e6fd..9e8cdb7 100644 --- a/server/public/board.js +++ b/server/public/board.js @@ -10,6 +10,9 @@ // every team name on the board links to that team's page (schedule, record, next match) const teamHref = t => `/t/${state.slug}/teams/${encodeURIComponent(t.id)}`; const name = t => t ? `${esc(t.name)}` : 'TBD'; + const withdrawnIds = () => new Set(state.withdrawn.map(t => t.id)); + const wdClass = t => t && withdrawnIds().has(t.id) ? 'wd' : ''; + const forfeitTag = m => m.forfeitBy ? `Forfeit · ${esc(state.withdrawn.concat(state.teams).find(t => t.id === m.forfeitBy)?.name ?? '')}` : ''; const fromName = (t, from) => t ? name(t) : from ? `${from.loser ? 'loser' : 'winner'} on Court ${from.court}` : 'TBD'; const clock = ms => new Date(ms).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }); const isMine = m => myTeam && (m.a?.id === myTeam || m.b?.id === myTeam); @@ -102,7 +105,7 @@ ${p.standings.map((r, i) => ``).join('')}
TeamWLPts+/−
${i + 1}. ${name({ id: r.teamId, name: r.name })}${r.decidedBy ? `*` : ''}${r.w}${r.l}${r.pf}–${r.pa}${r.pointDiff > 0 ? '+' : ''}${r.pointDiff}
- Matches + Matches `).join('')}`; } @@ -162,9 +165,9 @@ const row = (t, side) => { const won = m.winner && t && m.winner === t.id; const pts = m.sets[0] ? m.sets.map(s => s[side]).join(' ') : (m.live && m.status === 'live' ? m.live[side] : ''); - return `
${t ? name(t) : `${feedLabel(m, side)}`}${pts}
`; + return `
${t ? name(t) : `${feedLabel(m, side)}`}${pts}
`; }; - const tag = m.status === 'live' ? `Court ${m.court}` : m.status === 'on_deck' ? `On deck${m.court ? ` · C${m.court}` : ''}` : m.status === 'forfeit' ? 'Forfeit' : m.label ? `${esc(m.label)}` : ''; + const tag = m.status === 'live' ? `Court ${m.court}` : m.status === 'on_deck' ? `On deck${m.court ? ` · C${m.court}` : ''}` : m.forfeitBy ? forfeitTag(m) : m.label ? `${esc(m.label)}` : ''; return `
${row(m.a, 0)}${row(m.b, 1)}${tag}
`; } @@ -181,7 +184,7 @@ function bracketList(stage, ms) { const rounds = [...new Set(ms.map(m => m.round))].sort((a, b) => a - b); - return rounds.map(r => `
${roundName(stage, r, rounds.length, ms)}
${ms.filter(m => m.round === r).map(m => `
${['a', 'b'].map((k, i) => { const t = m[k]; const won = m.winner && t && m.winner === t.id; return `
${t ? name(t) : `${feedLabel(m, i)}`}${m.sets[0] ? m.sets.map(s => s[i]).join(' ') : (m.live && m.status === 'live' ? m.live[i] : '')}
`; }).join('')}${m.status === 'live' ? `Court ${m.court}` : m.status === 'on_deck' ? `On deck${m.court ? ` · C${m.court}` : ''}` : m.status === 'forfeit' ? 'Forfeit' : m.label ? `${esc(m.label)}` : ''}
`).join('')}
`).join(''); + return rounds.map(r => `
${roundName(stage, r, rounds.length, ms)}
${ms.filter(m => m.round === r).map(m => `
${['a', 'b'].map((k, i) => { const t = m[k]; const won = m.winner && t && m.winner === t.id; return `
${t ? name(t) : `${feedLabel(m, i)}`}${m.sets[0] ? m.sets.map(s => s[i]).join(' ') : (m.live && m.status === 'live' ? m.live[i] : '')}
`; }).join('')}${m.status === 'live' ? `Court ${m.court}` : m.status === 'on_deck' ? `On deck${m.court ? ` · C${m.court}` : ''}` : m.forfeitBy ? forfeitTag(m) : m.label ? `${esc(m.label)}` : ''}
`).join('')}
`).join(''); } const isMineId = id => myTeam && id === myTeam; diff --git a/test/engine.test.js b/test/engine.test.js index f44dd2b..6e6bc5f 100644 --- a/test/engine.test.js +++ b/test/engine.test.js @@ -216,3 +216,29 @@ test('manual bracket: hand-picked round-1 pairs land in the chosen matches', () assert.throws(() => t.generateBracketFromPairs([[a, a], [b, c], [d, e], [f, null]]), /placed twice/); assert.throws(() => t.generateBracketFromPairs([[a, b], [c, d], [e, null], [null, null]]), /Not placed/); }); + +test('withdrawal mid-bracket shows as forfeits (not byes) and play continues to a champion', () => { + const t = setup(8, { stages: ['bracket'] }); + t.closeRegistration(); + t.generateBracket(ids(t), { type: 'double' }); + let clock = 0; + const eng = new CourtEngine(t, { now: () => clock }); + eng.start(); + // play two matches, then withdraw a team that is live on a court + for (let i = 0; i < 2; i++) { const c = eng.courts.find(c => c.matchId); clock += 10 * 60_000; eng.recordResult(c.matchId, [[21, 10]]); } + const liveMatch = t.match(eng.courts.find(c => c.matchId).matchId); + const quitter = liveMatch.teamA; + eng.withdrawTeam(quitter, { mode: 'forfeit' }); + // the live match is now a forfeit by the quitter, and any later match they land in forfeits too + assert.equal(liveMatch.status, 'forfeit'); assert.equal(liveMatch.loser, quitter); + let guard = 0; + while (t.phase === 'live' && guard++ < 100) { + const c = eng.courts.find(c => c.matchId); assert.ok(c, 'stalled'); + clock += 10 * 60_000; eng.recordResult(c.matchId, [[21, 10]]); + } + assert.equal(t.phase, 'final'); + const theirs = t.matches.filter(m => [m.teamA, m.teamB].includes(quitter) && m.stage !== 'pool'); + assert.ok(theirs.length >= 2, 'quitter appears in WB and LB'); + assert.ok(theirs.every(m => m.status === 'forfeit' && m.loser === quitter), 'every match of the quitter is a forfeit against them'); + assert.equal(t.matches.filter(m => m.status === 'bye' && m.round > 1).length, 0, 'no silent byes created by the withdrawal'); +});