Scoring rules editable from the desk until the first score

Release 0.6.2.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MB7nCCAscYsb3zzkT6LHZi
This commit is contained in:
bkvargyasandClaude Fable 5.1 committed 2026-09-06 15:56:30 +00:00
1 parent 110077314d
commit 1fb31c5eec
5 files changed
+25 -3

No files matched your search

+15 -1
View File
@@ -170,7 +170,21 @@ export function buildRouter({ registry, auth, store }) {
if (body.timezone !== undefined) { if (body.timezone && !validTz(body.timezone)) throw new Error('Unknown time zone'); t.timezone = body.timezone || null; }
if (body.date !== undefined) t.date = String(body.date).trim() || null;
if (body.notes !== undefined) t.notes = String(body.notes).slice(0, 500);
t.emit({ type: 'settings', timezone: t.timezone, date: t.date });
if (body.name !== undefined && String(body.name).trim()) t.name = String(body.name).trim().slice(0, 60);
// scoring rules can change until the first score is on the books
if (['pointsTo', 'winBy', 'cap', 'bestOf', 'teamSize'].some(k => body[k] !== undefined)) {
if (t.matches.some(m => ['final', 'forfeit'].includes(m.status))) throw new Error('Scores have been entered; rules are locked');
const r = { ...t.rules };
if (body.pointsTo !== undefined) r.pointsTo = +body.pointsTo;
if (body.winBy !== undefined) r.winBy = +body.winBy;
if (body.cap !== undefined) r.cap = +body.cap || 0;
if (body.bestOf !== undefined) r.bestOf = +body.bestOf;
if (body.teamSize !== undefined) r.teamSize = +body.teamSize;
if (!(r.pointsTo >= 5 && r.pointsTo <= 50) || !(r.winBy >= 1 && r.winBy <= 5) || ![1, 3, 5].includes(r.bestOf) || !(r.teamSize >= 1 && r.teamSize <= 6)) throw new Error('Rules out of range');
if (r.cap && r.cap < r.pointsTo) throw new Error('Cap must be at least points-to (or 0 for no cap)');
t.rules = r;
}
t.emit({ type: 'settings', timezone: t.timezone, date: t.date, rules: t.rules });
return 'Settings saved';
});
action('/banner', ({ t, body }) => { t.banner = String(body.banner ?? '').trim().slice(0, 200) || null; t.emit({ type: 'banner', banner: t.banner }); return t.banner ? 'Banner set' : 'Banner cleared'; });