Even more refactoring

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

View File

@ -5,6 +5,7 @@
#pragma once
#include "../libs.h"
#include "player.h"
/** How many chips each player has by defautl */
#define POKER_BET_PLAYER_CHIPS_DEFAULT 10000
@ -15,16 +16,6 @@
/** The default blind cost for the small blind. (Defaults half big blind) */
#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 {
/** Blinds */
int32_t blindSmall, blindBig;
@ -53,22 +44,34 @@ void pokerBetInit(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.
*
* @param poker Poker game instance.
* @param bet Poker bet instance.
* @param player Poker player instance.
* @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
* 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.
@ -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
* 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.
*/
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.
*
* @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
);