From bb9732850beb1baadf232ae33305ca32090b0c80 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 11 Jul 2018 12:30:46 +0100 Subject: Add sequence state printing and fix small bugs --- src/main/game/card.cpp | 1 + src/main/game/search-state/game_state.cpp | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/main/game') diff --git a/src/main/game/card.cpp b/src/main/game/card.cpp index 60aaa74..1d18029 100644 --- a/src/main/game/card.cpp +++ b/src/main/game/card.cpp @@ -83,6 +83,7 @@ card::rank_t card::get_rank() const { std::string card::to_string() const { if (face_down) return "##"; + if (card_rank == 0) return "__"; string s; switch(card_rank) { diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp index fdfb1ce..0139262 100644 --- a/src/main/game/search-state/game_state.cpp +++ b/src/main/game/search-state/game_state.cpp @@ -158,6 +158,21 @@ game_state::game_state(const sol_rules& s_rules, int seed, streamliner_options s } } + // Deals to the sequence piles + if (rules.sequence_count > 0) { + for (int t = 0; !deck.empty(); t++) { + card c = deck.back(); + if (c.get_rank() == 1) c = card(); // Inserts gaps where aces would be + + // Adds the randomly generated card to the tableau piles + auto s = t % sequences.size(); + + pile::ref seq_pile = sequences[s]; + place_card(seq_pile, c); + deck.pop_back(); + } + } + // This only occurs during testing if (rules.tableau_pile_count == 0) return; @@ -195,21 +210,6 @@ game_state::game_state(const sol_rules& s_rules, int seed, streamliner_options s if (!p.empty()) p[0].turn_face_up(); - // Deals to the sequence piles - if (rules.sequence_count > 0) { - for (int t = 0; !deck.empty(); t++) { - card c = deck.back(); - if (c.get_rank() == 1) c = card(); // Inserts gaps where aces would be - - // Adds the randomly generated card to the tableau piles - auto s = t % sequences.size(); - - pile::ref seq_pile = sequences[s]; - place_card(seq_pile, c); - deck.pop_back(); - } - } - // The size of all piles must equal the deck size int piles_sz = 0; for (auto& p : piles) piles_sz += p.size(); -- cgit v1.2.1