diff options
| author | thecharlesblake | 2018-01-02 11:28:47 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-01-02 11:28:47 +0000 |
| commit | 25d3f7591e2b7ca5303593e1da4bc880174e189a (patch) | |
| tree | 88bc64bd854e861390c170a9e8579307db7ead6d /src/main/game | |
| parent | Add unit tests for bakers dozen (diff) | |
| download | metasol-25d3f7591e2b7ca5303593e1da4bc880174e189a.tar.gz metasol-25d3f7591e2b7ca5303593e1da4bc880174e189a.zip | |
Add rules parsing for bakers dozen
Diffstat (limited to 'src/main/game')
| -rw-r--r-- | src/main/game/sol_rules.cpp | 23 | ||||
| -rw-r--r-- | src/main/game/sol_rules.h | 9 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp index 353c8db..87d556f 100644 --- a/src/main/game/sol_rules.cpp +++ b/src/main/game/sol_rules.cpp @@ -111,11 +111,11 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) { if (d["tableau piles"].HasMember("build policy")) { if (d["tableau piles"]["build policy"].IsString()) { - string bo_str = d["tableau piles"]["build policy"].GetString(); + string bp_str = d["tableau piles"]["build policy"].GetString(); - if (bo_str == "any-suit") { + if (bp_str == "any-suit") { sr.build_pol = build_policy::ANY_SUIT; - } else if (bo_str == "red-black") { + } else if (bp_str == "red-black") { sr.build_pol = build_policy::RED_BLACK; } else { util::json_parse_err("[tableau piles][build policy] is invalid"); @@ -126,6 +126,23 @@ void sol_rules::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d["tableau piles"].HasMember("spaces policy")) { + if (d["tableau piles"]["spaces policy"].IsString()) { + string sp_str = d["tableau piles"]["spaces policy"].GetString(); + + if (sp_str == "any") { + sr.spaces_pol = spaces_policy::ANY; + } else if (sp_str == "no-build") { + sr.spaces_pol = spaces_policy::NO_BUILD; + } else { + util::json_parse_err("[tableau piles][spaces policy] is invalid"); + } + + } else { + util::json_parse_err("[tableau piles][spaces policy] must be an string"); + } + } + } else { util::json_parse_err("[tableau piles] must be an object"); } diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index a2f8fe9..96c10d5 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -43,16 +43,21 @@ public: RED_BLACK, N_A }; + enum class spaces_policy { + NO_BUILD, + ANY + }; static bool is_suit(build_policy); static card::suit_t suit_val(build_policy); - static const sol_rules from_preset(const std::string); - static const sol_rules from_file(const std::string); + static const sol_rules from_preset(std::string); + static const sol_rules from_file(std::string); uint8_t tableau_pile_count; build_order build_ord; build_policy build_pol; + spaces_policy spaces_pol; card::rank_t max_rank; bool hole; bool foundations; |
