aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/game_state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/game/game_state.cpp')
-rw-r--r--src/main/game/game_state.cpp24
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();