From 067152f57ced18c5f706144909345125754e8664 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Mon, 8 Jan 2018 19:02:36 +0000 Subject: Add game logic for built pile (AA) and refactor --- src/main/input-output/output/state_printer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/input-output/output/state_printer.cpp') diff --git a/src/main/input-output/output/state_printer.cpp b/src/main/input-output/output/state_printer.cpp index 2c23496..cf9f09e 100644 --- a/src/main/input-output/output/state_printer.cpp +++ b/src/main/input-output/output/state_printer.cpp @@ -51,7 +51,7 @@ void state_printer::print_piles(ostream& stream, const vector& pile_rs, const game_state& gs) { bool empty_row = false; - vector::size_type row_idx = 0; + pile::size_type row_idx = 0; // Loops through the rows in each pile, starting from the bottom, until // one is empty @@ -67,8 +67,9 @@ void state_printer::print_piles(ostream& stream, if (!empty_row || row_idx == 0) { // Loops through the current (non-empty) row, and outputs the values for (const game_state::pile_ref pile_r : pile_rs) { - if (gs.piles[pile_r].size() > row_idx) { - print_card(stream, gs.piles[pile_r][row_idx]); + const pile& p = gs.piles[pile_r]; + if (p.size() > row_idx) { + print_card(stream, p[p.size() - 1 - row_idx]); } else if (row_idx == 0) { stream << "[]"; } -- cgit v1.2.1