More code cleaning.
This commit is contained in:
@ -12,21 +12,38 @@ void _pokerGameActionFlopOnStart(
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
pokerdiscussiondata_t discussion;
|
||||
queueaction_t *next;
|
||||
bool hasDoneFlop;
|
||||
|
||||
// Prep convo
|
||||
discussion.poker = game;
|
||||
|
||||
// Get how many players are left in the round.
|
||||
if(pokerInRoundGetCount(&game->poker) > 1) {// Still more than 1
|
||||
// Add the actual flop action.
|
||||
next = pokerActionNextFlopAdd(queue, &game->poker);
|
||||
|
||||
// Reset all the players
|
||||
pokerResetBettingRound(&game->poker);
|
||||
|
||||
// Do actual flop action
|
||||
hasDoneFlop = true;
|
||||
switch(game->poker.communitySize) {
|
||||
case 0x00:
|
||||
pokerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerTurn(&game->poker, POKER_FLOP_CARD_COUNT);
|
||||
break;
|
||||
case POKER_FLOP_CARD_COUNT:
|
||||
pokerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerTurn(&game->poker, POKER_TURN_CARD_COUNT);
|
||||
break;
|
||||
case POKER_FLOP_CARD_COUNT+POKER_TURN_CARD_COUNT:
|
||||
pokerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerTurn(&game->poker, POKER_RIVER_CARD_COUNT);
|
||||
break;
|
||||
default:
|
||||
hasDoneFlop = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Is there any flop "left to do" ?
|
||||
if(next != NULL) {
|
||||
if(hasDoneFlop) {
|
||||
// Talk about it.
|
||||
discussion.reason = POKER_DISCUSSION_REASON_FLOP;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "restack.h"
|
||||
#include "winner.h"
|
||||
#include "bet.h"
|
||||
#include "../../../poker/actions/flop.h"
|
||||
|
||||
/** Callback that is fired when the flop action starts */
|
||||
void _pokerGameActionFlopOnStart(
|
||||
|
@ -20,30 +20,26 @@ void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
||||
// 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);
|
||||
|
||||
// Take the blinds.
|
||||
pokerActionBlindsAdd(queue, &game->poker);
|
||||
|
||||
// Speak
|
||||
data.reason = POKER_DISCUSSION_REASON_BLINDS_TAKEN;
|
||||
pokerDiscussionQueue(&data);
|
||||
|
||||
// Deal
|
||||
pokerActionDealAdd(queue, &game->poker);
|
||||
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. This will queue for one player only and then the round
|
||||
// will take over.
|
||||
|
||||
pokerResetBettingRound(&game->poker);
|
||||
// Begin Betting Round
|
||||
pokerGameActionBetAdd(game);
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/actions/blinds.h"
|
||||
#include "../../../poker/actions/deal.h"
|
||||
#include "action.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "bet.h"
|
||||
|
@ -24,12 +24,10 @@ void _pokerGameActionStartOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
||||
&game->poker, POKER_BET_BLIND_SMALL_DEFAULT, POKER_BET_BLIND_BIG_DEFAULT
|
||||
);
|
||||
for(j = 0; j < POKER_PLAYER_COUNT_MAX; j++) {
|
||||
k = pokerPlayerAdd(&game->poker);
|
||||
pokerPlayerChipsAdd(
|
||||
game->poker.players + k,
|
||||
POKER_BET_PLAYER_CHIPS_DEFAULT
|
||||
);
|
||||
k = pokerPlayerAdd(&game->poker);
|
||||
pokerPlayerChipsAdd(game->poker.players+k, POKER_BET_PLAYER_CHIPS_DEFAULT);
|
||||
}
|
||||
pokerSetDealer(&game->poker, game->poker.playerCount/2);
|
||||
|
||||
// Say that.
|
||||
data.poker = game;
|
||||
|
@ -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