From 25d3f7591e2b7ca5303593e1da4bc880174e189a Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Tue, 2 Jan 2018 11:28:47 +0000 Subject: Add rules parsing for bakers dozen --- src/main/game/sol_rules.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/game/sol_rules.h') 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; -- cgit v1.2.1 From 77a7aeba7854d15b140cc6dc3c69b15ed5f3b936 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 3 Jan 2018 12:30:14 +0000 Subject: Major refactor, putting pile logic into game_state Much of the logic that was in the pile class was beginning to seem out of place. A lot of the rules have fairly arbitrary interactons *between* piles, which weren't best represented in the pile classes themselves, which were getting unweildy and inefficient. Hence, much of this logic has been moved to the game state class. --- src/main/game/sol_rules.h | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 96c10d5..3d4995d 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -15,42 +15,22 @@ class sol_rules { public: - enum class valid_sol { - BLACK_HOLE, - SIMPLE_BLACK_HOLE, - SPANISH_PATIENCE, - SIMPLE_SPANISH_PATIENCE, - FREE_CELL, - SIMPLE_FREE_CELL, - CANFIELD, - SIMPLE_CANFIELD - }; + // Tableau policies enum class build_order { - NO_BUILD, DESCENDING, - ASCENDING, - BOTH, - SINGLE_CARD, - ANY + ASCENDING }; enum class build_policy { - CLUBS, - DIAMONDS, - HEARTS, - SPADES, - ANY_SUIT, + NO_BUILD, SAME_SUIT, RED_BLACK, - N_A + ANY_SUIT }; 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(std::string); static const sol_rules from_file(std::string); @@ -62,15 +42,11 @@ public: bool hole; bool foundations; uint8_t cells; - uint8_t reserve_size; uint8_t stock_size; private: static sol_rules get_default(); static void modify_sol_rules(sol_rules&, rapidjson::Document&); - static void parse_err(const std::string&); - - static valid_sol valid_sol_enum(const std::string&); }; #endif //SOLVITAIRE_SOL_RULES_H -- cgit v1.2.1 From 758d919cb5d600a421636ce54df9f28b6fc832ba Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 3 Jan 2018 12:51:47 +0000 Subject: Refactor sol_rules into seperate parser class --- src/main/game/sol_rules.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 3d4995d..1e6dfa4 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -5,16 +5,13 @@ #ifndef SOLVITAIRE_SOL_RULES_H #define SOLVITAIRE_SOL_RULES_H -#include #include -#include #include #include "card.h" -class sol_rules { -public: +struct sol_rules { // Tableau policies enum class build_order { DESCENDING, @@ -31,9 +28,6 @@ public: ANY }; - 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; @@ -43,10 +37,6 @@ public: bool foundations; uint8_t cells; uint8_t stock_size; - -private: - static sol_rules get_default(); - static void modify_sol_rules(sol_rules&, rapidjson::Document&); }; #endif //SOLVITAIRE_SOL_RULES_H -- cgit v1.2.1 From 0bf65cecb1a8b9d3c8269ad579ddd833dd7f3163 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 4 Jan 2018 11:40:01 +0000 Subject: Add rules parsing for (FF) foundations init card --- src/main/game/sol_rules.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 1e6dfa4..6afb238 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -35,6 +35,7 @@ struct sol_rules { card::rank_t max_rank; bool hole; bool foundations; + bool foundations_init_card; uint8_t cells; uint8_t stock_size; }; -- cgit v1.2.1 From 6e458408c692f05f8d8033a29c38fe3fdc18723c Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 4 Jan 2018 15:45:57 +0000 Subject: Add rules parsing for flower garden --- src/main/game/sol_rules.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 6afb238..5c7713c 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -38,6 +38,7 @@ struct sol_rules { bool foundations_init_card; uint8_t cells; uint8_t stock_size; + uint8_t reserve_size; }; #endif //SOLVITAIRE_SOL_RULES_H -- cgit v1.2.1 From e1eb16767fee2241aa27896332a01ed5987fdf8b Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Fri, 5 Jan 2018 15:54:31 +0000 Subject: Add rules parsing for stacked reserve (canfield) --- src/main/game/sol_rules.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 5c7713c..11f169f 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -39,6 +39,7 @@ struct sol_rules { uint8_t cells; uint8_t stock_size; uint8_t reserve_size; + bool reserve_stacked; }; #endif //SOLVITAIRE_SOL_RULES_H -- cgit v1.2.1 From f481f8bb2f6ba7c34e36fb3a439500ebf0b42b35 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Fri, 5 Jan 2018 18:03:09 +0000 Subject: Add diagonal deal to rules parser (somerset) --- src/main/game/sol_rules.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 11f169f..e9d130b 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -36,6 +36,7 @@ struct sol_rules { bool hole; bool foundations; bool foundations_init_card; + bool diagonal_deal; uint8_t cells; uint8_t stock_size; uint8_t reserve_size; -- cgit v1.2.1 From cc5cb4243d2015f218ed5258df47ec678175a486 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Mon, 8 Jan 2018 18:59:44 +0000 Subject: Add rules parsing for built pile (AS) --- src/main/game/sol_rules.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index e9d130b..3e0393d 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -32,6 +32,7 @@ struct sol_rules { build_order build_ord; build_policy build_pol; spaces_policy spaces_pol; + bool move_built_group; card::rank_t max_rank; bool hole; bool foundations; -- cgit v1.2.1 From 9efeb027c72460e7d5b6e320819788b7f38d8035 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Tue, 9 Jan 2018 08:52:22 +0000 Subject: Add rules parsing for stock-tableau deal & 2 deck --- src/main/game/sol_rules.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main/game/sol_rules.h') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 3e0393d..87266ee 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -27,12 +27,17 @@ struct sol_rules { NO_BUILD, ANY }; + enum class stock_deal_type { + WASTE, + TABLEAU_PILES + }; uint8_t tableau_pile_count; build_order build_ord; build_policy build_pol; spaces_policy spaces_pol; bool move_built_group; + bool two_decks; card::rank_t max_rank; bool hole; bool foundations; @@ -40,6 +45,7 @@ struct sol_rules { bool diagonal_deal; uint8_t cells; uint8_t stock_size; + stock_deal_type stock_deal_t; uint8_t reserve_size; bool reserve_stacked; }; -- cgit v1.2.1