Added Royal Flush checker.
This commit is contained in:
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user