Even more refactoring

This commit is contained in:
2021-09-19 20:50:35 -07:00
parent 3ed24da3b6
commit e87e04decf
22 changed files with 120 additions and 114 deletions

View File

@ -27,7 +27,7 @@ int32_t main() {
// Load GLAD // Load GLAD
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glfwSwapInterval(0); glfwSwapInterval(0);
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
// Setup window listeners // Setup window listeners
glfwSetWindowSizeCallback(window, &glfwOnResize); glfwSetWindowSizeCallback(window, &glfwOnResize);

View File

@ -51,7 +51,7 @@ void renderListRenderPass(
item->onRender(list, renderPass, engine, i); item->onRender(list, renderPass, engine, i);
} }
frameBufferUnbind(&engine->render, false); frameBufferUnbind(engine->render.width, engine->render.height, false);
} }
void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader) { void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader) {
@ -79,5 +79,5 @@ void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader) {
} }
// Unbind the framebuffer. // Unbind the framebuffer.
frameBufferUnbind(&engine->render, false); frameBufferUnbind(engine->render.width, engine->render.height, false);
} }

View File

@ -7,11 +7,11 @@
#pragma once #pragma once
#include "../libs.h" #include "../libs.h"
#include "../game/game.h"
#include "framebuffer.h" #include "framebuffer.h"
#include "primitive.h" #include "primitive.h"
#include "shader.h" #include "shader.h"
#include "camera.h" #include "camera.h"
#include "../engine/engine.h"
#include "primitives/quad.h" #include "primitives/quad.h"
#include "../util/dynarray.h" #include "../util/dynarray.h"

View File

