More code cleaning.
This commit is contained in:
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "blinds.h"
|
||||
|
||||
void _pokerActionBlindsOnStart(queue_t *queue,queueaction_t *action,uint8_t i) {
|
||||
poker_t *poker;
|
||||
poker = (poker_t *)action->data;
|
||||
|
||||
pokerTakeBlinds(poker, poker->blindSmall, poker->blindBig);
|
||||
|
||||
printf("Taken Blinds\n");
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerActionBlindsAdd(queue_t *queue, poker_t *poker) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(queue);
|
||||
action->data = (void *)poker;
|
||||
action->onStart = &_pokerActionBlindsOnStart;
|
||||
return action;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../poker.h"
|
||||
#include "../../libs.h"
|
||||
#include "../../display/animation/queue.h"
|
||||
|
||||
/** Callback for the blinds action */
|
||||
void _pokerActionBlindsOnStart(queue_t *queue,queueaction_t *action,uint8_t i);
|
||||
|
||||
/**
|
||||
* Adds a blinds action onto the specified queue.
|
||||
*
|
||||
* @param queue Queue to add to.
|
||||
* @param poker Poker game instance to deal.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerActionBlindsAdd(queue_t *queue, poker_t *poker);
|
@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "deal.h"
|
||||
|
||||
void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
|
||||
poker_t *poker;
|
||||
poker = (poker_t *)action->data;
|
||||
|
||||
// Shuffle the deck
|
||||
// TODO: State yknow
|
||||
// poker->state = POKER_STATE_DEALING;
|
||||
cardShuffle(poker->deck, CARD_DECK_SIZE);
|
||||
|
||||
// Deal 2 card to each player
|
||||
pokerPlayerDealAll(poker, POKER_PLAYER_HAND_SIZE_MAX);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerActionDealAdd(queue_t *queue, poker_t *poker) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(queue);
|
||||
action->data = (void *)poker;
|
||||
action->onStart = &_pokerActionDealOnStart;
|
||||
return action;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../display/animation/queue.h"
|
||||
#include "../poker.h"
|
||||
|
||||
/** Callback for the deal action */
|
||||
void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
|
||||
|
||||
/**
|
||||
* Adds a deal action onto the specified queue.
|
||||
*
|
||||
* @param queue Queue to add to.
|
||||
* @param poker Poker game instance to deal.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerActionDealAdd(queue_t *queue, poker_t *poker);
|
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
pokerBurn(poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerTurn(poker, 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;
|
||||
}
|
||||
|
||||
queueaction_t * pokerActionNextFlopAdd(queue_t *queue, poker_t *poker) {
|
||||
switch(poker->communitySize) {
|
||||
case 0:
|
||||
return pokerActionFlopAdd(queue, poker);
|
||||
|
||||
case POKER_FLOP_CARD_COUNT:
|
||||
return pokerActionTurnAdd(queue, poker);
|
||||
|
||||
case POKER_FLOP_CARD_COUNT+POKER_TURN_CARD_COUNT:
|
||||
return pokerActionRiverAdd(queue, poker);
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../display/animation/queue.h"
|
||||
#include "../poker.h"
|
||||
|
||||
/** How many cards the dealer should burn before dealing the flop */
|
||||
#define POKER_FLOP_BURN_COUNT 1
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Queues the next type of flop action onto the queue. This will automatically
|
||||
* select River, Flop or Turn depending on what's happened already.
|
||||
*
|
||||
* @param queue Queue to add to.
|
||||
* @param poker Poker game instance
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerActionNextFlopAdd(queue_t *queue, poker_t *poker);
|
@ -103,6 +103,7 @@ void pokerSetDealer(poker_t *poker, uint8_t dealer) {
|
||||
void pokerTakeBlinds(poker_t *poker, int32_t small, int32_t big) {
|
||||
pokerPlayerBet(poker, poker->playerSmallBlind, small);
|
||||
pokerPlayerBet(poker, poker->playerBigBlind, big);
|
||||
pokerResetBettingRound(poker);
|
||||
}
|
||||
|
||||
int32_t pokerGetCallValue(poker_t *poker) {
|
||||
|
@ -89,6 +89,8 @@
|
||||
#define POKER_FLOP_CARD_COUNT 3
|
||||
#define POKER_TURN_CARD_COUNT 1
|
||||
#define POKER_RIVER_CARD_COUNT 1
|
||||
/** How many cards the dealer should burn before dealing the flop */
|
||||
#define POKER_FLOP_BURN_COUNT 1
|
||||
|
||||
typedef struct {
|
||||
/** Count of chips the player has */
|
||||
|
Reference in New Issue
Block a user