aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--centre.cpp10
-rw-r--r--golf.json9
-rw-r--r--metasol.cpp21
-rw-r--r--metasol.h4
4 files changed, 41 insertions, 3 deletions
diff --git a/centre.cpp b/centre.cpp
index a19697b..f72aa50 100644
--- a/centre.cpp
+++ b/centre.cpp
@@ -69,6 +69,7 @@ sol_rules::stock_deal_type convert_stock_deal(stock_deal_t sd) {
switch (sd) {
case STOCK_TO_WASTE: return sol_rules::stock_deal_type::WASTE;
case STOCK_TO_TABLEAU: return sol_rules::stock_deal_type::TABLEAU_PILES;
+ case STOCK_TO_HOLE: return sol_rules::stock_deal_type::HOLE;
default: assert(false);
}
}
@@ -127,6 +128,7 @@ sol_rules convert_rules(ms_rules *sr) {
r.built_group_pol = convert_build_policy(sr->built_group_policy);
r.max_rank = sr->max_rank;
r.hole = sr->hole_present;
+ r.hole_build_loops = sr->hole_build_loops;
r.foundations_present = sr->foundations_present;
r.foundations_init_cards =
convert_foundations_init(sr->foundations_init_cards);
@@ -808,8 +810,15 @@ ms_rules json_rules(const char *filename) {
arp("tableau size", NUMBER_TYPE, &r.tableau_size);
arp("deck count", NUMBER_TYPE, &r.deck_count);
arp("max rank", NUMBER_TYPE, &r.max_rank);
+
arp("hole", BOOL_TYPE, &r.hole_present);
+ arp("hole present", BOOL_TYPE, &r.hole_present);
+
+ arp("hole build loops", BOOL_TYPE, &r.hole_build_loops);
+
arp("foundations", BOOL_TYPE, &r.foundations_present);
+ arp("foundations present", BOOL_TYPE, &r.foundations_present);
+
arp("foundations removable", BOOL_TYPE,
&r.foundations_removable);
@@ -848,6 +857,7 @@ ms_rules json_rules(const char *filename) {
are("move built group", str_built_group, &r.move_built_group);
are("group build policy", str_build_policy,
&r.built_group_policy);
+
are("foundations initialised", str_foundations_init,
&r.foundations_init_cards);
diff --git a/golf.json b/golf.json
new file mode 100644
index 0000000..67684dd
--- /dev/null
+++ b/golf.json
@@ -0,0 +1,9 @@
+{
+ "tableau size": 7,
+ "build policy": "no build",
+ "foundations present": false,
+ "cards in stock": 16,
+ "stock deal type": "stock to hole",
+ "hole present": true,
+ "hole build loops": true
+}
diff --git a/metasol.cpp b/metasol.cpp
index 340f620..f022f12 100644
--- a/metasol.cpp
+++ b/metasol.cpp
@@ -129,7 +129,10 @@ stock_deal_t str_stock_deal(char *str) {
{ "stock to waste", STOCK_TO_WASTE },
{ "tableau", STOCK_TO_TABLEAU },
- { "stock to tableau", STOCK_TO_TABLEAU }
+ { "stock to tableau", STOCK_TO_TABLEAU },
+
+ { "hole", STOCK_TO_HOLE },
+ { "stock to hole", STOCK_TO_HOLE }
};
lower(str);
@@ -401,6 +404,12 @@ int shuffle_hidden(ms_game_state *gs) {
}
ms_card_pile *get_pile_by_index(ms_game_state *gs, ms_rules *r, uint8_t i) {
+ if (r->hole_present) {
+ if (i-- == 0) {
+ return &gs->hole;
+ }
+ }
+
if (i < gs->foundations.size()) {
return &gs->foundations[i];
} else {
@@ -831,12 +840,13 @@ ms_rules fetch_default_rules() {
dr.build_policy = BUILD_ANY;
dr.spaces_policy = ANY_FILL_SPACE;
dr.move_built_group = CANNOT_MOVE_BUILT_GROUP;
- dr.built_group_policy = dr.build_policy;
+ dr.built_group_policy = NO_BUILD;
dr.deck_count = 1u;
dr.max_rank = 13u;
dr.hole_present = false;
+ dr.hole_build_loops = true;
dr.foundations_present = true;
dr.foundations_init_cards = NO_FOUNDATION_INIT;
@@ -1079,6 +1089,13 @@ ms_game_state random_game_state(long user_seed, ms_rules *r) {
}
}
+ if (!deck.empty() && r->hole_present) {
+ ms_card c = deck.back();
+ c.hidden = false;
+ deck.pop_back();
+ gs.hole.push_back(c);
+ }
+
assert(deck.empty());
return gs;
}
diff --git a/metasol.h b/metasol.h
index 8c9d9dc..77602e7 100644
--- a/metasol.h
+++ b/metasol.h
@@ -62,7 +62,8 @@ suite(accordion_policy);
#define stock_deal_t_gen \
C(STOCK_TO_WASTE)\
- C(STOCK_TO_TABLEAU)
+ C(STOCK_TO_TABLEAU)\
+ C(STOCK_TO_HOLE)
suite(stock_deal);
#define face_up_policy_t_gen \
@@ -102,6 +103,7 @@ typedef struct ms_rules {
unsigned deck_count;
unsigned max_rank;
bool hole_present;
+ bool hole_build_loops;
bool foundations_present;
foundations_init_t foundations_init_cards;
bool specific_foundations_base;