From e0cbfc79cd1c8e6133cf9b0fa59ed32ba75a90c2 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 18 Jul 2018 22:31:39 +0100 Subject: Canfield rules schema and update default rules --- .../input/json-parsing/rules_parser.cpp | 32 +++++++++++++++++++--- src/main/input-output/input/sol_preset_types.cpp | 6 ++-- 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src/main/input-output/input') 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 b70abdf..f7de6d8 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -462,6 +462,9 @@ string rules_parser::rules_schema_json() { { "$schema": "http://json-schema.org/draft-04/schema#", "description": "JSON Schema representing a generic solitaire game", + "definitions": { + "rank": {"type": "string", "pattern": "^(([0-9]|1[0-3]|a|A|j|J|q|Q|k|K))$"}, + }, "type": "object", "properties": { "tableau piles": { @@ -485,15 +488,24 @@ string rules_parser::rules_schema_json() { "enum": [ "any", "no-build", - "kings" + "kings", + "auto-reserve" ] }, "diagonal deal": { "type": "boolean" }, - "move built group": { + "wraps": { "type": "boolean" }, + "move built group": { + "type": "string", + "enum": [ + "yes", + "no", + "whole-pile" + ] + }, "move built group policy": { "type": "string", "enum": [ @@ -520,8 +532,20 @@ string rules_parser::rules_schema_json() { "present": { "type": "boolean" }, - "initial card": { - "type": "boolean" + "initial cards": { + "type": "string", + "enum": [ + "none", + "one", + "all" + ] + }, + "base card": { + "type": "string", + "oneOf":[ + {"$ref": "#/definitions/rank"}, + {"type": "string","enum": ["random"]} + ] }, "removable": { "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 0c96651..65100e0 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -25,13 +25,15 @@ map sol_preset_types::mp = { "build policy": "any-suit", "spaces policy": "any", "diagonal deal": false, - "move built group": false, + "wraps": false, + "move built group": "no", "move built group policy": "same-as-build", "face up cards": "all" }, "foundations": { "present": true, - "initial card": false, + "initial cards": "none", + "base card": "A", "removable": false, "only complete pile moves": false }, -- cgit v1.2.1 From 28c5a79425fa12f9466e27385404f429f76f7524 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 19 Jul 2018 11:06:38 +0100 Subject: Update rules so new schema works w/ existing games --- .../input/json-parsing/deal_parser.cpp | 3 +- .../input/json-parsing/rules_parser.cpp | 37 ++++++++++--- src/main/input-output/input/sol_preset_types.cpp | 62 +++++++++++----------- 3 files changed, 63 insertions(+), 39 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index 7b8cf18..7531cec 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -13,6 +13,7 @@ using namespace rapidjson; typedef sol_rules::build_policy pol; typedef sol_rules::stock_deal_type sdt; typedef sol_rules::face_up_policy fu; +typedef sol_rules::foundations_init_type fit; void deal_parser::parse(game_state &gs, const rapidjson::Document& doc) { // There are two stages to reading in the supplied deal. It is both put @@ -65,7 +66,7 @@ void deal_parser::parse(game_state &gs, const rapidjson::Document& doc) { if (gs.rules.foundations_present) { bool supplied_foundations = parse_foundations(gs, doc); - if (!supplied_foundations && gs.rules.foundations_init_card) { + if (!supplied_foundations && gs.rules.foundations_init_cards == fit::ALL) { fill_foundations(gs); } } 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 f7de6d8..4e0634f 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -24,6 +24,8 @@ typedef sol_rules::accordion_policy acc_pol; typedef sol_rules::stock_deal_type sdt; typedef sol_rules::face_up_policy fu; typedef sol_rules::direction dir; +typedef sol_rules::built_group_type bgt; +typedef sol_rules::foundations_init_type fit; const sol_rules rules_parser::from_file(const string rules_file) { sol_rules sr = get_default(); @@ -125,10 +127,20 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } if (d["tableau piles"].HasMember("move built group")) { - if (d["tableau piles"]["move built group"].IsBool()) { - sr.move_built_group = d["tableau piles"]["move built group"].GetBool(); + if (d["tableau piles"]["move built group"].IsString()) { + string mbg_str = d["tableau piles"]["move built group"].GetString(); + + if (mbg_str == "yes") { + sr.move_built_group = bgt::YES; + } else if (mbg_str == "no") { + sr.move_built_group = bgt::NO; + } else if (mbg_str == "whole-pile") { + sr.move_built_group = bgt::WHOLE_PILE; + } else { + json_helper::json_parse_err("[tableau piles][move built group] is invalid"); + } } else { - json_helper::json_parse_err("[tableau piles][move built group] must be a boolean"); + json_helper::json_parse_err("[tableau piles][move built group] must be a string"); } } @@ -198,11 +210,22 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } - if (d["foundations"].HasMember("initial card")) { - if (d["foundations"]["initial card"].IsBool()) { - sr.foundations_init_card = d["foundations"]["initial card"].GetBool(); + if (d["foundations"].HasMember("initial cards")) { + if (d["foundations"]["initial cards"].IsString()) { + string ic_str = d["foundations"]["initial cards"].GetString(); + + if (ic_str == "none") { + sr.foundations_init_cards = fit::NONE; + } else if (ic_str == "one") { + sr.foundations_init_cards = fit::ONE; + } else if (ic_str == "all") { + sr.foundations_init_cards = fit::ALL; + } else { + string err = "[foundations][initial cards] is invalid: " + ic_str; + json_helper::json_parse_err(err); + } } else { - json_helper::json_parse_err("[foundations][initial card] must be a boolean"); + json_helper::json_parse_err("[foundations][initial cards] must be a string"); } } diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 65100e0..85edcd3 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -202,7 +202,7 @@ map sol_preset_types::mp = { "build policy": "same-suit" }, "foundations": { - "initial card": true + "initial cards": "all" }, "stock": { "size": 36 @@ -221,7 +221,7 @@ map sol_preset_types::mp = { "build policy": "same-suit" }, "foundations": { - "initial card": true + "initial cards": "all" }, "stock": { "size": 3 @@ -276,7 +276,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 4, "build policy": "red-black", - "move built group": true + "move built group": "yes" }, "stock": { "size": 34 @@ -297,7 +297,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 3, "build policy": "red-black", - "move built group": true + "move built group": "yes" }, "stock": { "size": 1 @@ -354,10 +354,10 @@ map sol_preset_types::mp = { "tableau piles": { "count": 12, "build policy": "same-suit", - "move built group": true + "move built group": "yes" }, "foundations": { - "initial card": true + "initial cards": "all" } } )" @@ -371,10 +371,10 @@ map sol_preset_types::mp = { "tableau piles": { "count": 3, "build policy": "same-suit", - "move built group": true + "move built group": "yes" }, "foundations": { - "initial card": true + "initial cards": "all" }, "max rank": 6 } @@ -389,7 +389,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 10, "build policy": "any-suit", - "move built group": true, + "move built group": "yes", "move built group policy": "same-suit" }, "foundations": { @@ -412,7 +412,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 4, "build policy": "any-suit", - "move built group": true, + "move built group": "yes", "move built group policy": "same-suit" }, "foundations": { @@ -437,7 +437,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 4, "build policy": "red-black", - "move built group": true, + "move built group": "yes", "diagonal deal": true, "face up cards": "top" }, @@ -467,7 +467,7 @@ map sol_preset_types::mp = { }, "foundations": { "removable": true, - "initial card": true + "initial cards": "all" } } )" @@ -483,7 +483,7 @@ map sol_preset_types::mp = { "count": 7, "build policy": "red-black", "spaces policy": "kings", - "move built group": true, + "move built group": "yes", "diagonal deal": true, "face up cards": "top" }, @@ -509,7 +509,7 @@ map sol_preset_types::mp = { "count": 7, "build policy": "red-black", "spaces policy": "kings", - "move built group": true, + "move built group": "yes", "diagonal deal": true, "face up cards": "top" }, @@ -569,7 +569,7 @@ map sol_preset_types::mp = { "build policy": "same-suit" }, "foundations": { - "initial card": true + "initial cards": "all" } } )" @@ -585,7 +585,7 @@ map sol_preset_types::mp = { "build policy": "red-black" }, "foundations": { - "initial card": true, + "initial cards": "all", "removable": true } } @@ -602,7 +602,7 @@ map sol_preset_types::mp = { "build policy": "red-black" }, "foundations": { - "initial card": true, + "initial cards": "all", "removable": true }, "cells": 1 @@ -620,7 +620,7 @@ map sol_preset_types::mp = { "build policy": "red-black" }, "foundations": { - "initial card": true, + "initial cards": "all", "removable": true }, "cells": 2 @@ -798,12 +798,12 @@ map sol_preset_types::mp = { "tableau piles": { "count": 7, "build policy": "same-suit", - "move built group": true, + "move built group": "yes", "spaces policy": "kings" }, "cells": 7, "foundations": { - "initial card": true + "initial cards": "all" } } )" @@ -817,7 +817,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 10, "build policy": "same-suit", - "move built group": true, + "move built group": "yes", "spaces policy": "kings" }, "cells": 4 @@ -833,10 +833,10 @@ map sol_preset_types::mp = { "tableau piles": { "count": 4, "build policy": "red-black", - "move built group": true + "move built group": "yes" }, "foundations": { - "initial card": true + "initial cards": "all" }, "reserve": { "size": 12 @@ -856,7 +856,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 3, "build policy": "any-suit", - "move built group": true + "move built group": "yes" }, "reserve": { "size": 13, @@ -911,10 +911,10 @@ map sol_preset_types::mp = { "tableau piles": { "count": 6, "build policy": "red-black", - "move built group": true + "move built group": "yes" }, "foundations": { - "initial card": true, + "initial cards": "all", "removable": true }, "stock": { @@ -932,7 +932,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 7, "build policy": "red-black", - "move built group": true, + "move built group": "yes", "face up cards": "top" }, "foundations": { @@ -953,7 +953,7 @@ map sol_preset_types::mp = { { "tableau piles": { "build policy": "red-black", - "move built group": true, + "move built group": "yes", "spaces policy": "kings", "diagonal deal": true }, @@ -995,7 +995,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 7, "build policy": "any-suit", - "move built group": true, + "move built group": "yes", "move built group policy": "same-suit", "diagonal deal": true }, @@ -1018,7 +1018,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 7, "build policy": "any-suit", - "move built group": true, + "move built group": "yes", "move built group policy": "same-suit" }, "foundations": { @@ -1040,7 +1040,7 @@ map sol_preset_types::mp = { "tableau piles": { "count": 10, "diagonal deal": true, - "move built group": true, + "move built group": "yes", "move built group policy": "same-suit" }, "foundations": { -- cgit v1.2.1 From 0a8e51f63a36440910dd4cd1185986ff9566497d Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 19 Jul 2018 11:17:49 +0100 Subject: Add Canfield default rules --- src/main/input-output/input/sol_preset_types.cpp | 25 ++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 85edcd3..34ad822 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -276,10 +276,18 @@ map sol_preset_types::mp = { "tableau piles": { "count": 4, "build policy": "red-black", - "move built group": "yes" + "move built group": "whole-pile", + "spaces policy": "auto-reserve", + "wraps": true + }, + "foundations": { + "initial cards": "one", + "base card": "random" }, "stock": { - "size": 34 + "size": 34, + "deal count": 3, + "redeal": true }, "reserve": { "size": 14, @@ -297,10 +305,19 @@ map sol_preset_types::mp = { "tableau piles": { "count": 3, "build policy": "red-black", - "move built group": "yes" + "move built group": "yes", + "move built group": "whole-pile", + "spaces policy": "auto-reserve", + "wraps": true + }, + "foundations": { + "initial cards": "one", + "base card": "random" }, "stock": { - "size": 1 + "size": 1, + "deal count": 3, + "redeal": true }, "reserve": { "size": 2, -- cgit v1.2.1 From 12e8d1f342303394f8e6be72c08a92e3a4097bfb Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 19 Jul 2018 15:45:14 +0100 Subject: Add Canfield unit tests --- src/main/input-output/input/json-parsing/rules_parser.cpp | 2 +- src/main/input-output/input/sol_preset_types.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/input-output/input') 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 4e0634f..da43cf3 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -512,7 +512,7 @@ string rules_parser::rules_schema_json() { "any", "no-build", "kings", - "auto-reserve" + "auto-reserve-then-waste" ] }, "diagonal deal": { diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 34ad822..dc5f6b1 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -277,7 +277,7 @@ map sol_preset_types::mp = { "count": 4, "build policy": "red-black", "move built group": "whole-pile", - "spaces policy": "auto-reserve", + "spaces policy": "auto-reserve-then-waste", "wraps": true }, "foundations": { @@ -307,7 +307,7 @@ map sol_preset_types::mp = { "build policy": "red-black", "move built group": "yes", "move built group": "whole-pile", - "spaces policy": "auto-reserve", + "spaces policy": "auto-reserve-then-waste", "wraps": true }, "foundations": { -- cgit v1.2.1 From 2775a9ba0ef4e698acd0c0d32179d6a1e404297a Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 19 Jul 2018 16:16:39 +0100 Subject: Add parsing of new rules --- .../input/json-parsing/deal_parser.cpp | 6 ++++++ .../input/json-parsing/rules_parser.cpp | 25 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index 7531cec..453398e 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -283,6 +283,12 @@ bool deal_parser::parse_foundations(game_state &gs, const rapidjson::Document& d } } + // If the game uses a random base for foundations, assume that the first card in the first foundation is that base + if (!gs.rules.foundations_base) { + auto& first_found = gs.piles[gs.foundations[0]]; + gs.foundation_base = first_found[first_found.size() - 1].get_rank(); + } + return true; } 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 da43cf3..a6c84c5 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -117,6 +117,8 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { sr.spaces_pol = s_pol::NO_BUILD; } else if (sp_str == "kings") { sr.spaces_pol = s_pol::KINGS; + } else if (sp_str == "auto-reserve-then-waste") { + sr.spaces_pol = s_pol::AUTO_RESERVE_THEN_WASTE; } else { json_helper::json_parse_err("[tableau piles][spaces policy] is invalid"); } @@ -195,6 +197,14 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d["tableau piles"].HasMember("wraps")) { + if (d["tableau piles"]["wraps"].IsBool()) { + sr.tableau_wraps = d["tableau piles"]["wraps"].GetBool(); + } else { + json_helper::json_parse_err("[tableau piles][wraps] must be a boolean"); + } + } + } else { json_helper::json_parse_err("[tableau piles] must be an object"); } @@ -229,6 +239,21 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d["foundations"].HasMember("base card")) { + if (d["foundations"]["base card"].IsString()) { + string base_card_str = d["foundations"]["base card"].GetString(); + + if (base_card_str == "random") { + sr.foundations_base = boost::none; + } else { + base_card_str += "H"; + sr.foundations_base = card(base_card_str.c_str()).get_rank(); + } + } else { + json_helper::json_parse_err("[foundations][base card] must be a string"); + } + } + if (d["foundations"].HasMember("removable")) { if (d["foundations"]["removable"].IsBool()) { sr.foundations_removable = d["foundations"]["removable"].GetBool(); -- cgit v1.2.1 From 5333895e0519c4425136bb299fedb5c19c5d4c0a Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 19 Jul 2018 16:58:31 +0100 Subject: Add random gen for Canfield --- src/main/input-output/input/json-parsing/deal_parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index 453398e..e51313f 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -286,7 +286,7 @@ bool deal_parser::parse_foundations(game_state &gs, const rapidjson::Document& d // If the game uses a random base for foundations, assume that the first card in the first foundation is that base if (!gs.rules.foundations_base) { auto& first_found = gs.piles[gs.foundations[0]]; - gs.foundation_base = first_found[first_found.size() - 1].get_rank(); + gs.foundations_base = first_found[first_found.size() - 1].get_rank(); } return true; -- cgit v1.2.1 From 390a3cb4f15d84cde2312411b16203b70dbb2df5 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 23 Jul 2018 10:31:37 +0100 Subject: Add foundation wrap logic and fix top-of-waste bug --- src/main/input-output/input/json-parsing/deal_parser.cpp | 4 ---- src/main/input-output/input/json-parsing/rules_parser.cpp | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index e51313f..b80ac0e 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -209,10 +209,6 @@ void deal_parser::parse_reserve(game_state &gs, const Document& doc) { // We treat a regular reserve like multiple single-card piles, // but a stacked reserve as a single multiple-card pile - if (json_reserve_piles.Size() != gs.rules.reserve_size) { - json_helper::json_parse_err("Incorrect reserve size"); - } - for (pile::ref i = 0; i < json_card_arr.Size(); i++) { assert(json_card_arr[i].IsString()); pile::ref pr = gs.original_reserve[0]; 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 a6c84c5..209153f 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -5,6 +5,8 @@ #include #include +#include "../../../../../lib/rapidjson/error/en.h" + #include "rules_parser.h" #include "json_helper.h" #include "../sol_preset_types.h" @@ -494,7 +496,6 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { "must be true"); } - rules_schema_json(); // Throws an error if it fails Document vd; vd.Parse(rules_schema_json().c_str()); assert(!vd.HasParseError()); @@ -510,9 +511,6 @@ string rules_parser::rules_schema_json() { { "$schema": "http://json-schema.org/draft-04/schema#", "description": "JSON Schema representing a generic solitaire game", - "definitions": { - "rank": {"type": "string", "pattern": "^(([0-9]|1[0-3]|a|A|j|J|q|Q|k|K))$"}, - }, "type": "object", "properties": { "tableau piles": { @@ -591,8 +589,8 @@ string rules_parser::rules_schema_json() { "base card": { "type": "string", "oneOf":[ - {"$ref": "#/definitions/rank"}, - {"type": "string","enum": ["random"]} + {"pattern": "^(([0-9]|1[0-3]|a|A|j|J|q|Q|k|K))$"}, + {"enum": ["random"]} ] }, "removable": { -- cgit v1.2.1 From 357fab143bcb41d55fb9060bcfbf257a8586e03c Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 23 Jul 2018 12:54:47 +0100 Subject: Small bug fixes inc found. base card & whole piles --- .../input-output/input/json-parsing/deal_parser.cpp | 17 ++++------------- src/main/input-output/input/sol_preset_types.cpp | 1 - 2 files changed, 4 insertions(+), 14 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index b80ac0e..e5ecae2 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -106,9 +106,7 @@ string deal_parser::deal_schema_json() { "tableau piles": { "type": "array", "items": {"$ref": "#/definitions/cardarray"} }, - "foundations": { - "type": "array", "items": {"$ref": "#/definitions/cardarray"} - }, + "foundations": {"$ref": "#/definitions/cardarray"}, "sequences": { "type": "array", "items": {"$ref": "#/definitions/cardarraywithempty"} }, @@ -266,17 +264,10 @@ bool deal_parser::parse_foundations(game_state &gs, const rapidjson::Document& d const Value& json_foundations = doc["foundations"]; assert(json_foundations.IsArray()); - if (json_foundations.Size() != 4 * (gs.rules.two_decks ? 2 : 1) ) { - json_helper::json_parse_err("Incorrect number of foundations"); - } - for (auto j = begin(json_foundations.GetArray()); j != end(json_foundations.GetArray()); j++) { - - for (auto& json_card : j->GetArray()) { - assert(json_card.IsString()); - card c = card(json_card.GetString()); - gs.place_card(gs.foundations[c.get_suit()], c); - } + assert(j->IsString()); + card c = card(j->GetString()); + gs.place_card(gs.foundations[c.get_suit()], c); } // If the game uses a random base for foundations, assume that the first card in the first foundation is that base diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index dc5f6b1..d3daf40 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -305,7 +305,6 @@ map sol_preset_types::mp = { "tableau piles": { "count": 3, "build policy": "red-black", - "move built group": "yes", "move built group": "whole-pile", "spaces policy": "auto-reserve-then-waste", "wraps": true -- cgit v1.2.1 From 2acab3e51cabd8ba80738b1faf791980d2abf724 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Tue, 24 Jul 2018 12:00:04 +0100 Subject: Fix canfield to pass all unit tests --- src/main/input-output/input/sol_preset_types.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index d3daf40..0aee219 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -290,7 +290,7 @@ map sol_preset_types::mp = { "redeal": true }, "reserve": { - "size": 14, + "size": 13, "stacked": true } } @@ -314,7 +314,7 @@ map sol_preset_types::mp = { "base card": "random" }, "stock": { - "size": 1, + "size": 6, "deal count": 3, "redeal": true }, -- cgit v1.2.1