Here's the detect possible flush:
size_t get_suit_count(const short unsigned int suit, const vector<card>& remaining_unflipped_cards)
{
size_t count = 0;
for (size_t i = 0; i < remaining_unflipped_cards.size(); i++)
if (suit == remaining_unflipped_cards[i].suit)
count++;
return count;
}
bool is_possible_flush(const vector<card>& sorted_hand, const vector<card>& remaining_unflipped_cards)
{
const size_t num_wildcards = MAX_NUM_CARDS_PER_HAND - sorted_hand.size();
map<short unsigned int, size_t> value_counts;
map<short unsigned int, size_t> suit_counts;
for (size_t i = 0; i < sorted_hand.size(); i++)
{
value_counts[sorted_hand[i].value]++;
suit_counts[sorted_hand[i].suit]++;
}
// Is there only one suit?
if (suit_counts.size() != 1)
return false;
size_t the_suit_count = get_suit_count(suit_counts.begin()->first, remaining_unflipped_cards);
if (the_suit_count < num_wildcards)
return false;
return true;
}