From 8431c820445d4dcf85090b90e94ae8b007fb0eba Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sat, 15 Jan 2022 20:00:41 -0800 Subject: [PATCH] progress --- src/conversation/queue.c | 18 +++++++++++------- src/conversation/textbox.h | 4 ++-- src/poker/player.h | 6 +++--- src/poker/poker.c | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/conversation/queue.c b/src/conversation/queue.c index 0c035d7..2137cff 100644 --- a/src/conversation/queue.c +++ b/src/conversation/queue.c @@ -48,7 +48,6 @@ void conversationQueueBeginBetting() { // This is an AI player, get their turn. BGB_MESSAGE("AI turn to bet"); pokerAi(POKER_PLAYER_BETTER, &turn); - BGB_printf("AI Decided to %u, with %u chips and %u confidence, bluffin: %u", turn.type, turn.chips, turn.confidence, turn.bluff); switch(turn.type) { @@ -121,7 +120,10 @@ void conversationQueueNextBetter() { // If we reach this point then we either need to begin the betting round, or // we are going to move to the winning decider. - if(POKER_COMMUNITY_SIZE_MAX == POKER_COMMUNITY_SIZE) { + if( + POKER_COMMUNITY_SIZE_MAX == POKER_COMMUNITY_SIZE || + pokerGetRemainingBetterCount() <= 1 + ) { QUEUE_ITEM = QUEUE_WINNER_DECIDE; conversationQueueNext(); return; @@ -133,6 +135,7 @@ void conversationQueueNextBetter() { void conversationQueueFlopTurnRiver() { uint8_t i, count; + pokerplayer_t *player; QUEUE_ITEM = QUEUE_BEGIN_BETTING; @@ -154,15 +157,16 @@ void conversationQueueFlopTurnRiver() { } // Reset each players required to bet state - for(i = 0; i < POKER_PLAYER_COUNT_MAX; i++) { - POKER_PLAYERS[i].state &= ~POKER_PLAYER_STATE_HAS_BET_THIS_ROUND; - POKER_PLAYERS[i].timesRaised = 0; - } + do { + player = POKER_PLAYERS + i; + player->state &= ~POKER_PLAYER_STATE_HAS_BET_THIS_ROUND; + player->timesRaised = 0; + } while(++i < POKER_PLAYER_COUNT_MAX); // In reality we'd burn the top card but that would waste some CPU I need. // Deal the top cards. for(i = 0; i < count; i++) { - POKER_COMMUNITY[POKER_COMMUNITY_SIZE++] = POKER_DECK[POKER_DECK_SIZE--]; + POKER_COMMUNITY[POKER_COMMUNITY_SIZE++] = POKER_DECK[--POKER_DECK_SIZE]; } } diff --git a/src/conversation/textbox.h b/src/conversation/textbox.h index 4f75379..2387e93 100644 --- a/src/conversation/textbox.h +++ b/src/conversation/textbox.h @@ -23,8 +23,8 @@ #define BORDER_TILE_BOTTOM_CENTER BORDER_TILE_BOTTOM_LEFT + 1 #define BORDER_TILE_BOTTOM_RIGHT BORDER_TILE_BOTTOM_CENTER + 1 -#define TEXTBOX_STATE_VISIBLE 1 << 0 -#define TEXTBOX_STATE_SCROLLED 1 << 1 +#define TEXTBOX_STATE_VISIBLE (1 << 0) +#define TEXTBOX_STATE_SCROLLED (1 << 1) #define TEXTBOX_WIDTH_IN_TILES 20 #define TEXTBOX_HEIGHT_IN_TILES 5 diff --git a/src/poker/player.h b/src/poker/player.h index 32c61a6..a4bda80 100644 --- a/src/poker/player.h +++ b/src/poker/player.h @@ -12,9 +12,9 @@ #define POKER_PLAYER_COUNT_MAX 5 #define POKER_PLAYER_HAND_SIZE_MAX 2 -#define POKER_PLAYER_STATE_FOLDED 1 << 0 -#define POKER_PLAYER_STATE_OUT 1 << 1 -#define POKER_PLAYER_STATE_HAS_BET_THIS_ROUND 1 << 2 +#define POKER_PLAYER_STATE_FOLDED (1 << 0) +#define POKER_PLAYER_STATE_OUT (1 << 1) +#define POKER_PLAYER_STATE_HAS_BET_THIS_ROUND (1 << 2) // #define POKER_PLAYER_STATE_SHOWING 1 << 3 typedef struct { diff --git a/src/poker/poker.c b/src/poker/poker.c index 075c927..c5147ad 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -294,11 +294,11 @@ void pokerAi(uint8_t player, pokerturn_t *turn) { turn->confidence = confidence; if(amount == plyr->chips) { - turn->type == POKER_TURN_TYPE_ALL_IN; + turn->type = POKER_TURN_TYPE_ALL_IN; } else if(amount == callBet) { turn->type = POKER_TURN_TYPE_CALL; } else { - turn->type == POKER_TURN_TYPE_BET; + turn->type = POKER_TURN_TYPE_BET; } } else if(pokerCanPlayerCheck(player)) {