Working on the poker game stuff.

This commit is contained in:
2022-01-09 20:15:16 -08:00
parent 29215a3b6f
commit cc9e50c4ab
7 changed files with 265 additions and 31 deletions

View File

@@ -8,18 +8,22 @@
#include "poker.h"
pokerplayer_t POKER_PLAYERS[POKER_PLAYER_COUNT_MAX];
uint8_t POKER_DECK[CARD_DECK_SIZE];
uint8_t POKER_DECK_SIZE;
uint8_t POKER_COMMUNITY[POKER_COMMUNITY_SIZE_MAX];
uint8_t POKER_COMMUNITY_SIZE;
uint8_t POKER_PLAYER_DEALER;
uint8_t POKER_PLAYER_SMALL_BLIND;
uint8_t POKER_PLAYER_BIG_BLIND;
uint8_t POKER_PLAYER_BETTER;
uint16_t POKER_GAME_BLINDS_CURRENT;
uint16_t POKER_GAME_POT;
pokerpot_t POKER_POTS[POKER_POT_COUNT_MAX];
uint8_t POKER_POT_CURRENT;
uint8_t POKER_POT_COUNT;
void pokerInit() {
uint8_t i;
@@ -33,8 +37,6 @@ void pokerInit() {
// Set up the initial state.
// TODO: Should this be randomized?
POKER_PLAYER_DEALER = 0;
POKER_GAME_POT = 0;
POKER_GAME_BLINDS_CURRENT = 10;
// Reset the round state (For the first round)
@@ -47,6 +49,15 @@ void pokerNewRound() {
// Reset round state
POKER_COMMUNITY_SIZE = 0;
POKER_POT_COUNT = 0;
POKER_POT_CURRENT = 0;
// Reset the pots.
for(i = 0; i < POKER_POT_COUNT_MAX; i++) {
POKER_POTS[i].chips = 0;
POKER_POTS[i].call = 0;
POKER_POTS[i].playersCount = 0;
}
// Fill deck
for(i = 0; i < CARD_DECK_SIZE; i++) POKER_DECK[i] = i;
@@ -91,11 +102,13 @@ void pokerNewRound() {
POKER_PLAYERS[i].hand[j] = POKER_DECK[POKER_DECK_SIZE--];
}
}
}
void pokerTakeBlinds() {
// Take blinds
// TODO: I need to make sure the blind players even have the chips to blind.
POKER_PLAYERS[POKER_PLAYER_SMALL_BLIND].chips -= POKER_GAME_BLINDS_CURRENT;
POKER_PLAYERS[POKER_PLAYER_BIG_BLIND].chips -= (POKER_GAME_BLINDS_CURRENT*2);
POKER_GAME_POT += POKER_GAME_BLINDS_CURRENT * 3;
POKER_POT_BET(POKER_PLAYER_SMALL_BLIND, POKER_GAME_BLINDS_CURRENT);
POKER_POT_BET(POKER_PLAYER_BIG_BLIND, (POKER_GAME_BLINDS_CURRENT*2));
// Set the initial better, we set this to the BIG BLIND player because we will
// cycle to the "next better" as soon as the game starts.
POKER_PLAYER_BETTER = POKER_PLAYER_BIG_BLIND;
}