diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/game/global_cache.cpp | 22 | ||||
| -rw-r--r-- | src/main/game/global_cache.h | 1 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp index f1cf185..079ed77 100644 --- a/src/main/game/global_cache.cpp +++ b/src/main/game/global_cache.cpp @@ -49,12 +49,21 @@ cached_game_state::cached_game_state(const game_state& gs) : live(true) { if (gs.rules.stock_size > 0) { add_pile(gs.stock, gs); - add_card_divider(); if (gs.rules.stock_deal_t == sdt::WASTE) { - add_pile(gs.waste, gs); - add_card_divider(); + bool waste_deal_symmetry = gs.rules.stock_redeal + && gs.piles[gs.waste].size() % gs.rules.stock_deal_count == 0; + + if (waste_deal_symmetry) { + add_pile_in_reverse(gs.waste, gs); + add_card_divider(); + } else { + add_card_divider(); + add_pile_in_reverse(gs.waste, gs); + } } + + add_card_divider(); } for (pile::ref pr : gs.reserve) { @@ -86,6 +95,13 @@ void cached_game_state::add_pile(pile::ref pr, const game_state& gs) { } } +void cached_game_state::add_pile_in_reverse(pile::ref pr, const game_state& gs) { + for (auto i = gs.piles[pr].pile_vec.size(); i-->0;) { + card c = gs.piles[pr].pile_vec[i]; + add_card(c, gs); + } +} + void cached_game_state::add_card(card c, const game_state& gs) { auto& target = data; diff --git a/src/main/game/global_cache.h b/src/main/game/global_cache.h index dd4670e..e9bb412 100644 --- a/src/main/game/global_cache.h +++ b/src/main/game/global_cache.h @@ -23,6 +23,7 @@ struct cached_game_state { explicit cached_game_state(const game_state&); void add_pile(pile::ref, const game_state&); + void add_pile_in_reverse(pile::ref, const game_state&); void add_card(card, const game_state&); void add_card_divider(); |
