diff options
| author | thecharlesblake | 2018-04-09 19:14:34 +0100 |
|---|---|---|
| committer | thecharlesblake | 2018-04-09 19:14:34 +0100 |
| commit | 7b37110a67cdf6add945224915ebae7817fa444c (patch) | |
| tree | 68dbb8ceafadeaefa3be7d897c6b3d4d018ea3ca /src/main/game | |
| parent | Merge pull request #57 from thecharlesblake/local-results (diff) | |
| download | metasol-7b37110a67cdf6add945224915ebae7817fa444c.tar.gz metasol-7b37110a67cdf6add945224915ebae7817fa444c.zip | |
fin
Diffstat (limited to 'src/main/game')
| -rw-r--r-- | src/main/game/game_state.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 58f5f68..2e79f41 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -464,8 +464,8 @@ bool game_state::is_valid_auto_foundation_move(pile_ref target_pile) const { // The max difference between the 'move up' card and the foundations of the // same colour and the other colour - int same_col_rank_diff = 0; - int other_col_rank_diff = 0; + int same_rank_diff = 0; + int other_rank_diff = 0; for (pile_ref pr : foundations) { if (pr == target_pile) continue; @@ -475,22 +475,24 @@ bool game_state::is_valid_auto_foundation_move(pile_ref target_pile) const { card c(s, r); auto rank_diff = int(move_up_card.get_rank() - r); - if (move_up_card.get_colour() == c.get_colour()) { - same_col_rank_diff = rank_diff; + if (move_up_card.get_suit() == c.get_suit() + || (rules.build_pol == pol::RED_BLACK + && move_up_card.get_colour() == c.get_colour())) { + same_rank_diff = rank_diff; } else { - other_col_rank_diff = max(other_col_rank_diff, rank_diff); + other_rank_diff = max(other_rank_diff, rank_diff); } } - bool other_col_within_1 = other_col_rank_diff <= 1; - bool other_col_within_2 = other_col_rank_diff <= 2; - bool same_col_within_3 = same_col_rank_diff <= 3; + bool other_within_1 = other_rank_diff <= 1; + bool other_within_2 = other_rank_diff <= 2; + bool same_within_3 = same_rank_diff <= 3; if (rules.build_pol == pol::RED_BLACK) { - return other_col_within_1 || (other_col_within_2 && same_col_within_3); + return other_within_1 || (other_within_2 && same_within_3); } else { assert(rules.build_pol == pol::ANY_SUIT); - return other_col_within_2; + return other_within_2; } } |
