Cleaning more code.
This commit is contained in:
@ -35,6 +35,8 @@ void _pokerGameActionBetOnUpdate(
|
|||||||
if(isHuman) {
|
if(isHuman) {
|
||||||
// turn = game->ui.betTurn;
|
// turn = game->ui.betTurn;
|
||||||
// turnMade = game->ui.betTurnMade;
|
// turnMade = game->ui.betTurnMade;
|
||||||
|
turn = pokerTurnGetForPlayer(&game->poker, game->poker.better);
|
||||||
|
turnMade = true;
|
||||||
} else {
|
} else {
|
||||||
turn = pokerTurnGetForPlayer(&game->poker, game->poker.better);
|
turn = pokerTurnGetForPlayer(&game->poker, game->poker.better);
|
||||||
turnMade = true;
|
turnMade = true;
|
||||||
|
@ -18,7 +18,8 @@ void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
|||||||
pokergame_t *game = (pokergame_t *)action->data;
|
pokergame_t *game = (pokergame_t *)action->data;
|
||||||
|
|
||||||
// Start the round
|
// Start the round
|
||||||
pokerActionRoundAdd(queue, &game->poker);
|
pokerResetRound(&game->poker);
|
||||||
|
pokerNewDealer(&game->poker);
|
||||||
|
|
||||||
// Speak
|
// Speak
|
||||||
data.poker = game;
|
data.poker = game;
|
||||||
@ -42,7 +43,6 @@ void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
|||||||
// Begin Betting Round. This will queue for one player only and then the round
|
// Begin Betting Round. This will queue for one player only and then the round
|
||||||
// will take over.
|
// will take over.
|
||||||
|
|
||||||
// TODO: finish
|
|
||||||
pokerResetBettingRound(&game->poker);
|
pokerResetBettingRound(&game->poker);
|
||||||
pokerGameActionBetAdd(game);
|
pokerGameActionBetAdd(game);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../../libs.h"
|
#include "../../../libs.h"
|
||||||
|
#include "../../../poker/actions/blinds.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "../pokerdiscussion.h"
|
#include "../pokerdiscussion.h"
|
||||||
#include "bet.h"
|
#include "bet.h"
|
||||||
|
@ -15,8 +15,22 @@ void _pokerGameActionStartOnStart(
|
|||||||
|
|
||||||
void _pokerGameActionStartOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
void _pokerGameActionStartOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
||||||
pokerdiscussiondata_t data;
|
pokerdiscussiondata_t data;
|
||||||
|
uint8_t j, k;
|
||||||
pokergame_t *game = (pokergame_t *)action->data;
|
pokergame_t *game = (pokergame_t *)action->data;
|
||||||
|
|
||||||
|
//TODO: Init Players betterer.
|
||||||
|
pokerInit(&game->poker);
|
||||||
|
pokerSetBlinds(
|
||||||
|
&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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Say that.
|
// Say that.
|
||||||
data.poker = game;
|
data.poker = game;
|
||||||
data.reason = POKER_DISCUSSION_REASON_MATCH_START;
|
data.reason = POKER_DISCUSSION_REASON_MATCH_START;
|
||||||
|
@ -11,10 +11,7 @@ void _pokerActionBlindsOnStart(queue_t *queue,queueaction_t *action,uint8_t i) {
|
|||||||
poker_t *poker;
|
poker_t *poker;
|
||||||
poker = (poker_t *)action->data;
|
poker = (poker_t *)action->data;
|
||||||
|
|
||||||
// TODO: Fix State
|
pokerTakeBlinds(poker, poker->blindSmall, poker->blindBig);
|
||||||
// poker->state = POKER_STATE_TAKING_BLINDS;
|
|
||||||
// TODO: Fix Blinds
|
|
||||||
// pokerTakeBlinds(&poker, poker->blindSmall, poker->blindBig);
|
|
||||||
|
|
||||||
printf("Taken Blinds\n");
|
printf("Taken Blinds\n");
|
||||||
queueNext(queue);
|
queueNext(queue);
|
||||||
|
@ -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;
|
|
||||||
}
|
|
@ -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);
|
|
@ -13,6 +13,12 @@ void pokerInit(poker_t *poker) {
|
|||||||
poker->playerSmallBlind = 0;
|
poker->playerSmallBlind = 0;
|
||||||
poker->playerBigBlind = 0;
|
poker->playerBigBlind = 0;
|
||||||
pokerResetRound(poker);
|
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) {
|
void pokerResetRound(poker_t *poker) {
|
||||||
@ -31,6 +37,7 @@ void pokerResetRound(poker_t *poker) {
|
|||||||
player = poker->players + i;
|
player = poker->players + i;
|
||||||
player->cardCount = 0;
|
player->cardCount = 0;
|
||||||
player->currentBet = 0;
|
player->currentBet = 0;
|
||||||
|
player->timesRaised = 0;
|
||||||
player->state &= ~(
|
player->state &= ~(
|
||||||
POKER_PLAYER_STATE_FOLDED |
|
POKER_PLAYER_STATE_FOLDED |
|
||||||
POKER_PLAYER_STATE_HAS_BET_THIS_ROUND |
|
POKER_PLAYER_STATE_HAS_BET_THIS_ROUND |
|
||||||
|
@ -80,10 +80,8 @@
|
|||||||
|
|
||||||
/** How many chips each player has by defautl */
|
/** How many chips each player has by defautl */
|
||||||
#define POKER_BET_PLAYER_CHIPS_DEFAULT 1200
|
#define POKER_BET_PLAYER_CHIPS_DEFAULT 1200
|
||||||
|
|
||||||
/** The default blind cost for the big blind. */
|
/** The default blind cost for the big blind. */
|
||||||
#define POKER_BET_BLIND_BIG_DEFAULT 600
|
#define POKER_BET_BLIND_BIG_DEFAULT 600
|
||||||
|
|
||||||
/** The default blind cost for the small blind. (Defaults half big blind) */
|
/** The default blind cost for the small blind. (Defaults half big blind) */
|
||||||
#define POKER_BET_BLIND_SMALL_DEFAULT (POKER_BET_BLIND_BIG_DEFAULT/2)
|
#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 ? */
|
/** Which player is the current active better ? */
|
||||||
uint8_t better;
|
uint8_t better;
|
||||||
|
|
||||||
|
/** Size of the small blind */
|
||||||
|
int32_t blindSmall;
|
||||||
|
/** Size of the big blind */
|
||||||
|
int32_t blindBig;
|
||||||
} poker_t;
|
} poker_t;
|
||||||
|
|
||||||
|
|
||||||
@ -183,6 +186,15 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
void pokerInit(poker_t *poker);
|
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.
|
* Reset the poker game instance for the new round.
|
||||||
*
|
*
|
||||||
|
@ -54,9 +54,9 @@ void test_pokerResetRound_should_ResetThePlayers(void) {
|
|||||||
|
|
||||||
for(i = 0; i < poker.playerCount; i++) {
|
for(i = 0; i < poker.playerCount; i++) {
|
||||||
TEST_ASSERT_EQUAL_UINT8(0, poker.players[i].cardCount);
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[i].cardCount);
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[i].timesRaised);
|
||||||
TEST_ASSERT_EQUAL_INT32(0, poker.players[i].currentBet);
|
TEST_ASSERT_EQUAL_INT32(0, poker.players[i].currentBet);
|
||||||
TEST_ASSERT_EQUAL_INT32(100, poker.players[i].chips);
|
TEST_ASSERT_EQUAL_INT32(100, poker.players[i].chips);
|
||||||
TEST_ASSERT_EQUAL_INT32(100, poker.players[i].chips);
|
|
||||||
TEST_ASSERT_BITS_LOW(POKER_PLAYER_STATE_FOLDED, poker.players[i].state);
|
TEST_ASSERT_BITS_LOW(POKER_PLAYER_STATE_FOLDED, poker.players[i].state);
|
||||||
TEST_ASSERT_BITS_LOW(
|
TEST_ASSERT_BITS_LOW(
|
||||||
POKER_PLAYER_STATE_HAS_BET_THIS_ROUND, poker.players[i].state
|
POKER_PLAYER_STATE_HAS_BET_THIS_ROUND, poker.players[i].state
|
||||||
@ -288,6 +288,7 @@ void test_pokerPlayerAdd_should_ResetThePlayer(void) {
|
|||||||
TEST_ASSERT_EQUAL_INT32(0, player->chips);
|
TEST_ASSERT_EQUAL_INT32(0, player->chips);
|
||||||
TEST_ASSERT_EQUAL_INT32(0, player->currentBet);
|
TEST_ASSERT_EQUAL_INT32(0, player->currentBet);
|
||||||
TEST_ASSERT_EQUAL_UINT8(0, player->cardCount);
|
TEST_ASSERT_EQUAL_UINT8(0, player->cardCount);
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(0, poker.players[i].timesRaised);
|
||||||
TEST_ASSERT_EQUAL_UINT8(POKER_PLAYER_STATE_OUT, player->state);
|
TEST_ASSERT_EQUAL_UINT8(POKER_PLAYER_STATE_OUT, player->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user