From a09e74ce7678c6e59cfcb5d13672f0d49a0c9ecc Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 11 Oct 2021 21:24:43 -0700 Subject: [PATCH] Improving tests. --- client/glfwclient/glfwclient.h | 6 ------ src/game/poker/actions/flop.c | 10 ++++------ src/game/poker/actions/flop.h | 2 +- src/game/poker/actions/round.h | 1 + src/poker/poker.c | 1 + test/poker/poker.c | 2 +- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/client/glfwclient/glfwclient.h b/client/glfwclient/glfwclient.h index c5f7baf6..a5694e2a 100644 --- a/client/glfwclient/glfwclient.h +++ b/client/glfwclient/glfwclient.h @@ -17,12 +17,6 @@ #define GLFW_PLATFORM_INPUT_MOUSE_X (inputsource_t)0xFF #define GLFW_PLATFORM_INPUT_MOUSE_Y (inputsource_t)0xFE -/** The current running game state. */ -extern game_t *GAME_STATE; - -/** The GLFW Window Context Pointer */ -extern GLFWwindow *window; - /** * Entry of the program * @return 0 if success, anything else for failure. diff --git a/src/game/poker/actions/flop.c b/src/game/poker/actions/flop.c index 8e9174da..c1debf37 100644 --- a/src/game/poker/actions/flop.c +++ b/src/game/poker/actions/flop.c @@ -13,7 +13,6 @@ void _pokerGameActionFlopOnStart( pokergame_t *game = (pokergame_t *)action->data; pokerdiscussiondata_t discussion; queueaction_t *next; - uint8_t nextBetter; // Prep convo discussion.poker = game; @@ -23,7 +22,8 @@ void _pokerGameActionFlopOnStart( // Add the actual flop action. next = pokerActionNextFlopAdd(queue, &game->poker); - // Reset all the players + // Reset all the players + pokerResetBettingRound(&game->poker); // Is there any flop "left to do" ? if(next != NULL) { @@ -31,14 +31,12 @@ void _pokerGameActionFlopOnStart( discussion.reason = POKER_DISCUSSION_REASON_FLOP; pokerDiscussionQueue(&discussion); - nextBetter = pokerPlayerGetRemainingBetter(&game->poker); - // 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) { // Begin betting. - game->poker.better = nextBetter; - pokerGameActionLookAdd(game, nextBetter); + game->poker.better = pokerPlayerGetRemainingBetter(&game->poker); + pokerGameActionLookAdd(game, game->poker.better); pokerGameActionBetAdd(game); } else { //No actual players to bet, so add the following flop instead. diff --git a/src/game/poker/actions/flop.h b/src/game/poker/actions/flop.h index 77b1d945..b424802e 100644 --- a/src/game/poker/actions/flop.h +++ b/src/game/poker/actions/flop.h @@ -12,7 +12,7 @@ #include "restack.h" #include "winner.h" #include "bet.h" -#include "../../poker/actions/flop.h" +#include "../../../poker/actions/flop.h" /** Callback that is fired when the flop action starts */ void _pokerGameActionFlopOnStart( diff --git a/src/game/poker/actions/round.h b/src/game/poker/actions/round.h index fd198bf3..3f20eb7e 100644 --- a/src/game/poker/actions/round.h +++ b/src/game/poker/actions/round.h @@ -6,6 +6,7 @@ #pragma once #include "../../../libs.h" #include "../../../poker/actions/blinds.h" +#include "../../../poker/actions/deal.h" #include "action.h" #include "../pokerdiscussion.h" #include "bet.h" diff --git a/src/poker/poker.c b/src/poker/poker.c index ec2fc8e6..afe2f163 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -160,6 +160,7 @@ uint8_t pokerPlayerAdd(poker_t *poker) { player->chips = 0; player->currentBet = 0; player->state = POKER_PLAYER_STATE_OUT; + player->timesRaised = 0; return i; } diff --git a/test/poker/poker.c b/test/poker/poker.c index b4e29854..3b746dbd 100644 --- a/test/poker/poker.c +++ b/test/poker/poker.c @@ -288,7 +288,7 @@ void test_pokerPlayerAdd_should_ResetThePlayer(void) { TEST_ASSERT_EQUAL_INT32(0, player->chips); TEST_ASSERT_EQUAL_INT32(0, player->currentBet); TEST_ASSERT_EQUAL_UINT8(0, player->cardCount); - TEST_ASSERT_EQUAL_UINT8(0, poker.players[i].timesRaised); + TEST_ASSERT_EQUAL_UINT8(0, player->timesRaised); TEST_ASSERT_EQUAL_UINT8(POKER_PLAYER_STATE_OUT, player->state); }