From ef6ab568e89475e110bafdaa9558e0df8ecf3b99 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Thu, 20 Jan 2022 15:40:21 -0800 Subject: [PATCH] Working --- src/conversation/queue.c | 41 +++++++++++++++++++++++++--------------- src/poker/poker.c | 6 ++++++ src/poker/winner.h | 6 ++++++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/conversation/queue.c b/src/conversation/queue.c index 739f1f6..4f018fa 100644 --- a/src/conversation/queue.c +++ b/src/conversation/queue.c @@ -172,25 +172,36 @@ void conversationQueueFlopTurnRiver() { void conversationQueueWinnerDecide() { pokerpot_t *pot; - pokerplayerwinning_t winners[POKER_PLAYER_COUNT_MAX]; - uint8_t winnerPlayers[POKER_PLAYER_COUNT_MAX]; - uint8_t participants[POKER_PLAYER_COUNT_MAX]; - uint8_t winnerCount, participantCount; + uint8_t i, countOfPotsWithChips; QUEUE_ITEM = QUEUE_DEBUG; - pot = POKER_POTS + 0; - pokerWinnerDetermineForPot( - pot, - winners, - winnerPlayers, - &winnerCount, - participants, - &participantCount - ); + countOfPotsWithChips = 0; + for(i = 0; i < POKER_POT_COUNT; i++) { + pot = POKER_POTS + i; + if(pot->chips == 0) break; + countOfPotsWithChips++; + } - // BGB_printf("Winner count %u", winnerCount); - // BGB_printf("Winner %u", winners[0]); + // Message + if(countOfPotsWithChips == 1) { + } else { + } + + // Pots. + for(i = 0; i < countOfPotsWithChips; i++) { + pot = POKER_POTS + i; + pokerWinnerDetermineForPot( + pot, + POKER_WINNERS, + POKER_WINNER_PLAYERS, + &POKER_WINNER_COUNT, + POKER_WINNER_PARTICIPANTS, + &POKER_WINNER_PARTICIPANT_COUNT + ); + + // TODO: hand out the winnings. + } // TODO: Decide on a winner for real. conversationTextboxString(DEBUG_WINNER_DECIDED); diff --git a/src/poker/poker.c b/src/poker/poker.c index 09d2f35..d0ee3b9 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -25,6 +25,12 @@ pokerpot_t POKER_POTS[POKER_POT_COUNT_MAX]; uint8_t POKER_POT_CURRENT; uint8_t POKER_POT_COUNT; +pokerplayerwinning_t POKER_WINNERS[POKER_PLAYER_COUNT_MAX]; +uint8_t POKER_WINNER_PLAYERS[POKER_PLAYER_COUNT_MAX]; +uint8_t POKER_WINNER_PARTICIPANTS[POKER_PLAYER_COUNT_MAX]; +uint8_t POKER_WINNER_COUNT; +uint8_t POKER_WINNER_PARTICIPANT_COUNT; + void pokerInit() { uint8_t i; diff --git a/src/poker/winner.h b/src/poker/winner.h index 9db5c63..bcd7950 100644 --- a/src/poker/winner.h +++ b/src/poker/winner.h @@ -40,6 +40,12 @@ #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 */