From 3ce4c07a3d78082590629d36d4039d68f0a84663 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 10 Jan 2018 18:15:14 +0000 Subject: Add asserts to program and fix bugs they raise --- src/main/input-output/input/json-parsing/rules_parser.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/input-output/input/json-parsing/rules_parser.cpp') 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(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(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(); -- cgit v1.2.1