aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/input/json-parsing/deal_parser.cpp6
-rw-r--r--src/main/input-output/input/json-parsing/rules_parser.cpp25
2 files changed, 31 insertions, 0 deletions
diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp
index 7531cec..453398e 100644
--- a/src/main/input-output/input/json-parsing/deal_parser.cpp
+++ b/src/main/input-output/input/json-parsing/deal_parser.cpp
@@ -283,6 +283,12 @@ bool deal_parser::parse_foundations(game_state &gs, const rapidjson::Document& d
}
}
+ // If the game uses a random base for foundations, assume that the first card in the first foundation is that base
+ if (!gs.rules.foundations_base) {
+ auto& first_found = gs.piles[gs.foundations[0]];
+ gs.foundation_base = first_found[first_found.size() - 1].get_rank();
+ }
+
return true;
}
diff --git a/src/main/input-output/input/json-parsing/rules_parser.cpp b/src/main/input-output/input/json-parsing/rules_parser.cpp
index da43cf3..a6c84c5 100644
--- a/src/main/input-output/input/json-parsing/rules_parser.cpp
+++ b/src/main/input-output/input/json-parsing/rules_parser.cpp
@@ -117,6 +117,8 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
sr.spaces_pol = s_pol::NO_BUILD;
} else if (sp_str == "kings") {
sr.spaces_pol = s_pol::KINGS;
+ } else if (sp_str == "auto-reserve-then-waste") {
+ sr.spaces_pol = s_pol::AUTO_RESERVE_THEN_WASTE;
} else {
json_helper::json_parse_err("[tableau piles][spaces policy] is invalid");
}
@@ -195,6 +197,14 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
}
}
+ if (d["tableau piles"].HasMember("wraps")) {
+ if (d["tableau piles"]["wraps"].IsBool()) {
+ sr.tableau_wraps = d["tableau piles"]["wraps"].GetBool();
+ } else {
+ json_helper::json_parse_err("[tableau piles][wraps] must be a boolean");
+ }
+ }
+
} else {
json_helper::json_parse_err("[tableau piles] must be an object");
}
@@ -229,6 +239,21 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
}
}
+ if (d["foundations"].HasMember("base card")) {
+ if (d["foundations"]["base card"].IsString()) {
+ string base_card_str = d["foundations"]["base card"].GetString();
+
+ if (base_card_str == "random") {
+ sr.foundations_base = boost::none;
+ } else {
+ base_card_str += "H";
+ sr.foundations_base = card(base_card_str.c_str()).get_rank();
+ }
+ } else {
+ json_helper::json_parse_err("[foundations][base card] must be a string");
+ }
+ }
+
if (d["foundations"].HasMember("removable")) {
if (d["foundations"]["removable"].IsBool()) {
sr.foundations_removable = d["foundations"]["removable"].GetBool();