diff options
| author | thecharlesblake | 2018-01-05 15:56:18 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-01-05 15:56:18 +0000 |
| commit | 6ff8eb79720d76110f2477c07ab95eac167d0389 (patch) | |
| tree | 16fa6832c2841405b09eaff740c01b7eac659f94 /src/main/game/game_state.cpp | |
| parent | Add deal parser for stacked reserve (canfield) (diff) | |
| download | metasol-6ff8eb79720d76110f2477c07ab95eac167d0389.tar.gz metasol-6ff8eb79720d76110f2477c07ab95eac167d0389.zip | |
Add game state setup for stacked reserve (canfield)
Diffstat (limited to 'src/main/game/game_state.cpp')
| -rw-r--r-- | src/main/game/game_state.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 841e213..8da5bac 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -68,7 +68,9 @@ game_state::game_state(const sol_rules& s_rules) : // If there is a reserve, creates piles if (rules.reserve_size > 0) { - for (uint8_t i = 0; i < rules.reserve_size; i++) { + uint8_t pile_count = rules.reserve_stacked ? + uint8_t(1) : rules.reserve_size; + for (uint8_t i = 0; i < pile_count; i++) { piles.emplace_back(); reserve.push_back(static_cast<pile_ref>(piles.size() - 1)); } @@ -116,10 +118,13 @@ game_state::game_state(const sol_rules& s_rules, int seed) : } } - // If there is a reserve, deals to it + // If there is a reserve, deals to it. + // We treat a regular reserve like multiple single-card piles, + // but a stacked reserve as a single multiple-card pile. if (rules.reserve_size > 0) { for (unsigned int i = 0; i < rules.reserve_size; i++) { - piles[reserve[i]].place(deck.back()); + int idx = rules.reserve_stacked ? 0 : i; + piles[reserve[idx]].place(deck.back()); deck.pop_back(); } } |
