diff options
Diffstat (limited to 'src/main/input-output/input')
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 45 | ||||
| -rw-r--r-- | src/main/input-output/input/sol_preset_types.cpp | 18 |
2 files changed, 53 insertions, 10 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..6fa89bc 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -56,7 +56,6 @@ sol_rules rules_parser::get_default() { } void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { - if (!d.IsObject()) { json_helper::json_parse_err("JSON doc must be object"); } @@ -109,7 +108,7 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } else { - json_helper::json_parse_err("[tableau piles][spaces policy] must be an string"); + json_helper::json_parse_err("[tableau piles][spaces policy] must be a string"); } } @@ -121,6 +120,28 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d["tableau piles"].HasMember("move built group policy")) { + if (d["tableau piles"]["move built group policy"].IsString()) { + string mbgp_str = d["tableau piles"]["move built group policy"].GetString(); + + if (mbgp_str == "same-as-build") { + sr.built_group_pol = sr.build_pol; + } else if (mbgp_str == "any-suit") { + sr.built_group_pol = pol::ANY_SUIT; + } else if (mbgp_str == "red-black") { + sr.built_group_pol = pol::RED_BLACK; + } else if (mbgp_str == "same-suit") { + sr.built_group_pol = pol::SAME_SUIT; + } else if (mbgp_str == "no-build") { + sr.built_group_pol = pol::NO_BUILD; + } else { + json_helper::json_parse_err("[tableau piles][move built group policy] is invalid"); + } + } else { + json_helper::json_parse_err("[tableau piles][move built group policy] must be a string"); + } + } + if (d["tableau piles"].HasMember("diagonal deal")) { if (d["tableau piles"]["diagonal deal"].IsBool()) { sr.diagonal_deal = d["tableau piles"]["diagonal deal"].GetBool(); @@ -169,10 +190,6 @@ 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(); @@ -189,6 +206,14 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d.HasMember("foundations complete piles")) { + if (d["foundations complete piles"].IsBool()) { + sr.foundations_comp_piles = d["foundations complete piles"].GetBool(); + } else { + json_helper::json_parse_err("[foundations complete piles] must be a boolean"); + } + } + if (d.HasMember("cells")) { if (d["cells"].IsInt()) { sr.cells = static_cast<uint8_t>(d["cells"].GetInt()); @@ -232,4 +257,12 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { json_helper::json_parse_err("[reserve stacked] must be a boolean"); } } + + int solution_types = 0; + if (sr.hole) solution_types++; + if (sr.foundations) solution_types++; + if (solution_types != 1) { + json_helper::json_parse_err("one and only one of [hole] and [foundations] " + "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 de0fd41..1fa6009 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -25,7 +25,8 @@ std::map<string, string> sol_preset_types::mp = { "build policy": "any-suit", "spaces policy": "any", "diagonal deal": false, - "move built group": false + "move built group": false, + "move built group policy": "same-as-build" }, "max rank": 13, "two decks": false, @@ -33,6 +34,7 @@ std::map<string, string> sol_preset_types::mp = { "foundations": true, "foundations initial card": false, "foundations removable": false, + "foundations complete piles": false, "cells": 0, "stock size": 0, "stock deal type": "waste", @@ -318,10 +320,14 @@ std::map<string, string> sol_preset_types::mp = { R"( { "tableau piles": { - "count": 10 + "count": 10, + "build policy": "any-suit", + "move built group": true, + "move built group policy": "same-suit" }, + "foundations complete piles": true, "two decks": true, - "stock size": 60, + "stock size": 50, "stock deal type": "tableau piles" } )" @@ -333,8 +339,12 @@ std::map<string, string> sol_preset_types::mp = { R"( { "tableau piles": { - "count": 4 + "count": 4, + "build policy": "any-suit", + "move built group": true, + "move built group policy": "same-suit" }, + "foundations complete piles": true, "two decks": true, "max rank": 3, "stock size": 12, |
