Skip to content

feat(minesweeper): Game Center leaderboard + submit-on-win (#291) - #312

Merged
wei18 merged 1 commit into
mainfrom
feat/ms-game-center-leaderboard-291
Jun 4, 2026
Merged

wei18 merged 1 commit into
mainfrom
feat/ms-game-center-leaderboard-291

Conversation

@wei18

@wei18 wei18 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Closes #291. Wires Minesweeper's Game Center leaderboard, mirroring Sudoku.

  • Shared GameCenterKit: added a game-agnostic submitScore(leaderboardId:elapsedSeconds:) primitive to the protocol; Sudoku's typed submitScore(puzzleId:difficulty:leaderboardKind:) now delegates to it (behavior-identical). Keeps MS types out of the shared layer.
  • MS: MinesweeperGameCenterDashboard (GKGameCenterViewController modal, mirror Sudoku Switch to native GameCenter UI — remove custom LeaderboardView #49 — not an AppRoute), Home Leaderboard card enabled (no longer a stub), MinesweeperLeaderboardID (per-difficulty .v1 best-time IDs), submit-on-win in MinesweeperGameViewModel.submitBestTimeIfWon() (latched once per win, non-blocking via ErrorReporter).
  • Composition: .live() = LiveGameCenterClient, .preview() = Fake.

CR: APPROVE-WITH-NITS (no Blocker/High). Verified: Sudoku leaderboard submission behavior-identical (3 Sudoku tests assert exact ID+score, green); MS submit latched + non-blocking; card is a working modal side-effect, nav-invariant tested; 62 (MinesweeperKit) + 57 (GameCenterKit) tests pass; zero Sudoku source changes. ASC registration of the 3 MS leaderboard IDs is a separate user-owned step.

🤖 Generated with Claude Code

…hboard (#291)

Mirror Sudoku's Game Center integration for Minesweeper:

- Wire the shared `GameCenterClient` into `MinesweeperAppComposition`
  (`.live()` = `LiveGameCenterClient(authDriver: GKAuthDriver())`,
  `.preview()` = `FakeGameCenterClient`); thread through `LiveRouteFactory`
  → `MinesweeperBoardView` → `MinesweeperGameViewModel`.
- Add a game-agnostic raw submit to the shared protocol:
  `submitScore(leaderboardId:elapsedSeconds:)`. Sudoku's typed
  `submitScore(puzzleId:…)` now delegates to it (single centisecond-
  conversion site). The Sudoku-typed method's `SudokuEngine.Difficulty` +
  `LeaderboardKind` coupling kept it unusable for MS directly.
- `MinesweeperGameCenterDashboard` — native GC modal presenter mirroring
  Sudoku's `GameCenterDashboard` (iOS `GKGameCenterViewController`, macOS
  `GKAccessPoint` collapse). NOT an AppRoute (#49).
- Enable the Home Leaderboard card (remove `.disabled`, "Coming soon" →
  "Best times"); `select(.leaderboard)` presents the dashboard modal.
- `MinesweeperLeaderboardID` — per-difficulty `.v1` best-time leaderboard
  IDs (beginner/intermediate/expert). ASC registration of these IDs is a
  separate user-owned / ASCRegister step.
- Submit-on-win in `MinesweeperGameViewModel`: on `.won`, submit elapsed
  seconds to the difficulty's best-time leaderboard exactly once; errors
  funnel through `ErrorReporter` (non-blocking, no-retry, never crashes
  gameplay — mirrors Sudoku's `GameCenterSink`).

Tests: submit-on-win (per-difficulty id + once + swallowed-error +
losing-never-submits), leaderboard-card present (no route push), raw-submit
centisecond conversion. MinesweeperKit 62 tests green; GameCenterKit suite
green; SudokuKit builds (additive protocol change). Zero Sudoku source
touched.

Closes #291

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit d2af927 into main Jun 4, 2026
@wei18
wei18 deleted the feat/ms-game-center-leaderboard-291 branch June 4, 2026 03:21
wei18 added a commit that referenced this pull request Jun 4, 2026
…oring Sudoku (#291) (#328)

* feat(ascregister): app-aware GC config + Minesweeper daily leaderboards (#291)

Make the Game Center leaderboard reconcile app-parameterized, mirroring the
metadata `--app <sudoku|minesweeper>` precedent (#310), without duplicating
the reconciler or touching Sudoku's behavior.

- New `Config.GCApp` enum (sudoku|minesweeper); `Config.leaderboards(for:)` +
  `ConfigSnapshot.live(for:)` return the per-app leaderboard set. Sudoku's
  `Config.leaderboards` / `.live` stay as the default, so every existing call
  site (validate, iap, tests) is unchanged.
- `plan` / `apply` / `validate` accept optional `--app` (defaults to sudoku);
  for `--app minesweeper` the action list is filtered to leaderboard actions
  (MS has no achievements/IAPs in its GC detail).
- Add MS's 3 recurring-daily leaderboards
  `com.wei18.minesweeper.leaderboard.{easy,medium,hard}.daily.v1` — same shape
  as Sudoku (ELAPSED_TIME_CENTISECOND, ASC sort, FREQ=DAILY;INTERVAL=1, PT24H,
  BEST_SCORE), with reference names + en/zh-Hant title localizations under an
  app-scoped `gc.minesweeper.leaderboard.*` xcstrings namespace.
- `LeaderboardConfig` gains `titleKey` so each app's title key namespace flows
  through the reconciler unchanged.
- ConfigConsistencyTests: pin the 3 MS leaderboard ids byte-equal to the MS
  runtime constant + assert the recurring-daily shape, so a drift fails a test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(minesweeper): per-difficulty daily Game Center leaderboards mirroring Sudoku (#291)

Change MS runtime leaderboard ids from the non-recurring best-time shape to
Sudoku's recurring-daily shape, so the MS leaderboards mirror Sudoku exactly
(supersedes #291 Decision 3 per the GC-leaderboards dispatch).

- `MinesweeperLeaderboardID`: `{beginner,intermediate,expert}.besttime.v1`
  → `{easy,medium,hard}.daily.v1`. MS engine difficulty
  (beginner/intermediate/expert) maps to Sudoku's id segment
  (easy/medium/hard); ids stay byte-equal to
  `Config.leaderboards(for: .minesweeper)` (ConfigConsistencyTests pins it).
  `bestTime(for:)` → `daily(for:)`.
- Submit site (`MinesweeperGameViewModel`) + completion dashboard
  (`MinesweeperBoardView`) call `daily(for:)`; submit stays latched +
  non-blocking (no behavior change beyond the id, #312 policy preserved).
- Tests updated to the daily-id scheme + a difficulty→segment mapping assertion.

Note for Leader: MS still submits on ALL wins; Sudoku gates on daily-mode only.
See meetings/2026-06-04_ms-gc-daily-leaderboards-asc.impl-notes.md for the
divergence + open decision.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

feat(minesweeper): Leaderboard / Game Center integration

1 participant