From babc3f5085da20bfe30b6052e5e43fa68ee22a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 5 Aug 2023 11:58:18 +0200 Subject: [PATCH] check for emptiness of draw pile when reverting turn --- game_state.hpp | 4 ++-- main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/game_state.hpp b/game_state.hpp index 197ea40..f4f66d2 100644 --- a/game_state.hpp +++ b/game_state.hpp @@ -144,8 +144,8 @@ namespace Hanabi { _card_positions[_hands[_turn][index]] = draw_pile; - // draw a new card if the draw pile is not empty - if (_draw_pile.back().card == _hands[_turn][index]) { + // put card back into draw pile (at the back) + if (!_draw_pile.empty() and _draw_pile.back().card == _hands[_turn][index]) { _draw_pile.back().multiplicity++; } else { _draw_pile.push_back({_hands[_turn][index], 1}); diff --git a/main.cpp b/main.cpp index 1d6aece..9654795 100644 --- a/main.cpp +++ b/main.cpp @@ -54,7 +54,7 @@ void print_sizes() { } int main() { -// Hanabi::test_game(); + Hanabi::test_game(); Hanabi::download(); return 0;