Fixed betting bugs.
This commit is contained in:
68
src/game/poker/actions/flop.c
Normal file
68
src/game/poker/actions/flop.c
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "flop.h"
|
||||
|
||||
void _pokerGameActionFlopOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
pokerdiscussiondata_t discussion;
|
||||
queueaction_t *next;
|
||||
|
||||
// Prep convo
|
||||
discussion.poker = game;
|
||||
|
||||
// Get how many players are left in the round.
|
||||
if(pokerPlayerGetCountInRound(game->poker.players) > 1) {// Still more than 1
|
||||
// Add the actual flop action.
|
||||
next = pokerActionNextFlopAdd(queue, &game->poker);
|
||||
|
||||
// Is there any flop "left to do" ?
|
||||
if(next != NULL) {
|
||||
// Talk about it.
|
||||
discussion.reason = POKER_DISCUSSION_REASON_FLOP;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
// Now, get the count of players left to bet. If "everyone is all in" then
|
||||
// this will be 0 and no actual betting needs to happen.
|
||||
if(pokerBetGetRemainingPlayerCount(
|
||||
&game->poker.bet, game->poker.players
|
||||
) > 1) {
|
||||
// Reset the better to the betting round initial.
|
||||
pokerBetResetBetter(
|
||||
&game->poker.bet, game->poker.players, game->poker.roundSmallBlind
|
||||
);
|
||||
|
||||
// Begin betting.
|
||||
pokerGameActionLookAdd(game, game->poker.bet.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
} else {
|
||||
//No actual players to bet, so add the following flop instead.
|
||||
pokerGameActionFlopAdd(game);
|
||||
}
|
||||
|
||||
// Do next action.
|
||||
queueNext(queue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Done betting
|
||||
printf("All betting is done, reveal\n");
|
||||
pokerGameActionRestackAdd(game);
|
||||
pokerGameActionWinnerAdd(game);
|
||||
|
||||
// Do next action
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionFlopAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionFlopOnStart;
|
||||
return action;
|
||||
}
|
Reference in New Issue
Block a user