Working on more poker logic improvements

This commit is contained in:
2022-01-24 08:42:35 -08:00
parent 7f31185223
commit 31ac40c731
3 changed files with 45 additions and 10 deletions

View File

@@ -140,7 +140,6 @@ void conversationQueueFlopTurnRiver() {
uint8_t i, count;
pokerplayer_t *player;
QUEUE_ITEM = QUEUE_BEGIN_BETTING;
switch(POKER_COMMUNITY_SIZE) {
case 0:
@@ -171,13 +170,25 @@ void conversationQueueFlopTurnRiver() {
for(i = 0; i < count; i++) {
POKER_COMMUNITY[POKER_COMMUNITY_SIZE++] = POKER_DECK[--POKER_DECK_SIZE];
}
// Check how many players need to bet, if it's zero then all players are
// either folded or all-in
if(pokerGetRemainingBetterCount() == 0x00) {
if(POKER_COMMUNITY_SIZE == POKER_COMMUNITY_SIZE_MAX) {
QUEUE_ITEM = QUEUE_WINNER_DECIDE;
} else {
QUEUE_ITEM = QUEUE_FLOP;
}
} else {
QUEUE_ITEM = QUEUE_BEGIN_BETTING;
}
}
void conversationQueueWinnerDecide() {
pokerpot_t *pot;
uint8_t i, j, countOfPotsWithChips, chipsEach;
QUEUE_ITEM = QUEUE_DEBUG;
QUEUE_ITEM = QUEUE_BEGIN;
countOfPotsWithChips = 0;
for(i = 0; i < POKER_POT_COUNT; i++) {
@@ -214,6 +225,9 @@ void conversationQueueWinnerDecide() {
// TODO: Decide on a winner for real.
conversationTextboxString(DEBUG_WINNER_DECIDED);
// New Round
pokerNewRound();
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -146,12 +146,24 @@ void main() {
tiles[5] = mainGetChar('F');
}
if(j == POKER_PLAYER_BETTER) {
tiles[6] = mainGetChar('<');
} else {
if((POKER_PLAYERS[j].state & POKER_PLAYER_STATE_HAS_BET_THIS_ROUND) == 0) {
tiles[6] = COMMON_TILE_3;
} else {
tiles[6] = mainGetChar('H');
}
set_bkg_tiles(0x00, j, 7, 1, tiles);
if((POKER_PLAYERS[j].state & POKER_PLAYER_STATE_OUT) == 0) {
tiles[7] = COMMON_TILE_3;
} else {
tiles[7] = mainGetChar('O');
}
if(j == POKER_PLAYER_BETTER) {
tiles[8] = mainGetChar('<');
} else {
tiles[8] = COMMON_TILE_3;
}
set_bkg_tiles(0x00, j, 9, 1, tiles);
}
for(j = 0; j < POKER_COMMUNITY_SIZE_MAX; j++) {

View File

@@ -52,6 +52,7 @@ void pokerInit() {
void pokerNewRound() {
uint8_t i, j, k;
uint8_t found;
pokerplayer_t *player;
// Reset round state
POKER_COMMUNITY_SIZE = 0;
@@ -84,15 +85,23 @@ void pokerNewRound() {
found = 0;
POKER_PLAYER_DEALER++;
// Update players for the round.
for(i = 0; i < POKER_PLAYER_COUNT_MAX; i++) {
POKER_PLAYERS[i].state &= ~(
player = POKER_PLAYERS + i;
player->timesRaised = 0;
player->state &= ~(
POKER_PLAYER_STATE_FOLDED |
POKER_PLAYER_STATE_HAS_BET_THIS_ROUND
);
POKER_PLAYERS[i].timesRaised = 0;
// Update out state.
if(player->chips == 0) player->state |= POKER_PLAYER_STATE_OUT;
// Is the player out?
if((player->state & POKER_PLAYER_STATE_OUT) != 0) continue;
// Have we found the dealer, small blind, and big blind players?
if(found != 3 && (POKER_PLAYERS[i].state & POKER_PLAYER_STATE_OUT) == 0){
if(found != 3) {
k = (POKER_PLAYER_DEALER + i) % POKER_PLAYER_COUNT_MAX;
if(found == 0) {// Have we found the dealer?
@@ -109,7 +118,7 @@ void pokerNewRound() {
// Deal two cards to the player.
for(j = 0; j < POKER_PLAYER_HAND_SIZE_MAX; j++) {
POKER_PLAYERS[i].hand[j] = POKER_DECK[--POKER_DECK_SIZE];
player->hand[j] = POKER_DECK[--POKER_DECK_SIZE];
}
}