Working on poker logic
This commit is contained in:
@ -24,6 +24,9 @@
|
||||
/** State for whether or not the player is out */
|
||||
#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 */
|
||||
typedef struct {
|
||||
/** Cards in the players' hand */
|
||||
|
@ -137,5 +137,4 @@ typedef struct {
|
||||
texture_t cardTexture;
|
||||
tileset_t cardTileset;
|
||||
primitive_t cardPrimitive;
|
||||
|
||||
} poker_t;
|
@ -11,4 +11,12 @@ void pokerPlayerBet(poker_t *poker, pokerplayer_t *player, int32_t chips) {
|
||||
poker->pot += chips;
|
||||
player->chips -= 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 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void pokerBetPlayerUpdate(poker_t *poker, pokerplayer_t *player) {
|
||||
pokerBetPlayerNext(poker);
|
||||
}
|
||||
|
||||
void pokerBetPlayerInit(poker_t *poker, pokerplayer_t *player) {
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
printf("Betting round start\n");
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <dawn/dawn.h>
|
||||
#include "flop.h"
|
||||
#include "winner.h"
|
||||
#include "../player.h"
|
||||
|
||||
void pokerBetPlayerNext(poker_t *poker);
|
||||
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(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
||||
player = poker->players + x;
|
||||
if(!pokerPlayerIsAlive(player)) continue;
|
||||
cardDeal(
|
||||
poker->deck, &poker->deckSize,
|
||||
player->cards, &player->cardCount
|
||||
|
@ -15,7 +15,7 @@ void pokerMatchInit(poker_t *poker) {
|
||||
// Reset the main game state. This does not init the round.
|
||||
poker->blindBig = POKER_BLIND_BIG_DEFAULT;
|
||||
poker->blindSmall = POKER_BLIND_SMALL_DEFAULT;
|
||||
poker->roundDealer = 0x00;
|
||||
poker->roundDealer = POKER_PLAYER_COUNT-2;
|
||||
poker->roundTextCounter = 0;
|
||||
poker->round = POKER_ROUND_MATCH;
|
||||
|
||||
|
@ -35,7 +35,7 @@ void pokerStartInit(poker_t *poker) {
|
||||
}
|
||||
|
||||
// Decide on the dealer
|
||||
poker->roundDealer++;
|
||||
poker->roundDealer = (poker->roundDealer+1) % POKER_PLAYER_COUNT;
|
||||
|
||||
// Find the players.
|
||||
i = poker->roundDealer;
|
||||
@ -43,8 +43,7 @@ void pokerStartInit(poker_t *poker) {
|
||||
foundSmallBlind = false;
|
||||
while(true) {
|
||||
player = poker->players + i;
|
||||
if(player->state & POKER_PLAYER_STATE_FOLDED) continue;
|
||||
if(player->state & POKER_PLAYER_STATE_OUT) continue;
|
||||
if(!pokerPlayerIsAlive(player)) continue;
|
||||
if(!foundDealer) {
|
||||
indexDealer = i;
|
||||
foundDealer = true;
|
||||
@ -59,6 +58,7 @@ void pokerStartInit(poker_t *poker) {
|
||||
}
|
||||
|
||||
// Update players for the round.
|
||||
poker->roundDealer = indexDealer;
|
||||
poker->roundBigBlind = indexBigBlind;
|
||||
poker->roundSmallBlind = indexSmallBlind;
|
||||
|
||||
|
@ -8,5 +8,6 @@
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "blinds.h"
|
||||
#include "../player.h"
|
||||
|
||||
void pokerStartInit(poker_t *poker);
|
@ -9,6 +9,13 @@
|
||||
#include "winner.h"
|
||||
|
||||
void pokerWinnerInit(poker_t *poker) {
|
||||
uint8_t i;
|
||||
|
||||
poker->round = POKER_ROUND_WINNER;
|
||||
printf("Winner Winner Chicken Dinner\n");
|
||||
|
||||
// Bruh Moment
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user