diff options
| author | thecharlesblake | 2018-03-08 23:29:30 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-03-08 23:29:30 +0000 |
| commit | 2cc12c2cc24701dbe89281c3b71031649a748879 (patch) | |
| tree | bbf882f6ee0e405ebf225758d8baf5efc80d930f /src/main/input-output/input/json-parsing | |
| parent | Add stock deal when no empty tableau piles logic (diff) | |
| download | metasol-2cc12c2cc24701dbe89281c3b71031649a748879.tar.gz metasol-2cc12c2cc24701dbe89281c3b71031649a748879.zip | |
Add solve by ordered tableau json parsing
Diffstat (limited to 'src/main/input-output/input/json-parsing')
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 21 |
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"); + } } |
