From 3cdbf30876ea8cf38239337591bb2b616404e07d Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 23 Jun 2021 19:18:36 -0700 Subject: [PATCH] Added flusg --- src/poker/round/winner.c | 45 +++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/poker/round/winner.c b/src/poker/round/winner.c index 2fe7c061..86eaf05e 100644 --- a/src/poker/round/winner.c +++ b/src/poker/round/winner.c @@ -44,14 +44,12 @@ winning_t pokerWinnerGetStatus(poker_t *poker, pokerplayer_t *player) { // TESTING HAND winning.full[0] = CARD_CLUBS_ACE; - winning.full[1] = CARD_SPADES_ACE; - - winning.full[2] = CARD_HEARTS_TWO; - winning.full[3] = CARD_DIAMONDS_TWO; + winning.full[1] = CARD_CLUBS_TWO; + winning.full[2] = CARD_CLUBS_FIVE; + winning.full[3] = CARD_DIAMONDS_THREE; winning.full[4] = CARD_SPADES_TWO; - - winning.full[5] = CARD_HEARTS_QUEEN; - winning.full[6] = CARD_HEARTS_JACK; + winning.full[5] = CARD_CLUBS_QUEEN; + winning.full[6] = CARD_CLUBS_JACK; //////////////////////// Now look for the winning set //////////////////////// @@ -126,7 +124,38 @@ winning_t pokerWinnerGetStatus(poker_t *poker, pokerplayer_t *player) { return winning; } - // High card (worst) + // Flush (5 same suit) + for(i = 0; i < winning.size; i++) { + card = winning.full[i]; + suit = cardGetSuit(card); + winning.set[0] = i; + winning.count = 1; + for(j = i+1; j < winning.size; j++) { + if(cardGetSuit(winning.full[j]) != suit) continue; + winning.set[winning.count] = j; + winning.count++; + if(winning.count == POKER_WINNING_SET_SIZE) break; + } + if(winning.count < POKER_WINNING_SET_SIZE) continue; + winning.type = POKER_WINNING_TYPE_FOUR_OF_A_KIND; + printf("Four of a kind\n"); + return winning; + } + + // Straight (sequence any suit) + winning.count = 0; + + // Three of a kind + winning.count = 0; + + // Two Pair + winning.count = 0; + + // Pair + winning.count = 0; + + // High card + return winning; }