Cleaning more code.

This commit is contained in:
2021-10-11 21:07:59 -07:00
parent 8bbfcf7c43
commit 169a4e9632
10 changed files with 43 additions and 65 deletions

View File

@ -11,10 +11,7 @@ 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);
pokerTakeBlinds(poker, poker->blindSmall, poker->blindBig);
printf("Taken Blinds\n");
queueNext(queue);

View File

@ -1,32 +0,0 @@
/**
* 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){
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;
}

View File

@ -1,24 +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 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);

View File

@ -13,6 +13,12 @@ void pokerInit(poker_t *poker) {
poker->playerSmallBlind = 0;
poker->playerBigBlind = 0;
pokerResetRound(poker);
pokerSetBlinds(poker, 0, 0);
}
void pokerSetBlinds(poker_t *poker, int32_t blindSmall, int32_t blindBig) {
poker->blindSmall = blindSmall;
poker->blindBig = blindBig;
}
void pokerResetRound(poker_t *poker) {
@ -31,6 +37,7 @@ void pokerResetRound(poker_t *poker) {
player = poker->players + i;
player->cardCount = 0;
player->currentBet = 0;
player->timesRaised = 0;
player->state &= ~(
POKER_PLAYER_STATE_FOLDED |
POKER_PLAYER_STATE_HAS_BET_THIS_ROUND |

View File

@ -80,10 +80,8 @@
/** How many chips each player has by defautl */
#define POKER_BET_PLAYER_CHIPS_DEFAULT 1200
/** The default blind cost for the big blind. */
#define POKER_BET_BLIND_BIG_DEFAULT 600
/** The default blind cost for the small blind. (Defaults half big blind) */
#define POKER_BET_BLIND_SMALL_DEFAULT (POKER_BET_BLIND_BIG_DEFAULT/2)
@ -173,6 +171,11 @@ typedef struct {
/** Which player is the current active better ? */
uint8_t better;
/** Size of the small blind */
int32_t blindSmall;
/** Size of the big blind */
int32_t blindBig;
} poker_t;
@ -183,6 +186,15 @@ typedef struct {
*/
void pokerInit(poker_t *poker);
/**
* Set the game's current blinds.
*
* @param poker Poker game instance.
* @param blindSmall Small blind value.
* @param blindBig Big blind value.
*/
void pokerSetBlinds(poker_t *poker, int32_t blindSmall, int32_t blindBig);
/**
* Reset the poker game instance for the new round.
*