Still correcting betting logic.

This commit is contained in:
2021-10-11 20:41:26 -07:00
parent 6043130012
commit 8bbfcf7c43
3 changed files with 48 additions and 15 deletions

View File

@ -459,6 +459,32 @@ pokerturn_t pokerTurnGetForPlayer(poker_t *poker, uint8_t playerIndex) {
return turn;
}
void pokerTurnAction(poker_t *poker, uint8_t playerIndex, pokerturn_t turn) {
pokerplayer_t *player;
player = poker->players + playerIndex;
switch(turn.type) {
case POKER_TURN_TYPE_BET:
case POKER_TURN_TYPE_CALL:
case POKER_TURN_TYPE_ALL_IN:
pokerPlayerBet(poker, playerIndex, turn.chips);
player->timesRaised++;
break;
case POKER_TURN_TYPE_CHECK:
pokerPlayerBet(poker, playerIndex, 0);
player->timesRaised = 0;
break;
case POKER_TURN_TYPE_FOLD:
player->state |= POKER_PLAYER_STATE_FOLDED;
player->timesRaised = 0;
break;
}
player->state |= POKER_PLAYER_STATE_HAS_BET_THIS_ROUND;
}
int32_t pokerPlayerGetPotChipsSum(poker_t *poker, uint8_t playerIndex) {
int32_t count;
uint8_t i;

View File

@ -421,6 +421,15 @@ pokerturn_t pokerTurnBet(poker_t *poker, uint8_t playerIndex, int32_t chips);
*/
pokerturn_t pokerTurnGetForPlayer(poker_t *poker, uint8_t playerIndex);
/**
* Perform the turn's action.
*
* @param poker Poker game instance.
* @param playerIndex Player index.
* @param turn Turn to action.
*/
void pokerTurnAction(poker_t *poker, uint8_t playerIndex, pokerturn_t turn);
/**
* Returns the sum of chips in the pot(s) that the specified player is in. This
* does not consider the pot, player or hand, just the pure sum of chips.