Just cleaning

This commit is contained in:
2021-10-14 21:32:51 -07:00
parent 9a9e1d156c
commit e9c8d37360
17 changed files with 228 additions and 226 deletions

View File

@ -64,9 +64,7 @@ void _pokerGameActionBetOnEnd(
pokergame_t *game = (pokergame_t *)action->data;
// // Get which player is remaining to move.
game->poker.better = pokerPlayerGetNextBetter(
&game->poker, game->poker.better
);
game->poker.better = pokerBetGetNextPlayer(&game->poker);
// Restack
pokerGameActionRestackAdd(game);

View File

@ -7,6 +7,7 @@
#pragma once
#include "../../../libs.h"
#include "../../../poker/bet.h"
#include "../pokerdiscussion.h"
#include "action.h"
#include "restack.h"

View File

@ -26,16 +26,16 @@ void _pokerGameActionFlopOnStart(
hasDoneFlop = true;
switch(game->poker.communitySize) {
case 0x00:
pokerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
pokerTurn(&game->poker, POKER_FLOP_CARD_COUNT);
pokerDealerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
pokerDealerTurn(&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);
pokerDealerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
pokerDealerTurn(&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);
pokerDealerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
pokerDealerTurn(&game->poker, POKER_RIVER_CARD_COUNT);
break;
default:
hasDoneFlop = false;
@ -50,9 +50,9 @@ void _pokerGameActionFlopOnStart(
// Now, get the count of players left to bet. If "everyone is all in" then
// this will be 0 and no actual betting needs to happen.
if(pokerPlayerGetRemainingBetterCount(&game->poker) > 0x01) {
if(pokerBetGetRemainingPlayerCount(&game->poker) > 0x01) {
// Begin betting.
game->poker.better = pokerPlayerGetRemainingBetter(&game->poker);
game->poker.better = pokerBetGetRemainingPlayer(&game->poker);
pokerGameActionLookAdd(game, game->poker.better);
pokerGameActionBetAdd(game);
} else {

View File

@ -19,7 +19,7 @@ void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
// Start the round
pokerResetRound(&game->poker);
pokerNewDealer(&game->poker);
pokerDealerNew(&game->poker);
pokerTakeBlinds(&game->poker, game->poker.blindSmall, game->poker.blindBig);
// Speak

View File

@ -27,7 +27,7 @@ void _pokerGameActionStartOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
k = pokerPlayerAdd(&game->poker);
pokerPlayerChipsAdd(game->poker.players+k, POKER_BET_PLAYER_CHIPS_DEFAULT);
}
pokerSetDealer(&game->poker, game->poker.playerCount/2);
pokerDealerSet(&game->poker, game->poker.playerCount/2);
// Say that.
data.poker = game;

View File

@ -97,12 +97,12 @@ void pokerUiUpdate(
void pokerUiRender(
pokerui_t *ui, engine_t *engine, pokergameassets_t *assets, poker_t *poker
) {
uint8_t i, j;
pokerplayer_t *player;
// uint8_t i, j;
// pokerplayer_t *player;
float scale;
align_t align;
float gx, gy, gw, gh, x, y;
char message[128];
// align_t align;
// float gx, gy, gw, gh, x, y;
// char message[128];
// Get the default font scale size.
scale = fontGetScale(FONT_SIZE_DEFAULT);

View File

@ -7,7 +7,7 @@
#include "bet.h"
uint8_t pokerPlayerGetRemainingBetter(poker_t *poker) {
uint8_t pokerBetGetRemainingPlayer(poker_t *poker) {
uint8_t i, j;
for(i = 0; i < poker->playerCount; i++) {
@ -17,22 +17,16 @@ uint8_t pokerPlayerGetRemainingBetter(poker_t *poker) {
return 0xFF;
}
uint8_t pokerPlayerGetNextBetter(poker_t *poker, uint8_t current) {
uint8_t pokerBetGetNextPlayer(poker_t *poker) {
uint8_t i, j;
for(i = 0; i < poker->playerCount; i++) {
j = (i + current + 1) % poker->playerCount;
j = (i + poker->better + 1) % poker->playerCount;
if(pokerPlayerDoesNeedToBetThisRound(poker, j)) return j;
}
return 0xFF;
}
int32_t pokerPlayerGetCallBet(poker_t *poker, pokerplayer_t *player) {
return pokerGetCallValue(poker) - player->currentBet;
}
uint8_t pokerPlayerGetRemainingBetterCount(poker_t *poker) {
uint8_t pokerBetGetRemainingPlayerCount(poker_t *poker) {
uint8_t i, count;
count = 0;
for(i = 0; i < poker->playerCount; i++) {
@ -42,7 +36,7 @@ uint8_t pokerPlayerGetRemainingBetterCount(poker_t *poker) {
return count;
}
void pokerPlayerBetPot(
void pokerBet(
poker_t *poker, pokerpot_t *pot, uint8_t playerIndex, int32_t chips
) {
pokerplayer_t *player;
@ -54,8 +48,17 @@ void pokerPlayerBetPot(
pokerPotAddPlayer(pot, playerIndex);
}
void pokerPlayerBet(poker_t *poker, uint8_t playerIndex, int32_t chips) {
pokerPlayerBetPot(
void pokerBetForPlayer(poker_t *poker, uint8_t playerIndex, int32_t chips) {
pokerBet(
poker, poker->pots + (poker->potCount - 1), playerIndex, chips
);
}
//eh
int32_t pokerPlayerGetCallBet(poker_t *poker, pokerplayer_t *player) {
return pokerGetCallValue(poker) - player->currentBet;
}

View File

@ -10,7 +10,6 @@
#include "fuck.h"
#include "poker.h"
/**
* Returns the index of the first player that remains to bet for the current
* round.
@ -18,7 +17,7 @@
* @param poker Poker game instance.
* @return The player index of the remaining player, otherwise 0xFF.
*/
uint8_t pokerPlayerGetRemainingBetter(poker_t *poker);
uint8_t pokerBetGetRemainingPlayer(poker_t *poker);
/**
* Returns the index of the first player that remains to bet for the current
@ -28,7 +27,7 @@ uint8_t pokerPlayerGetRemainingBetter(poker_t *poker);
* @param current Current better player index.
* @return The player index of the next remaining player, otherwise 0xFF.
*/
uint8_t pokerPlayerGetNextBetter(poker_t *poker, uint8_t current);
uint8_t pokerBetGetNextPlayer(poker_t *poker);
/**
* Get the bet necessary for a specific player to make a call. This takes the
@ -47,7 +46,7 @@ int32_t pokerPlayerGetCallBet(poker_t *poker, pokerplayer_t *player);
* @param poker Poker game instance.
* @return Count of players left to bet.
*/
uint8_t pokerPlayerGetRemainingBetterCount(poker_t *poker);
uint8_t pokerBetGetRemainingPlayerCount(poker_t *poker);
/**
* Let a player bet chips into the pot.
@ -57,7 +56,7 @@ uint8_t pokerPlayerGetRemainingBetterCount(poker_t *poker);
* @param playerIndex The players' index that is betting.
* @param chips The amount of chips the player is betting.
*/
void pokerPlayerBetPot(
void pokerBet(
poker_t *poker, pokerpot_t *pot, uint8_t playerIndex, int32_t chips
);
@ -68,4 +67,4 @@ void pokerPlayerBetPot(
* @param playerIndex The players' index that is betting.
* @param chips The amount of chips the player is betting.
*/
void pokerPlayerBet(poker_t *poker, uint8_t playerIndex, int32_t chips);
void pokerBetForPlayer(poker_t *poker, uint8_t playerIndex, int32_t chips);

View File

@ -6,8 +6,8 @@
*/
#include "card.h"
void cardDeal(card_t *source, uint8_t *sourceSize, card_t *dest,
uint8_t *destSize
void cardDeal(
card_t *source, uint8_t *sourceSize, card_t *dest, uint8_t *destSize
) {
card_t card;
uint8_t i;
@ -78,7 +78,7 @@ uint8_t cardWriteDeck(card_t *hand) {
return CARD_DECK_SIZE;
}
card_t cardGetHighestCard(card_t *cards, uint8_t cardCount) {
card_t cardGetHighest(card_t *cards, uint8_t cardCount) {
uint8_t i, number, bestNumber;
card_t card, bestCard;

View File

@ -140,8 +140,8 @@ typedef uint8_t card_t;
* @param dest Array destination.
* @param destSize Pointer to the size of the destination array.
*/
void cardDeal(card_t *source, uint8_t *sourceSize, card_t *dest,
uint8_t *destSize
void cardDeal(
card_t *source, uint8_t *sourceSize, card_t *dest, uint8_t *destSize
);
/**
@ -211,4 +211,4 @@ uint8_t cardWriteDeck(card_t *hand);
* @param cardCount Length of the array.
* @return The highest card in the array.
*/
card_t cardGetHighestCard(card_t *cards, uint8_t cardCount);
card_t cardGetHighest(card_t *cards, uint8_t cardCount);

View File

@ -7,11 +7,7 @@
#include "dealer.h"
void pokerNewDealer(poker_t *poker) {
pokerSetDealer(poker, poker->playerDealer + 1);
}
void pokerSetDealer(poker_t *poker, uint8_t dealer) {
void pokerDealerSet(poker_t *poker, uint8_t dealer) {
uint8_t i, k;
pokerplayer_t *player;
bool foundDealer;
@ -38,7 +34,11 @@ void pokerSetDealer(poker_t *poker, uint8_t dealer) {
}
}
void pokerTurn(poker_t *poker, uint8_t count) {
void pokerDealerNew(poker_t *poker) {
pokerDealerSet(poker, poker->playerDealer + 1);
}
void pokerDealerTurn(poker_t *poker, uint8_t count) {
uint8_t i;
for(i = 0; i < count; i++) {
cardDeal(
@ -47,21 +47,21 @@ void pokerTurn(poker_t *poker, uint8_t count) {
}
}
void pokerBurn(poker_t *poker, uint8_t count) {
void pokerDealerBurn(poker_t *poker, uint8_t count) {
uint8_t i;
for(i = 0; i < count; i++) {
cardDeal(poker->deck, &poker->deckSize, poker->grave, &poker->graveSize);
}
}
void pokerPlayerDeal(poker_t *poker, pokerplayer_t *player, uint8_t count) {
void pokerDeal(poker_t *poker, pokerplayer_t *player, uint8_t count) {
uint8_t i;
for(i = 0; i < count; i++) {
cardDeal(poker->deck, &poker->deckSize, player->cards, &player->cardCount);
}
}
void pokerPlayerDealAll(poker_t *poker, uint8_t count) {
void pokerDealAllPlayers(poker_t *poker, uint8_t count) {
uint8_t i, j;
pokerplayer_t *player;
@ -74,7 +74,7 @@ void pokerPlayerDealAll(poker_t *poker, uint8_t count) {
continue;
}
pokerPlayerDeal(poker, player, 1);
pokerDeal(poker, player, 1);
}
}
}

View File

@ -8,14 +8,7 @@
#pragma once
#include "fuck.h"
#include "poker.h"
/**
* Cycles to the next dealer. This will also select the new small and big blind
* players.
*
* @param poker Poker game to select a new dealer for.
*/
void pokerNewDealer(poker_t *poker);
#include "card.h"
/**
* Set a next dealer. This will also select the new small and big blind players.
@ -24,7 +17,15 @@ void pokerNewDealer(poker_t *poker);
* @param poker Poker game to select a new dealer for.
* @param dealer Dealer to become the new dealer.
*/
void pokerSetDealer(poker_t *poker, uint8_t dealer);
void pokerDealerSet(poker_t *poker, uint8_t dealer);
/**
* Cycles to the next dealer. This will also select the new small and big blind
* players.
*
* @param poker Poker game to select a new dealer for.
*/
void pokerDealerNew(poker_t *poker);
/**
* Turns over cards from the deck onto the table (from the deck into the dealer
@ -33,7 +34,7 @@ void pokerSetDealer(poker_t *poker, uint8_t dealer);
* @param poker Poker game instance.
* @param count Count of cards to deal.
*/
void pokerTurn(poker_t *poker, uint8_t count);
void pokerDealerTurn(poker_t *poker, uint8_t count);
/**
* Burns a set of cards off the top of the deck into the graveyard.
@ -41,7 +42,7 @@ void pokerTurn(poker_t *poker, uint8_t count);
* @param poker Poker game instance.
* @param count Count of cards to burn.
*/
void pokerBurn(poker_t *poker, uint8_t count);
void pokerDealerBurn(poker_t *poker, uint8_t count);
/**
* Deal a card to a player.
@ -50,7 +51,7 @@ void pokerBurn(poker_t *poker, uint8_t count);
* @param player Poker player to deal to.
* @param count Count of cards to deal to the player.
*/
void pokerPlayerDeal(poker_t *poker, pokerplayer_t *player, uint8_t count);
void pokerDeal(poker_t *poker, pokerplayer_t *player, uint8_t count);
/**
* Deal card(s) to every active player.
@ -58,4 +59,4 @@ void pokerPlayerDeal(poker_t *poker, pokerplayer_t *player, uint8_t count);
* @param poker Poker game instance.
* @param count Count of cards to deal.
*/
void pokerPlayerDealAll(poker_t *poker, uint8_t count);
void pokerDealAllPlayers(poker_t *poker, uint8_t count);

View File

@ -66,12 +66,12 @@ void pokerResetBettingRound(poker_t *poker) {
// Then we check who's remaining. We do this because the default better may
// have folded already.
poker->better = pokerPlayerGetRemainingBetter(poker);
poker->better = pokerBetGetRemainingPlayer(poker);
}
void pokerTakeBlinds(poker_t *poker, int32_t small, int32_t big) {
pokerPlayerBet(poker, poker->playerSmallBlind, small);
pokerPlayerBet(poker, poker->playerBigBlind, big);
pokerBetForPlayer(poker, poker->playerSmallBlind, small);
pokerBetForPlayer(poker, poker->playerBigBlind, big);
pokerResetBettingRound(poker);
}

View File

@ -10,6 +10,7 @@
#include "../util/flags.h"
#include "../util/array.h"
#include "../util/math.h"
#include "bet.h"
#include "card.h"
#include "dealer.h"
#include "fuck.h"

View File

@ -110,7 +110,7 @@ pokerturn_t pokerTurnGetForPlayer(poker_t *poker, uint8_t playerIndex) {
(float)callBet + (float)pokerPlayerGetPotChipsSum(poker, playerIndex)
);
} else {
potOdds = 1.0f / (float)pokerPlayerGetRemainingBetterCount(poker);
potOdds = 1.0f / (float)pokerBetGetRemainingPlayerCount(poker);
}
// Now determine the expected ROI
@ -202,12 +202,12 @@ void pokerTurnAction(poker_t *poker, uint8_t playerIndex, pokerturn_t turn) {
case POKER_TURN_TYPE_BET:
case POKER_TURN_TYPE_CALL:
case POKER_TURN_TYPE_ALL_IN:
pokerPlayerBet(poker, playerIndex, turn.chips);
pokerBetForPlayer(poker, playerIndex, turn.chips);
player->timesRaised++;
break;
case POKER_TURN_TYPE_CHECK:
pokerPlayerBet(poker, playerIndex, 0);
pokerBetForPlayer(poker, playerIndex, 0);
player->timesRaised = 0;
break;

View File

@ -238,35 +238,35 @@ void test_cardWriteDeck_should_ReturnCardsWritten(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, cardWriteDeck(cards));
}
void test_cardGetHighestCard_should_ReturnTheHighestCard(void) {
void test_cardGetHighest_should_ReturnTheHighestCard(void) {
card_t cards[CARD_DECK_SIZE];
uint8_t l = cardWriteDeck(cards);
TEST_ASSERT_EQUAL(CARD_CLUBS_ACE, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_CLUBS_ACE, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_CLUBS_ACE, cardGetHighest(cards, l));
TEST_ASSERT_EQUAL(CARD_CLUBS_ACE, cardGetHighest(cards, l));
l = 3;
TEST_ASSERT_EQUAL(CARD_CLUBS_FOUR, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_CLUBS_FOUR, cardGetHighest(cards, l));
cards[0] = CARD_CLUBS_SIX;
cards[1] = CARD_HEARTS_SEVEN;
cards[2] = CARD_DIAMONDS_EIGHT;
cards[3] = CARD_SPADES_NINE;
l = 4;
TEST_ASSERT_EQUAL(CARD_SPADES_NINE, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_SPADES_NINE, cardGetHighest(cards, l));
cards[2] = CARD_DIAMONDS_TEN;
TEST_ASSERT_EQUAL(CARD_DIAMONDS_TEN, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_DIAMONDS_TEN, cardGetHighest(cards, l));
cards[2] = CARD_DIAMONDS_TEN;
TEST_ASSERT_EQUAL(CARD_DIAMONDS_TEN, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_DIAMONDS_TEN, cardGetHighest(cards, l));
cards[4] = CARD_CLUBS_TEN;
l = 5;
TEST_ASSERT_EQUAL(CARD_DIAMONDS_TEN, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_DIAMONDS_TEN, cardGetHighest(cards, l));
cards[1] = CARD_HEARTS_TEN;
TEST_ASSERT_EQUAL(CARD_HEARTS_TEN, cardGetHighestCard(cards, l));
TEST_ASSERT_EQUAL(CARD_HEARTS_TEN, cardGetHighest(cards, l));
}
int test_card() {
@ -284,7 +284,7 @@ int test_card() {
RUN_TEST(test_cardCountPairs_should_CountPairs);
RUN_TEST(test_cardWriteDeck_should_WriteCardsToArray);
RUN_TEST(test_cardWriteDeck_should_ReturnCardsWritten);
RUN_TEST(test_cardGetHighestCard_should_ReturnTheHighestCard);
RUN_TEST(test_cardGetHighest_should_ReturnTheHighestCard);
return UNITY_END();
}

View File

@ -90,7 +90,7 @@ void test_pokerResetBettingRound_should_ResetTheBettingRound(void) {
}
}
void test_pokerNewDealer_should_FindANewDealer(void) {
void test_pokerDealerNew_should_FindANewDealer(void) {
poker_t poker;
pokerInit(&poker);
@ -104,28 +104,28 @@ void test_pokerNewDealer_should_FindANewDealer(void) {
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(2, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
TEST_ASSERT_EQUAL_UINT8(2, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(4, poker.playerBigBlind);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(4, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
TEST_ASSERT_EQUAL_UINT8(4, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
}
void test_pokerSetDealer_should_SetANewSetOfPlayers(void) {
void test_pokerDealerSet_should_SetANewSetOfPlayers(void) {
poker_t poker;
pokerInit(&poker);
@ -135,38 +135,38 @@ void test_pokerSetDealer_should_SetANewSetOfPlayers(void) {
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerSetDealer(&poker, 0x00);
pokerDealerSet(&poker, 0x00);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(2, poker.playerBigBlind);
pokerSetDealer(&poker, 0x01);
pokerDealerSet(&poker, 0x01);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(2, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
pokerSetDealer(&poker, 0x02);
pokerDealerSet(&poker, 0x02);
TEST_ASSERT_EQUAL_UINT8(2, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(4, poker.playerBigBlind);
pokerSetDealer(&poker, 0x03);
pokerDealerSet(&poker, 0x03);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(4, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
pokerSetDealer(&poker, 0x04);
pokerDealerSet(&poker, 0x04);
TEST_ASSERT_EQUAL_UINT8(4, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
pokerSetDealer(&poker, 0x00);
pokerDealerSet(&poker, 0x00);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(2, poker.playerBigBlind);
}
void test_pokerSetDealer_should_SkipOutPlayers(void) {
void test_pokerDealerSet_should_SkipOutPlayers(void) {
poker_t poker;
pokerInit(&poker);
@ -176,27 +176,27 @@ void test_pokerSetDealer_should_SkipOutPlayers(void) {
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerPlayerAdd(&poker);
pokerSetDealer(&poker, 0x00);
pokerDealerSet(&poker, 0x00);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
pokerSetDealer(&poker, 0x01);
pokerDealerSet(&poker, 0x01);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerBigBlind);
pokerSetDealer(&poker, 0x02);
pokerDealerSet(&poker, 0x02);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
pokerSetDealer(&poker, 0x03);
pokerDealerSet(&poker, 0x03);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerBigBlind);
pokerSetDealer(&poker, 0x04);
pokerDealerSet(&poker, 0x04);
TEST_ASSERT_EQUAL_UINT8(0, poker.playerDealer);
TEST_ASSERT_EQUAL_UINT8(1, poker.playerSmallBlind);
TEST_ASSERT_EQUAL_UINT8(3, poker.playerBigBlind);
@ -212,7 +212,7 @@ void test_pokerTakeBlinds_should_TakeTheBlinds(void) {
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 0)->chips);
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 1)->chips);
@ -228,7 +228,7 @@ void test_pokerTakeBlinds_should_TakeTheBlinds(void) {
TEST_ASSERT_EQUAL_INT32(800, (poker.players + 3)->chips);
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 4)->chips);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
pokerTakeBlinds(&poker, 100, 200);
TEST_ASSERT_EQUAL_INT32(1000, (poker.players + 0)->chips);
@ -342,19 +342,19 @@ void test_pokerPlayerAdd_should_ResetThePlayer(void) {
TEST_ASSERT_EQUAL_UINT8(POKER_PLAYER_STATE_OUT, player->state);
}
void test_pokerTurn_should_TurnCardsFromTheDeck(void) {
void test_pokerDealerTurn_should_TurnCardsFromTheDeck(void) {
poker_t poker;
pokerInit(&poker);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(0, poker.communitySize);
pokerTurn(&poker, 1);
pokerDealerTurn(&poker, 1);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 1, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(1, poker.communitySize);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, poker.community[0]);
pokerTurn(&poker, 3);
pokerDealerTurn(&poker, 3);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 4, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(4, poker.communitySize);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, poker.community[1]);
@ -362,19 +362,19 @@ void test_pokerTurn_should_TurnCardsFromTheDeck(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.community[3]);
}
void test_pokerBurn_should_SendCardsToTheGrave(void) {
void test_pokerDealerBurn_should_SendCardsToTheGrave(void) {
poker_t poker;
pokerInit(&poker);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(0, poker.graveSize);
pokerBurn(&poker, 1);
pokerDealerBurn(&poker, 1);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 1, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(1, poker.graveSize);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, poker.grave[0]);
pokerBurn(&poker, 3);
pokerDealerBurn(&poker, 3);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 4, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(4, poker.graveSize);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, poker.grave[1]);
@ -393,15 +393,15 @@ void test_pokerGetCallValue_should_CalculateTheCallValue(void) {
pokerPlayerChipsAdd(poker.players + second, 10000);
TEST_ASSERT_EQUAL_INT32(0, pokerGetCallValue(&poker));
pokerPlayerBet(&poker, first, 100);
pokerBetForPlayer(&poker, first, 100);
TEST_ASSERT_EQUAL_INT32(100, pokerGetCallValue(&poker));
pokerPlayerBet(&poker, second, 150);
pokerBetForPlayer(&poker, second, 150);
TEST_ASSERT_EQUAL_INT32(150, pokerGetCallValue(&poker));
pokerPotAdd(&poker);
TEST_ASSERT_EQUAL_INT32(150, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL_INT32(0, poker.pots[1].chips);
pokerPlayerBet(&poker, second, 50);
pokerBetForPlayer(&poker, second, 50);
TEST_ASSERT_EQUAL_INT32(200, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL_INT32(50, poker.pots[1].chips);
}
@ -413,15 +413,15 @@ void test_pokerGetCallValue_should_SkipOutPlayers(void) {
i = pokerPlayerAdd(&poker);
pokerPlayerChipsAdd(poker.players + i, 10000);
pokerPlayerBet(&poker, i, 300);
pokerBetForPlayer(&poker, i, 300);
i = pokerPlayerAdd(&poker);
pokerPlayerChipsAdd(poker.players + i, 10000);
pokerPlayerBet(&poker, i, 500);
pokerBetForPlayer(&poker, i, 500);
i = pokerPlayerAdd(&poker);
pokerPlayerChipsAdd(poker.players + i, 10000);
pokerPlayerBet(&poker, i, 200);
pokerBetForPlayer(&poker, i, 200);
TEST_ASSERT_EQUAL_INT32(500, pokerGetCallValue(&poker));
poker.players[1].state |= POKER_PLAYER_STATE_OUT;
@ -430,7 +430,7 @@ void test_pokerGetCallValue_should_SkipOutPlayers(void) {
TEST_ASSERT_EQUAL_INT32(200, pokerGetCallValue(&poker));
}
void test_pokerPlayerDeal_should_DealCardsToThePlayer(void) {
void test_pokerDeal_should_DealCardsToThePlayer(void) {
poker_t poker;
uint8_t playerIndex;
pokerplayer_t *player;
@ -443,12 +443,12 @@ void test_pokerPlayerDeal_should_DealCardsToThePlayer(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(0, player->cardCount);
pokerPlayerDeal(&poker, player, 0x01);
pokerDeal(&poker, player, 0x01);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 1, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(1, player->cardCount);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, player->cards[0]);
pokerPlayerDeal(&poker, player, 0x01);
pokerDeal(&poker, player, 0x01);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 2, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(2, player->cardCount);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, player->cards[1]);
@ -487,7 +487,7 @@ void test_pokerPlayerChipsAdd_should_TurnOutStateOff(void) {
TEST_ASSERT_BITS_LOW(POKER_PLAYER_STATE_OUT, player->state);
}
void test_pokerPlayerDealAll_should_DealCardsToEveryone(void) {
void test_pokerDealAllPlayers_should_DealCardsToEveryone(void) {
poker_t poker;
pokerInit(&poker);
@ -500,7 +500,7 @@ void test_pokerPlayerDealAll_should_DealCardsToEveryone(void) {
TEST_ASSERT_EQUAL_UINT8(0, poker.players[1].cardCount);
TEST_ASSERT_EQUAL_UINT8(0, poker.players[2].cardCount);
pokerPlayerDealAll(&poker, 1);
pokerDealAllPlayers(&poker, 1);
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE - 3, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(1, poker.players[0].cardCount);
TEST_ASSERT_EQUAL_UINT8(1, poker.players[1].cardCount);
@ -511,7 +511,7 @@ void test_pokerPlayerDealAll_should_DealCardsToEveryone(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, poker.players[2].cards[0]);
}
void test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone(void) {
void test_pokerDealAllPlayers_should_DealMultipleCardsToEveryone(void) {
poker_t poker;
pokerInit(&poker);
@ -522,7 +522,7 @@ void test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
pokerPlayerDealAll(&poker, 0x02);
pokerDealAllPlayers(&poker, 0x02);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[0].cardCount);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[1].cardCount);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[2].cardCount);
@ -535,7 +535,7 @@ void test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_NINE, poker.players[2].cards[1]);
}
void test_pokerPlayerDealAll_should_NotDealToOutPlayers(void) {
void test_pokerDealAllPlayers_should_NotDealToOutPlayers(void) {
poker_t poker;
pokerInit(&poker);
@ -546,7 +546,7 @@ void test_pokerPlayerDealAll_should_NotDealToOutPlayers(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_DECK_SIZE, poker.deckSize);
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
pokerPlayerDealAll(&poker, 0x02);
pokerDealAllPlayers(&poker, 0x02);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[0].cardCount);
TEST_ASSERT_EQUAL_UINT8(0, poker.players[1].cardCount);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[2].cardCount);
@ -557,7 +557,7 @@ void test_pokerPlayerDealAll_should_NotDealToOutPlayers(void) {
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.players[2].cards[1]);
}
void test_pokerPlayerDealAll_should_NotDealToFoldedPlayers(void) {
void test_pokerDealAllPlayers_should_NotDealToFoldedPlayers(void) {
poker_t poker;
pokerInit(&poker);
@ -566,7 +566,7 @@ void test_pokerPlayerDealAll_should_NotDealToFoldedPlayers(void) {
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 100);
poker.players[0].state |= POKER_PLAYER_STATE_FOLDED;
pokerPlayerDealAll(&poker, 2);
pokerDealAllPlayers(&poker, 2);
TEST_ASSERT_EQUAL_UINT8(0, poker.players[0].cardCount);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[1].cardCount);
TEST_ASSERT_EQUAL_UINT8(2, poker.players[2].cardCount);
@ -588,15 +588,15 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_CheckCallValue(void) {
pokerPlayerChipsAdd(poker.players + first, 10000);
pokerPlayerChipsAdd(poker.players + second, 10000);
pokerPlayerBet(&poker, first, 100);
pokerBetForPlayer(&poker, first, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
pokerPlayerBet(&poker, second, 200);
pokerBetForPlayer(&poker, second, 200);
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
pokerPlayerBet(&poker, first, 100);
pokerBetForPlayer(&poker, first, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
}
@ -613,11 +613,11 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_CheckWhetherHasBetYet(void) {
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
pokerPlayerBet(&poker, first, 100);
pokerBetForPlayer(&poker, first, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
pokerPlayerBet(&poker, second, 100);
pokerBetForPlayer(&poker, second, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
}
@ -634,7 +634,7 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_IgnoreFoldedPlayers(void) {
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
pokerPlayerBet(&poker, first, 100);
pokerBetForPlayer(&poker, first, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(true, pokerPlayerDoesNeedToBetThisRound(&poker, second));
@ -642,12 +642,12 @@ void test_pokerPlayerDoesNeedToBetThisRound_should_IgnoreFoldedPlayers(void) {
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
pokerPlayerBet(&poker, first, 100);
pokerBetForPlayer(&poker, first, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, first));
TEST_ASSERT_EQUAL(false, pokerPlayerDoesNeedToBetThisRound(&poker, second));
}
void test_pokerPlayerGetRemainingBetter_should_ReturnRemainingBetters(void) {
void test_pokerBetGetRemainingPlayer_should_ReturnRemainingBetters(void) {
poker_t poker;
uint8_t p0, p1, p2, p3, p4;
pokerInit(&poker);
@ -664,46 +664,45 @@ void test_pokerPlayerGetRemainingBetter_should_ReturnRemainingBetters(void) {
pokerPlayerChipsAdd(poker.players + p2, 10000);
pokerPlayerChipsAdd(poker.players + p3, 10000);
pokerPlayerChipsAdd(poker.players + p4, 10000);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
// Blind + 1
TEST_ASSERT_EQUAL(0x04, pokerPlayerGetRemainingBetter(&poker));
TEST_ASSERT_EQUAL(0x04, pokerBetGetRemainingPlayer(&poker));
// Blind + 2
pokerPlayerBet(&poker, 0x04, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL(0x00, pokerPlayerGetRemainingBetter(&poker));
pokerBetForPlayer(&poker, 0x04, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL(0x00, pokerBetGetRemainingPlayer(&poker));
// Blind + 3
pokerPlayerBet(&poker, 0x00, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL(0x01, pokerPlayerGetRemainingBetter(&poker));
pokerBetForPlayer(&poker, 0x00, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL(0x01, pokerBetGetRemainingPlayer(&poker));
// Blind + 4 / Small Blind
pokerPlayerBet(&poker, 0x01, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL(0x02, pokerPlayerGetRemainingBetter(&poker));
pokerBetForPlayer(&poker, 0x01, pokerGetCallValue(&poker));
TEST_ASSERT_EQUAL(0x02, pokerBetGetRemainingPlayer(&poker));
// Blind + 5 / Big Blind
pokerPlayerBet(
pokerBetForPlayer(
&poker, 0x02, pokerGetCallValue(&poker) - poker.players[0x01].currentBet
);
TEST_ASSERT_EQUAL(0x03, pokerPlayerGetRemainingBetter(&poker));
TEST_ASSERT_EQUAL(0x03, pokerBetGetRemainingPlayer(&poker));
// No remaining players.
pokerPlayerBet(&poker, 0x03, 0);
TEST_ASSERT_EQUAL(0xFF, pokerPlayerGetRemainingBetter(&poker));
pokerBetForPlayer(&poker, 0x03, 0);
TEST_ASSERT_EQUAL(0xFF, pokerBetGetRemainingPlayer(&poker));
// Raise
pokerPlayerBet(&poker, 0x03, 100);
TEST_ASSERT_EQUAL(0x04, pokerPlayerGetRemainingBetter(&poker));
pokerBetForPlayer(&poker, 0x03, 100);
TEST_ASSERT_EQUAL(0x04, pokerBetGetRemainingPlayer(&poker));
// Raise
pokerPlayerBet(&poker, 0x04, 100);
TEST_ASSERT_EQUAL(0x00, pokerPlayerGetRemainingBetter(&poker));
pokerBetForPlayer(&poker, 0x04, 100);
TEST_ASSERT_EQUAL(0x00, pokerBetGetRemainingPlayer(&poker));
}
void test_pokerPlayerGetNextBetter_should_GetTheNextBetter(void) {
void test_pokerBetGetNextPlayer_should_GetTheNextBetter(void) {
poker_t poker;
uint8_t p0, p1, p2, p3, p4;
uint8_t better;
pokerInit(&poker);
p0 = pokerPlayerAdd(&poker);
@ -717,52 +716,54 @@ void test_pokerPlayerGetNextBetter_should_GetTheNextBetter(void) {
pokerPlayerChipsAdd(poker.players + p2, 10000);
pokerPlayerChipsAdd(poker.players + p3, 10000);
pokerPlayerChipsAdd(poker.players + p4, 10000);
pokerNewDealer(&poker);
pokerDealerNew(&poker);
// Start at blind+1
better = poker.playerBigBlind;
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x04, better);
poker.better = poker.playerBigBlind;
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x04, poker.better);
// Blind+2
pokerPlayerBet(&poker, better, pokerGetCallValue(&poker));
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x00, better);
pokerBetForPlayer(&poker, poker.better, pokerGetCallValue(&poker));
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x00, poker.better);
// BLind+3
pokerPlayerBet(&poker, better, pokerGetCallValue(&poker));
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x01, better);
pokerBetForPlayer(&poker, poker.better, pokerGetCallValue(&poker));
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x01, poker.better);
// Dealer
pokerPlayerBet(&poker, better, pokerGetCallValue(&poker));
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x02, better);
pokerBetForPlayer(&poker, poker.better, pokerGetCallValue(&poker));
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x02, poker.better);
// Small blind
pokerPlayerBet(
&poker, better, pokerGetCallValue(&poker) - poker.players[0x02].currentBet
pokerBetForPlayer(
&poker, poker.better,
pokerGetCallValue(&poker) - poker.players[0x02].currentBet
);
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x03, better);
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x03, poker.better);
// Big Blind
pokerPlayerBet(
&poker, better, pokerGetCallValue(&poker) - poker.players[0x03].currentBet
pokerBetForPlayer(
&poker, poker.better,
pokerGetCallValue(&poker) - poker.players[0x03].currentBet
);
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0xFF, better);
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0xFF, poker.better);
// Raise
better = poker.playerBigBlind;
pokerPlayerBet(&poker, better, 100);
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x04, better);
poker.better = poker.playerBigBlind;
pokerBetForPlayer(&poker, poker.better, 100);
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x04, poker.better);
// Raise
pokerPlayerBet(&poker, better, 100);
better = pokerPlayerGetNextBetter(&poker, better);
TEST_ASSERT_EQUAL_UINT8(0x00, better);
pokerBetForPlayer(&poker, poker.better, 100);
poker.better = pokerBetGetNextPlayer(&poker);
TEST_ASSERT_EQUAL_UINT8(0x00, poker.better);
}
void test_pokerPlayerGetCallBet_should_GetCallBet(void) {
@ -774,17 +775,17 @@ void test_pokerPlayerGetCallBet_should_GetCallBet(void) {
p1 = pokerPlayerAdd(&poker);
p2 = pokerPlayerAdd(&poker);
pokerPlayerBet(&poker, p0, 100);
pokerBetForPlayer(&poker, p0, 100);
TEST_ASSERT_EQUAL_INT32(0, pokerPlayerGetCallBet(&poker,poker.players+p0));
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p1));
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p2));
pokerPlayerBet(&poker, p1, 200);
pokerBetForPlayer(&poker, p1, 200);
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p0));
TEST_ASSERT_EQUAL_INT32(0, pokerPlayerGetCallBet(&poker,poker.players+p1));
TEST_ASSERT_EQUAL_INT32(200, pokerPlayerGetCallBet(&poker,poker.players+p2));
pokerPlayerBet(&poker, p2, 300);
pokerBetForPlayer(&poker, p2, 300);
TEST_ASSERT_EQUAL_INT32(200, pokerPlayerGetCallBet(&poker,poker.players+p0));
TEST_ASSERT_EQUAL_INT32(100, pokerPlayerGetCallBet(&poker,poker.players+p1));
TEST_ASSERT_EQUAL_INT32(0, pokerPlayerGetCallBet(&poker,poker.players+p2));
@ -816,7 +817,7 @@ void test_pokerInRoundGetCount_should_ReturnCountOfPlayersInRound(void) {
TEST_ASSERT_EQUAL_UINT8(0x00, pokerInRoundGetCount(&poker));
}
void test_pokerPlayerGetRemainintBetterCount_should_ReturnCountNeedsToBet(void){
void test_pokerBetGetRemainingPlayerCount_should_ReturnCountNeedsToBet(void){
poker_t poker;
uint8_t p0, p1, p2;
@ -825,24 +826,24 @@ void test_pokerPlayerGetRemainintBetterCount_should_ReturnCountNeedsToBet(void){
p1 = pokerPlayerAdd(&poker);
p2 = pokerPlayerAdd(&poker);
TEST_ASSERT_EQUAL_UINT8(0x00, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x00, pokerBetGetRemainingPlayerCount(&poker));
pokerPlayerChipsAdd(poker.players + p0, 1000);
TEST_ASSERT_EQUAL_UINT8(0x01, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x01, pokerBetGetRemainingPlayerCount(&poker));
pokerPlayerChipsAdd(poker.players + p2, 1000);
TEST_ASSERT_EQUAL_UINT8(0x02, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x02, pokerBetGetRemainingPlayerCount(&poker));
pokerPlayerChipsAdd(poker.players + p1, 1000);
TEST_ASSERT_EQUAL_UINT8(0x03, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x03, pokerBetGetRemainingPlayerCount(&poker));
poker.players[0].state |= POKER_PLAYER_STATE_FOLDED;
TEST_ASSERT_EQUAL_UINT8(0x02, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x02, pokerBetGetRemainingPlayerCount(&poker));
poker.players[1].state |= POKER_PLAYER_STATE_HAS_BET_THIS_ROUND;
TEST_ASSERT_EQUAL_UINT8(0x01, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x01, pokerBetGetRemainingPlayerCount(&poker));
poker.players[2].chips = 0;
TEST_ASSERT_EQUAL_UINT8(0x00, pokerPlayerGetRemainingBetterCount(&poker));
TEST_ASSERT_EQUAL_UINT8(0x00, pokerBetGetRemainingPlayerCount(&poker));
}
void test_pokerPlayerBetPot_should_AddChipsToThePot(void) {
void test_pokerBet_should_AddChipsToThePot(void) {
poker_t poker;
pokerpot_t *pot;
pokerplayer_t *player;
@ -857,12 +858,12 @@ void test_pokerPlayerBetPot_should_AddChipsToThePot(void) {
TEST_ASSERT_EQUAL_INT32(0, pot->chips);
TEST_ASSERT_EQUAL_INT32(1000, player->chips);
pokerPlayerBetPot(&poker, pot, i, 100);
pokerBet(&poker, pot, i, 100);
TEST_ASSERT_EQUAL_INT32(100, pot->chips);
TEST_ASSERT_EQUAL_INT32(900, player->chips);
}
void test_pokerPlayerBetPot_should_UpdatePlayerState(void) {
void test_pokerBet_should_UpdatePlayerState(void) {
poker_t poker;
uint8_t i;
pokerplayer_t *player;
@ -875,15 +876,15 @@ void test_pokerPlayerBetPot_should_UpdatePlayerState(void) {
TEST_ASSERT_BITS_LOW(POKER_PLAYER_STATE_HAS_BET_THIS_ROUND, player->state);
TEST_ASSERT_EQUAL_INT32(0, player->currentBet);
pokerPlayerBetPot(&poker, poker.pots, i, 100);
pokerBet(&poker, poker.pots, i, 100);
TEST_ASSERT_BITS_HIGH(POKER_PLAYER_STATE_HAS_BET_THIS_ROUND, player->state);
TEST_ASSERT_EQUAL_INT32(100, player->currentBet);
pokerPlayerBetPot(&poker, poker.pots, i, 250);
pokerBet(&poker, poker.pots, i, 250);
TEST_ASSERT_EQUAL_INT32(350, player->currentBet);
}
void test_pokerPlayerBet_should_BetToTheActivePot(void) {
void test_pokerBetForPlayer_should_BetToTheActivePot(void) {
poker_t poker;
pokerpot_t *pot;
uint8_t i, j;
@ -894,11 +895,11 @@ void test_pokerPlayerBet_should_BetToTheActivePot(void) {
pot = poker.pots;
TEST_ASSERT_EQUAL_INT32(0, pot->chips);
pokerPlayerBet(&poker, i, 100);
pokerBetForPlayer(&poker, i, 100);
TEST_ASSERT_EQUAL_INT32(100, pot->chips);
j = pokerPotAdd(&poker);
pokerPlayerBet(&poker, i, 50);
pokerBetForPlayer(&poker, i, 50);
TEST_ASSERT_EQUAL_INT32(100, pot->chips);
pot = poker.pots + j;
TEST_ASSERT_EQUAL_INT32(50, pot->chips);
@ -916,27 +917,27 @@ void test_pokerPlayerCanCheck_should_CompareThePotAndPlayerBet(void) {
pokerPlayerChipsAdd(poker.players + p1, 1000);
pokerPlayerChipsAdd(poker.players + p2, 1000);
pokerPlayerBet(&poker, p0, 100);
pokerBetForPlayer(&poker, p0, 100);
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p0));
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p1));
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p2));
pokerPlayerBet(&poker, p1, 100);
pokerBetForPlayer(&poker, p1, 100);
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p0));
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p1));
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p2));
pokerPlayerBet(&poker, p2, 100);
pokerBetForPlayer(&poker, p2, 100);
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p0));
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p1));
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p2));
pokerPlayerBet(&poker, p2, 100);
pokerBetForPlayer(&poker, p2, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p0));
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p1));
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p2));
pokerPlayerBet(&poker, p1, 100);
pokerBetForPlayer(&poker, p1, 100);
TEST_ASSERT_EQUAL(false, pokerPlayerCanCheck(&poker, poker.players+p0));
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p1));
TEST_ASSERT_EQUAL(true, pokerPlayerCanCheck(&poker, poker.players+p2));
@ -992,15 +993,15 @@ void test_pokerTurnBet_should_ReturnACallAction(void) {
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerPlayerChipsAdd(poker.players + pokerPlayerAdd(&poker), 1000);
pokerPlayerBet(&poker, 0, 300);
pokerPlayerBet(&poker, 1, 500);
pokerBetForPlayer(&poker, 0, 300);
pokerBetForPlayer(&poker, 1, 500);
turn = pokerTurnBet(&poker, 0x00, 200);
TEST_ASSERT_EQUAL_INT32(200, turn.chips);
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_CALL, turn.type);
TEST_ASSERT_EQUAL_FLOAT(1.0f, turn.confidence);
pokerPlayerBet(&poker, 0, 300);
pokerBetForPlayer(&poker, 0, 300);
turn = pokerTurnBet(&poker, 0x01, 100);
TEST_ASSERT_EQUAL_INT32(100, turn.chips);
TEST_ASSERT_EQUAL_UINT8(POKER_TURN_TYPE_CALL, turn.type);
@ -1034,11 +1035,11 @@ void test_pokerHandGetFull_should_ReturnTheFullHand(void) {
i = pokerPlayerAdd(&poker);
player = poker.players + i;
pokerPlayerDeal(&poker, player, POKER_PLAYER_HAND_SIZE_MAX);
pokerDeal(&poker, player, POKER_PLAYER_HAND_SIZE_MAX);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_ACE, player->cards[0]);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_KING, player->cards[1]);
pokerTurn(&poker, POKER_COMMUNITY_SIZE_MAX);
pokerDealerTurn(&poker, POKER_COMMUNITY_SIZE_MAX);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_QUEEN, poker.community[0]);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_JACK, poker.community[1]);
TEST_ASSERT_EQUAL_UINT8(CARD_SPADES_TEN, poker.community[2]);
@ -1593,35 +1594,33 @@ int test_poker() {
RUN_TEST(test_pokerPotAdd_should_AddAPot);
RUN_TEST(test_pokerPotAdd_should_ResetThePot);
RUN_TEST(test_pokerPotHasPlayer_should_DetermineIfPlayerInThePot);
RUN_TEST(test_pokerNewDealer_should_FindANewDealer);
RUN_TEST(test_pokerSetDealer_should_SetANewSetOfPlayers);
RUN_TEST(test_pokerSetDealer_should_SkipOutPlayers);
RUN_TEST(test_pokerDealerNew_should_FindANewDealer);
RUN_TEST(test_pokerDealerSet_should_SetANewSetOfPlayers);
RUN_TEST(test_pokerDealerSet_should_SkipOutPlayers);
RUN_TEST(test_pokerTakeBlinds_should_TakeTheBlinds);
RUN_TEST(test_pokerPotAddPlayer_should_AddAPlayer);
RUN_TEST(test_pokerPlayerAdd_should_ResetThePlayer);
RUN_TEST(test_pokerTurn_should_TurnCardsFromTheDeck);
RUN_TEST(test_pokerBurn_should_SendCardsToTheGrave);
RUN_TEST(test_pokerDealerTurn_should_TurnCardsFromTheDeck);
RUN_TEST(test_pokerDealerBurn_should_SendCardsToTheGrave);
RUN_TEST(test_pokerGetCallValue_should_CalculateTheCallValue);
RUN_TEST(test_pokerPlayerDeal_should_DealCardsToThePlayer);
RUN_TEST(test_pokerDeal_should_DealCardsToThePlayer);
RUN_TEST(test_pokerPlayerChipsAdd_should_AddChipsToThePlayer);
RUN_TEST(test_pokerPlayerChipsAdd_should_TurnOutStateOff);
RUN_TEST(test_pokerPlayerDealAll_should_DealCardsToEveryone);
RUN_TEST(test_pokerPlayerDealAll_should_DealMultipleCardsToEveryone);
RUN_TEST(test_pokerPlayerDealAll_should_NotDealToOutPlayers);
RUN_TEST(test_pokerPlayerDealAll_should_NotDealToFoldedPlayers);
RUN_TEST(test_pokerDealAllPlayers_should_DealCardsToEveryone);
RUN_TEST(test_pokerDealAllPlayers_should_DealMultipleCardsToEveryone);
RUN_TEST(test_pokerDealAllPlayers_should_NotDealToOutPlayers);
RUN_TEST(test_pokerDealAllPlayers_should_NotDealToFoldedPlayers);
RUN_TEST(test_pokerPlayerDoesNeedToBetThisRound_should_CheckCallValue);
RUN_TEST(test_pokerPlayerDoesNeedToBetThisRound_should_CheckWhetherHasBetYet);
RUN_TEST(test_pokerPlayerDoesNeedToBetThisRound_should_IgnoreFoldedPlayers);
RUN_TEST(test_pokerPlayerGetRemainingBetter_should_ReturnRemainingBetters);
RUN_TEST(test_pokerPlayerGetNextBetter_should_GetTheNextBetter);
RUN_TEST(test_pokerBetGetRemainingPlayer_should_ReturnRemainingBetters);
RUN_TEST(test_pokerBetGetNextPlayer_should_GetTheNextBetter);
RUN_TEST(test_pokerPlayerGetCallBet_should_GetCallBet);
RUN_TEST(test_pokerInRoundGetCount_should_ReturnCountOfPlayersInRound);
RUN_TEST(
test_pokerPlayerGetRemainintBetterCount_should_ReturnCountNeedsToBet
);
RUN_TEST(test_pokerPlayerBetPot_should_AddChipsToThePot);
RUN_TEST(test_pokerPlayerBetPot_should_UpdatePlayerState);
RUN_TEST(test_pokerPlayerBet_should_BetToTheActivePot);
RUN_TEST(test_pokerBetGetRemainingPlayerCount_should_ReturnCountNeedsToBet);
RUN_TEST(test_pokerBet_should_AddChipsToThePot);
RUN_TEST(test_pokerBet_should_UpdatePlayerState);
RUN_TEST(test_pokerBetForPlayer_should_BetToTheActivePot);
RUN_TEST(test_pokerPlayerCanCheck_should_CompareThePotAndPlayerBet);
RUN_TEST(test_pokerTurnFold_should_ReturnAFoldAction);
RUN_TEST(test_pokerTurnBet_should_ReturnACheckAction);