From 92bb31b18e61aa56169658b2d7fa2d3dad2c52b6 Mon Sep 17 00:00:00 2001 From: Hans de Zwart Date: Tue, 11 Aug 2026 14:39:32 +0200 Subject: [PATCH] Track a match: length, score sheet, and a clock that survives a quit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match length is a new first row in the settings, 1 to 29 points, stepping by 2 so it can only ever be odd. The Time setting now means time *per point* and each clock starts at time × points, which the settings sheet spells out. The middle bar icon opens a score sheet. Edits are staged there and only reach the state on Done, which then does one of three things: nothing changed turn, delay position and moves all untouched score changed displayed times become the reserves, then back to the first tap with moves zeroed — the clocks keep their value clock changed the spent delay is added back on so the panel shows exactly what was typed, and the turn carries on Tapping outside the sheet discards the staged edits, so a stray tap can't restart a game. reset() was called both by the Reset button and by every settings change, so clearing the score in it would have wiped a live match whenever the delay was nudged. It splits into resetClocks() and resetAll(); only the button clears the score. Shortening a match clamps a score that no longer fits. The whole game now persists, not just the settings: score, both reserves, moves, whose turn and how much delay was left, saved on the discrete transitions and on pagehide/visibilitychange. Time passing while the app is dead can't be charged to anyone, so a running clock is stored as paused and comes back on the play button. A malformed saved game is ignored rather than half-applied. Each panel shows its own score first, stacked above its move count at the top left. Co-Authored-By: Claude Opus 5 --- public_html/README.md | 54 +++++-- public_html/index.html | 346 +++++++++++++++++++++++++++++++++++++---- public_html/sw.js | 2 +- 3 files changed, 362 insertions(+), 40 deletions(-) diff --git a/public_html/README.md b/public_html/README.md index dd5d0aa..79bfe7e 100644 --- a/public_html/README.md +++ b/public_html/README.md @@ -51,16 +51,43 @@ except installation and the service worker. - The waiting player's taps are ignored, so a stray hand won't stop the clock. - The bar under the big time is the delay draining. When it empties you get a soft tick and your reserve starts moving. That's the moment worth hearing. -- **Reset** returns to the starting position. It takes two taps: the first arms - the button — it lights up and a ring unwinds around it — and a second tap - within those two seconds does it. One stray thumb can't wipe a live game. +- **Reset** starts a whole new match: clocks back to full *and* the score back to + 0–0. It takes two taps: the first arms the button — it lights up and a ring + unwinds around it — and a second tap within those two seconds does it. One + stray thumb can't wipe a live match. - **Pause** freezes mid-turn and resumes exactly where it stopped, delay - included. Opening settings pauses automatically, and leaves it paused so the - clock only restarts when both players are ready. + included. Opening either sheet pauses automatically, and leaves it paused so + the clock only restarts when both players are ready. Backgammon clocks pause between games, and after a cocked die the delay is normally restarted — use pause and reset for those. +## Matches + +Set **Match** in the settings to the number of points you're playing to — 1, 3, +5 and up to 29. The time you set is *per point*, so a 5-point match at 2:00 a +point puts 10:00 on each clock, and the settings sheet shows you that sum. + +The score sheet is the middle icon in the bar. It reads **You** for whoever is +holding the phone — the bottom half — and **Them** for the far end, and each +panel shows its own score first, so both players read their own score on the +left: `Score: 1 - 3, out of 5`. + +Nothing in that sheet takes effect until you press **Done**: + +- **Done with nothing changed** leaves everything exactly as it was — same turn, + same delay part-spent, same move counts. Tapping outside the sheet is the same + as changing nothing, so a stray tap can't restart a game. +- **Change a score** and the game restarts when you press Done: move counters + back to zero and the turn back to the first tap, waiting on whoever rolls the + lower die. The clocks keep whatever they were showing. +- **Change only a clock** — the sheet also lets you correct either player's time + to the second — and the game carries on undisturbed: same turn, same delay + position, same moves. + +Shortening the match to fewer points than someone has already won pulls their +score down to fit. + ## Settings At the top of the sheet are three presets — **2m / 12s**, **3m / 12s** and @@ -70,17 +97,24 @@ numbers and it comes back on. | Setting | Range | Default | | --- | --- | --- | -| Time | 0:15 – 99:00 | 3:00 | +| Match | 1 – 29 points, odd | 1 | +| Time | 0:15 – 99:00 per point | 3:00 | | Delay | 0 – 60 s | 15 s | | Colour | Sage, Brass, Slate, Teal, Plum | Sage | | Sound | on / off | on | Brass is the colour in the chess.com app, if you want the exact original look. -Changing time or delay resets the clock. Settings are kept in `localStorage`, so -they survive closing the tab, force-quitting the installed app and rebooting the +Changing match, time or delay resets the clocks — the score is left alone, so you +can fix the delay mid-match without losing where you are. + +Settings **and the match in progress** are kept in `localStorage`, so they +survive closing the tab, force-quitting the installed app and rebooting the phone — the app also asks for persistent storage so they aren't evicted when the -device runs low on space (Chrome honours that request; Safari ignores it). Only -the settings are stored; a game in progress isn't. +device runs low on space (Chrome honours that request; Safari ignores it). +Reopening restores the score, both clocks, the move counts, whose turn it is and +how much delay was left. The one thing it can't restore is time passing while +the app was closed, so it comes back paused rather than charging anyone for the +gap: a crash shouldn't decide a game. ## Sounds diff --git a/public_html/index.html b/public_html/index.html index 0186adf..9d967ef 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -75,16 +75,23 @@ .panel--top .inner{padding:14px 20px max(14px,env(safe-area-inset-top))} .panel--bottom .inner{padding:14px 20px max(14px,env(safe-area-inset-bottom))} - .moves{ - align-self:flex-end; + .head{ + display:flex;flex-direction:column;align-items:flex-start; + gap:3px; + order:-1; + } + .score,.moves{ font-size:clamp(13px,3.7vw,20px); font-weight:700; letter-spacing:.01em; color:var(--idle-mute); - order:-1; + white-space:nowrap; } + .panel[data-state="active"] .score, .panel[data-state="active"] .moves, + .panel[data-state="flagged"] .score, .panel[data-state="flagged"] .moves{color:var(--accent-mute)} + .panel[data-state="flagged"] .score, .panel[data-state="flagged"] .moves{color:rgba(255,255,255,.55)} .stack{ @@ -138,7 +145,7 @@ display:flex;align-items:center; padding:0 clamp(12px,4vw,28px); } - .bar .gap{flex:1.5} + .bar .gap{flex:.75} .btn{ flex:1; height:100%; @@ -303,7 +310,10 @@
-
Moves: 0
+
+
Score: 0 - 0, out of 1
+
Moves: 0
+
3:00
@@ -330,6 +340,15 @@ + + + 1pts + +
+
+
@@ -377,7 +411,7 @@

Time

-

Reserve time per player.

+

Reserve time per point.

@@ -418,7 +452,67 @@
-

Changing time or delay resets the clock.

+

Changing match, time or delay resets the clocks. The score is left alone.

+
+ +