Skip to content

feat: US-006 - Play stats: pure session clock + per-game persisted playtime ledger - #11

Merged
Varonal merged 2 commits into
mainfrom
ralph/external-companion
Nov 20, 2026
Merged

Varonal merged 2 commits into
mainfrom
ralph/external-companion

Conversation

@Varonal

@Varonal Varonal commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary (US-006)

Pure session clock — src/PKForge.Domain/PlaySession.cs:

  • SessionClock state machine: Start / Pause / Resume / Close / Tick take timestamps only — no timer, no polling, and after Close (→ Idle) nothing measures (double-Close is a no-op; SessionElapsed guards against clock skew).
  • PlaySessionStats ledger per game (key = ROM path): Total, SessionElapsed(now), GrandTotal(now), FormatDuration → h:mm:ss. Contract IPlaySessionStore.

Persistence per game: JsonPlaySessionStore (Infrastructure, atomic temp+move JSON, keyed by game, corrupt file → empty), registered in MauiProgram as AppDataDirectory/play-sessions.json.

Wired into the US-004 lifecycle in GameCompanionStore: external StartForGameAsync → SessionClock.Start + persist; ResumeExternalIfAny → Resume; StopExternal → Close (banks the stretch) before clearing the companion state — zero background measuring after Stop.

Display data: IGameCompanionStore.External (US-001/003) already carries DexPercent + save PlaytimeHours/Minutes; the session chrono comes from the ledger. 5 new FR/EN strings in AppStrings. 12 new tests (clock transitions, no-measure-after-close, per-game accumulation, duration format, store roundtrip/reopen/corrupt).

prd.json: US-006 passes: true + on-device notes. progress.txt: appended.

Verification

  • CI (this PR): dotnet test tests/PKForge.Domain.Tests -c Release + dotnet build src/PKForge.App -f net10.0-android.
  • Local: no .NET SDK in this sandbox — static checks (Domain purity: no File/Timer in PlaySession.cs, DI, AppStrings keys) passed.
  • Manual on device (US-007 renders it): session chrono ticks while a DS game runs externally; on return the total is banked and survives app restarts; no timer/CPU activity after Stop.

mistral-vibe and others added 2 commits November 20, 2026 08:49
Pure SessionClock state machine (Start/Pause/Resume/Close/Tick on timestamps
only - no timer, no background measuring; Close banks the stretch and goes
Idle, double Close is a no-op). PlaySessionStats ledger per game (key = ROM
path) with SessionElapsed/GrandTotal/FormatDuration(h:mm:ss).

Persisted per game via IPlaySessionStore + JsonPlaySessionStore (atomic JSON,
AppDataDirectory/play-sessions.json, registered in MauiProgram). Wired into
the US-004 lifecycle in GameCompanionStore: StartForGameAsync opens the
session, ResumeExternalIfAny resumes it, StopExternal closes+banks it before
clearing the companion state. Snapshot display data (DexPercent, save
playtime) already rides on IGameCompanionStore.External; 5 new FR/EN strings
in AppStrings. 12 new tests (clock transitions, no-measure-after-close,
per-game accumulation, duration format, store roundtrip/reopen/corrupt).

prd.json: US-006 passes=true. progress.txt: appended learnings.

Co-authored-by: Varonal <Varonal@users.noreply.github.com>
…xternal (CS8604)

Co-authored-by: Varonal <Varonal@users.noreply.github.com>
@Varonal
Varonal merged commit d45c289 into main Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants