Added set dealer method.

This commit is contained in:
2021-10-12 08:43:22 -07:00
parent 2e38770061
commit 01b49c364c
7 changed files with 72 additions and 65 deletions

View File

@ -17,7 +17,6 @@ void _pokerActionBlindsOnStart(queue_t *queue,queueaction_t *action,uint8_t i) {
queueNext(queue);
}
queueaction_t * pokerActionBlindsAdd(queue_t *queue, poker_t *poker) {
queueaction_t *action;
action = queueAdd(queue);

View File

@ -11,8 +11,6 @@ void _pokerActionFlopDo(queue_t *queue, queueaction_t *action, uint8_t count) {
poker_t *poker;
poker = (poker_t *)action->data;
// TODO: Fix State
// poker->state = POKER_STATE_CARDS_FLOPPING;
pokerBurn(poker, POKER_FLOP_BURN_COUNT);
pokerTurn(poker, count);

View File

@ -1,33 +0,0 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "match.h"
void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i){
poker_t *poker;
uint8_t x;
poker = (poker_t *)action->data;
// TODO: Fix state
// poker->state = POKER_STATE_STARTING_MATCH;
// Reset the main game state. This will also init the round.
pokerInit(&poker);
//TODO: Add Players here
queueNext(queue);
}
queueaction_t * pokerActionMatchAdd(queue_t *queue, poker_t *poker) {
queueaction_t *action;
action = queueAdd(queue);
action->data = (void *)poker;
action->onStart = &_pokerActionMatchOnStart;
return action;
}

View File

@ -1,21 +0,0 @@
// Copyright (c) 2021 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "../../libs.h"
#include "../../display/animation/queue.h"
#include "../poker.h"
/** Callback for when the poker match aciton starts */
void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
/**
* Adds a Poker Match Begin Action onto a queue.
*
* @param queue Queue to add to
* @param poker Poker game instance to use.
* @return The queued match start action.
*/
queueaction_t * pokerActionMatchAdd(queue_t *queue, poker_t *poker);

View File

@ -70,17 +70,21 @@ void pokerResetBettingRound(poker_t *poker) {
}
void pokerNewDealer(poker_t *poker) {
uint8_t i, j, k;
pokerSetDealer(poker, poker->playerDealer + 1);
}
void pokerSetDealer(poker_t *poker, uint8_t dealer) {
uint8_t i, k;
pokerplayer_t *player;
bool foundDealer;
bool foundSmall;
foundDealer = false;
foundSmall = false;
poker->playerDealer = dealer;
j = poker->playerDealer + 1;
for(i = 0; i < poker->playerCount; i++) {
k = (j + i) % poker->playerCount;
k = (dealer + i) % poker->playerCount;
player = poker->players + k;
if(player->state & POKER_PLAYER_STATE_OUT) continue;
if(!foundDealer) {

View File

@ -217,6 +217,15 @@ void pokerResetBettingRound(poker_t *poker);
*/
void pokerNewDealer(poker_t *poker);
/**
* Set a next dealer. This will also select the new small and big blind players.
* This will automatically skip out players if you provide one.
*
* @param poker Poker game to select a new dealer for.
* @param dealer Dealer to become the new dealer.
*/
void pokerSetDealer(poker_t *poker, uint8_t dealer);
/**
* Take the blinds from the blind players.
*