Cleaning more.
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/player.h"
|
||||
#include "../../../poker/dealer.h"
|
||||
#include "action.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "bet.h"
|
||||
|
@ -54,11 +54,18 @@ void pokerBetForPlayer(poker_t *poker, uint8_t playerIndex, int32_t chips) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t pokerBetGetCurrentCallValue(poker_t *poker) {
|
||||
uint8_t i;
|
||||
int32_t call;
|
||||
call = 0;
|
||||
for(i = 0; i < poker->playerCount; i++) {
|
||||
call = mathMax(call, poker->players[i].currentBet);
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
|
||||
//eh
|
||||
int32_t pokerPlayerGetCallBet(poker_t *poker, pokerplayer_t *player) {
|
||||
return pokerGetCallValue(poker) - player->currentBet;
|
||||
return pokerBetGetCurrentCallValue(poker) - player->currentBet;
|
||||
}
|
@ -68,3 +68,11 @@ void pokerBet(
|
||||
* @param chips The amount of chips the player is betting.
|
||||
*/
|
||||
void pokerBetForPlayer(poker_t *poker, uint8_t playerIndex, int32_t chips);
|
||||
|
||||
/**
|
||||
* Gets the amount of chips necessary to call the current bet.
|
||||
*
|
||||
* @param poker Poker game instance.
|
||||
* @return Chips necessary to call the current bet.
|
||||
*/
|
||||
int32_t pokerBetGetCurrentCallValue(poker_t *poker);
|
@ -34,10 +34,26 @@ bool pokerPlayerDoesNeedToBetThisRound(poker_t *poker, uint8_t playerIndex) {
|
||||
if(player->state & POKER_PLAYER_STATE_FOLDED) return false;
|
||||
if(player->chips <= 0) return false;
|
||||
if(!(player->state & POKER_PLAYER_STATE_HAS_BET_THIS_ROUND)) return true;
|
||||
if(player->currentBet < pokerGetCallValue(poker)) return true;
|
||||
if(player->currentBet < pokerBetGetCurrentCallValue(poker)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pokerPlayerCanCheck(poker_t *poker, pokerplayer_t *player) {
|
||||
return pokerGetCallValue(poker) <= player->currentBet;
|
||||
}
|
||||
return pokerBetGetCurrentCallValue(poker) <= player->currentBet;
|
||||
}
|
||||
|
||||
void pokerPlayerGetFullHand(
|
||||
poker_t *poker, pokerplayer_t *player, card_t *cards
|
||||
) {
|
||||
uint8_t i;
|
||||
|
||||
// Add the dealer hand
|
||||
for(i = 0; i < poker->communitySize; i++) {
|
||||
cards[i] = poker->community[i];
|
||||
}
|
||||
|
||||
// Add the player hand
|
||||
for(i = 0; i < player->cardCount; i++) {
|
||||
cards[i+poker->communitySize] = player->cards[i];
|
||||
}
|
||||
}
|
||||
|
@ -46,4 +46,15 @@ bool pokerPlayerDoesNeedToBetThisRound(poker_t *poker, uint8_t playerIndex);
|
||||
* @param player Player to check.
|
||||
* @return True if the player can check, false if they need to call first.
|
||||
*/
|
||||
bool pokerPlayerCanCheck(poker_t *poker, pokerplayer_t *player);
|
||||
bool pokerPlayerCanCheck(poker_t *poker, pokerplayer_t *player);
|
||||
|
||||
/**
|
||||
* Returns the full hand for a given player including the cards on the bench.
|
||||
*
|
||||
* @param poker Poker game instance.
|
||||
* @param player Poker player to get the hand for.
|
||||
* @param cards Array to store the cards.
|
||||
*/
|
||||
void pokerPlayerGetFullHand(
|
||||
poker_t *poker, pokerplayer_t *player, card_t *cards
|
||||
);
|
@ -69,28 +69,11 @@ void pokerResetBettingRound(poker_t *poker) {
|
||||
poker->better = pokerBetGetRemainingPlayer(poker);
|
||||
}
|
||||
|
||||
void pokerTakeBlinds(poker_t *poker, int32_t small, int32_t big) {
|
||||
pokerBetForPlayer(poker, poker->playerSmallBlind, small);
|
||||
pokerBetForPlayer(poker, poker->playerBigBlind, big);
|
||||
pokerResetBettingRound(poker);
|
||||
void pokerTakeBlinds(poker_t *poker) {
|
||||
pokerBetForPlayer(poker, poker->playerSmallBlind, poker->blindSmall);
|
||||
pokerBetForPlayer(poker, poker->playerBigBlind, poker->blindBig);
|
||||
}
|
||||
|
||||
int32_t pokerGetCallValue(poker_t *poker) {
|
||||
uint8_t i;
|
||||
int32_t call;
|
||||
call = 0;
|
||||
for(i = 0; i < poker->playerCount; i++) {
|
||||
call = mathMax(call, poker->players[i].currentBet);
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
// Pot functions
|
||||
|
||||
// Dealer Functions
|
||||
|
||||
// Player Functions
|
||||
|
||||
uint8_t pokerInRoundGetCount(poker_t *poker) {
|
||||
uint8_t i, count;
|
||||
pokerplayer_t *player;
|
||||
@ -121,21 +104,4 @@ int32_t pokerPlayerGetPotChipsSum(poker_t *poker, uint8_t playerIndex) {
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// Winning
|
||||
void pokerHandGetFull(
|
||||
poker_t *poker, pokerplayer_t *player, card_t cards[POKER_WINNING_FULL_SIZE]
|
||||
) {
|
||||
uint8_t i;
|
||||
|
||||
// Add the dealer hand
|
||||
for(i = 0; i < poker->communitySize; i++) {
|
||||
cards[i] = poker->community[i];
|
||||
}
|
||||
|
||||
// Add the player hand
|
||||
for(i = 0; i < player->cardCount; i++) {
|
||||
cards[i+poker->communitySize] = player->cards[i];
|
||||
}
|
||||
}
|
||||
}
|
@ -55,18 +55,9 @@ void pokerResetBettingRound(poker_t *poker);
|
||||
* Take the blinds from the blind players.
|
||||
*
|
||||
* @param poker Poker game instance.
|
||||
* @param small Small blind amount.
|
||||
* @param big Big blind amount.
|
||||
*/
|
||||
void pokerTakeBlinds(poker_t *poker, int32_t small, int32_t big);
|
||||
void pokerTakeBlinds(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Gets the amount of chips necessary to call the current bet.
|
||||
*
|
||||
* @param poker Poker game instance.
|
||||
* @return Chips necessary to call the current bet.
|
||||
*/
|
||||
int32_t pokerGetCallValue(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Gets the count of players still currently left in the round.
|
||||
@ -86,18 +77,6 @@ uint8_t pokerInRoundGetCount(poker_t *poker);
|
||||
*/
|
||||
int32_t pokerPlayerGetPotChipsSum(poker_t *poker, uint8_t playerIndex);
|
||||
|
||||
/**
|
||||
* Returns the full hand for a given player including the best cards on the
|
||||
* bench.
|
||||
*
|
||||
* @param poker Poker game instance.
|
||||
* @param player Poker player to get the hand for.
|
||||
* @param cards Array to store the cards.
|
||||
*/
|
||||
void pokerHandGetFull(
|
||||
poker_t *poker, pokerplayer_t *player, card_t cards[POKER_WINNING_FULL_SIZE]
|
||||
);
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dealer
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Betting
|
||||
|
@ -31,7 +31,7 @@ pokerturn_t pokerTurnBet(poker_t *poker, uint8_t playerIndex, int32_t chips) {
|
||||
} else {
|
||||
turn.chips = chips;
|
||||
turn.type = POKER_TURN_TYPE_BET;
|
||||
i = pokerGetCallValue(poker);
|
||||
i = pokerBetGetCurrentCallValue(poker);
|
||||
|
||||
if(chips == (i - player->currentBet)) {
|
||||
turn.type = POKER_TURN_TYPE_CALL;
|
||||
|
@ -52,7 +52,7 @@ void pokerWinnerGetForPlayer(
|
||||
|
||||
// Get the full poker hand (should be a 7 card hand, but MAY not be)
|
||||
winning->fullSize = poker->communitySize + player->cardCount;
|
||||
pokerHandGetFull(poker, player, winning->full);
|
||||
pokerPlayerGetFullHand(poker, player, winning->full);
|
||||
cardHandSort(winning->full, winning->fullSize);
|
||||
|
||||
// Reset the winning status.
|
||||
|
@ -6,9 +6,10 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "card.h"
|
||||
#include "fuck.h"
|
||||
#include "../libs.h"
|
||||
#include "player.h"
|
||||
|
||||
/**
|
||||
* Fills the remaining cards for a given poker player winning hand. Essentially
|
||||
|
Reference in New Issue
Block a user