Fixed betting bugs.
This commit is contained in:
@ -86,11 +86,8 @@ void _pokerGameActionBetOnUpdate(
|
||||
void _pokerGameActionBetOnEnd(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
queueaction_t *next;
|
||||
pokerdiscussiondata_t discussion;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
|
||||
// Get which player is remaining to move.
|
||||
game->poker.bet.better = pokerBetGetRemainingPlayer(
|
||||
&game->poker.bet, game->poker.players, game->poker.roundSmallBlind
|
||||
@ -101,47 +98,14 @@ void _pokerGameActionBetOnEnd(
|
||||
|
||||
// Are we waiting on any players?
|
||||
if(game->poker.bet.better != 0xFF) {
|
||||
if(game->poker.bet.better == POKER_PLAYER_HUMAN_INDEX) {
|
||||
pokerGameActionLookAdd(game, POKER_DEALER_INDEX);
|
||||
} else {
|
||||
pokerGameActionLookAdd(game, game->poker.bet.better);
|
||||
}
|
||||
pokerGameActionLookAdd(game, game->poker.bet.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
return;
|
||||
}
|
||||
|
||||
// Prep convo
|
||||
discussion.poker = game;
|
||||
|
||||
// Not waiting, restack and do next action.
|
||||
// Not waiting, do next action.
|
||||
printf("Not waiting on anything!\n");
|
||||
|
||||
// Is there a next round, or did someone just win?
|
||||
if(pokerBetGetRemainingPlayerCount(&game->poker.bet,game->poker.players) > 1){
|
||||
// No! Begin the next flop.
|
||||
next = pokerActionNextFlopAdd(queue, &game->poker);
|
||||
if(next != NULL) {
|
||||
discussion.reason = POKER_DISCUSSION_REASON_FLOP;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
pokerBetResetBetter(
|
||||
&game->poker.bet, game->poker.players, game->poker.roundSmallBlind
|
||||
);
|
||||
pokerGameActionRestackAdd(game);
|
||||
pokerGameActionLookAdd(game, game->poker.bet.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Done betting
|
||||
printf("All betting is done, reveal\n");
|
||||
discussion.reason = POKER_DISCUSSION_REASON_BETTING_DONE;
|
||||
discussion.poker = game;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
pokerGameActionRestackAdd(game);
|
||||
pokerGameActionWinnerAdd(game);
|
||||
pokerGameActionFlopAdd(game);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionBetAdd(pokergame_t *game) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "action.h"
|
||||
#include "restack.h"
|
||||
#include "winner.h"
|
||||
#include "flop.h"
|
||||
|
||||
/** Callback when the bet action is updated. */
|
||||
void _pokerGameActionBetOnUpdate(
|
||||
|
25
src/game/poker/actions/flop.h
Normal file
25
src/game/poker/actions/flop.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/actions/flop.h"
|
||||
#include "../../../poker/turn.h"
|
||||
#include "../../../poker/bet.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "action.h"
|
||||
#include "restack.h"
|
||||
#include "winner.h"
|
||||
#include "bet.h"
|
||||
|
||||
/**
|
||||
* Queues a flop action on to the queue.
|
||||
*
|
||||
* @param game Game to queue on to.
|
||||
* @return queueaction_t*
|
||||
*/
|
||||
queueaction_t * pokerGameActionFlopAdd(pokergame_t *game);
|
@ -10,7 +10,10 @@
|
||||
void _pokerGameActionWinnerOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokerdiscussiondata_t discussion;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// Calculate the winners
|
||||
printf("Winner start action");
|
||||
pokerWinnerCalculate(
|
||||
&game->poker.winner,
|
||||
@ -18,12 +21,22 @@ void _pokerGameActionWinnerOnStart(
|
||||
game->poker.players
|
||||
);
|
||||
|
||||
// Action
|
||||
pokerGameWin(&game->poker);
|
||||
|
||||
// Debug printing.
|
||||
printf("Winner Count %u\n", game->poker.winner.winnerCount);
|
||||
for(uint8_t i = 0; i < game->poker.winner.winnerCount; i++) {
|
||||
uint8_t winner = game->poker.winner.winners[i];
|
||||
printf("Winner %u\n", winner);
|
||||
}
|
||||
|
||||
// Say stuff
|
||||
discussion.reason = POKER_DISCUSSION_REASON_BETTING_DONE;
|
||||
discussion.poker = game;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
// Begin next round.
|
||||
pokerGameActionRoundAdd(game);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/winner.h"
|
||||
#include "../../../poker/poker.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "action.h"
|
||||
#include "round.h"
|
||||
|
@ -106,8 +106,10 @@ void pokerDiscussionQueue(pokerdiscussiondata_t *data) {
|
||||
pokerdiscussion_t discussion;
|
||||
uint8_t i, player;
|
||||
|
||||
// Fetch the discussion item for the given data.
|
||||
pokerDiscussionGet(&discussion, data);
|
||||
|
||||
// Now for each discussion item, queue a task.
|
||||
for(i = 0; i < discussion.count; i++) {
|
||||
player = discussion.players[i];
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
|
||||
/** Representation of data that poker game actions can have access to. */
|
||||
typedef struct {
|
||||
uint8_t lookAtPlayer;
|
||||
} pokergameactiondata_t;
|
Reference in New Issue
Block a user