diff options
| -rw-r--r-- | src/main/game/sol_rules.h | 6 | ||||
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 21 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 3e0393d..87266ee 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -27,12 +27,17 @@ struct sol_rules { NO_BUILD, ANY }; + enum class stock_deal_type { + WASTE, + TABLEAU_PILES + }; uint8_t tableau_pile_count; build_order build_ord; build_policy build_pol; spaces_policy spaces_pol; bool move_built_group; + bool two_decks; card::rank_t max_rank; bool hole; bool foundations; @@ -40,6 +45,7 @@ struct sol_rules { bool diagonal_deal; uint8_t cells; uint8_t stock_size; + stock_deal_type stock_deal_t; uint8_t reserve_size; bool reserve_stacked; }; 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 9ec2339..948eb39 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -19,6 +19,7 @@ using namespace rapidjson; 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; const sol_rules rules_parser::from_file(const string rules_file) { sol_rules sr = get_default(); @@ -155,6 +156,14 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d.HasMember("two decks")) { + if (d["two decks"].IsBool()) { + sr.two_decks = d["two decks"].GetBool(); + } else { + json_helper::json_parse_err("[two decks] must be a boolean"); + } + } + if (d.HasMember("hole")) { if (d["hole"].IsBool()) { sr.hole = d["hole"].GetBool(); @@ -195,6 +204,18 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d.HasMember("stock deal type")) { + if (d["stock deal type"].IsString()) { + if(string(d["stock deal type"].GetString()) == "waste") { + sr.stock_deal_t = sdt::WASTE; + } else { + sr.stock_deal_t = sdt::TABLEAU_PILES; + } + } else { + json_helper::json_parse_err("[stock deal type] must be a string"); + } + } + if (d.HasMember("reserve size")) { if (d["reserve size"].IsInt()) { sr.reserve_size = static_cast<uint8_t>(d["reserve size"].GetInt()); |
