From 4161e60c9d332826129efddd5dabc60e3393057d Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 4 Jan 2018 15:47:00 +0000 Subject: Create game state setup for flower garden --- src/main/game/game_state.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/main/game/game_state.cpp') 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(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(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(piles.size() - 1)); + reserve.push_back(static_cast(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(); -- cgit v1.2.1