From 21a816bd52298ba2b152449472d3be7c7709d296 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Tue, 14 Nov 2017 22:56:52 +0000 Subject: Fix deal bug when no cards in starting tableau --- src/main/game/game_state.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/main/game/game_state.cpp') diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp index 3e8d129..1814a41 100644 --- a/src/main/game/game_state.cpp +++ b/src/main/game/game_state.cpp @@ -82,20 +82,19 @@ game_state::game_state(int seed, const sol_rules& s_rules) : } } + // Creates the tableau piles + for (unsigned int i = 0; i < rules.tableau_pile_count; i++) { + tableau_piles.push_back(pile::tableau_factory(rules.build_ord)); + } + // Deal to the tableau piles (row-by-row) unsigned int t = 0; while (!deck.empty()) { card c = deck.back(); deck.pop_back(); - // For the first row we must create all the tableau pile vectors - if (t / rules.tableau_pile_count == 0) { - tableau_piles.push_back(pile::tableau_factory(rules.build_ord)); - } - // Add the randomly generated card to the tableau piles - tableau_piles[t % rules.tableau_pile_count].place(c); - t++; + tableau_piles[t++ % rules.tableau_pile_count].place(c); } // If there are foundation piles, create the relevant pile vectors -- cgit v1.2.1