Skip to content

feat(2048): gameplay ui — board, gestures, viewmodel — SDD-004 m3 (#479) - #497

Merged
wei18 merged 5 commits into
mainfrom
feat/sdd004-m3-gameplay-ui
Jun 15, 2026
Merged

wei18 merged 5 commits into
mainfrom
feat/sdd004-m3-gameplay-ui

Conversation

@wei18

@wei18 wei18 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Milestone 3 of SDD-004: the 2048 board is playable. Game2048GameViewModel (@mainactor @observable over the actor session) + Game2048BoardView (4×4 grid, swipe gestures → slide, spring tile animation, \.gameChrome mm:ss push, scenePhase save trigger, pause overlay, inline stuck card) + Game2048TileView + GameMode + expanded AppRoute + Game2048Root nav. Mirrors the Minesweeper gameplay twins file-for-file.

9/9 ViewModel tests, 6 board snapshots (initial/midGame/stuck × light/dark), scan:l10n green (3 catalogs). 1258 LOC running total (#479 budget ≤2.5k; ~1.2k headroom for M4). M3→M4 seams documented (persistence, GC submit, banner, completion screen, modal GameRoot flow, theme).

🤖 Generated with Claude Code

wei18 and others added 5 commits June 15, 2026 12:48
…elines (SDD-004 M3)

- Game2048GameViewModel: @mainactor @observable bridge over Game2048Session;
  slide/pause/resume/refresh; seeded preview seam; persistCurrentState() stub
  documented for M4 (no PersistenceKit dep yet)
- Game2048TileView: 4×4 cell renderer with value→colour palette (2…2048+)
- Game2048BoardView: 4×4 grid, DragGesture swipe in 4 directions, compact/
  mac layout split, gameChrome elapsed push (mm:ss), PauseOverlayView cover,
  inline "Game Over" stuck overlay (M4 → shared CompletionScreen)
- GameMode: leaf enum mirroring MinesweeperUI (daily/practice)
- AppRoute: expanded board(seed:mode:) parameters; settings stub
- Game2048Root: NavigationStack wired with daily/practice seed derivation
- Game2048UITests: 9 ViewModel unit tests (all pass) + 6 snapshot baselines
  (initial/midGame/stuck ×light/dark)
- Localizable.xcstrings: 10 strings ×7 locales; scan:l10n green
- Package.swift: M3 deps (Game2048CoreKit, GameAppKit, swift-snapshot-testing)

Co-Authored-By: Claude Fable 5 <[email protected]>
- TileView: split 12-arm switch into two ≤10-complexity helpers; remove
  superfluous identifier_name disable (not triggered)
- BoardView: remove superfluous file_length disable (file is under 400 lines)
- Snapshot fixture: collapse extra comma spacing in tile literal arrays

Co-Authored-By: Claude Fable 5 <[email protected]>
…lexity gate)

Cyclomatic complexity rule ≤ 10: an 11-arm switch exceeds it; a dictionary
lookup has complexity 1 regardless of entry count.

Co-Authored-By: Claude Fable 5 <[email protected]>
blocking-1: add `stuckOverlayForSnapshot: Bool` init param to
Game2048BoardView; overlay condition is now
`viewModel.isTerminal && (!suppressTickerForSnapshot || stuckOverlayForSnapshot)`.
Stuck snapshot tests pass the new flag; two baselines re-recorded with the
"Game Over" card visible. Mirrors MinesweeperBoardView's
`completionViewModelForSnapshot` seam (#388 / #315).

blocking-2: replace @State tickerTask + .onAppear/.onDisappear with a single
`.task(id: ObjectIdentifier(viewModel))` loop (structured cancellation on
disappear; VM-swap restarts it). Matches MinesweeperBoardView line ~229 and
Sudoku BoardView line ~63 exactly. Also removed the incoherent comment block
that claimed a "nonisolated(unsafe) stored property" when it was @State.

nit (folded): update header comment to note .task(id:) is correct here
(#361 arm64 bug is Root-only bootstrap, not long-lived ticker loops);
add M4 L10n comment per review instruction.

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 merged commit 08b9d4b into main Jun 15, 2026
4 checks passed
@wei18
wei18 deleted the feat/sdd004-m3-gameplay-ui branch June 15, 2026 05:30
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.

1 participant