diff options
| author | Charlie Blake | 2018-01-10 18:16:34 +0000 |
|---|---|---|
| committer | GitHub | 2018-01-10 18:16:34 +0000 |
| commit | 2a62143fb9edb929f410b1b9b3aed16a16ceba39 (patch) | |
| tree | d5d7839783cebb097af9f071751d693f47e3af6d /src/main/input-output/input/json-parsing/rules_parser.cpp | |
| parent | Merge pull request #28 from thecharlesblake/all-canonical-games (diff) | |
| parent | Add asserts to program and fix bugs they raise (diff) | |
| download | metasol-2a62143fb9edb929f410b1b9b3aed16a16ceba39.tar.gz metasol-2a62143fb9edb929f410b1b9b3aed16a16ceba39.zip | |
Merge pull request #29 from thecharlesblake/refactor-improve-debug
Refactor improve debug
Diffstat (limited to 'src/main/input-output/input/json-parsing/rules_parser.cpp')
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 28 |
1 files changed, 10 insertions, 18 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 948eb39..9154ffd 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -16,7 +16,6 @@ using namespace rapidjson; // Static // //////////// -typedef sol_rules::build_order ord; typedef sol_rules::build_policy pol; typedef sol_rules::spaces_policy s_pol; typedef sol_rules::stock_deal_type sdt; @@ -67,25 +66,11 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d["tableau piles"].HasMember("count")) { if (d["tableau piles"]["count"].IsInt()) { sr.tableau_pile_count = static_cast<uint8_t>(d["tableau piles"]["count"].GetInt()); - } else { - json_helper::json_parse_err("[tableau piles][count] must be an integer"); - } - } - - if (d["tableau piles"].HasMember("build order")) { - if (d["tableau piles"]["build order"].IsString()) { - string bo_str = d["tableau piles"]["build order"].GetString(); - - if (bo_str == "ascending") { - sr.build_ord = ord::ASCENDING; - } else if (bo_str == "descending") { - sr.build_ord = ord::DESCENDING; - } else { - json_helper::json_parse_err("[tableau piles][build order] is invalid"); + if (sr.tableau_pile_count > 52) { + json_helper::json_parse_warning("[tableau piles][count] may be too high"); } - } else { - json_helper::json_parse_err("[tableau piles][build order] must be an string"); + json_helper::json_parse_err("[tableau piles][count] must be an integer"); } } @@ -151,6 +136,9 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d.HasMember("max rank")) { if (d["max rank"].IsInt()) { sr.max_rank = static_cast<card::rank_t>(d["max rank"].GetInt()); + if (sr.max_rank > 13) { + json_helper::json_parse_err("[max rank] must be a valid rank"); + } } else { json_helper::json_parse_err("[max rank] must be an integer"); } @@ -180,6 +168,10 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + 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(); |
