aboutsummaryrefslogtreecommitdiff
path: root/src/main/game
diff options
context:
space:
mode:
authorCharlie Blake2018-07-19 11:06:38 +0100
committerCharlie Blake2018-07-19 11:06:38 +0100
commit28c5a79425fa12f9466e27385404f429f76f7524 (patch)
tree40301029469de5e8e114cc8527c4ca98069c2df2 /src/main/game
parentCanfield rules schema and update default rules (diff)
downloadmetasol-28c5a79425fa12f9466e27385404f429f76f7524.tar.gz
metasol-28c5a79425fa12f9466e27385404f429f76f7524.zip

Update rules so new schema works w/ existing games

Diffstat (limited to 'src/main/game')
-rw-r--r--src/main/game/search-state/game_state.cpp3
-rw-r--r--src/main/game/search-state/game_state.legal_moves.cpp3
-rw-r--r--src/main/game/sol_rules.cpp6
-rw-r--r--src/main/game/sol_rules.h14
4 files changed, 20 insertions, 6 deletions
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp
index 0388d9c..10c8e20 100644
--- a/src/main/game/search-state/game_state.cpp
+++ b/src/main/game/search-state/game_state.cpp
@@ -38,6 +38,7 @@ typedef sol_rules::build_policy pol;
typedef sol_rules::stock_deal_type sdt;
typedef sol_rules::face_up_policy fu;
typedef game_state::streamliner_options sos;
+typedef sol_rules::foundations_init_type fit;
//////////////////
// CONSTRUCTORS //
@@ -139,7 +140,7 @@ game_state::game_state(const sol_rules& s_rules, int seed, streamliner_options s
}
// If the foundations begin filled, then fills them
- if (rules.foundations_init_card) {
+ if (rules.foundations_init_cards == fit::ALL) {
for (uint8_t f_idx = 0; f_idx < 4*(rules.two_decks ? 2:1); f_idx++) {
card c = card(f_idx % uint8_t(4), 1);
diff --git a/src/main/game/search-state/game_state.legal_moves.cpp b/src/main/game/search-state/game_state.legal_moves.cpp
index e1cbc8e..99a37d6 100644
--- a/src/main/game/search-state/game_state.legal_moves.cpp
+++ b/src/main/game/search-state/game_state.legal_moves.cpp
@@ -22,6 +22,7 @@ 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;
////////////////////////////////
// MAIN LEGAL MOVE GEN CYCLE ///
@@ -97,7 +98,7 @@ vector<move> game_state::get_legal_moves(move parent_move) {
if (rules.stock_size > 0 && rules.stock_deal_t == sdt::WASTE && !piles[stock].empty())
add_stock_to_tableau_moves(moves);
- if (rules.move_built_group)
+ if (rules.move_built_group != bgt::NO)
add_built_group_moves(moves);
// Tableau to tableau moves
diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp
index 0ea998e..d19d0b8 100644
--- a/src/main/game/sol_rules.cpp
+++ b/src/main/game/sol_rules.cpp
@@ -9,6 +9,8 @@ typedef sol_rules::spaces_policy s_pol;
typedef sol_rules::stock_deal_type sdt;
typedef sol_rules::direction dir;
typedef sol_rules::face_up_policy fu;
+typedef sol_rules::built_group_type bgt;
+typedef sol_rules::foundations_init_type fit;
// Note that the 'default' sol rules are set up by parsing the default json
// rules description. This initialisation is really just for testing purposes.
@@ -16,13 +18,13 @@ sol_rules::sol_rules() :
tableau_pile_count(0),
build_pol(pol::ANY_SUIT),
spaces_pol(s_pol::ANY),
- move_built_group(false),
+ move_built_group(bgt::NO),
built_group_pol(pol::ANY_SUIT),
two_decks(false),
max_rank(13),
hole(false),
foundations_present(false),
- foundations_init_card(false),
+ foundations_init_cards(fit::NONE),
foundations_only_comp_piles(false),
diagonal_deal(false),
cells(0),
diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h
index 0673771..25dcbe4 100644
--- a/src/main/game/sol_rules.h
+++ b/src/main/game/sol_rules.h
@@ -44,17 +44,27 @@ struct sol_rules {
RIGHT,
BOTH
};
+ enum class built_group_type {
+ YES,
+ NO,
+ WHOLE_PILE
+ };
+ enum class foundations_init_type {
+ NONE,
+ ONE,
+ ALL
+ };
uint8_t tableau_pile_count;
build_policy build_pol;
spaces_policy spaces_pol;
- bool move_built_group;
+ built_group_type move_built_group;
build_policy built_group_pol;
bool two_decks;
uint8_t max_rank;
bool hole;
bool foundations_present;
- bool foundations_init_card;
+ foundations_init_type foundations_init_cards;
bool foundations_removable;
bool foundations_only_comp_piles;
bool diagonal_deal;