Fixed Winner logic

This commit is contained in:
2021-09-20 18:33:00 -07:00
parent 19e7a12458
commit 11e4bfe23b
11 changed files with 113 additions and 11 deletions

View File

@ -34,7 +34,7 @@ void _pokerGameActionBetOnUpdate(
isHuman = game->poker.bet.better == POKER_PLAYER_HUMAN_INDEX;
// Handle as an AI
if(isHuman) {
if(isHuman && false) {
turn = game->ui.betTurn;
turnMade = game->ui.betTurnMade;
} else {
@ -90,6 +90,7 @@ void _pokerGameActionBetOnEnd(
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
@ -109,6 +110,9 @@ void _pokerGameActionBetOnEnd(
return;
}
// Prep convo
discussion.poker = game;
// Not waiting, restack and do next action.
printf("Not waiting on anything!\n");
@ -116,7 +120,6 @@ void _pokerGameActionBetOnEnd(
next = pokerActionNextFlopAdd(queue, &game->poker);
if(next != NULL) {
discussion.reason = POKER_DISCUSSION_REASON_FLOP;
discussion.poker = game;
pokerDiscussionQueue(&discussion);
pokerBetResetBetter(
@ -128,8 +131,13 @@ void _pokerGameActionBetOnEnd(
return;
}
/** Queue a restack */
// 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);
}
queueaction_t * pokerGameActionBetAdd(pokergame_t *game) {

View File

@ -7,13 +7,13 @@
#pragma once
#include "../../../libs.h"
#include "action.h"
#include "restack.h"
#include "../../../input/input.h"
#include "../../../poker/actions/flop.h"
#include "../../../poker/turn.h"
#include "../../../poker/bet.h"
#include "../../../poker/actions/flop.h"
#include "../pokerdiscussion.h"
#include "action.h"
#include "restack.h"
#include "winner.h"
/** Callback when the bet action is updated. */
void _pokerGameActionBetOnUpdate(

View File

@ -0,0 +1,32 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "winner.h"
void _pokerGameActionWinnerOnStart(
queue_t *queue, queueaction_t *action, uint8_t i
) {
pokergame_t *game = (pokergame_t *)action->data;
printf("Winner start action");
pokerWinnerCalculate(
&game->poker.winner,
&game->poker.dealer,
game->poker.players
);
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);
}
}
queueaction_t * pokerGameActionWinnerAdd(pokergame_t *game) {
queueaction_t *action = pokerGameActionAdd(game);
action->onStart = &_pokerGameActionWinnerOnStart;
return action;
}

View 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/winner.h"
#include "../pokerdiscussion.h"
#include "action.h"
/** Callback to fire when the winner starts */
void _pokerGameActionWinnerOnStart(
queue_t *queue, queueaction_t *action, uint8_t i
);
/**
* Queue a winning game action.
*
* @param game Game to queue for.
* @return The queued winning action.
*/
queueaction_t * pokerGameActionWinnerAdd(pokergame_t *game);

View File

@ -96,6 +96,8 @@ void pokerDiscussionGet(
}
void pokerDiscussionQueue(pokerdiscussiondata_t *data) {
return;
pokerdiscussion_t discussion;
uint8_t i, player;

View File

@ -25,6 +25,7 @@
#define POKER_DISCUSSION_REASON_PLAYER_RAISING 0x07
#define POKER_DISCUSSION_REASON_FLOP 0x08
#define POKER_DISCUSSION_REASON_DEAL 0x09
#define POKER_DISCUSSION_REASON_BETTING_DONE 0x0A
typedef struct {
pokergame_t *poker;

View File

@ -116,6 +116,13 @@ void pokerUiRender(
imageRender(&ui->card, &assets->shader, i * 64.0f, j * 100.0f);
}
}
for(j = 0; j < poker->dealer.cardsFacing; j++) {
pokerUiSetImageToCard(
&ui->card, &assets->cardTexture, poker->dealer.cards[j]
);
imageRender(&ui->card, &assets->shader, 200, j * 100.0f);
}
}
// Betting UI