Still working on updating code to new poker code.
This commit is contained in:
30
src/poker/actions/blinds.c
Normal file
30
src/poker/actions/blinds.c
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// TODO: Fix State
|
||||
// poker->state = POKER_STATE_TAKING_BLINDS;
|
||||
// TODO: Fix Blinds
|
||||
// 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;
|
||||
}
|
23
src/poker/actions/blinds.h
Normal file
23
src/poker/actions/blinds.h
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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);
|
30
src/poker/actions/deal.c
Normal file
30
src/poker/actions/deal.c
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
23
src/poker/actions/deal.h
Normal file
23
src/poker/actions/deal.h
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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);
|
75
src/poker/actions/flop.c
Normal file
75
src/poker/actions/flop.c
Normal file
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// TODO: Fix State
|
||||
// poker->state = POKER_STATE_CARDS_FLOPPING;
|
||||
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->dealer.cardsFacing) {
|
||||
// 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;
|
||||
}
|
66
src/poker/actions/flop.h
Normal file
66
src/poker/actions/flop.h
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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);
|
33
src/poker/actions/match.c
Normal file
33
src/poker/actions/match.c
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "match.h"
|
||||
|
||||
void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i){
|
||||
poker_t *poker;
|
||||
uint8_t x;
|
||||
|
||||
poker = (poker_t *)action->data;
|
||||
|
||||
// TODO: Fix state
|
||||
// poker->state = POKER_STATE_STARTING_MATCH;
|
||||
|
||||
// Reset the main game state. This will also init the round.
|
||||
pokerInit(&poker);
|
||||
|
||||
//TODO: Add Players here
|
||||
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerActionMatchAdd(queue_t *queue, poker_t *poker) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(queue);
|
||||
action->data = (void *)poker;
|
||||
action->onStart = &_pokerActionMatchOnStart;
|
||||
return action;
|
||||
}
|
21
src/poker/actions/match.h
Normal file
21
src/poker/actions/match.h
Normal file
@ -0,0 +1,21 @@
|
||||
// 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 when the poker match aciton starts */
|
||||
void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
|
||||
|
||||
/**
|
||||
* Adds a Poker Match Begin Action onto a queue.
|
||||
*
|
||||
* @param queue Queue to add to
|
||||
* @param poker Poker game instance to use.
|
||||
* @return The queued match start action.
|
||||
*/
|
||||
queueaction_t * pokerActionMatchAdd(queue_t *queue, poker_t *poker);
|
36
src/poker/actions/round.c
Normal file
36
src/poker/actions/round.c
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "round.h"
|
||||
|
||||
void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
|
||||
uint8_t j, indexDealer, indexSmallBlind, indexBigBlind;
|
||||
bool foundDealer, foundSmallBlind;
|
||||
pokerplayer_t *player;
|
||||
poker_t *poker;
|
||||
|
||||
poker = (poker_t *)action->data;
|
||||
|
||||
// TODO: Fix State
|
||||
// poker->state = POKER_STATE_STARTING_ROUND;
|
||||
|
||||
// Prepare the initial game stat
|
||||
pokerResetRound(&poker);
|
||||
|
||||
// Decide on the dealer
|
||||
pokerNewDealer(&poker);
|
||||
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerActionRoundAdd(queue_t *queue, poker_t *poker) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(queue);
|
||||
action->data = (void *)poker;
|
||||
action->onStart = &_pokerActionRoundOnStart;
|
||||
return action;
|
||||
}
|
24
src/poker/actions/round.h
Normal file
24
src/poker/actions/round.h
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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 when the poker round start aciton begins. */
|
||||
void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
|
||||
|
||||
/**
|
||||
* Queues the round action onto a queue. Round action should be queued at the
|
||||
* start of every poker round.
|
||||
*
|
||||
* @param queue Queue to add to.
|
||||
* @param poker Poker game instance.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerActionRoundAdd(queue_t *queue, poker_t *poker);
|
@ -192,6 +192,22 @@ int32_t pokerPlayerGetCallBet(poker_t *poker, pokerplayer_t *player) {
|
||||
return pokerGetCallValue(poker) - player->currentBet;
|
||||
}
|
||||
|
||||
uint8_t pokerInRoundGetCount(poker_t *poker) {
|
||||
uint8_t i, count;
|
||||
pokerplayer_t *player;
|
||||
|
||||
count = 0;
|
||||
for(i = 0; i < poker->playerCount; i++) {
|
||||
player = poker->players + i;
|
||||
if(player->state & (POKER_PLAYER_STATE_FOLDED | POKER_PLAYER_STATE_OUT)) {
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// Betting
|
||||
void pokerPlayerBetPot(
|
||||
poker_t *poker, pokerpot_t *pot, uint8_t playerIndex, int32_t chips
|
||||
|
@ -85,6 +85,11 @@
|
||||
/** The default blind cost for the small blind. (Defaults half big blind) */
|
||||
#define POKER_BET_BLIND_SMALL_DEFAULT (POKER_BET_BLIND_BIG_DEFAULT/2)
|
||||
|
||||
/** How many cards are dealt for the flop, turn and river */
|
||||
#define POKER_FLOP_CARD_COUNT 3
|
||||
#define POKER_TURN_CARD_COUNT 1
|
||||
#define POKER_RIVER_CARD_COUNT 1
|
||||
|
||||
typedef struct {
|
||||
/** Count of chips the player has */
|
||||
int32_t chips;
|
||||
@ -317,6 +322,13 @@ uint8_t pokerPlayerGetNextBetter(poker_t *poker, uint8_t current);
|
||||
*/
|
||||
int32_t pokerPlayerGetCallBet(poker_t *poker, pokerplayer_t *player);
|
||||
|
||||
/**
|
||||
* Gets the count of players still currently left in the round.
|
||||
*
|
||||
* @param poker Poker game instance.
|
||||
* @return The count of players in the round.
|
||||
*/
|
||||
uint8_t pokerInRoundGetCount(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Let a player bet chips into the pot.
|
||||
|
Reference in New Issue
Block a user