diff options
| author | Charlie Blake | 2018-10-14 15:06:44 +0100 |
|---|---|---|
| committer | GitHub | 2018-10-14 15:06:44 +0100 |
| commit | 247fba9d4cefc511aebec4d494ce7659ac31beb5 (patch) | |
| tree | e2a941215006fecf4bd0379e3b6dbf7494ed0720 /src/main | |
| parent | Merge pull request #98 from thecharlesblake/deal-print (diff) | |
| parent | Add pre-filled cells (diff) | |
| download | metasol-247fba9d4cefc511aebec4d494ce7659ac31beb5.tar.gz metasol-247fba9d4cefc511aebec4d494ce7659ac31beb5.zip | |
Merge pull request #99 from thecharlesblake/pre-filled-cells
Add pre-filled cells
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/game/search-state/game_state.cpp | 9 | ||||
| -rw-r--r-- | src/main/game/sol_rules.cpp | 1 | ||||
| -rw-r--r-- | src/main/game/sol_rules.h | 1 | ||||
| -rw-r--r-- | src/main/input-output/input/json-parsing/rules_parser.cpp | 34 | ||||
| -rw-r--r-- | src/main/input-output/input/sol_preset_types.cpp | 102 |
5 files changed, 120 insertions, 27 deletions
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp index 36f92d7..6cd1262 100644 --- a/src/main/game/search-state/game_state.cpp +++ b/src/main/game/search-state/game_state.cpp @@ -166,6 +166,15 @@ game_state::game_state(const sol_rules& s_rules, int seed, streamliner_options s place_card(foundations[(f_idx + rand_suit)], c); } + // If there are pre-filled cells, deals to them + auto it = begin(original_cells); + for (uint8_t i = 0; i < rules.cells_pre_filled; i++) { + pile::ref r = *it; + place_card(r, deck.back()); + deck.pop_back(); + it++; + } + // If there is a stock, deals to it and set up a waste pile too if (rules.stock_size > 0) { for (unsigned int i = 0; i < rules.stock_size; i++) { diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp index 55c6757..940b1a4 100644 --- a/src/main/game/sol_rules.cpp +++ b/src/main/game/sol_rules.cpp @@ -29,6 +29,7 @@ sol_rules::sol_rules() : foundations_only_comp_piles(false), diagonal_deal(false), cells(0), + cells_pre_filled(0), stock_size(0), stock_deal_t(sdt::TABLEAU_PILES), stock_deal_count(1), diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 642e4a6..130ebcd 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -75,6 +75,7 @@ struct sol_rules { bool foundations_only_comp_piles; bool diagonal_deal; uint8_t cells; + uint8_t cells_pre_filled; uint8_t stock_size; stock_deal_type stock_deal_t; uint8_t stock_deal_count; 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 bcff1fd..731ab47 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -280,10 +280,24 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } if (d.HasMember("cells")) { - if (d["cells"].IsInt()) { - sr.cells = static_cast<uint8_t>(d["cells"].GetInt()); + if (d["cells"].IsObject()) { + if (d["cells"].HasMember("count")) { + if (d["cells"]["count"].IsInt()) { + sr.cells = static_cast<uint8_t>(d["cells"]["count"].GetInt()); + } else { + json_helper::json_parse_err("[cells][count] must be an integer"); + } + } + + if (d["cells"].HasMember("pre-filled")) { + if (d["cells"]["pre-filled"].IsInt()) { + sr.cells_pre_filled = static_cast<uint8_t>(d["cells"]["pre-filled"].GetInt()); + } else { + json_helper::json_parse_err("[cells][pre-filled] must be an integer"); + } + } } else { - json_helper::json_parse_err("[cells] must be an integer"); + json_helper::json_parse_err("[cells] must be an object"); } } @@ -606,8 +620,18 @@ string rules_parser::rules_schema_json() { "type": "boolean" }, "cells": { - "type": "integer", - "minimum": 0 + "type": "object", + "properties": { + "count": { + "type": "integer", + "minimum": 0 + }, + "pre-filled": { + "type": "integer", + "minimum": 0 + } + }, + "additionalProperties": false }, "stock": { "type": "object", diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index b7acd1b..b169370 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -37,7 +37,9 @@ map<string, string> sol_preset_types::mp = { "only complete pile moves": false }, "hole": false, - "cells": 0, + "cells": { + "count": 0 + }, "stock": { "size": 0, "deal type": "waste", @@ -104,7 +106,9 @@ map<string, string> sol_preset_types::mp = { "tableau piles": { "build policy": "red-black" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -118,7 +122,9 @@ map<string, string> sol_preset_types::mp = { "count": 4, "build policy": "red-black" }, - "cells": 1, + "cells": { + "count": 1 + }, "max rank": 4 } )" @@ -555,7 +561,9 @@ map<string, string> sol_preset_types::mp = { "foundations": { "removable": true }, - "cells": 1 + "cells": { + "count": 1 + } } )" @@ -622,7 +630,9 @@ map<string, string> sol_preset_types::mp = { "initial cards": "all", "removable": true }, - "cells": 1 + "cells": { + "count": 1 + } } )" @@ -640,7 +650,9 @@ map<string, string> sol_preset_types::mp = { "initial cards": "all", "removable": true }, - "cells": 2 + "cells": { + "count": 2 + } } )" @@ -653,7 +665,9 @@ map<string, string> sol_preset_types::mp = { "tableau piles": { "build policy": "red-black" }, - "cells": 3 + "cells": { + "count": 3 + } } )" @@ -666,7 +680,9 @@ map<string, string> sol_preset_types::mp = { "tableau piles": { "build policy": "red-black" }, - "cells": 2 + "cells": { + "count": 2 + } } )" @@ -679,7 +695,9 @@ map<string, string> sol_preset_types::mp = { "tableau piles": { "build policy": "red-black" }, - "cells": 1 + "cells": { + "count": 1 + } } )" @@ -691,8 +709,7 @@ map<string, string> sol_preset_types::mp = { { "tableau piles": { "build policy": "red-black" - }, - "cells": 0 + } } )" @@ -706,7 +723,9 @@ map<string, string> sol_preset_types::mp = { "count": 7, "build policy": "red-black" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -720,7 +739,9 @@ map<string, string> sol_preset_types::mp = { "count": 6, "build policy": "red-black" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -734,7 +755,9 @@ map<string, string> sol_preset_types::mp = { "count": 5, "build policy": "red-black" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -748,7 +771,9 @@ map<string, string> sol_preset_types::mp = { "count": 4, "build policy": "red-black" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -761,7 +786,9 @@ map<string, string> sol_preset_types::mp = { "tableau piles": { "build policy": "same-suit" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -775,7 +802,10 @@ map<string, string> sol_preset_types::mp = { "build policy": "same-suit", "spaces policy": "kings" }, - "cells": 8 + "cells": { + "count": 8, + "pre-filled": 4 + } } )" @@ -788,7 +818,9 @@ map<string, string> sol_preset_types::mp = { "tableau piles": { "build policy": "same-suit" }, - "cells": 8 + "cells": { + "count": 8 + } } )" @@ -802,7 +834,27 @@ map<string, string> sol_preset_types::mp = { "build policy": "red-black", "spaces policy": "kings" }, - "cells": 4 + "cells": { + "count": 4, + "pre-filled": 4 + } +} +)" + + }, + { + "fore-cell-same-suit", + + R"( +{ + "tableau piles": { + "build policy": "same-suit", + "spaces policy": "kings" + }, + "cells": { + "count": 4, + "pre-filled": 4 + } } )" @@ -818,7 +870,9 @@ map<string, string> sol_preset_types::mp = { "move built group": "yes", "spaces policy": "kings" }, - "cells": 7, + "cells": { + "count": 7 + }, "foundations": { "initial cards": "all" } @@ -837,7 +891,9 @@ map<string, string> sol_preset_types::mp = { "move built group": "yes", "spaces policy": "kings" }, - "cells": 4 + "cells": { + "count": 4 + } } )" @@ -1536,7 +1592,9 @@ map<string, string> sol_preset_types::mp = { "foundations": { "present": false }, - "cells": 1, + "cells": { + "count": 1 + }, "hole": true } )" |
