Added FLOP action

This commit is contained in:
2021-07-28 09:52:29 -07:00
parent c3b0ad7950
commit b89f27f3ec
8 changed files with 140 additions and 10 deletions

55
src/poker/actions/flop.c Normal file
View File

@ -0,0 +1,55 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "flop.h"
void _pokerActionFlopDo(queue_t *queue, queueaction_t *action, uint8_t count) {
poker_t *poker;
poker = (poker_t *)action->data;
pokerDealerBurn(&poker->dealer, 1);
pokerDealerTurn(&poker->dealer, count);
printf("Turned %u cards\n", count);
queueNext(queue);
}
void _pokerActionFlopOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
_pokerActionFlopDo(queue, action, POKER_FLOP_CARD_COUNT);
}
void _pokerActionTurnOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
_pokerActionFlopDo(queue, action, POKER_TURN_CARD_COUNT);
}
void _pokerActionRiverOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
_pokerActionFlopDo(queue, action, POKER_RIVER_CARD_COUNT);
}
queueaction_t * pokerActionFlopAdd(queue_t *queue, poker_t *poker) {
queueaction_t *action;
action = queueAdd(queue);
action->data = (void *)poker;
action->onStart = &_pokerActionFlopOnStart;
return action;
}
queueaction_t * pokerActionTurnAdd(queue_t *queue, poker_t *poker) {
queueaction_t *action;
action = queueAdd(queue);
action->data = (void *)poker;
action->onStart = &_pokerActionTurnOnStart;
return action;
}
queueaction_t * pokerActionRiverAdd(queue_t *queue, poker_t *poker) {
queueaction_t *action;
action = queueAdd(queue);
action->data = (void *)poker;
action->onStart = &_pokerActionRiverOnStart;
return action;
}

53
src/poker/actions/flop.h Normal file
View File

@ -0,0 +1,53 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../../display/animation/queue.h"
#include "../dealer.h"
/**
* Shorthand action callback parser. Takes the queue, action and the intended
* turn count to complete the action.
*
* @param queue Queue that fired the action.
* @param action Action that was fired.
* @param count Count of cards to turn over from the deck.
*/
void _pokerActionFlopDo(queue_t *queue, queueaction_t *action, uint8_t count);
/** Callbacks for River, Turn and Flop Actions */
void _pokerActionFlopOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
void _pokerActionTurnOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
void _pokerActionRiverOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
/**
* Queues a flop action onto the queue.
*
* @param queue Queue to add to.
* @param poker Poker game instance to flop.
* @return The queued action.
*/
queueaction_t * pokerActionFlopAdd(queue_t *queue, poker_t *poker);
/**
* Queues a turn action onto the queue.
*
* @param queue Queue to add to.
* @param poker Poker game instance to turn.
* @return The queued action.
*/
queueaction_t * pokerActionTurnAdd(queue_t *queue, poker_t *poker);
/**
* Queues a river action onto the queue.
*
* @param queue Queue to add to.
* @param poker Poker game instance to river.
* @return The queued action.
*/
queueaction_t * pokerActionRiverAdd(queue_t *queue, poker_t *poker);