check for emptiness of draw pile when reverting turn

This commit is contained in:
Maximilian Keßler 2023-08-05 11:58:18 +02:00
parent 2a311bb736
commit babc3f5085
Signed by: max
GPG Key ID: BCC5A619923C0BA5
2 changed files with 3 additions and 3 deletions

View File

@ -144,8 +144,8 @@ namespace Hanabi {
_card_positions[_hands[_turn][index]] = draw_pile; _card_positions[_hands[_turn][index]] = draw_pile;
// draw a new card if the draw pile is not empty // put card back into draw pile (at the back)
if (_draw_pile.back().card == _hands[_turn][index]) { if (!_draw_pile.empty() and _draw_pile.back().card == _hands[_turn][index]) {
_draw_pile.back().multiplicity++; _draw_pile.back().multiplicity++;
} else { } else {
_draw_pile.push_back({_hands[_turn][index], 1}); _draw_pile.push_back({_hands[_turn][index], 1});

View File

@ -54,7 +54,7 @@ void print_sizes() {
} }
int main() { int main() {
// Hanabi::test_game(); Hanabi::test_game();
Hanabi::download(); Hanabi::download();
return 0; return 0;