check for emptiness of draw pile when reverting turn
This commit is contained in:
parent
2a311bb736
commit
babc3f5085
2 changed files with 3 additions and 3 deletions
|
@ -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});
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue