Working on poker logic
This commit is contained in:
@ -24,6 +24,9 @@
|
|||||||
/** State for whether or not the player is out */
|
/** State for whether or not the player is out */
|
||||||
#define POKER_PLAYER_STATE_OUT 0x04
|
#define POKER_PLAYER_STATE_OUT 0x04
|
||||||
|
|
||||||
|
/** The index that the player who is the human... is */
|
||||||
|
#define POKER_PLAYER_HUMAN_INDEX 0x02
|
||||||
|
|
||||||
/** Poker Player State */
|
/** Poker Player State */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** Cards in the players' hand */
|
/** Cards in the players' hand */
|
||||||
|
@ -137,5 +137,4 @@ typedef struct {
|
|||||||
texture_t cardTexture;
|
texture_t cardTexture;
|
||||||
tileset_t cardTileset;
|
tileset_t cardTileset;
|
||||||
primitive_t cardPrimitive;
|
primitive_t cardPrimitive;
|
||||||
|
|
||||||
} poker_t;
|
} poker_t;
|
@ -11,4 +11,12 @@ void pokerPlayerBet(poker_t *poker, pokerplayer_t *player, int32_t chips) {
|
|||||||
poker->pot += chips;
|
poker->pot += chips;
|
||||||
player->chips -= chips;
|
player->chips -= chips;
|
||||||
player->currentBet += chips;
|
player->currentBet += chips;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pokerPlayerIsAlive(pokerplayer_t *player) {
|
||||||
|
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;
|
||||||
}
|
}
|
@ -14,4 +14,23 @@
|
|||||||
* @param player Poker player instance.
|
* @param player Poker player instance.
|
||||||
* @param chips Chips to bet.
|
* @param chips Chips to bet.
|
||||||
*/
|
*/
|
||||||
void pokerPlayerBet(poker_t *poker, pokerplayer_t *player, int32_t chips);
|
void pokerPlayerBet(poker_t *poker, pokerplayer_t *player, int32_t chips);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the player is still alive and in the current game/
|
||||||
|
* Defined as: Not out, not folded.
|
||||||
|
*
|
||||||
|
* @param player Player to check
|
||||||
|
* @returns True if alive/in teh current game.
|
||||||
|
*/
|
||||||
|
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);
|
@ -38,4 +38,8 @@ void pokerFrameGui(poker_t *poker, render_t *render) {
|
|||||||
);
|
);
|
||||||
cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0);
|
cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0);
|
||||||
shaderUseCamera(&poker->shader, &poker->cameraGui);
|
shaderUseCamera(&poker->shader, &poker->cameraGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerFrameRender(poker_t *poker, render_t *render) {
|
||||||
|
|
||||||
}
|
}
|
@ -26,20 +26,27 @@ void pokerBetPlayerNext(poker_t *poker) {
|
|||||||
pokerBetPlayerInit(poker, poker->players + poker->roundBetCurrent);
|
pokerBetPlayerInit(poker, poker->players + poker->roundBetCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerBetPlayerUpdate(poker_t *poker, pokerplayer_t *player) {
|
|
||||||
pokerBetPlayerNext(poker);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokerBetPlayerInit(poker_t *poker, pokerplayer_t *player) {
|
void pokerBetPlayerInit(poker_t *poker, pokerplayer_t *player) {
|
||||||
// Check the player state (to see if we even can init, e.g. folded/not)
|
// Check the player state (to see if we even can init, e.g. folded/not)
|
||||||
if(player->state & (POKER_PLAYER_STATE_FOLDED|POKER_PLAYER_STATE_OUT)) {
|
if(!pokerPlayerIsAlive(player)) {
|
||||||
pokerBetPlayerNext(poker);
|
pokerBetPlayerNext(poker);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Betting round player %u\n", poker->roundBetCurrent);
|
printf("Betting round player %u\n", poker->roundBetCurrent);
|
||||||
|
if(pokerPlayerIsHuman(poker, player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pokerBetPlayerNext(poker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pokerBetPlayerUpdate(poker_t *poker, pokerplayer_t *player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void pokerBetInit(poker_t *poker) {
|
void pokerBetInit(poker_t *poker) {
|
||||||
printf("Betting round start\n");
|
printf("Betting round start\n");
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "flop.h"
|
#include "flop.h"
|
||||||
#include "winner.h"
|
#include "winner.h"
|
||||||
|
#include "../player.h"
|
||||||
|
|
||||||
void pokerBetPlayerNext(poker_t *poker);
|
void pokerBetPlayerNext(poker_t *poker);
|
||||||
void pokerBetPlayerInit(poker_t *poker, pokerplayer_t *player);
|
void pokerBetPlayerInit(poker_t *poker, pokerplayer_t *player);
|
||||||
|
@ -29,6 +29,7 @@ void pokerDealInit(poker_t *poker) {
|
|||||||
for(y = 0; y < POKER_DEAL_CARD_EACH; y++) {
|
for(y = 0; y < POKER_DEAL_CARD_EACH; y++) {
|
||||||
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
||||||
player = poker->players + x;
|
player = poker->players + x;
|
||||||
|
if(!pokerPlayerIsAlive(player)) continue;
|
||||||
cardDeal(
|
cardDeal(
|
||||||
poker->deck, &poker->deckSize,
|
poker->deck, &poker->deckSize,
|
||||||
player->cards, &player->cardCount
|
player->cards, &player->cardCount
|
||||||
|
@ -15,7 +15,7 @@ void pokerMatchInit(poker_t *poker) {
|
|||||||
// Reset the main game state. This does not init the round.
|
// Reset the main game state. This does not init the round.
|
||||||
poker->blindBig = POKER_BLIND_BIG_DEFAULT;
|
poker->blindBig = POKER_BLIND_BIG_DEFAULT;
|
||||||
poker->blindSmall = POKER_BLIND_SMALL_DEFAULT;
|
poker->blindSmall = POKER_BLIND_SMALL_DEFAULT;
|
||||||
poker->roundDealer = 0x00;
|
poker->roundDealer = POKER_PLAYER_COUNT-2;
|
||||||
poker->roundTextCounter = 0;
|
poker->roundTextCounter = 0;
|
||||||
poker->round = POKER_ROUND_MATCH;
|
poker->round = POKER_ROUND_MATCH;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ void pokerStartInit(poker_t *poker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decide on the dealer
|
// Decide on the dealer
|
||||||
poker->roundDealer++;
|
poker->roundDealer = (poker->roundDealer+1) % POKER_PLAYER_COUNT;
|
||||||
|
|
||||||
// Find the players.
|
// Find the players.
|
||||||
i = poker->roundDealer;
|
i = poker->roundDealer;
|
||||||
@ -43,8 +43,7 @@ void pokerStartInit(poker_t *poker) {
|
|||||||
foundSmallBlind = false;
|
foundSmallBlind = false;
|
||||||
while(true) {
|
while(true) {
|
||||||
player = poker->players + i;
|
player = poker->players + i;
|
||||||
if(player->state & POKER_PLAYER_STATE_FOLDED) continue;
|
if(!pokerPlayerIsAlive(player)) continue;
|
||||||
if(player->state & POKER_PLAYER_STATE_OUT) continue;
|
|
||||||
if(!foundDealer) {
|
if(!foundDealer) {
|
||||||
indexDealer = i;
|
indexDealer = i;
|
||||||
foundDealer = true;
|
foundDealer = true;
|
||||||
@ -59,6 +58,7 @@ void pokerStartInit(poker_t *poker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update players for the round.
|
// Update players for the round.
|
||||||
|
poker->roundDealer = indexDealer;
|
||||||
poker->roundBigBlind = indexBigBlind;
|
poker->roundBigBlind = indexBigBlind;
|
||||||
poker->roundSmallBlind = indexSmallBlind;
|
poker->roundSmallBlind = indexSmallBlind;
|
||||||
|
|
||||||
|
@ -8,5 +8,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "blinds.h"
|
#include "blinds.h"
|
||||||
|
#include "../player.h"
|
||||||
|
|
||||||
void pokerStartInit(poker_t *poker);
|
void pokerStartInit(poker_t *poker);
|
@ -9,6 +9,13 @@
|
|||||||
#include "winner.h"
|
#include "winner.h"
|
||||||
|
|
||||||
void pokerWinnerInit(poker_t *poker) {
|
void pokerWinnerInit(poker_t *poker) {
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
poker->round = POKER_ROUND_WINNER;
|
poker->round = POKER_ROUND_WINNER;
|
||||||
printf("Winner Winner Chicken Dinner\n");
|
printf("Winner Winner Chicken Dinner\n");
|
||||||
|
|
||||||
|
// Bruh Moment
|
||||||
|
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user