diff options
Diffstat (limited to 'src/main/input-output/input')
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 21 | ||||
| -rw-r--r-- | src/main/input-output/input/sol_preset_types.cpp | 6 |
2 files changed, 20 insertions, 7 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"); + } } diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 2eea9df..75a0b01 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -33,7 +33,7 @@ std::map<string, string> sol_preset_types::mp = { "foundations": true, "foundations initial card": false, "foundations removable": false, - "ordered-tableau-sol": false, + "solve by ordered tableau": false, "cells": 0, "stock size": 0, "stock deal type": "waste", @@ -322,7 +322,7 @@ std::map<string, string> sol_preset_types::mp = { "count": 10, "move built group": false }, - "ordered-tableau-sol": true, + "solve by ordered tableau": true, "two decks": true, "stock size": 50, "stock deal type": "tableau piles" @@ -339,7 +339,7 @@ std::map<string, string> sol_preset_types::mp = { "count": 4, "move built group": false }, - "ordered-tableau-sol": true, + "solve by ordered tableau": true, "two decks": true, "max rank": 3, "stock size": 12, |
