diff options
| author | thecharlesblake | 2018-01-10 18:15:14 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-01-10 18:15:14 +0000 |
| commit | 3ce4c07a3d78082590629d36d4039d68f0a84663 (patch) | |
| tree | d5d7839783cebb097af9f071751d693f47e3af6d /src/main/input-output/input/json-parsing/rules_parser.cpp | |
| parent | Add debug mode to benchmark script (diff) | |
| download | metasol-3ce4c07a3d78082590629d36d4039d68f0a84663.tar.gz metasol-3ce4c07a3d78082590629d36d4039d68f0a84663.zip | |
Add asserts to program and fix bugs they raise
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 | 10 |
1 files changed, 10 insertions, 0 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 1893ff7..9154ffd 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -66,6 +66,9 @@ 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()); + 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][count] must be an integer"); } @@ -133,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"); } @@ -162,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(); |
