diff --git a/src/conversation/queue.c b/src/conversation/queue.c index 4f018fa..9485b62 100644 --- a/src/conversation/queue.c +++ b/src/conversation/queue.c @@ -172,7 +172,7 @@ void conversationQueueFlopTurnRiver() { void conversationQueueWinnerDecide() { pokerpot_t *pot; - uint8_t i, countOfPotsWithChips; + uint8_t i, j, countOfPotsWithChips, chipsEach; QUEUE_ITEM = QUEUE_DEBUG; @@ -183,7 +183,7 @@ void conversationQueueWinnerDecide() { countOfPotsWithChips++; } - // Message + // TODO: Messages if(countOfPotsWithChips == 1) { } else { } @@ -200,7 +200,13 @@ void conversationQueueWinnerDecide() { &POKER_WINNER_PARTICIPANT_COUNT ); - // TODO: hand out the winnings. + chipsEach = pot->chips / POKER_WINNER_COUNT; + for(j = 0; j < POKER_WINNER_COUNT; j++) { + POKER_PLAYERS[POKER_WINNER_PLAYERS[j]].chips += chipsEach; + // TODO: I can determine rounding error here if I need to, just sub the + // taken chips for each player and when I get to chips remaining less than + // the chipsEach, then reward the rounding offset. + } } // TODO: Decide on a winner for real. diff --git a/src/poker/poker.c b/src/poker/poker.c index d0ee3b9..43995c1 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -72,12 +72,12 @@ void pokerNewRound() { POKER_DECK_SIZE = CARD_DECK_SIZE; // Shuffle Deck - // for(i = CARD_DECK_SIZE-1; i > 0; i--) { - // k = POKER_DECK[i]; - // j = rand() % (i+1); - // POKER_DECK[i] = POKER_DECK[j]; - // POKER_DECK[j] = k; - // } + for(i = CARD_DECK_SIZE-1; i > 0; i--) { + k = POKER_DECK[i]; + j = rand() % (i+1); + POKER_DECK[i] = POKER_DECK[j]; + POKER_DECK[j] = k; + } // Reset Players and decide new blinds. found = 0; diff --git a/src/poker/winner.h b/src/poker/winner.h index bcd7950..ff79c99 100644 --- a/src/poker/winner.h +++ b/src/poker/winner.h @@ -40,12 +40,6 @@ #define POKER_WINNING_CONFIDENCE_PAIR 200 #define POKER_WINNING_CONFIDENCE_HIGH_CARD 100 -extern pokerplayerwinning_t POKER_WINNERS[POKER_PLAYER_COUNT_MAX]; -extern uint8_t POKER_WINNER_PLAYERS[POKER_PLAYER_COUNT_MAX]; -extern uint8_t POKER_WINNER_PARTICIPANTS[POKER_PLAYER_COUNT_MAX]; -extern uint8_t POKER_WINNER_COUNT; -extern uint8_t POKER_WINNER_PARTICIPANT_COUNT; - /** Holds information about a player's winning state */ typedef struct { /** The full set of both the dealer and player's hand */ @@ -61,4 +55,10 @@ typedef struct { /** If there was a kicker card it will be here, otherwise -1 for no kicker */ uint8_t kicker; -} pokerplayerwinning_t; \ No newline at end of file +} pokerplayerwinning_t; + +extern pokerplayerwinning_t POKER_WINNERS[POKER_PLAYER_COUNT_MAX]; +extern uint8_t POKER_WINNER_PLAYERS[POKER_PLAYER_COUNT_MAX]; +extern uint8_t POKER_WINNER_PARTICIPANTS[POKER_PLAYER_COUNT_MAX]; +extern uint8_t POKER_WINNER_COUNT; +extern uint8_t POKER_WINNER_PARTICIPANT_COUNT; \ No newline at end of file