Fixed crash

This commit is contained in:
2022-01-11 07:58:21 -08:00
parent 18260920b4
commit 5620d6c517
5 changed files with 31 additions and 25 deletions

Binary file not shown.

View File

@@ -35,9 +35,6 @@ void conversationQueueDealCards() {
void conversationQueueBeginBetting() { void conversationQueueBeginBetting() {
// Begin the betting process. First we need to decide if the player or the // Begin the betting process. First we need to decide if the player or the
// AI is betting, then based on that we decide what to do next. // AI is betting, then based on that we decide what to do next.
QUEUE_ITEM = QUEUE_DEBUG;
conversationTextboxString(DEBUG_WINNER_DECIDED);
return;
// TODO: Actually bet. // TODO: Actually bet.
if(POKER_PLAYER_BETTER == POKER_HUMAN_INDEX) { if(POKER_PLAYER_BETTER == POKER_HUMAN_INDEX) {
@@ -53,7 +50,6 @@ void conversationQueueBeginBetting() {
POKER_PLAYER_BETTER POKER_PLAYER_BETTER
].state |= POKER_PLAYER_STATE_HAS_BET_THIS_ROUND; ].state |= POKER_PLAYER_STATE_HAS_BET_THIS_ROUND;
} }
QUEUE_ITEM = QUEUE_NEXT_BETTER; QUEUE_ITEM = QUEUE_NEXT_BETTER;
conversationQueueNext(); conversationQueueNext();
} }
@@ -69,6 +65,7 @@ void conversationQueueNextBetter() {
// Next better is the better to the right of the current better. // Next better is the better to the right of the current better.
j = (POKER_PLAYER_BETTER + i) % POKER_PLAYER_COUNT_MAX; j = (POKER_PLAYER_BETTER + i) % POKER_PLAYER_COUNT_MAX;
// Can this player even participate? // Can this player even participate?
if( if(
( (
@@ -93,6 +90,7 @@ void conversationQueueNextBetter() {
// Is the player called into this pot all the way? // Is the player called into this pot all the way?
if(POKER_POTS[k].players[j] == POKER_POTS[k].call) continue; if(POKER_POTS[k].players[j] == POKER_POTS[k].call) continue;
break;
} }
// Then skip to next player. // Then skip to next player.
@@ -100,8 +98,12 @@ void conversationQueueNextBetter() {
} }
// They haven't bet yet, make them the "next better" // They haven't bet yet, make them the "next better"
BGB_printf("NEXT BETTER IS NOW %d", j);
POKER_PLAYER_BETTER = j; POKER_PLAYER_BETTER = j;
conversationQueueNext();
QUEUE_ITEM = QUEUE_BEGIN_BETTING;
conversationPause(1);
// conversationQueueNext();
return; return;
} }
@@ -233,7 +235,8 @@ inline void conversationQueueInit() {
} }
inline void conversationQueueNext() { inline void conversationQueueNext() {
if(QUEUE_ITEM > QUEUE_WINNER_DECIDE) return; BGB_printf("Doing %d", QUEUE_ITEM);
if(QUEUE_ITEM >= QUEUE_WINNER_DECIDE) return;
if(QUEUE_CALLBACKS[QUEUE_ITEM] == NULL) return; if(QUEUE_CALLBACKS[QUEUE_ITEM] == NULL) return;
QUEUE_CALLBACKS[QUEUE_ITEM](); QUEUE_CALLBACKS[QUEUE_ITEM]();
} }

View File

@@ -107,10 +107,26 @@ void pokerNewRound() {
// Take blinds // Take blinds
// TODO: I need to make sure the blind players even have the chips to blind. // TODO: I need to make sure the blind players even have the chips to blind.
POKER_POT_BET(POKER_PLAYER_SMALL_BLIND, POKER_GAME_BLINDS_CURRENT); pokerBet(POKER_PLAYER_SMALL_BLIND, POKER_GAME_BLINDS_CURRENT);
POKER_POT_BET(POKER_PLAYER_BIG_BLIND, (POKER_GAME_BLINDS_CURRENT*2)); pokerBet(POKER_PLAYER_BIG_BLIND, (POKER_GAME_BLINDS_CURRENT*2));
// Set the initial better, we set this to the BIG BLIND player because we will // Set the initial better, we set this to the BIG BLIND player because we will
// cycle to the "next better" as soon as the game starts. // cycle to the "next better" as soon as the game starts.
POKER_PLAYER_BETTER = POKER_PLAYER_BIG_BLIND; POKER_PLAYER_BETTER = POKER_PLAYER_BIG_BLIND;
} }
inline void pokerBet(uint8_t player, uint16_t amount) {
// TODO: This may become a function because if a player doesn't have enough
// chips to bet to the active pot, then the pot needs to autosplit, take those
// who have bet into the pot up to the amount that the player betting can bet,
// and push them into a new pot.
// There also needs to be a limit on this, for example;
// player 0 has $1200, and bets $1000, he can't bet more than that ever.
// player 1 has $1000, and bets all of it. The remanin
// player 2 has $700, and bets all o it. A new $300 sidepot auto creates
// player 3 has $500 and bets all of it, Another sidepot with $200 is auto made.
POKER_PLAYERS[player].chips -= amount;\
POKER_POTS[POKER_POT_CURRENT].chips += amount;\
POKER_POTS[POKER_POT_CURRENT].call = amount;
}

View File

@@ -33,3 +33,5 @@ extern uint16_t POKER_GAME_BLINDS_CURRENT;
void pokerInit(); void pokerInit();
void pokerNewRound(); void pokerNewRound();
inline void pokerBet(uint8_t player, uint16_t amount);

View File

@@ -25,18 +25,3 @@ typedef struct {
extern pokerpot_t POKER_POTS[]; extern pokerpot_t POKER_POTS[];
extern uint8_t POKER_POT_CURRENT; extern uint8_t POKER_POT_CURRENT;
extern uint8_t POKER_POT_COUNT; extern uint8_t POKER_POT_COUNT;
// TODO: This may become a function because if a player doesn't have enough
// chips to bet to the active pot, then the pot needs to autosplit, take those
// who have bet into the pot up to the amount that the player betting can bet,
// and push them into a new pot.
// There also needs to be a limit on this, for example;
// player 0 has $1200, and bets $1000, he can't bet more than that ever.
// player 1 has $1000, and bets all of it. The remanin
// player 2 has $700, and bets all o it. A new $300 sidepot auto creates
// player 3 has $500 and bets all of it, Another sidepot with $200 is auto made.
#define POKER_POT_BET(player, amount) \
POKER_PLAYERS[player].chips -= amount;\
POKER_POTS[POKER_POT_CURRENT].chips += amount;\
POKER_POTS[POKER_POT_CURRENT].call = amount;