Skip to content

feat(minesweeper): add board pause/resume parity with Sudoku (#434) - #435

Merged
wei18 merged 1 commit into
mainfrom
feat/434-ms-pause-resume
Jun 9, 2026
Merged

wei18 merged 1 commit into
mainfrom
feat/434-ms-pause-resume

Conversation

@wei18

@wei18 wei18 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Closes #434.

What this mirrors from Sudoku

Adds board Pause/Resume to Minesweeper, matching Sudoku's board exactly:

  • Session (MinesweeperSession): new .paused status + pause() / resume() that freeze / restart the elapsed clock (reusing the existing freezeRunningClock running-span accounting). reveal / toggleFlag already guard .idle || .playing, so taps are absorbed while paused.
  • ViewModel (MinesweeperGameViewModel): pause() / resume() / isPaused (status == .paused), mirroring Sudoku's GameViewModel.
  • BoardView (MinesweeperBoardView): toolbar Pause/Resume toggle (icon-only on iPhone, icon+text on Mac, accessibilityLabel Resume/Pause + accessibilityIdentifier), a board-cover overlay that hides the minefield while paused (so the player can't study the board with the clock stopped, "Tap to resume"), and banner suppression while paused — all mirroring Sudoku.

Reuse-vs-duplicate decision

Extracted the shared overlay (the project rule's preferred path). PauseOverlayView now lives in GameShellUI; Sudoku's BoardView was refactored to consume it and the SudokuUI-local copy deleted. Low-risk because:

  • Both SudokuUI and MinesweeperUI already depend on GameShellUI, and the overlay only uses tokens (theme.accent.primary, theme.text.primary) that already live in GameShellUI's Theme.
  • The one app-divergent bit — the "Tap to resume" string — is injected as a LocalizedStringKey parameter so each app resolves it from its own Localizable.xcstrings (the exact pattern CompletionScreen already uses).
  • The pause/resume logic stays per-game in each VM (each owns its session actor + timer), as required.

Localization

Added Pause / Resume / Tap to resume to the Minesweeper catalog in all 7 locales (en, zh-Hant, zh-Hans, ja, es, th, ko), mirroring Sudoku's existing translations. Diff is purely additive (no reordering of existing keys).

Verify (all green)

  • swift build + swift test — MinesweeperCoreKit 81, MinesweeperKit 121, GameShellKit 19, SudokuKit 216 — all pass.
  • New tests: session pause freezes elapsed / resume restarts without losing accumulated time / pause+resume no-op outside legal states / reveal-while-paused absorbed; VM isPaused reflects state + elapsed frozen while paused.
  • Re-recorded the 4 playing-state board baselines (midReveal + flagged, light+dark) that legitimately gained the new toolbar toggle. The .lost board (mineHit) re-recorded byte-identical (no toggle). PNGs committed.
  • mise run scan:l10n — PASS (both catalogs 0 placeholders, all 7 locales complete).
  • Pre-commit hooks (gitleaks / hygiene / swiftlint) — green.

🤖 Generated with Claude Code

Mirror Sudoku's board Pause/Resume on the Minesweeper board:

- MinesweeperSession actor: add `.paused` status + `pause()` / `resume()`
  that freeze / restart the elapsed clock (reuses the existing
  freezeRunningClock running-span accounting). Reveal / flag stay gated to
  `.idle || .playing`, so taps are absorbed while paused.
- MinesweeperGameViewModel: `pause()` / `resume()` / `isPaused`
  (`status == .paused`), mirroring Sudoku's GameViewModel.
- MinesweeperBoardView: toolbar Pause/Resume toggle (icon-only on iPhone,
  icon+text on Mac, accessibilityLabel Resume/Pause + accessibilityIdentifier),
  a board-cover overlay that hides the minefield while paused, and banner
  suppression while paused — all mirroring Sudoku's BoardView.

Reuse over duplication: extracted the shared `PauseOverlayView` into
GameShellUI and refactored Sudoku's BoardView to consume it (deleting the
SudokuUI-local copy). The resume label is injected as a `LocalizedStringKey`
so each app resolves it from its own catalog (same pattern as
CompletionScreen). The pause/resume LOGIC stays per-game in each VM (each
owns its session actor + timer).

Localized Pause / Resume / Tap to resume in all 7 locales in the Minesweeper
catalog, mirroring Sudoku's existing translations.

Tests: session-level pause freezes elapsed time, resume restarts without
losing accumulated time, pause/resume no-op outside their legal states,
reveal-while-paused is absorbed; VM-level isPaused reflects state + elapsed
stays frozen while paused. Re-recorded the 4 playing-state board baselines
(midReveal + flagged, light+dark) that gained the new toolbar toggle.

Verify (all green): swift build + swift test on MinesweeperCoreKit (81),
MinesweeperKit (121), GameShellKit (19), SudokuKit (216); mise run scan:l10n
PASS.

Co-Authored-By: Wei18 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit 595171c into main Jun 9, 2026
4 checks passed
@wei18
wei18 deleted the feat/434-ms-pause-resume branch June 9, 2026 06:25
wei18 added a commit that referenced this pull request Jun 9, 2026
…#443)

Land the real GADBannerView and unify the two placeholder banner slots into
one shared MonetizationUI.BannerSlotView consumed by both apps.

- AdsAdMob: LiveAdMobBridge now wraps its retained BannerView in a
  UIViewRepresentable (iOS-only, #if canImport(UIKit)) and exposes it as a
  type-erased AnyView via a new bridge method. GoogleMobileAds stays confined
  to LiveAdMobBridge (isolation audit: exactly 1 import site).
- New BannerViewProviding seam in MonetizationUI lets the loaded banner view
  cross AdsAdMob -> MonetizationUI as an AnyView WITHOUT leaking the SDK type
  (foundations.md §9.1: BannerView never crosses the target border). The live
  provider conforms; SudokuUI/MinesweeperUI cast `adProvider as? any
  BannerViewProviding` so neither UI imports AdsAdMob.
- Shared MonetizationUI.BannerSlotView (mirrors the #435 PauseOverlayView
  extraction): 50pt height contract, dismiss button, honest status captions.
  The .loaded branch renders the real banner from the host; nil host (fakes /
  macOS NoopAdProvider) falls back to nothing-in-rect. Theme decoupled via DI
  Color params (mirrors ToastView). Deleted SudokuUI.BannerSlotView and
  MinesweeperUI.MinesweeperBannerSlotView; repointed all 4 call sites.
- Debug/Release ad-unit-id split (user decision): DEBUG builds force Google's
  universal TEST banner unit id inside LiveAdMobBridge so a dev/sim build can
  never request prod ads; Release reads the per-app prod id from Info.plist
  (GADBannerUnitID, injected from Tuist/AdMob.xcconfig) as before.

Verify (macOS, swift build + test all green):
- AppMonetizationKit 114 tests, SudokuKit 220 tests, MinesweeperKit 127 tests.
- mise run scan:l10n PASS (banner labels stay bare literals — no catalog keys
  dropped or added).
- GoogleMobileAds import audit: 1 site (LiveAdMobBridge.swift).

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): board missing Pause/Resume (parity with Sudoku)

1 participant