aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthecharlesblake2018-01-04 11:47:01 +0000
committerthecharlesblake2018-01-04 11:47:01 +0000
commit03178af360824a22d9b6487705f40ee1ca32acce (patch)
treecaa090959f3e133718f964cc8128a2625d079827
parentAdd deal parsing for (FF) foundations init card (diff)
downloadmetasol-03178af360824a22d9b6487705f40ee1ca32acce.tar.gz
metasol-03178af360824a22d9b6487705f40ee1ca32acce.zip

Update random deal gen with foundations init cards

-rw-r--r--src/main/game/game_state.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp
index 11e74ff..666b970 100644
--- a/src/main/game/game_state.cpp
+++ b/src/main/game/game_state.cpp
@@ -90,6 +90,16 @@ game_state::game_state(const sol_rules& s_rules, int seed) :
piles[hole].place(card("AS"));
}
+ // If the foundations begin filled, then fills them
+ if (rules.foundations_init_card) {
+ for (uint8_t f_idx = 0; f_idx < 4; f_idx++) {
+ card c = card(card::to_suit(f_idx), 1);
+
+ deck.erase(find(begin(deck), end(deck), c));
+ piles[foundations[f_idx]].place(c);
+ }
+ }
+
// 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++) {
@@ -167,13 +177,16 @@ void game_state::undo_move(const move m) {
////////////////////////
bool game_state::is_solved() const {
- for (auto f : foundations) {
- if (piles[f].size() != rules.max_rank) {
- return false;
+ if (rules.hole) {
+ return piles[hole].size() == rules.max_rank * 4;
+ } else {
+ for (auto f : foundations) {
+ if (piles[f].size() != rules.max_rank) {
+ return false;
+ }
}
+ return true;
}
-
- return !rules.hole || piles[hole].size() == rules.max_rank * 4;
}
const vector<pile>& game_state::get_data() const {