simplify play card logic: always consider bombs
This commit is contained in:
parent
3be7378903
commit
a116ec45e3
2 changed files with 10 additions and 9 deletions
|
@ -143,12 +143,6 @@ namespace Hanabi {
|
|||
|
||||
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
||||
void HanabiState<num_suits, num_players, hand_size>::play(Hanabi::hand_index_t index) {
|
||||
const Card card = _hands[_turn][index];
|
||||
if (!is_playable(card)) {
|
||||
draw<false>(index);
|
||||
incr_turn();
|
||||
return;
|
||||
}
|
||||
play_and_potentially_update<false>(index);
|
||||
}
|
||||
|
||||
|
@ -157,6 +151,11 @@ namespace Hanabi {
|
|||
unsigned long HanabiState<num_suits, num_players, hand_size>::play_and_potentially_update(hand_index_t index) {
|
||||
ASSERT(index < _hands[_turn].size());
|
||||
const Card played_card = _hands[_turn][index];
|
||||
if (!is_playable(played_card)) {
|
||||
const unsigned long multiplicity = draw<false>(index);
|
||||
incr_turn();
|
||||
return multiplicity;
|
||||
}
|
||||
ASSERT(is_playable(played_card));
|
||||
|
||||
_actions_log.emplace(ActionType::play, played_card, index, _num_clues == 8);
|
||||
|
@ -169,7 +168,7 @@ namespace Hanabi {
|
|||
_num_clues++;
|
||||
}
|
||||
|
||||
unsigned long multiplicity = draw<update_card_positions>(index);
|
||||
const unsigned long multiplicity = draw<update_card_positions>(index);
|
||||
|
||||
incr_turn();
|
||||
return multiplicity;
|
||||
|
@ -403,7 +402,9 @@ namespace Hanabi {
|
|||
_num_clues--;
|
||||
}
|
||||
revert_draw(last_action.index, last_action.discarded);
|
||||
if(_stacks[last_action.discarded.suit] == last_action.discarded.rank) {
|
||||
_stacks[last_action.discarded.suit]++;
|
||||
}
|
||||
_score--;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue