aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/game_state.cpp
diff options
context:
space:
mode:
authorthecharlesblake2017-11-12 10:51:09 +0000
committerthecharlesblake2017-11-12 10:51:09 +0000
commitc651b6894081ba71609249c98f61789ebbe31f0d (patch)
treec7f01462ec7178346d62f3d4da489f00c74f04ca /src/main/game/game_state.cpp
parentClean up sol_rules class (diff)
downloadmetasol-c651b6894081ba71609249c98f61789ebbe31f0d.tar.gz
metasol-c651b6894081ba71609249c98f61789ebbe31f0d.zip

Add factory to pile class to create std pile types

Diffstat (limited to 'src/main/game/game_state.cpp')
-rw-r--r--src/main/game/game_state.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp
index 9432239..9d03155 100644
--- a/src/main/game/game_state.cpp
+++ b/src/main/game/game_state.cpp
@@ -12,7 +12,6 @@
#include <rapidjson/document.h>
#include "game_state.h"
-#include "pile.h"
using namespace rapidjson;
using namespace std;
@@ -54,10 +53,10 @@ game_state::game_state(const Document& doc)
// Construct an initial game state from a seed
game_state::game_state(int seed, const sol_rules& s_rules) :
- reserve(true, ord::NO_BUILD, pol::ANY_SUIT, false),
- stock(true, ord::NO_BUILD, pol::ANY_SUIT, false),
- waste(true, ord::NO_BUILD, pol::ANY_SUIT, false),
- hole(false, ord::BOTH, pol::ANY_SUIT, true, s_rules.max_rank),
+ reserve(pile::reserve_factory()),
+ stock(pile::stock_factory()),
+ waste(pile::waste_factory()),
+ hole(pile::hole_factory(s_rules.max_rank)),
rules(s_rules) {
vector<card> deck = shuffled_deck(seed, rules.max_rank);
@@ -94,8 +93,7 @@ game_state::game_state(int seed, const sol_rules& s_rules) :
// For the first row we must create all the tableau pile vectors
if (i / rules.tableau_pile_count == 0) {
- pile p(true, rules.build_ord, pol::ANY_SUIT, false);
- tableau_piles.push_back(p);
+ tableau_piles.push_back(pile::tableau_factory(rules.build_ord));
}
// Add the randomly generated card to the tableau piles
@@ -107,16 +105,14 @@ game_state::game_state(int seed, const sol_rules& s_rules) :
// If there are foundation piles, create the relevant pile vectors
if (rules.foundations) {
for (int i = 0; i < 4; i++) {
- pile p(true, ord::ASCENDING, pol(i), false);
- foundations.push_back(p);
+ foundations.push_back(pile::foundation_factory(pol(i)));
}
}
// If there are cell piles, create the relevant cell vectors
if (rules.cells > 0) {
for (unsigned int i = 0; i < rules.cells; i++) {
- pile p(true, ord::SINGLE_CARD, pol::ANY_SUIT, false);
- cells.push_back(p);
+ cells.push_back(pile::cell_factory());
}
}
}