bugfix: correctly revert manual cases even when rotate_next_draw was used

This commit is contained in:
Maximilian Keßler 2023-11-11 13:28:43 +01:00
parent b9b73406f2
commit ab31588dbb
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -386,10 +386,18 @@ namespace Hanabi {
} }
} else } else
{ {
if (!_draw_pile.empty() and _draw_pile.front().card.suit == drawn.suit and // We don't know where the card came from (between the card having been removed from the draw pile
_draw_pile.front().card.rank == drawn.rank) { // and re-adding it now, the user may have arbitrarily permuted the draw pile implicitly)
_draw_pile.front().multiplicity++; // so we have to check if it is already contained in the draw pile somewhere
} else { auto it = std::find_if(_draw_pile.begin(), _draw_pile.end(), [&drawn](CardMultiplicity const & mult){
return mult.card == drawn;
});
if (it != _draw_pile.end())
{
it->multiplicity++;
}
else
{
_draw_pile.push_front({drawn, 1}); _draw_pile.push_front({drawn, 1});
} }
} }