aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/game_state.cpp
diff options
context:
space:
mode:
authorthecharlesblake2017-12-26 17:29:24 +0000
committerthecharlesblake2017-12-26 17:29:24 +0000
commitb8f4cae869eace06df73ac7c1c390cc42cfe499b (patch)
tree0440d8c082388f3fb04f7c977b16eeb4ddf024ef /src/main/game/game_state.cpp
parentRefactor game state to prep for deal parse (diff)
downloadmetasol-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.cpp14
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));
}
-