fix find_card_in_hand function: respect different representation of trash
This commit is contained in:
parent
0a8facb585
commit
6f5419b2d8
2 changed files with 9 additions and 8 deletions
|
@ -256,10 +256,11 @@ namespace Hanabi {
|
||||||
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
||||||
std::uint8_t HanabiState<num_suits, num_players, hand_size>::find_card_in_hand(
|
std::uint8_t HanabiState<num_suits, num_players, hand_size>::find_card_in_hand(
|
||||||
const Hanabi::Card &card) const {
|
const Hanabi::Card &card) const {
|
||||||
for (std::uint8_t i = 0; i < hand_size; i++) {
|
auto it = std::find_if(_hands[_turn].begin(), _hands[_turn].end(),[&card, this](Card const & card_in_hand){
|
||||||
if (_hands[_turn][i].rank == card.rank && _hands[_turn][i].suit == card.suit) {
|
return card_in_hand == card or (is_trash(card) and is_trash(card_in_hand));
|
||||||
return i;
|
});
|
||||||
}
|
if (it != _hands[_turn].end()) {
|
||||||
|
return std::distance(_hands[_turn].begin(), it);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Hanabi {
|
||||||
|
|
||||||
game.goto_draw_pile_size(draw_pile_size);
|
game.goto_draw_pile_size(draw_pile_size);
|
||||||
if (draw_pile_size != 0 and game.state->draw_pile_size() != static_cast<size_t>(draw_pile_size)) {
|
if (draw_pile_size != 0 and game.state->draw_pile_size() != static_cast<size_t>(draw_pile_size)) {
|
||||||
std::cout << "This given draw pile size (" << draw_pile_size << ") cannot be obtained with the specified replay." << std::endl;
|
std::cout << "The given draw pile size (" << draw_pile_size << ") cannot be obtained with the specified replay." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
game.state->modify_clues(clue_modifier);
|
game.state->modify_clues(clue_modifier);
|
||||||
|
@ -60,7 +60,7 @@ namespace Hanabi {
|
||||||
for(size_t remaining_cards = 1; remaining_cards <= max_draw_pile_size; remaining_cards++) {
|
for(size_t remaining_cards = 1; remaining_cards <= max_draw_pile_size; remaining_cards++) {
|
||||||
if (!game.goto_draw_pile_size(remaining_cards))
|
if (!game.goto_draw_pile_size(remaining_cards))
|
||||||
{
|
{
|
||||||
std::cout << "This given draw pile size (" << remaining_cards << ") cannot be obtained with the specified replay." << std::endl;
|
std::cout << "The given draw pile size (" << remaining_cards << ") cannot be obtained with the specified replay." << std::endl;
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if (all_clues) {
|
if (all_clues) {
|
||||||
|
|
Loading…
Reference in a new issue