Repository navigation
feat: US-006 - Play stats: pure session clock + per-game persisted playtime ledger - #11
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (US-006)
Pure session clock —
src/PKForge.Domain/PlaySession.cs:SessionClockstate machine:Start / Pause / Resume / Close / Ticktake timestamps only — no timer, no polling, and afterClose(→Idle) nothing measures (double-Close is a no-op;SessionElapsedguards against clock skew).PlaySessionStatsledger per game (key = ROM path):Total,SessionElapsed(now),GrandTotal(now),FormatDuration→h:mm:ss. ContractIPlaySessionStore.Persistence per game:
JsonPlaySessionStore(Infrastructure, atomic temp+move JSON, keyed by game, corrupt file → empty), registered inMauiProgramasAppDataDirectory/play-sessions.json.Wired into the US-004 lifecycle in
GameCompanionStore: externalStartForGameAsync→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 carriesDexPercent+ savePlaytimeHours/Minutes; the session chrono comes from the ledger. 5 new FR/EN strings inAppStrings. 12 new tests (clock transitions, no-measure-after-close, per-game accumulation, duration format, store roundtrip/reopen/corrupt).prd.json: US-006passes: true+ on-device notes.progress.txt: appended.Verification
dotnet test tests/PKForge.Domain.Tests -c Release+dotnet build src/PKForge.App -f net10.0-android.