Added Royal Flush checker.

This commit is contained in:
2021-06-21 09:52:57 -07:00
parent 24329045a7
commit 20e30f187b
7 changed files with 131 additions and 17 deletions

View File

@@ -24,8 +24,7 @@ void cardDeal(card_t *source, uint8_t *sourceSize, card_t *dest,
}
void cardHandSort(card_t *cards, uint8_t length) {
// arraySortUint8(cards, length);
arraySort(sizeof(card_t), cards, (int32_t)length, &_cardSorter);
arraySort(sizeof(card_t), cards, (int32_t)length, (arraysort_t *)&_cardSorter);
}
int32_t _cardSorter(const void* left, const void* right) {
@@ -48,4 +47,20 @@ int32_t _cardSorter(const void* left, const void* right) {
// Get the suit and the value of the card (reversed)
return numberR - numberL;
}
int32_t cardContains(card_t *hand, uint8_t length, card_t card) {
int32_t i;
for(i = 0; i < length; i++) {
if(hand[i] == card) return i;
}
return -1;
}
int32_t cardContainsNumber(card_t *hand, uint8_t length, uint8_t number) {
int32_t i;
for(i = 0; i < length; i++) {
if(cardGetNumber(hand[i]) == number) return i;
}
return -1;
}