aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
authorthecharlesblake2018-01-08 19:02:36 +0000
committerthecharlesblake2018-01-08 19:02:36 +0000
commit067152f57ced18c5f706144909345125754e8664 (patch)
treecd893ea4ec1754c64f5a2b0c20d41d7d4d104988 /src/main/input-output
parentAdd game setup for built pile (AS) (diff)
downloadmetasol-067152f57ced18c5f706144909345125754e8664.tar.gz
metasol-067152f57ced18c5f706144909345125754e8664.zip

Add game logic for built pile (AA) and refactor

Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/output/state_printer.cpp7
1 files changed, 4 insertions, 3 deletions
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<game_state::pile_ref>& pile_rs,
const game_state& gs) {
bool empty_row = false;
- vector<card>::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 << "[]";
}