From f909451fba0e50420ffe1c7a375d6de6a636d917 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 27 Apr 2022 20:17:08 -0700 Subject: [PATCH] Fixed all in text display --- src/conversation/queue.c | 1 + src/conversation/textbox.c | 3 +- src/libs.h | 2 +- src/main.c | 69 ++++++++++++++++++++++++++------------ src/poker/poker.c | 5 +-- 5 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/conversation/queue.c b/src/conversation/queue.c index f498167..4898b89 100644 --- a/src/conversation/queue.c +++ b/src/conversation/queue.c @@ -78,6 +78,7 @@ void conversationQueueBeginBetting() { } else { conversationTextboxSetText(STR_POKER_GAME_AI_ALL_IN); } + break; case POKER_TURN_TYPE_CHECK: if(turn.bluff) { diff --git a/src/conversation/textbox.c b/src/conversation/textbox.c index 07c95a0..2c38e38 100644 --- a/src/conversation/textbox.c +++ b/src/conversation/textbox.c @@ -22,7 +22,6 @@ inline void conversationTextboxInit() { TEXTBOX_STATE = 0; // Setup window data - // move_win(7, SCREENHEIGHT - (TEXTBOX_HEIGHT_IN_TILES * 8)); set_win_data(FONT_DATA_POSITION, FONT_IMAGE_TILES, FONT_IMAGE); set_win_data(BORDER_DATA_POSITION, BORDER_IMAGE_TILES, BORDER_IMAGE); } @@ -89,7 +88,7 @@ void conversationTextboxSetText(char *text) { inline void textboxFillBlank() { uint8_t TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * TEXTBOX_HEIGHT_IN_TILES]; - + frameBuffer(TEXTBOX_TILES, TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES, TEXTBOX_TILE_BLANK); set_bkg_tiles( diff --git a/src/libs.h b/src/libs.h index 7883c60..eaca791 100644 --- a/src/libs.h +++ b/src/libs.h @@ -9,7 +9,7 @@ #include #include #include -// #include +#include #include #include #include \ No newline at end of file diff --git a/src/main.c b/src/main.c index ab01751..7a88f43 100644 --- a/src/main.c +++ b/src/main.c @@ -11,7 +11,7 @@ inline uint8_t mainGetChar(char c) { return c - TEXTBOX_FONT_START + FONT_DATA_POSITION; } -inline void mainBufferChar(uint8_t card, uint8_t *tiles) { +inline void mainBufferCard(uint8_t card, uint8_t *tiles) { uint8_t suit, number; if(card >= CARD_DECK_SIZE) { @@ -82,40 +82,57 @@ inline void mainBufferChar(uint8_t card, uint8_t *tiles) { } inline void mainDebugDraw() { - uint8_t j; + uint8_t j, i, n; // DEBUG DRAW - uint8_t tiles[10]; - for(j = 0; j < POKER_PLAYER_COUNT; j++) { - mainBufferChar(POKER_PLAYERS[j].hand[0], tiles); - mainBufferChar(POKER_PLAYERS[j].hand[1], tiles + 2); + uint8_t tiles[15]; + char buffer[6]; + buffer[0] = '\0'; - tiles[4] = COMMON_TILE_3; + for(j = 0; j < POKER_PLAYER_COUNT; j++) { + n = 0; + + if(j == POKER_PLAYER_BETTER) { + tiles[n++] = mainGetChar('>'); + } else { + tiles[n++] = COMMON_TILE_3; + } + + mainBufferCard(POKER_PLAYERS[j].hand[0], tiles+n); + n+=2; + mainBufferCard(POKER_PLAYERS[j].hand[1], tiles+n); + n+=2; + + tiles[n++] = COMMON_TILE_3; if((POKER_PLAYERS[j].state & POKER_PLAYER_STATE_FOLDED) == 0) { - tiles[5] = COMMON_TILE_3; + tiles[n++] = COMMON_TILE_3; } else { - tiles[5] = mainGetChar('F'); + tiles[n++] = mainGetChar('F'); } if((POKER_PLAYERS[j].state & POKER_PLAYER_STATE_HAS_BET_THIS_ROUND) == 0) { - tiles[6] = COMMON_TILE_3; + tiles[n++] = COMMON_TILE_3; } else { - tiles[6] = mainGetChar('H'); + tiles[n++] = mainGetChar('H'); } if((POKER_PLAYERS[j].state & POKER_PLAYER_STATE_OUT) == 0) { - tiles[7] = COMMON_TILE_3; + tiles[n++] = COMMON_TILE_3; } else { - tiles[7] = mainGetChar('O'); + tiles[n++] = mainGetChar('O'); } - if(j == POKER_PLAYER_BETTER) { - tiles[8] = mainGetChar('<'); - } else { - tiles[8] = COMMON_TILE_3; + tiles[n++] = COMMON_TILE_3; + + // Print chips + sprintf(buffer, "%u", (uint16_t)POKER_PLAYERS[j].chips); + for(i = 0; i < strlen(buffer); i++) { + tiles[n++] = mainGetChar(buffer[i]); } - set_bkg_tiles(0x00, j, 9, 1, tiles); + + while(n < 15) tiles[n++] = COMMON_TILE_3; + set_bkg_tiles(0x00, j, n - 1, 1, tiles); } for(j = 0; j < POKER_COMMUNITY_SIZE_MAX; j++) { @@ -123,11 +140,21 @@ inline void mainDebugDraw() { tiles[j*2] = COMMON_TILE_3; tiles[(j*2) + 1] = COMMON_TILE_3; } else { - mainBufferChar(POKER_COMMUNITY[j], tiles + (j * 2)); + mainBufferCard(POKER_COMMUNITY[j], tiles + (j * 2)); } } - set_bkg_tiles(0x00, POKER_PLAYER_COUNT + 1, 10, 1, tiles); + set_bkg_tiles(0x00, POKER_PLAYER_COUNT + 1, POKER_COMMUNITY_SIZE_MAX * 2, 1, tiles); + + + // Print Pot + n = 0; + sprintf(buffer, "%u", (uint16_t)POKER_POTS[POKER_POT_CURRENT].chips); + for(i = 0; i < strlen(buffer); i++) { + tiles[n++] = mainGetChar(buffer[i]); + } + while(n < 5) tiles[n++] = COMMON_TILE_3; + set_bkg_tiles(0x00, POKER_PLAYER_COUNT + 2, n, 1, tiles); } void main() { @@ -188,6 +215,6 @@ void main() { // Update conversation fade effect conversationFadeUpdate(); - // mainDebugDraw(); + mainDebugDraw(); } } \ No newline at end of file diff --git a/src/poker/poker.c b/src/poker/poker.c index 5c3e379..4ee33ea 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -316,14 +316,15 @@ void pokerAi(uint8_t player, pokerturn_t *turn) { turn->chips = amount; turn->confidence = confidence; - if(amount == plyr->chips) { + BGB_printf("Player chips %u is %u", plyr->chips, amount); + + if(plyr->chips == amount) { turn->type = POKER_TURN_TYPE_ALL_IN; } else if(amount == callBet) { turn->type = POKER_TURN_TYPE_CALL; } else { turn->type = POKER_TURN_TYPE_BET; } - } else if(pokerCanPlayerCheck(player)) { turn->type = POKER_TURN_TYPE_CHECK; turn->chips = 0;