diff options
| author | Charlie Blake | 2018-04-05 15:54:20 +0100 |
|---|---|---|
| committer | GitHub | 2018-04-05 15:54:20 +0100 |
| commit | 4c4bf8a2e153b0ead77931285704aa7a0d2b7475 (patch) | |
| tree | 716b8cc644945daaa1d9665f7ffc98a25d4a36d4 /src/main/input-output/input/json-parsing/rules_parser.cpp | |
| parent | Merge pull request #48 from thecharlesblake/wider-testing (diff) | |
| parent | Add cmd line opts to list games and describe rules (diff) | |
| download | metasol-4c4bf8a2e153b0ead77931285704aa7a0d2b7475.tar.gz metasol-4c4bf8a2e153b0ead77931285704aa7a0d2b7475.zip | |
Merge pull request #49 from thecharlesblake/add-more-games
Add more games
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 | 22 |
1 files changed, 21 insertions, 1 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 3c4bee3..02b2583 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -109,6 +109,8 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { sr.spaces_pol = s_pol::ANY; } else if (sp_str == "no-build") { sr.spaces_pol = s_pol::NO_BUILD; + } else if (sp_str == "kings") { + sr.spaces_pol = s_pol::KINGS; } else { json_helper::json_parse_err("[tableau piles][spaces policy] is invalid"); } @@ -248,6 +250,22 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d.HasMember("stock deal count")) { + if (d["stock deal count"].IsInt()) { + sr.stock_deal_count = static_cast<uint8_t>(d["stock deal count"].GetInt()); + } else { + json_helper::json_parse_err("[stock deal count] must be an integer"); + } + } + + if (d.HasMember("stock redeal")) { + if (d["stock redeal"].IsBool()) { + sr.stock_redeal = static_cast<uint8_t>(d["stock redeal"].GetBool()); + } else { + json_helper::json_parse_err("[stock redeal] must be a boolean"); + } + } + if (d.HasMember("reserve size")) { if (d["reserve size"].IsInt()) { sr.reserve_size = static_cast<uint8_t>(d["reserve size"].GetInt()); @@ -295,7 +313,7 @@ string rules_parser::rules_schema_json() { "type": "object", "properties": { "count": {"type": "integer", "minimum": 0}, "build policy": {"type": "string", "enum": ["any-suit", "red-black", "same-suit", "no-build"]}, - "spaces policy": {"type": "string", "enum": ["any", "no-build"]}, + "spaces policy": {"type": "string", "enum": ["any", "no-build", "kings"]}, "diagonal deal": {"type": "boolean"}, "move built group": {"type": "boolean"}, "move built group policy": {"type": "string", "enum": ["same-as-build", "any-suit", "red-black", "same-suit", "no-build"]} @@ -311,6 +329,8 @@ string rules_parser::rules_schema_json() { "cells": {"type": "integer", "minimum": 0}, "stock size": {"type": "integer", "minimum": 0}, "stock deal type": {"type": "string", "enum": ["waste", "tableau piles"]}, + "stock deal count": {"type": "integer", "minimum": 1}, + "stock redeal": {"type": "boolean"}, "reserve size": {"type": "integer", "minimum": 0}, "reserve stacked": {"type": "boolean"} |
