2021-10-12 09:25:42 -07:00

51 lines
1.3 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "round.h"
void _pokerGameActionRoundOnStart(
queue_t *queue, queueaction_t *action, uint8_t i
) {
queueNext(queue);
}
void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
pokerdiscussiondata_t data;
pokergame_t *game = (pokergame_t *)action->data;
// Start the round
pokerResetRound(&game->poker);
pokerNewDealer(&game->poker);
pokerTakeBlinds(&game->poker, game->poker.blindSmall, game->poker.blindBig);
// Speak
data.poker = game;
data.reason = POKER_DISCUSSION_REASON_ROUND_START;
pokerDiscussionQueue(&data);
// Speak
data.reason = POKER_DISCUSSION_REASON_BLINDS_TAKEN;
pokerDiscussionQueue(&data);
// Deal
cardShuffle(&game->poker.deck, CARD_DECK_SIZE);
pokerPlayerDealAll(&game->poker, POKER_PLAYER_HAND_SIZE_MAX);
// Speak
data.reason = POKER_DISCUSSION_REASON_DEAL;
pokerDiscussionQueue(&data);
// Begin Betting Round
pokerGameActionBetAdd(game);
}
queueaction_t * pokerGameActionRoundAdd(pokergame_t *game) {
queueaction_t *action = pokerGameActionAdd(game);
action->onStart = &_pokerGameActionRoundOnStart;
action->onEnd = &_pokerGameActionRoundOnEnd;
return action;
}