diff options
| author | thecharlesblake | 2018-01-04 15:47:00 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-01-04 15:47:00 +0000 |
| commit | 4161e60c9d332826129efddd5dabc60e3393057d (patch) | |
| tree | 57a5d3cfa981e4d0b125706dade4dacf01edee13 /src/main/game/game_state.cpp | |
| parent | Add deal parsing for flower garden (diff) | |
| download | metasol-4161e60c9d332826129efddd5dabc60e3393057d.tar.gz metasol-4161e60c9d332826129efddd5dabc60e3393057d.zip | |
Create game state setup for flower garden
Diffstat (limited to 'src/main/game/game_state.cpp')
| -rw-r--r-- | src/main/game/game_state.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 666b970..841e213 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -50,6 +50,14 @@ game_state::game_state(const sol_rules& s_rules) : } } + // If there are cell piles, creates the relevant cell vectors + if (rules.cells > 0) { + for (uint8_t i = 0; i < rules.cells; i++) { + piles.emplace_back(); + cells.push_back(static_cast<pile_ref>(piles.size() - 1)); + } + } + // If there is a stock & waste, creates piles if (rules.stock_size > 0) { piles.emplace_back(); @@ -58,11 +66,11 @@ game_state::game_state(const sol_rules& s_rules) : waste = static_cast<pile_ref>(piles.size() - 1); } - // If there are cell piles, creates the relevant cell vectors - if (rules.cells > 0) { - for (uint8_t i = 0; i < rules.cells; i++) { + // If there is a reserve, creates piles + if (rules.reserve_size > 0) { + for (uint8_t i = 0; i < rules.reserve_size; i++) { piles.emplace_back(); - cells.push_back(static_cast<pile_ref>(piles.size() - 1)); + reserve.push_back(static_cast<pile_ref>(piles.size() - 1)); } } @@ -108,6 +116,14 @@ game_state::game_state(const sol_rules& s_rules, int seed) : } } + // If there is a reserve, deals to it + if (rules.reserve_size > 0) { + for (unsigned int i = 0; i < rules.reserve_size; i++) { + piles[reserve[i]].place(deck.back()); + deck.pop_back(); + } + } + // Deals to the tableau piles (row-by-row) for (int t = 0; !deck.empty(); t++) { card c = deck.back(); |
