Add FreeCell variant - #26
Merged
Merged
Conversation
Split the monolithic game core into variant-aware and shared components and add FreeCell support. Key changes: - Introduce shared models and rules (Shared/Card.swift, Shared/GameRules.swift) and move Card into a shared location. - Split variant-specific logic into Klondike and FreeCell modules (rules, persistence, session, state, auto-move advisors). - Refactor AutoMoveAdvisor to a shared coordinator that delegates variant-specific behavior and to handle free cells as sources/destinations. - Update game persistence (SavedGamePayload) to sanitize and validate state per-variant and include free cell layout checks. - Adjust hint/auto-finish logic to be variant-aware (Klondike-specific hint planner and AutoFinishPlanner guarding for Klondike). - Add new FreeCell/Klondike views, tests, and documentation (docs/solitaire-rules-freecell.md). - Remove outdated GameModels/GameRules files and apply many file renames/moves to a Shared/ and variant-based structure. These changes prepare the codebase for multiple solitaire variants by centralizing common logic and isolating variant differences.
Introduce per-variant GameStatistics storage and an aggregated "All" view. Key changes: - GameStatistics: add aggregated(...) to combine multiple variant stats with overflow-safe counters and helpers. - GameStatisticsStore: switch to variant-scoped UserDefaults keys (defaultsKey(for:)), and update APIs (load/save/update/reset/markTrackingStarted) to accept a GameVariant parameter. - SolitaireViewModel: record and finalize stats using the current variant; mark tracking started when switching/decoding into the correct variant bucket. - StatisticsView & ContentView: add a scope picker (Klondike/FreeCell/All), show aggregated metrics for All, and remove direct new-variant buttons and menu items. - GameMenuCommands: remove obsolete newKlondike/newFreeCell actions. - Tests: update usages to load/reset per-variant, add tests for variant isolation, aggregation correctness, overflow safety, and variant-switch finalization; adjust test helper to preserve multiple variant keys. These changes allow tracking and resetting statistics per game variant and presenting combined statistics across variants when requested.
Simplify flipKlondikeTopCardIfNeeded by removing the unnecessary didFlip variable and its guard check. The top tableau card is flipped and the scoring, sound, and haptic effects are applied immediately. This reduces dead code and clarifies the flip logic without changing behavior.
Wrap TableauPileView content in a safety check so it only renders when viewModel.state.tableau contains the pileIndex, returning an inert clear placeholder otherwise to avoid out-of-bounds access during state changes. Rework the pile ZStack and geometry code: reorder/inline views, preserve drop highlight offsets, and update CardView usage (adds cardSize and related params) and drag handling. Minor UI tweak: remove a redundant caption from SettingsView. Documentation: update README to list supported variants (Klondike and FreeCell) and add a rules table with links to variant rule docs.
Replace the segmented Picker for selecting GameVariant with a custom card-style selector. Added a subtitle computed property to GameVariant and a new variantCard(_:) helper in SettingsView that renders stylized, accessible buttons (material background, shadow, selection stroke, opacity/scale) with haptic feedback and smooth animation on change. This improves clarity and visual presentation of the game type selection.
Show the currently selected table background label in the header and replace the old rectangular swatch+label rows with compact circular color swatches. Renamed backgroundColorRow to colorSwatch and updated visuals: swatches now display a checkmark and accent stroke when selected, expand to fill available space with a fixed aspect ratio, and include accessibility labels/selected traits. Selection still updates tableBackgroundColorRawValue and triggers haptic feedback.
Refactor FreeCellTopRowView to control spacing more precisely by grouping the four free cells and four foundations into fixed-width HStacks. Introduces computed innerGap, middleGap and groupWidth so the two groups are separated by a clear spacer (preserving alignment and visual gap) while keeping consistent inner spacing between cards. Also adds a simple placeholder marker in FoundationView when a foundation is empty (system "a" glyph, styled and non-interactive) so empty foundations have a subtle visual cue.
austin-smith
marked this pull request as ready for review
July 4, 2026 19:55
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5da88a3f40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
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.
Add FreeCell as a new game variant, refactor hint/advisor and auto-move logic, add new pixelated deck variant, and update app icon.
Summary