More code cleaning.
This commit is contained in:
@ -49,32 +49,7 @@ void _pokerGameActionBetOnUpdate(
|
||||
pokerTurnAction(&game->poker, player, &turn);
|
||||
|
||||
// Speak
|
||||
switch(turn.type) {
|
||||
case POKER_TURN_TYPE_BET:
|
||||
discussion.reason = POKER_DISCUSSION_REASON_PLAYER_RAISING;
|
||||
break;
|
||||
|
||||
case POKER_TURN_TYPE_CALL:
|
||||
discussion.reason = POKER_DISCUSSION_REASON_PLAYER_CALLING;
|
||||
break;
|
||||
|
||||
case POKER_TURN_TYPE_ALL_IN:
|
||||
discussion.reason = POKER_DISCUSSION_REASON_PLAYER_ALL_IN;
|
||||
break;
|
||||
|
||||
case POKER_TURN_TYPE_FOLD:
|
||||
discussion.reason = POKER_DISCUSSION_REASON_PLAYER_FOLDING;
|
||||
break;
|
||||
|
||||
case POKER_TURN_TYPE_CHECK:
|
||||
discussion.reason = POKER_DISCUSSION_REASON_PLAYER_CHECKING;
|
||||
break;
|
||||
|
||||
default:
|
||||
discussion.reason = POKER_DISCUSSION_REASON_TEST;
|
||||
break;
|
||||
}
|
||||
|
||||
discussion.reason = pokerDiscussionGetTypeFromTurnType(turn.type);
|
||||
discussion.poker = game;
|
||||
discussion.playerCause = game->poker.bet.better;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
@ -104,7 +79,6 @@ void _pokerGameActionBetOnEnd(
|
||||
}
|
||||
|
||||
// Not waiting, do next action.
|
||||
printf("Not waiting on anything!\n");
|
||||
pokerGameActionFlopAdd(game);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ void _pokerGameActionFlopOnStart(
|
||||
if(pokerBetGetRemainingPlayerCount(
|
||||
&game->poker.bet, game->poker.players
|
||||
) > 1) {
|
||||
|
||||
// Begin betting.
|
||||
pokerGameActionLookAdd(game, game->poker.bet.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
@ -56,7 +55,6 @@ void _pokerGameActionFlopOnStart(
|
||||
}
|
||||
|
||||
// Done betting
|
||||
printf("All betting is done, reveal\n");
|
||||
pokerGameActionRestackAdd(game);
|
||||
pokerGameActionWinnerAdd(game);
|
||||
|
||||
|
@ -16,6 +16,11 @@
|
||||
#include "winner.h"
|
||||
#include "bet.h"
|
||||
|
||||
/** Callback that is fired when the flop action starts */
|
||||
void _pokerGameActionFlopOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/**
|
||||
* Queues a flop action on to the queue.
|
||||
*
|
||||
|
@ -11,7 +11,6 @@ void _pokerGameActionRestackOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
printf("Restacking\n");
|
||||
pokerGameQueueRestack(game);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ void _pokerGameActionWinnerOnStart(
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// Calculate the winners
|
||||
printf("Winner start action");
|
||||
pokerWinnerCalculate(
|
||||
&game->poker.winner,
|
||||
&game->poker.dealer,
|
||||
@ -24,13 +23,6 @@ void _pokerGameActionWinnerOnStart(
|
||||
// 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;
|
||||
|
@ -109,6 +109,29 @@ void pokerDiscussionGet(
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType) {
|
||||
switch(winningType) {
|
||||
case POKER_TURN_TYPE_BET:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_RAISING;
|
||||
|
||||
case POKER_TURN_TYPE_CALL:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_CALLING;
|
||||
|
||||
case POKER_TURN_TYPE_ALL_IN:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_ALL_IN;
|
||||
|
||||
case POKER_TURN_TYPE_FOLD:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_FOLDING;
|
||||
break;
|
||||
|
||||
case POKER_TURN_TYPE_CHECK:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_CHECKING;
|
||||
|
||||
default:
|
||||
return POKER_DISCUSSION_REASON_TEST;
|
||||
}
|
||||
}
|
||||
|
||||
void pokerDiscussionQueue(pokerdiscussiondata_t *data) {
|
||||
pokerdiscussion_t discussion;
|
||||
uint8_t i, player;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "../../vn/conversation/vnconversation.h"
|
||||
#include "../../vn/conversation/talk.h"
|
||||
#include "actions/look.h"
|
||||
#include "../../poker/turn.h"
|
||||
|
||||
/** Maximum number of messages that the discussion buffer can hold */
|
||||
#define POKER_DISCUSSION_MESSAGE_COUNT_MAX 32
|
||||
@ -49,6 +50,14 @@ typedef struct {
|
||||
*/
|
||||
void pokerDiscussionGet(pokerdiscussion_t *disc, pokerdiscussiondata_t *data);
|
||||
|
||||
/**
|
||||
* Fetch the discussion type from a turn type.
|
||||
*
|
||||
* @param winningType Winning type
|
||||
* @return Relevant discussion type.
|
||||
*/
|
||||
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType);
|
||||
|
||||
/**
|
||||
* Queue a discussion data result onto the conversation stack.
|
||||
*
|
||||
|
@ -69,7 +69,7 @@ void pokerUiUpdate(
|
||||
player = players + j;
|
||||
|
||||
// Locate the XYZ position of the camera to look at the player
|
||||
seat = pokerGameSeatFromIndex(i);
|
||||
seat = pokerWorldSeatFromIndex(i);
|
||||
x = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||
y = POKER_UI_PLAYER_IMAGE_Y;
|
||||
z = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||
|
@ -15,7 +15,7 @@ void pokerWorldInit(
|
||||
vncharacter_t *character;
|
||||
uint8_t i;
|
||||
|
||||
world->seat = POKER_GAME_SEAT_DEALER;
|
||||
world->seat = POKER_WORLD_SEAT_DEALER;
|
||||
world->seatTime = 0;
|
||||
|
||||
// Initialize the skywal
|
||||
@ -25,14 +25,14 @@ void pokerWorldInit(
|
||||
for(i = 0x00; i < POKER_PLAYER_COUNT; i++) {
|
||||
character = scene->characters + scene->characterCount;
|
||||
vnCharacterInit(character, &assets->pennyTexture,
|
||||
POKER_GAME_PENNY_BASE_WIDTH, POKER_GAME_PENNY_BASE_HEIGHT,
|
||||
POKER_GAME_PENNY_FACE_X, POKER_GAME_PENNY_FACE_Y,
|
||||
POKER_GAME_PENNY_FACE_WIDTH, POKER_GAME_PENNY_FACE_HEIGHT
|
||||
POKER_WORLD_PENNY_BASE_WIDTH, POKER_WORLD_PENNY_BASE_HEIGHT,
|
||||
POKER_WORLD_PENNY_FACE_X, POKER_WORLD_PENNY_FACE_Y,
|
||||
POKER_WORLD_PENNY_FACE_WIDTH, POKER_WORLD_PENNY_FACE_HEIGHT
|
||||
);
|
||||
character->x = POKER_WORLD_SEAT_POSITION_X(POKER_GAME_SEAT_FOR_PLAYER(i));
|
||||
character->x = POKER_WORLD_SEAT_POSITION_X(POKER_WORLD_SEAT_FOR_PLAYER(i));
|
||||
character->y = POKER_WORLD_SEAT_POSITION_Y;
|
||||
character->z = POKER_WORLD_SEAT_POSITION_Z(POKER_GAME_SEAT_FOR_PLAYER(i));
|
||||
character->yaw = POKER_WORLD_SEAT_ROTATION(POKER_GAME_SEAT_FOR_PLAYER(i));
|
||||
character->z = POKER_WORLD_SEAT_POSITION_Z(POKER_WORLD_SEAT_FOR_PLAYER(i));
|
||||
character->yaw = POKER_WORLD_SEAT_ROTATION(POKER_WORLD_SEAT_FOR_PLAYER(i));
|
||||
scene->characterCount++;
|
||||
}
|
||||
}
|
||||
|
@ -18,35 +18,46 @@
|
||||
#include "../../engine/engine.h"
|
||||
#include "pokergameassets.h"
|
||||
|
||||
|
||||
/** How far away from the camera are the characters distanced */
|
||||
#define POKER_WORLD_SEAT_DISTANCE -0.75f
|
||||
|
||||
/** How rotated is the player at a given seat */
|
||||
#define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f))
|
||||
|
||||
/** World X position of a given seat */
|
||||
#define POKER_WORLD_SEAT_POSITION_X(n) ( \
|
||||
POKER_WORLD_SEAT_DISTANCE * (float)sin(POKER_WORLD_SEAT_ROTATION(n)) \
|
||||
)
|
||||
/** Y Position of seats */
|
||||
#define POKER_WORLD_SEAT_POSITION_Y -0.2f
|
||||
/** World Z position of a given seat */
|
||||
#define POKER_WORLD_SEAT_POSITION_Z(n) ( \
|
||||
POKER_WORLD_SEAT_DISTANCE * (float)cos(POKER_WORLD_SEAT_ROTATION(n)) \
|
||||
)
|
||||
|
||||
#define POKER_GAME_SEAT_COUNT 8
|
||||
#define POKER_GAME_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2))
|
||||
#define POKER_GAME_SEAT_DEALER POKER_GAME_SEAT_FOR_PLAYER(POKER_DEALER_INDEX)
|
||||
/** Count of seats in the world */
|
||||
#define POKER_WORLD_SEAT_COUNT 8
|
||||
|
||||
#define pokerGameSeatFromIndex(i) (\
|
||||
/** The seat index for a given player index */
|
||||
#define POKER_WORLD_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2))
|
||||
|
||||
/** The seat that the dealer occupies */
|
||||
#define POKER_WORLD_SEAT_DEALER POKER_WORLD_SEAT_FOR_PLAYER(POKER_DEALER_INDEX)
|
||||
|
||||
/** The seat index for a given character index */
|
||||
#define pokerWorldSeatFromIndex(i) (\
|
||||
i == POKER_DEALER_INDEX ? \
|
||||
POKER_GAME_SEAT_DEALER : \
|
||||
POKER_GAME_SEAT_FOR_PLAYER(i) \
|
||||
POKER_WORLD_SEAT_DEALER : \
|
||||
POKER_WORLD_SEAT_FOR_PLAYER(i) \
|
||||
)
|
||||
|
||||
#define POKER_GAME_PENNY_BASE_WIDTH 1000
|
||||
#define POKER_GAME_PENNY_BASE_HEIGHT 1920
|
||||
#define POKER_GAME_PENNY_FACE_X 367
|
||||
#define POKER_GAME_PENNY_FACE_Y 256
|
||||
#define POKER_GAME_PENNY_FACE_WIDTH 280
|
||||
#define POKER_GAME_PENNY_FACE_HEIGHT 280
|
||||
|
||||
// Penny Defs.
|
||||
#define POKER_WORLD_PENNY_BASE_WIDTH 1000
|
||||
#define POKER_WORLD_PENNY_BASE_HEIGHT 1920
|
||||
#define POKER_WORLD_PENNY_FACE_X 367
|
||||
#define POKER_WORLD_PENNY_FACE_Y 256
|
||||
#define POKER_WORLD_PENNY_FACE_WIDTH 280
|
||||
#define POKER_WORLD_PENNY_FACE_HEIGHT 280
|
||||
|
||||
typedef struct {
|
||||
primitive_t skywall;
|
||||
@ -56,7 +67,6 @@ typedef struct {
|
||||
float seatTime;
|
||||
} pokerworld_t;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the poker renderer.
|
||||
*
|
||||
|
@ -18,8 +18,6 @@ void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
|
||||
|
||||
// Deal 2 card to each player
|
||||
pokerDealerDealAll(&poker->dealer, poker->players, POKER_DEAL_CARD_EACH);
|
||||
|
||||
printf("Cards Dealt\n");
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ void _pokerActionFlopDo(queue_t *queue, queueaction_t *action, uint8_t count) {
|
||||
|
||||
poker->state = POKER_STATE_CARDS_FLOPPING;
|
||||
|
||||
pokerDealerBurn(&poker->dealer, 1);
|
||||
pokerDealerBurn(&poker->dealer, POKER_FLOP_BURN_COUNT);
|
||||
pokerDealerTurn(&poker->dealer, count);
|
||||
|
||||
printf("Turned %u cards\n", count);
|
||||
|
@ -12,6 +12,9 @@
|
||||
#include "../poker.h"
|
||||
#include "../turn.h"
|
||||
|
||||
/** How many cards the dealer should burn before dealing the flop */
|
||||
#define POKER_FLOP_BURN_COUNT 1
|
||||
|
||||
/**
|
||||
* Shorthand action callback parser. Takes the queue, action and the intended
|
||||
* turn count to complete the action.
|
||||
|
@ -18,12 +18,12 @@ void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i){
|
||||
// Reset the main game state. This does not init the round.
|
||||
pokerBetInit(&poker->bet);
|
||||
poker->roundDealer = POKER_PLAYER_COUNT-2;
|
||||
|
||||
|
||||
// Reset the players
|
||||
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
||||
poker->players[x].state = 0x00;
|
||||
poker->players[x].chips = POKER_BET_PLAYER_CHIPS_DEFAULT;
|
||||
}
|
||||
printf("Match Start\n");
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
|
||||
pokerDealerInit(&poker->dealer);
|
||||
|
||||
// Reset the players
|
||||
printf("Resetting the players\n");
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
pokerPlayerReset(poker->players + i);
|
||||
}
|
||||
@ -56,8 +55,7 @@ void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
|
||||
poker->roundDealer = indexDealer;
|
||||
poker->roundBigBlind = indexBigBlind;
|
||||
poker->roundSmallBlind = indexSmallBlind;
|
||||
|
||||
printf("Round Start\n");
|
||||
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "../util/array.h"
|
||||
|
||||
/** How many chips each player has by defautl */
|
||||
#define POKER_BET_PLAYER_CHIPS_DEFAULT 10000
|
||||
#define POKER_BET_PLAYER_CHIPS_DEFAULT 1200
|
||||
|
||||
/** The default blind cost for the big blind. */
|
||||
#define POKER_BET_BLIND_BIG_DEFAULT 600
|
||||
|
@ -52,4 +52,9 @@ typedef struct {
|
||||
uint8_t state;
|
||||
} poker_t;
|
||||
|
||||
/**
|
||||
* Action the poker game winning state after it has been calculated previously.
|
||||
*
|
||||
* @param poker Poker game to action the winning state of.
|
||||
*/
|
||||
void pokerGameWin(poker_t *poker);
|
Reference in New Issue
Block a user