aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output/input/json-parsing
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/input-output/input/json-parsing')
-rw-r--r--src/main/input-output/input/json-parsing/rules_parser.cpp21
1 files changed, 17 insertions, 4 deletions
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 395f2e7..cf01b2d 100644
--- a/src/main/input-output/input/json-parsing/rules_parser.cpp
+++ b/src/main/input-output/input/json-parsing/rules_parser.cpp
@@ -56,6 +56,7 @@ sol_rules rules_parser::get_default() {
}
void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
+ int solution_types = 0;
if (!d.IsObject()) {
json_helper::json_parse_err("JSON doc must be object");
@@ -156,6 +157,7 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
if (d.HasMember("hole")) {
if (d["hole"].IsBool()) {
sr.hole = d["hole"].GetBool();
+ solution_types++;
} else {
json_helper::json_parse_err("[hole] must be a boolean");
}
@@ -164,15 +166,12 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
if (d.HasMember("foundations")) {
if (d["foundations"].IsBool()) {
sr.foundations = d["foundations"].GetBool();
+ solution_types++;
} else {
json_helper::json_parse_err("[foundations] must be a boolean");
}
}
- if (!sr.hole && !sr.foundations) {
- json_helper::json_parse_err("one of [hole] and [foundations] must be true");
- }
-
if (d.HasMember("foundations initial card")) {
if (d["foundations initial card"].IsBool()) {
sr.foundations_init_card = d["foundations initial card"].GetBool();
@@ -189,6 +188,15 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
}
}
+ if (d.HasMember("solve by ordered tableau")) {
+ if (d["solve by ordered tableau"].IsBool()) {
+ sr.solve_ord_tab = d["solve by ordered tableau"].GetBool();
+ solution_types++;
+ } else {
+ json_helper::json_parse_err("[solve by ordered tableau] must be a boolean");
+ }
+ }
+
if (d.HasMember("cells")) {
if (d["cells"].IsInt()) {
sr.cells = static_cast<uint8_t>(d["cells"].GetInt());
@@ -232,4 +240,9 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) {
json_helper::json_parse_err("[reserve stacked] must be a boolean");
}
}
+
+ if (solution_types != 1)
+ json_helper::json_parse_err("one and only one of [hole], [foundations] "
+ "and [solve by ordered tableau] must be true");
+ }
}