aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/input-output/input')
-rw-r--r--src/main/input-output/input/json-parsing/rules_parser.cpp22
-rw-r--r--src/main/input-output/input/sol_preset_types.cpp80
2 files changed, 101 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"}
diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp
index 1315565..755f48a 100644
--- a/src/main/input-output/input/sol_preset_types.cpp
+++ b/src/main/input-output/input/sol_preset_types.cpp
@@ -37,6 +37,8 @@ std::map<string, string> sol_preset_types::mp = {
"cells": 0,
"stock size": 0,
"stock deal type": "waste",
+ "stock deal count": 1,
+ "stock redeal": false,
"reserve size": 0,
"reserve stacked": false
}
@@ -373,4 +375,82 @@ std::map<string, string> sol_preset_types::mp = {
},
+ {
+ "klondike",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 7,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "diagonal deal": true
+ },
+ "stock size": 24,
+ "stock deal count": 1,
+ "stock redeal": false
+}
+)"
+
+ },
+
+ {
+ "klondike-built-group",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 7,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "move built group": true,
+ "diagonal deal": true
+ },
+ "stock size": 24,
+ "stock deal count": 1,
+ "stock redeal": false
+}
+)"
+
+ },
+
+ {
+ "klondike-deal-3",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 7,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "diagonal deal": true
+ },
+ "stock size": 24,
+ "stock deal count": 3,
+ "stock redeal": true
+}
+)"
+
+ },
+
+ {
+ "klondike-deal-3-built-group",
+
+ R"(
+{
+ "tableau piles": {
+ "count": 7,
+ "build policy": "red-black",
+ "spaces policy": "kings",
+ "move built group": true,
+ "diagonal deal": true
+ },
+ "stock size": 24,
+ "stock deal count": 3,
+ "stock redeal": true
+}
+)"
+
+ },
+
}; \ No newline at end of file