diff options
| author | thecharlesblake | 2018-03-09 00:36:07 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-03-09 00:36:07 +0000 |
| commit | 1b56ea2cc3ca6ab1058391d8205fefbdeb202c12 (patch) | |
| tree | 114d929d71d3375767220ce8285720f8001be917 /src/main/game/game_state.cpp | |
| parent | Add solve by ordered tableau json parsing (diff) | |
| download | metasol-1b56ea2cc3ca6ab1058391d8205fefbdeb202c12.tar.gz metasol-1b56ea2cc3ca6ab1058391d8205fefbdeb202c12.zip | |
Add new solution type logic
Diffstat (limited to 'src/main/game/game_state.cpp')
| -rw-r--r-- | src/main/game/game_state.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 6067c15..52f35f8 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -440,10 +440,18 @@ bool game_state::is_valid_auto_foundation_move(pile_ref target_pile) const { bool game_state::is_solved() const { bool solved = true; - if (rules.hole) { + if (rules.solve_ord_tab) { + for (pile_ref tab_pr : tableau_piles) { + if (is_ordered_pile(tab_pr)) { + solved = false; + break; + } + } + } else if (rules.hole) { solved = piles[hole].size() == rules.max_rank * 4 * (rules.two_decks ? 2 : 1); } else { + assert(rules.foundations); for (auto f : foundations) { if (piles[f].size() != rules.max_rank) { solved = false; @@ -480,6 +488,16 @@ bool game_state::is_solved() const { return solved; } +bool game_state::is_ordered_pile(pile_ref pr) const { + if (piles[pr].size() != rules.max_rank) return false; + + card::suit_t s = piles[pr][0].get_suit(); + for (card::rank_t r = rules.max_rank; r >= 1; r--) { + if (piles[pr][r] != card(s, r)) return false; + } + return true; +} + const std::vector<pile>& game_state::get_data() const { return piles; } |
