diff options
| author | thecharlesblake | 2018-02-24 11:10:54 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-02-24 11:10:54 +0000 |
| commit | 5c168518766037ef7129cc28febdd03afb8e11ee (patch) | |
| tree | 4983a8a72065056e693b418510e64abdbdb0f2b7 /src/main/game/game_state.cpp | |
| parent | Add NO_CARD_JUST_MOVED optimisation flag to CMAKE (diff) | |
| download | metasol-5c168518766037ef7129cc28febdd03afb8e11ee.tar.gz metasol-5c168518766037ef7129cc28febdd03afb8e11ee.zip | |
Add card just moved optimisation to game logic
Diffstat (limited to 'src/main/game/game_state.cpp')
| -rw-r--r-- | src/main/game/game_state.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 322bfcc..6067c15 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -228,11 +228,11 @@ bool game_state::move::is_dominance() const { ///////////////////////// void game_state::make_move(const move m) { - assert(m.from < piles.size()); - assert(m.to < piles.size()); - // Handles special stock-to-tableau-piles move if (rules.stock_deal_t == sdt::TABLEAU_PILES && m.from == stock) { + assert(m.from == stock); + assert(m.count == 255 ); + for (pile_ref tab_pr = original_tableau_piles.front(); tab_pr < pile_ref(original_tableau_piles.front() + m.count); tab_pr++) { @@ -241,6 +241,9 @@ void game_state::make_move(const move m) { } // If this is not a built-pile move else if (m.count == 1 || m.is_dominance()) { + assert(m.from < piles.size()); + assert(m.to < piles.size()); + place_card(m.to, take_card(m.from)); #ifndef NO_AUTO_FOUNDATIONS update_auto_foundation_moves(m.to); @@ -248,7 +251,10 @@ void game_state::make_move(const move m) { } // If this is a built-pile move else { + assert(m.from < piles.size() ); + assert(m.to < piles.size() ); assert(m.count <= rules.max_rank); + // Adds the cards to the 'to' pile for (auto pile_idx = m.count; pile_idx-- > 0;) { place_card(m.to, piles[m.from][pile_idx]); |
