diff options
| author | thecharlesblake | 2017-12-26 17:29:24 +0000 |
|---|---|---|
| committer | thecharlesblake | 2017-12-26 17:29:24 +0000 |
| commit | b8f4cae869eace06df73ac7c1c390cc42cfe499b (patch) | |
| tree | 0440d8c082388f3fb04f7c977b16eeb4ddf024ef /src/main/game/game_state.cpp | |
| parent | Refactor game state to prep for deal parse (diff) | |
| download | metasol-b8f4cae869eace06df73ac7c1c390cc42cfe499b.tar.gz metasol-b8f4cae869eace06df73ac7c1c390cc42cfe499b.zip | |
Add basic tableau deal parsing
Diffstat (limited to 'src/main/game/game_state.cpp')
| -rw-r--r-- | src/main/game/game_state.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 580e454..01a17fb 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -12,6 +12,7 @@ #include <boost/functional/hash.hpp> #include "game_state.h" +#include "../input-output/deal_parser.h" using namespace std; using namespace rapidjson; @@ -26,10 +27,18 @@ game_state::game_state(const sol_rules& s_rules) : reserve(pile::reserve_factory()), stock(pile::stock_factory()), waste(pile::waste_factory()), - hole(pile::hole_factory(s_rules.max_rank)) {} + hole(pile::hole_factory(s_rules.max_rank)) { +} + +// Construct an initial game state from a JSON doc +game_state::game_state(const sol_rules& s_rules, const Document& doc) : + game_state(s_rules) { + deal_parser::parse(*this, doc); +} // Construct an initial game state from a seed -game_state::game_state(const sol_rules& s_rules, int seed) : game_state(s_rules) { +game_state::game_state(const sol_rules& s_rules, int seed) : + game_state(s_rules) { vector<card> deck = shuffled_deck(seed, rules.max_rank); @@ -328,4 +337,3 @@ size_t hash_value(game_state const& gs) { size_t hash_value(vector<pile> const& vp) { return hash_range(begin(vp), end(vp)); } - |
