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 ++++++++++++++++++++---- src/main/game/game_state.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/main/game') 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(); diff --git a/src/main/game/game_state.h b/src/main/game/game_state.h index 30af8a6..6aa3918 100644 --- a/src/main/game/game_state.h +++ b/src/main/game/game_state.h @@ -67,6 +67,7 @@ private: std::vector cells; pile_ref stock; pile_ref waste; + std::vector reserve; std::vector foundations; pile_ref hole; -- cgit v1.2.1