@ -10,7 +10,7 @@
#include "../game.h" #include "../game.h"
typedef struct { typedef struct {
int32_t INeedSomePropertyToStopCompilerComplaining; engine_t engine;
} dawngame_t; } dawngame_t;
/** /**

View File

@ -8,28 +8,18 @@
#include "../engine/engine.h" #include "../engine/engine.h"
#include "../locale/language.h" #include "../locale/language.h"
/** Describes the current game */
#if SETTING_GAME == SETTING_GAME_POKER #if SETTING_GAME == SETTING_GAME_POKER
#include "poker/pokergame.h" #include "poker/pokergame.h"
typedef pokergame_t game_t;
#elif SETTING_GAME == SETTING_GAME_DAWN #elif SETTING_GAME == SETTING_GAME_DAWN
#include "dawn/dawngame.h" #include "dawn/dawngame.h"
typedef dawngame_t game_t;
#elif SETTING_GAME == SETTING_GAME_SANDBOX #elif SETTING_GAME == SETTING_GAME_SANDBOX
#include "sandbox/sandboxscene.h" #include "sandbox/sandboxscene.h"
typedef sandboxscene_t game_t;
#endif #endif
/** Describes the current game */
typedef struct {
/** Engine for the game */
engine_t engine;
#if SETTING_GAME == SETTING_GAME_POKER
pokergame_t pokerGame;
#elif SETTING_GAME == SETTING_GAME_DAWN
dawngame_t dawnGame;
#elif SETTING_GAME == SETTING_GAME_SANDBOX
sandboxscene_t sandboxScene;
#endif
} game_t;
/** /**
* Initialize the game context. * Initialize the game context.
* *

View File

@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "../../../libs.h"
#include "action.h" #include "action.h"
#include "../../../libs.h"
#include "../../../display/animation/queue.h" #include "../../../display/animation/queue.h"
#include "../pokerworld.h" #include "../pokerworld.h"

View File

@ -10,9 +10,7 @@
#include "../../../vn/conversation/talk.h" #include "../../../vn/conversation/talk.h"
#include "../../../display/animation/queue.h" #include "../../../display/animation/queue.h"
#include "../../../poker/actions/match.h" #include "../../../poker/actions/match.h"
#include "../discussion/pokerdiscussion.h"
#include "action.h" #include "action.h"
#include "round.h"
/** Callback fired when the game action first starts */ /** Callback fired when the game action first starts */
void _pokerGameActionStartOnStart( void _pokerGameActionStartOnStart(

View File

@ -12,10 +12,9 @@
#include "../../vn/conversation/talk.h" #include "../../vn/conversation/talk.h"
#include "../../vn/vnscene.h" #include "../../vn/vnscene.h"
#include "../../util/array.h" #include "../../util/array.h"
#include "actions/start.h"
#include "ui/pokerui.h" #include "ui/pokerui.h"
#include "pokerworld.h" #include "pokerworld.h"
#include "actions/start.h" #include "pokergameaction.h"
#define POKER_GAME_SEAT_COUNT 8 #define POKER_GAME_SEAT_COUNT 8
#define POKER_GAME_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2)) #define POKER_GAME_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2))
@ -40,6 +39,9 @@
#define POKER_GAME_PENNY_FACE_HEIGHT 280 #define POKER_GAME_PENNY_FACE_HEIGHT 280
typedef struct { typedef struct {
/** Game Engine Instance */
engine_t engine;
/** Poker Game State */ /** Poker Game State */
poker_t poker; poker_t poker;
@ -57,9 +59,6 @@ typedef struct {
/** Data for the actions */ /** Data for the actions */
pokergameactiondata_t actionData[ANIMATION_QUEUE_ITEM_MAX]; pokergameactiondata_t actionData[ANIMATION_QUEUE_ITEM_MAX];
/** Pointer back to the game engine */
engine_t *engine;
} pokergame_t; } pokergame_t;
/** /**

View File

@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include <dawn/dawn.h> #include "../../libs.h"
typedef struct { typedef struct {
uint8_t lookAtPlayer; uint8_t lookAtPlayer;

View File

@ -12,6 +12,8 @@
#include "../../display/primitives/skywall.h" #include "../../display/primitives/skywall.h"
#include "../../vn/vnscene.h" #include "../../vn/vnscene.h"
#include "../../vn/vncharacter.h" #include "../../vn/vncharacter.h"
#include "pokergame.h"
#include "pokergameassets.h"
#define POKER_WORLD_SEAT_DISTANCE -1 #define POKER_WORLD_SEAT_DISTANCE -1
#define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f)) #define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f))

View File

@ -13,10 +13,13 @@
#include "../../../display/primitive.h" #include "../../../display/primitive.h"
#include "../../../display/primitives/quad.h" #include "../../../display/primitives/quad.h"
#include "../../../display/primitives/cube.h" #include "../../../display/primitives/cube.h"
#include "../../../display/shader.h"
#include "../../../engine/engine.h"
#include "../../../display/camera.h" #include "../../../display/camera.h"
#include "../../../vn/vncharacter.h" #include "../../../vn/vncharacter.h"
#include "../../../ui/grid.h" #include "../../../ui/grid.h"
#include "../../../ui/align.h" #include "../../../ui/align.h"
#include "../pokergame.h"
#define POKER_PLAYER_UI_IMAGE_SIZE 64 #define POKER_PLAYER_UI_IMAGE_SIZE 64
#define POKER_PLAYER_UI_WIDTH 300 #define POKER_PLAYER_UI_WIDTH 300

View File

@ -10,6 +10,7 @@
#include "../../../ui/label.h" #include "../../../ui/label.h"
#include "pokerplayerui.h" #include "pokerplayerui.h"
#include "pokercardui.h" #include "pokercardui.h"
#include "../pokergame.h"
typedef struct { typedef struct {
pokerplayerui_t player[POKER_PLAYER_COUNT]; pokerplayerui_t player[POKER_PLAYER_COUNT];

View File

@ -7,9 +7,7 @@
#include "sandboxscene.h" #include "sandboxscene.h"
scripter_t scripter; bool sandboxSceneInit(sandboxscene_t *game) {
bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine) {
assetFontLoad(&game->font, "fonts/opensans/OpenSans-Regular.ttf"); assetFontLoad(&game->font, "fonts/opensans/OpenSans-Regular.ttf");
assetTextureLoad(&game->texture, "test_texture.png"); assetTextureLoad(&game->texture, "test_texture.png");
assetShaderLoad(&game->shader, assetShaderLoad(&game->shader,
@ -19,11 +17,11 @@ bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine) {
return true; return true;
} }
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) { void sandboxSceneUpdate(sandboxscene_t *game) {
cameraLookAt(&game->camera, 3,3,3, 0,0,0); cameraLookAt(&game->camera, 3,3,3, 0,0,0);
cameraPerspective(&game->camera, 45, cameraPerspective(&game->camera, 45,
engine->render.width/engine->render.height, game->engine.render.width/game->engine.render.height,
0.01f, 1000.0f 0.01f, 1000.0f
); );

View File

@ -27,6 +27,7 @@
#include "../../ui/framedtextmenu.h" #include "../../ui/framedtextmenu.h"
typedef struct { typedef struct {
engine_t engine;
camera_t camera; camera_t camera;
primitive_t primitive; primitive_t primitive;
@ -42,7 +43,7 @@ typedef struct {
* @param engine Engine to use during init. * @param engine Engine to use during init.
* @return True if successful, otherwise false. * @return True if successful, otherwise false.
*/ */
bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine); bool sandboxSceneInit(sandboxscene_t *game);
/** /**
* Update a sandbox scene. * Update a sandbox scene.
@ -50,7 +51,7 @@ bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine);
* @param game Game to update. * @param game Game to update.
* @param engine Engine to use when updating. * @param engine Engine to use when updating.
*/ */
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine); void sandboxSceneUpdate(sandboxscene_t *game);
/** /**
* Dispose a previously created scene game. * Dispose a previously created scene game.

View File

@ -17,21 +17,27 @@ void pokerBetReset(pokerbet_t *bet) {
bet->currentBet = 0; bet->currentBet = 0;
} }
void pokerBetPlayer(poker_t *poker, pokerplayer_t *player, int32_t chips) { uint8_t pokerBetGetRoundPlayerDefault(uint8_t roundSmallBlind) {
poker->bet.pot += chips; return (roundSmallBlind + 1) % POKER_PLAYER_COUNT;
player->chips -= chips;
player->currentBet += chips;
poker->bet.currentBet = mathMax(poker->bet.currentBet, player->currentBet);
} }
void pokerBetResetBetter(poker_t *poker) { void pokerBetPlayer(pokerbet_t *bet, pokerplayer_t *player, int32_t chips) {
bet->pot += chips;
player->chips -= chips;
player->currentBet += chips;
bet->currentBet = mathMax(bet->currentBet, player->currentBet);
}
void pokerBetResetBetter(
pokerbet_t *poker, pokerplayer_t *players, uint8_t roundSmallBlind
) {
uint8_t i; uint8_t i;
pokerplayer_t *player; pokerplayer_t *player;
for(i = 0; i < POKER_PLAYER_COUNT; i++) { for(i = 0; i < POKER_PLAYER_COUNT; i++) {
player = poker->players + i; player = players + i;
player->state = flagOff(player->state, POKER_PLAYER_STATE_ROUND_MOVE); player->state = flagOff(player->state, POKER_PLAYER_STATE_ROUND_MOVE);
} }
poker->bet.better = POKER_BET_ROUND_PLAYER_DEFAULT(poker); bet->better = pokerBetGetRoundPlayerDefault(roundSmallBlind);
} }
bool pokerBetPlayerCanBet(pokerbet_t *bet, pokerplayer_t *player) { bool pokerBetPlayerCanBet(pokerbet_t *bet, pokerplayer_t *player) {
@ -43,22 +49,24 @@ bool pokerBetPlayerCanBet(pokerbet_t *bet, pokerplayer_t *player) {
return true; return true;
} }
uint8_t pokerBetGetRemainingPlayer(poker_t *poker) { uint8_t pokerBetGetRemainingPlayer(
pokerbet_t *bet, pokerplayer_t *players, uint8_t roundSmallBlind
) {
uint8_t def, j, pi; uint8_t def, j, pi;
def = POKER_BET_ROUND_PLAYER_DEFAULT(poker); def = pokerBetGetRoundPlayerDefault(roundSmallBlind);
for(j = 0; j < POKER_PLAYER_COUNT; j++) { for(j = 0; j < POKER_PLAYER_COUNT; j++) {
pi = ((def + j) % POKER_PLAYER_COUNT); pi = ((def + j) % POKER_PLAYER_COUNT);
if(!pokerBetPlayerCanBet(&poker->bet, poker->players + pi)) continue; if(!pokerBetPlayerCanBet(bet, players + pi)) continue;
return pi; return pi;
} }
return 0xFF; return 0xFF;
} }
void pokerBetTakeBlinds(poker_t *poker) { void pokerBetTakeBlinds(
pokerBetPlayer(poker, poker->players + poker->roundSmallBlind, pokerbet_t *bet, pokerplayer_t *players,
poker->bet.blindSmall uint8_t roundSmallBlind, uint8_t roundBigBlind,
); int32_t blindSmall, int32_t blindBig
pokerBetPlayer(poker, poker->players + poker->roundBigBlind, ) {
poker->bet.blindBig pokerBetPlayer(bet, players + roundSmallBlind, blindSmall);
); pokerBetPlayer(bet, players + roundBigBlind, blindBig);
} }

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include "../libs.h" #include "../libs.h"
#include "player.h"
/** How many chips each player has by defautl */ /** How many chips each player has by defautl */
#define POKER_BET_PLAYER_CHIPS_DEFAULT 10000 #define POKER_BET_PLAYER_CHIPS_DEFAULT 10000
@ -15,16 +16,6 @@
/** 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)
/**
* The default betting player for the round.
*
* @param poker Pointer to the poker instance.
* @return The Poker round default betting player.
*/
#define POKER_BET_ROUND_PLAYER_DEFAULT(poker) ( \
((poker)->roundSmallBlind + 1) % POKER_PLAYER_COUNT \
)
typedef struct { typedef struct {
/** Blinds */ /** Blinds */
int32_t blindSmall, blindBig; int32_t blindSmall, blindBig;
@ -53,22 +44,34 @@ void pokerBetInit(pokerbet_t *bet);
*/ */
void pokerBetReset(pokerbet_t *bet); void pokerBetReset(pokerbet_t *bet);
/**
* The default betting player for the round.
*
* @param roundSmallBlind Current round small blind player index.
* @return The Poker round default betting player index.
*/
uint8_t pokerBetGetRoundPlayerDefault(uint8_t roundSmallBlind);
/** /**
* Let a player bet chips into the pot. * Let a player bet chips into the pot.
* *
* @param poker Poker game instance. * @param bet Poker bet instance.
* @param player Poker player instance. * @param player Poker player instance.
* @param chips Chips to bet. * @param chips Chips to bet.
*/ */
void pokerBetPlayer(poker_t *poker, pokerplayer_t *player, int32_t chips); void pokerBetPlayer(pokerbet_t *bet, pokerplayer_t *player, int32_t chips);
/** /**
* Reset the current better back to the round/turns default. The better will * Reset the current better back to the round/turns default. The better will
* always be the player to the right of the small blind player. * always be the player to the right of the small blind player.
* *
* @param poker Poker game to update for. * @param bet Poker betting structure.
* @param player Array of poker players.
* @param roundSmallBlind Current round small blind player index.
*/ */
void pokerBetResetBetter(poker_t *poker); void pokerBetResetBetter(
pokerbet_t *poker, pokerplayer_t *players, uint8_t roundSmallBlind
);
/** /**
* Returns whether or not a player can bet for the current round. * Returns whether or not a player can bet for the current round.
@ -83,14 +86,22 @@ bool pokerBetPlayerCanBet(pokerbet_t *bet, pokerplayer_t *player);
* Returns the index of the first player that remains to bet for the current * Returns the index of the first player that remains to bet for the current
* round. * round.
* *
* @param poker Poker instance to fetch from. * @param bet Poker betting structure.
* @param player Array of poker players.
* @param roundSmallBlind Current round small blind player index.
* @return The player index of the remaining player, otherwise 0xFF. * @return The player index of the remaining player, otherwise 0xFF.
*/ */
uint8_t pokerBetGetRemainingPlayer(poker_t *poker); uint8_t pokerBetGetRemainingPlayer(
pokerbet_t *bet, pokerplayer_t *players, uint8_t roundSmallBlind
);
/** /**
* Takes the current blinds from the correct players. * Takes the current blinds from the correct players.
* *
* @param poker Poker game to take the blinds from. * @param poker Poker game to take the blinds from.
*/ */
void pokerBetTakeBlinds(poker_t *poker); void pokerBetTakeBlinds(
pokerbet_t *bet, pokerplayer_t *players,
uint8_t roundSmallBlind, uint8_t roundBigBlind,
int32_t blindSmall, int32_t blindBig
);

View File

@ -39,15 +39,17 @@ void pokerDealerDeal(pokerdealer_t *dealer, pokerplayer_t *player) {
cardDeal(dealer->deck, &dealer->deckSize, player->cards, &player->cardCount); cardDeal(dealer->deck, &dealer->deckSize, player->cards, &player->cardCount);
} }
void pokerDealerDealAll(poker_t *poker, uint8_t count) { void pokerDealerDealAll(
pokerdealer_t *dealer, pokerplayer_t *players, uint8_t count
) {
uint8_t x, y; uint8_t x, y;
pokerplayer_t *player; pokerplayer_t *player;
for(y = 0; y < count; y++) { for(y = 0; y < count; y++) {
for(x = 0; x < POKER_PLAYER_COUNT; x++) { for(x = 0; x < POKER_PLAYER_COUNT; x++) {
player = poker->players + x; player = players + x;
if(!pokerPlayerIsAlive(player)) continue; if(!pokerPlayerIsAlive(player)) continue;
pokerDealerDeal(&poker->dealer, player); pokerDealerDeal(dealer, player);
} }
} }
} }

View File

@ -5,7 +5,6 @@
#pragma once #pragma once
#include "../libs.h" #include "../libs.h"
#include "poker.h"
#include "card.h" #include "card.h"
#include "player.h" #include "player.h"
@ -68,7 +67,10 @@ void pokerDealerDeal(pokerdealer_t *dealer, pokerplayer_t *player);
/** /**
* Deal card(s) to every active player. * Deal card(s) to every active player.
* *
* @param poker Poker game instance. * @param dealer Poker dealer instance.
* @param players Array of poker players.
* @param count Count of cards to deal. * @param count Count of cards to deal.
*/ */
void pokerDealerDealAll(poker_t *poker, uint8_t count); void pokerDealerDealAll(
pokerdealer_t *dealer, pokerplayer_t *players, uint8_t count
);

View File

@ -11,10 +11,6 @@ bool pokerPlayerIsAlive(pokerplayer_t *player) {
return !(player->state & (POKER_PLAYER_STATE_FOLDED|POKER_PLAYER_STATE_OUT)); return !(player->state & (POKER_PLAYER_STATE_FOLDED|POKER_PLAYER_STATE_OUT));
} }
bool pokerPlayerIsHuman(poker_t *poker, pokerplayer_t *player) {
return (poker->players + POKER_PLAYER_HUMAN_INDEX) == player;
}
void pokerPlayerReset(pokerplayer_t *player) { void pokerPlayerReset(pokerplayer_t *player) {
player->cardCount = 0; player->cardCount = 0;
player->currentBet = 0; player->currentBet = 0;

View File

@ -7,8 +7,8 @@
#pragma once #pragma once
#include "../libs.h" #include "../libs.h"
#include "../util/flags.h"
#include "card.h" #include "card.h"
#include "poker.h"
/** How many cards a player can hold in their hand */ /** How many cards a player can hold in their hand */
#define POKER_PLAYER_HAND 2 #define POKER_PLAYER_HAND 2
@ -64,15 +64,6 @@ typedef struct {
*/ */
bool pokerPlayerIsAlive(pokerplayer_t *player); bool pokerPlayerIsAlive(pokerplayer_t *player);
/**
* Returns true if the player provided is human or not.
*
* @param poker Poker game instance.
* @param player Player instance.
* @returns True if the player is human.
*/
bool pokerPlayerIsHuman(poker_t *poker, pokerplayer_t *player);
/** /**
* Resets a poker player's state (for a new round). * Resets a poker player's state (for a new round).
* *

View File

@ -7,27 +7,27 @@
#include "winner.h" #include "winner.h"
void pokerWinnerHandGetFull(poker_t *poker, pokerplayer_t *player, void pokerWinnerHandGetFull(
card_t *cards pokerdealer_t *dealer, pokerplayer_t *player, card_t *cards
){ ) {
uint8_t i; uint8_t i;
// Add the dealer hand // Add the dealer hand
for(i = 0; i < poker->dealer.cardsFacing; i++) { for(i = 0; i < dealer->cardsFacing; i++) {
cards[i] = poker->dealer.cards[i]; cards[i] = dealer->cards[i];
} }
// Add the player hand // Add the player hand
for(i = 0; i < player->cardCount; i++) { for(i = 0; i < player->cardCount; i++) {
cards[i+poker->dealer.cardsFacing] = player->cards[i]; cards[i+dealer->cardsFacing] = player->cards[i];
} }
// Sort by card value // Sort by card value
cardHandSort(cards, poker->dealer.cardsFacing + player->cardCount); cardHandSort(cards, dealer->cardsFacing + player->cardCount);
} }
void pokerWinnerPlayerGet( void pokerWinnerPlayerGet(
poker_t *poker, pokerplayer_t *player, pokerplayerwinning_t *winning pokerdealer_t *dealer, pokerplayer_t *player, pokerplayerwinning_t *winning
) { ) {
uint8_t i, j, l; uint8_t i, j, l;
int32_t index; int32_t index;
@ -36,8 +36,8 @@ void pokerWinnerPlayerGet(
int32_t pairs[CARD_SUIT_COUNT]; int32_t pairs[CARD_SUIT_COUNT];
// Get the full poker hand (should be a 7 card hand, but MAY not be) // Get the full poker hand (should be a 7 card hand, but MAY not be)
winning->fullSize = poker->dealer.cardsFacing + player->cardCount; winning->fullSize = dealer->cardsFacing + player->cardCount;
pokerWinnerHandGetFull(poker, player, winning->full); pokerWinnerHandGetFull(dealer, player, winning->full);
// Reset the winning status. // Reset the winning status.
winning->setSize = 0; winning->setSize = 0;
@ -284,26 +284,26 @@ card_t pokerWinnerCompare(pokerplayerwinning_t *left, pokerplayerwinning_t *righ
return highCardLeft;//Greater or Equal to. return highCardLeft;//Greater or Equal to.
} }
void pokerWinnerCalculate(poker_t *poker) { void pokerWinnerCalculate(
pokerwinner_t *winner, pokerdealer_t *dealer, pokerplayer_t *players
) {
uint8_t i, j, number, highNumber; uint8_t i, j, number, highNumber;
pokerwinner_t *winner;
pokerplayerwinning_t *left, *right; pokerplayerwinning_t *left, *right;
pokerplayer_t *player; pokerplayer_t *player;
card_t card, highCard; card_t card, highCard;
bool isWinner; bool isWinner;
winner = &poker->winner;
winner->winnerCount = 0; winner->winnerCount = 0;
// Get winning sets // Get winning sets
for(i = 0; i < POKER_PLAYER_COUNT; i++) { for(i = 0; i < POKER_PLAYER_COUNT; i++) {
left = winner->winnings + i; left = winner->winnings + i;
left->type = POKER_WINNING_TYPE_NULL; left->type = POKER_WINNING_TYPE_NULL;
player = poker->players + i; player = players + i;
if(!pokerPlayerIsAlive(player)) continue; if(!pokerPlayerIsAlive(player)) continue;
// Get the players' winning state. // Get the players' winning state.
pokerWinnerPlayerGet(poker, player, left); pokerWinnerPlayerGet(dealer, player, left);
} }
// Compare against each player // Compare against each player

View File

@ -10,7 +10,7 @@
#include "card.h" #include "card.h"
#include "player.h" #include "player.h"
#include "winner.h" #include "winner.h"
#include "poker.h" #include "dealer.h"
/** Size of the FULL hand used to calculate a winning. */ /** Size of the FULL hand used to calculate a winning. */
#define POKER_WINNING_FULL_SIZE POKER_PLAYER_HAND+POKER_DEALER_HAND_SIZE #define POKER_WINNING_FULL_SIZE POKER_PLAYER_HAND+POKER_DEALER_HAND_SIZE
@ -59,24 +59,24 @@ typedef struct {
* Returns the full hand for a given player including the best cards on the * Returns the full hand for a given player including the best cards on the
* bench. * bench.
* *
* @param poker Poker game instance. * @param dealer Poker game dealer instance.
* @param player Poker player game instance. * @param player Poker player game instance.
* @param cards Array of at least 7 length to store the array. * @param cards Array of at least 7 length to store the array.
*/ */
void pokerWinnerHandGetFull(poker_t *poker, pokerplayer_t *player, void pokerWinnerHandGetFull(
card_t *cards pokerdealer_t *dealer, pokerplayer_t *player, card_t *cards
); );
/** /**
* Calculates and returns the winning state for a given player * Calculates and returns the winning state for a given player
* *
* @param poker Poker game instance. * @param dealer Poker game dealer instance.
* @param player Player game instance. * @param players Array of poker players.
* @param winning Pointer to the poker winning to fill out. * @param winning Pointer to the poker winning to fill out.
* @return The winning state for this player. * @return The winning state for this player.
*/ */
void pokerWinnerPlayerGet( void pokerWinnerPlayerGet(
poker_t *poker, pokerplayer_t *player, pokerplayerwinning_t *winning pokerdealer_t *dealer, pokerplayer_t *player, pokerplayerwinning_t *winning
); );
/** /**
@ -102,6 +102,10 @@ card_t pokerWinnerCompare(
* Determines the winning player for the game. Values will be stored back into * Determines the winning player for the game. Values will be stored back into
* the poker winning state. * the poker winning state.
* *
* @param poker Poker game instance. * @param winner Location to store the winner state.
* @param dealer Poker game dealer instance.
* @param players Array of poker players.
*/ */
void pokerWinnerCalculate(poker_t *poker); void pokerWinnerCalculate(
pokerwinner_t *winner, pokerdealer_t *dealer, pokerplayer_t *players
);