pkg:clod/com.clodhub/game-clock 0.11.0 Decision timers and level timers as pure functions over an injected now(): two clocks the caller runs or stops, deadlines on them, timeout actions, and client countdowns for web, Apple and Android. A turn-based game with clocks needs them to be fair and testable. This component keeps two clocks as plain values: the action clock (decisions, board runouts, result holds, offers) and the level clock (stake levels). Both advance only by the time between injected `now` readings, and only while the caller says they run: the caller stops them while the game is paused (host away, everyone offline, manual) or while a player holds the clock to look at cards or read a guide. A deadline is a reading of the action clock, so stopping the clock stops every countdown. The component builds decision timers (a settle to take in what happened, then the decision time; absent players get the settle only; computer players get a minimum plus a thinking time the caller draws from a random source), says what to do when time runs out, and works out the next wall time the game must wake up. Client files turn the countdown the server sends into a running display that stands still while frozen. Examples A hold'em table with 30 seconds per decision, stopped when the host disconnects. A turbo game with 10 seconds and fold on timeout. A relaxed game with `onTimeout` `none`. Package URL: pkg:clod/com.clodhub/game-clock@0.11.0 Class: Game clock (pkg:clod/com.clodhub/game-clock-class@1.1.0): Decision deadlines and countdowns that pause and expire. Any component of this class can fill a recipe slot that asks for it. Category games/turns-and-timing; https://clodhub.com/classes/game-clock-class.txt; 0 other components of this class: https://clodhub.com/components.txt?class=pkg%3Aclod%2Fcom.clodhub%2Fgame-clock-class Provides (1) - game-clock (com.clodhub/game-clock 1.0.0): Game clocks as pure functions over an injected `now` (epoch milliseconds). The caller says which clocks run between two readings (create, advance, reset, elapsed, wallAt); pauses and holds belong to presence and are not stored here. The action clock times decisions, runouts, result holds and offers; the level clock times stake levels. Timers (after, startDecision, startThinking, renewIfPresent, delay, isDue, remainingMs, settleLeftMs, timeoutAction, nextWake) read the action clock. Server: TypeScript `implementation/server/clock.ts`. Client countdowns: TypeScript `implementation/web/countdown.ts` (remaining, endsAt, formatClock), Swift `implementation/apple/Sources/Countdown.swift` and Kotlin `com.clodhub.clock` `Countdown.kt` (remaining, formatClock). Every function returns a new value. components that use it: https://clodhub.com/components.txt?requires=com.clodhub%2Fgame-clock Requires (0) - none Settings (2) The installer collects two settings. `decisionSeconds` is how long a player has to decide (whole number of seconds; default 30, as in the house rules). `onTimeout` is what the game does when time runs out: `check-or-fold` (check if free, otherwise fold; default), `fold`, or `none` (keep waiting). - decisionSeconds: integer; optional, default 30 - onTimeout: string (slug); optional, default "check-or-fold" Depends on components: none How to use in a recipe A recipe uses it through a slot of class Game clock (pkg:clod/com.clodhub/game-clock-class 1.1.0), naming pkg:clod/com.clodhub/game-clock as the slot's preferred component or substituting it for another component of the class. The recipe connects what it provides (game-clock) to the slots that use it. The recipe sets decisionSeconds and onTimeout; any it leaves out takes its default. - as a slot in recipe.json components: {"id":"game-clock","class":{"name":"pkg:clod/com.clodhub/game-clock-class","version":"1.1.0","digest":"7d7223e09dd99de86b93ad17705ccc24a75e97968d93c4c701075392a4f4938a"},"preferred":{"name":"pkg:clod/com.clodhub/game-clock","version":"0.11.0"}} - in place of another component of the class: clod fetch game-clock@0.11.0 --store store --from https://clodhub.com, then clod design RECIPE@VERSION --store store --answers answers.json --substitute SLOT=game-clock@0.11.0 --out definition.json Used by recipes: pkg:clod/com.clodhub/ourpoker-recipe 0.13.0 (slot game-clock) For developers: how an application uses it The turn engine keeps one `ClockState` (`create(now)`) and, at the start of every request and wake-up, calls `advance(clock, now, runs)`. Presence owns who is paused or holding the clock; the engine reads that and says which clocks run: `runs.action` is false while the table is paused or held, `runs.level` is also false while rebuy offers are open. `reset(clock, now)` starts a game, `elapsed(clock, 'action'|'level')` reads a clock (feed the level reading to `level-schedule`) and `wallAt(clock, which, targetMs)` gives the epoch time a clock reaches a target if it keeps running, for scheduling alarms. When a player becomes the actor the engine stores `startDecision(...)` (or `startThinking(...)` for a computer player, with a thinking time drawn from the random source) and when `isDue` it takes `timeoutAction`. Clients call `remaining(leftAtView, viewAt, now, frozen)` and `formatClock`. Presence timing itself (who is connected) is not here. Accounts and services No deployed service and no accounts. The host provides a wall clock and an alarm facility; the component only does arithmetic on the readings it is given. How it is checked `tests/web.test.ts` (required-local) checks settings, clock arithmetic with a clock that goes backwards, the separate level run flag, decision, absent and thinking timers, renewal when an absent player returns, timeout actions, next wake-up, `create`, `advance`, `reset`, `elapsed`, `wallAt` and the client countdown rows in `tests/fixtures/countdown.json`. `tests/native.py apple` compiles `Countdown.swift` with swiftc and checks the same rows (run and passed on this machine). `tests/native.py android` does the same with kotlinc; kotlinc is not installed here, so it was written but not run. - `node --test tests/web.test.ts` (web, required-local; tools: node 26.5) - `python3 tests/native.py apple` (apple, platform; tools: python3 3.12, swiftc 6.4) - `python3 tests/native.py android` (android, platform; tools: python3 3.12, kotlinc 2.2, java 26.0) Updates Patch updates replace the files only. The component keeps no data; the clock state lives in the game state the engine stores. Changing `decisionSeconds` affects timers started afterwards, not those already running. Tags: clock, game, games, turns-and-timing Targets: client android, ios, macos, tvos, web, windows; server none Publisher: George McIntyre (george-mcintyre) Guardians: Level N Ltd (guardian key 08775f20) Source: clodhub/game-clock release v0.11.0; digest sha256:c90e5feba7d6d1087228d94cef85512d46e6d61c65e41661458fb54f5cb1e8c5 Release: features Line 0.11: no security releases Quality: Integration-tested, certified Known vulnerabilities: none known (checked 2026-11-26 at OSV); https://clodhub.com/api/components/game-clock/0.11.0/vulnerabilities Downloads: 1 in 30 days; 1 of this version Classes: https://clodhub.com/classes.txt; this component as JSON: https://clodhub.com/api/components/game-clock/0.11.0 Bundle download: GET https://clodhub.com/api/components/game-clock/0.11.0/bundle returns a link valid for one hour Implements: pkg:clod/com.clodhub/game-clock-class@1.1.0 7d7223e09dd99de86b93ad17705ccc24a75e97968d93c4c701075392a4f4938a com.clodhub/game-clock 1.0.0 entry modules: android android/src/main/java, ios apple/Sources, macos apple/Sources, server server/index.ts, tvos apple/Sources, web web/index.ts, windows web/index.ts shared behaviour suites: shared Platforms: android, ios, macos, server, tvos, web, windows Toolchains: android >=8.0.0, ios >=17.0.0, java >=17.0.0 <27.0.0, kotlin =2.4.21, macos >=14.0.0, node >=26.5.0 <27.0.0, swift =6.4.2, tvos >=17.0.0 Frameworks: none Styles: scope none; 0 namespaces; 0 conflicts Licence: Apache-2.0; 0 upstream sources, 0 exact dependencies, 29 files (listed on the details page) Suitable for jobs: game-clock profile any: cost none; load none; regions any; compliance none Notes: Pure library; no provider limits apply. The host's alarm facility (for example a durable object alarm) is chosen by the server-host job, not here. Data migration: this component keeps no data Maintainers: Level N Ltd; https://github.com/clodhub/game-clock/issues; updates https://github.com/clodhub/game-clock/releases (manual) What you download game-clock-0.11.0.tar, from release v0.11.0 of clodhub/game-clock: 29 files - Documents and manifests (8): CONTRACT.md, INSTRUCTIONS.md, LICENCE, NOTICE, PROVENANCE.md, SOURCE.md, ... - Source code (6): android/ (1), apple/ (1), server/ (2), web/ (2) - Tests (5): android/ (1), apple/ (1), fixtures/ (1), native.py, web.test.ts - Interface documents (1): game-clock.json - Class files: the class's interfaces and shared checks (3): game-clock-class/ (3) - Examples (1): consumer.ts - Diagrams (5): definition.json, examples/ (1), output/ (3) Installing copies 6 of them into the application under components/game-clock/: android 1, apple 1, server 2, web 2 Not included: the values of its settings, which the recipe writes; any secret The archive is a release file on the publisher's public GitHub repository; ClodHub keeps this page and a pointer to the release, not the code. clod checks the archive's sha256 fingerprint before anything is copied, and installing runs none of the package's code. Versions - 0.11.0 features (2026-11-26T11:26:49.734Z) sha256:c90e5feba7d6d1087228d94cef85512d46e6d61c65e41661458fb54f5cb1e8c5 Links Details (package foundations, upstream sources, exact dependencies, styles, class inventories, files): https://clodhub.com/components/game-clock/details.txt?version=0.11.0 Page: https://clodhub.com/components/game-clock; JSON: https://clodhub.com/api/components/game-clock/0.11.0; connections diagram: https://clodhub.com/api/components/game-clock/0.11.0/connections.svg Copyright Level N Ltd 2026