Cleaned some of the betting code.

This commit is contained in:
2021-08-29 22:19:54 -07:00
parent 063c7b12ed
commit 7628417b72
3 changed files with 44 additions and 27 deletions

View File

@ -81,42 +81,21 @@ void _pokerGameActionBetOnUpdate(
void _pokerGameActionBetOnEnd(
queue_t *queue, queueaction_t *action, uint8_t i
) {
uint8_t j, k, p;
pokerplayer_t *player;
queueaction_t *next;
pokerdiscussiondata_t discussion;
bool playersPending;
pokergame_t *game = (pokergame_t *)action->data;
// Go to the next better
game->poker.bet.better = (game->poker.bet.better + 1) % POKER_PLAYER_COUNT;
playersPending = false;
// Check if each player needs to action.
k = POKER_BET_ROUND_PLAYER_DEFAULT(&game->poker);
for(j = 0; j < POKER_PLAYER_COUNT; j++) {
p = ((k + j) % POKER_PLAYER_COUNT);
player = game->poker.players + p;
if((player->state & POKER_PLAYER_STATE_FOLDED) != 0) continue;
if(player->state & POKER_PLAYER_STATE_OUT) continue;
if(player->state & POKER_PLAYER_STATE_ROUND_MOVE) {
if(player->currentBet >= game->poker.bet.currentBet && player) continue;
}
// Yes, this player needs to check, raise or fold
game->poker.bet.better = p;
pokerGameActionBetAdd(game);
playersPending = true;
break;
}
// Get which player is remaining to move.
game->poker.bet.better = pokerBetGetRemainingPlayer(&game->poker);
// Restack
pokerGameActionRestackAdd(game);
// Are we waiting on any players?
if(playersPending) return;
if(game->poker.bet.better != 0xFF) {
pokerGameActionBetAdd(game);
return;
}
// Not waiting, restack and do next action.
printf("Not waiting on anything!\n");