Last commit before another big refactor
This commit is contained in:
@ -162,6 +162,16 @@ typedef struct {
|
|||||||
/** Information about the current rendered text */
|
/** Information about the current rendered text */
|
||||||
fonttextinfo_t *talkTextInfo;
|
fonttextinfo_t *talkTextInfo;
|
||||||
|
|
||||||
|
/** Match Scene Variables */
|
||||||
|
float matchStart;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
texture_t dealerTexture;
|
texture_t dealerTexture;
|
||||||
tileset_t dealerTileset;
|
tileset_t dealerTileset;
|
||||||
primitive_t dealerPrimitive;
|
primitive_t dealerPrimitive;
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
#include "../../game/game.h"
|
#include "../../game/game.h"
|
||||||
#include "../../input/input.h"
|
#include "../../input/input.h"
|
||||||
|
|
||||||
#define WINDOW_WIDTH_DEFAULT 480
|
#define WINDOW_WIDTH_DEFAULT 1280
|
||||||
#define WINDOW_HEIGHT_DEFAULT 270
|
#define WINDOW_HEIGHT_DEFAULT WINDOW_WIDTH_DEFAULT/16*9
|
||||||
|
|
||||||
/** The current running game state. */
|
/** The current running game state. */
|
||||||
extern game_t *GAME_STATE;
|
extern game_t *GAME_STATE;
|
||||||
|
@ -54,8 +54,8 @@ int32_t cardContainsNumber(card_t *hand, uint8_t length, uint8_t number) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t cardCountPairs(
|
uint8_t cardCountPairs(card_t *in, uint8_t inCount, uint8_t number,
|
||||||
card_t *in, uint8_t inCount, uint8_t number, int32_t out[CARD_SUIT_COUNT]
|
int32_t out[CARD_SUIT_COUNT]
|
||||||
) {
|
) {
|
||||||
uint8_t i, count;
|
uint8_t i, count;
|
||||||
int32_t index;
|
int32_t index;
|
||||||
@ -68,4 +68,8 @@ uint8_t cardCountPairs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cardShuffle(card_t *hand, uint8_t length) {
|
||||||
|
arrayShuffle(sizeof(card_t), hand, length);
|
||||||
}
|
}
|
@ -83,4 +83,12 @@ int32_t cardContainsNumber(card_t *hand, uint8_t length, uint8_t number);
|
|||||||
*/
|
*/
|
||||||
uint8_t cardCountPairs(
|
uint8_t cardCountPairs(
|
||||||
card_t *in, uint8_t inCount, uint8_t number, int32_t out[4]
|
card_t *in, uint8_t inCount, uint8_t number, int32_t out[4]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuffles a hand / deck
|
||||||
|
*
|
||||||
|
* @param hand Hand to shuffle.
|
||||||
|
* @param length Length of the hand to shuffle.
|
||||||
|
*/
|
||||||
|
void cardShuffle(card_t *hand, uint8_t length);
|
@ -239,6 +239,38 @@ void pokerPlayerGetWinning(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pokerPlayerWinningFillRemaining(pokerwinning_t *winning) {
|
||||||
|
uint8_t i, highest, current;
|
||||||
|
card_t highestCard, currentCard;
|
||||||
|
|
||||||
|
// Set the kicker
|
||||||
|
winning->kicker = 0xFF;
|
||||||
|
|
||||||
|
// Fill the remaining cards
|
||||||
|
while(winning->setSize < POKER_WINNING_SET_SIZE) {
|
||||||
|
highest = 0xFF;
|
||||||
|
|
||||||
|
for(i = 0; i < winning->fullSize; i++) {
|
||||||
|
currentCard = winning->full[i];
|
||||||
|
if(cardContains(winning->set, winning->setSize, currentCard) != -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(highest == 0xFF) {
|
||||||
|
highestCard = currentCard;
|
||||||
|
highest = cardGetNumber(highestCard);
|
||||||
|
} else {
|
||||||
|
current = cardGetNumber(currentCard);
|
||||||
|
if(current != CARD_ACE && current < highest) continue;
|
||||||
|
highestCard = currentCard;
|
||||||
|
highest = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
winning->set[winning->setSize++] = highestCard;
|
||||||
|
}
|
||||||
|
cardHandSort(winning->set, winning->setSize);
|
||||||
|
}
|
||||||
|
|
||||||
card_t pokerPlayerCompareWinning(pokerwinning_t *left, pokerwinning_t *right) {
|
card_t pokerPlayerCompareWinning(pokerwinning_t *left, pokerwinning_t *right) {
|
||||||
uint8_t i, number;
|
uint8_t i, number;
|
||||||
@ -281,35 +313,63 @@ card_t pokerPlayerCompareWinning(pokerwinning_t *left, pokerwinning_t *right) {
|
|||||||
return highCardLeft;//Greater or Equal to.
|
return highCardLeft;//Greater or Equal to.
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerPlayerWinningFillRemaining(pokerwinning_t *winning) {
|
void pokerPlayerWinnerDetermine(poker_t *poker) {
|
||||||
uint8_t i, highest, current;
|
uint8_t i, j, number, highNumber;
|
||||||
card_t highestCard, currentCard;
|
pokerwinning_t *left, *right;
|
||||||
|
pokerplayer_t *player;
|
||||||
|
card_t card, highCard;
|
||||||
|
bool winner;
|
||||||
|
|
||||||
// Set the kicker
|
poker->winnerCount = 0;
|
||||||
winning->kicker = 0xFF;
|
|
||||||
|
|
||||||
// Fill the remaining cards
|
// Get winning sets
|
||||||
while(winning->setSize < POKER_WINNING_SET_SIZE) {
|
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||||
highest = 0xFF;
|
left = poker->winnings + i;
|
||||||
|
left->type = POKER_WINNING_TYPE_NULL;
|
||||||
|
player = poker->players + i;
|
||||||
|
if(!pokerPlayerIsAlive(player)) continue;
|
||||||
|
|
||||||
for(i = 0; i < winning->fullSize; i++) {
|
// Get the players' full hand.
|
||||||
currentCard = winning->full[i];
|
pokerPlayerGetWinning(poker, player, left);
|
||||||
if(cardContains(winning->set, winning->setSize, currentCard) != -1) {
|
}
|
||||||
continue;
|
|
||||||
|
// Compare against each player
|
||||||
|
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||||
|
left = poker->winnings + i;
|
||||||
|
if(left->type == POKER_WINNING_TYPE_NULL) continue;
|
||||||
|
|
||||||
|
winner = true;
|
||||||
|
highNumber = 0xFF;
|
||||||
|
|
||||||
|
for(j = 0; j < POKER_PLAYER_COUNT; j++) {
|
||||||
|
if(i == j) continue;
|
||||||
|
right = poker->winnings + j;
|
||||||
|
if(right->type == POKER_WINNING_TYPE_NULL) continue;
|
||||||
|
|
||||||
|
// Am I the better hand / Is it the better hand?
|
||||||
|
if(left->type < right->type) continue;
|
||||||
|
if(left->type > right->type) {
|
||||||
|
winner = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(highest == 0xFF) {
|
// Equal, compare hands.
|
||||||
highestCard = currentCard;
|
card = pokerPlayerCompareWinning(left, right);
|
||||||
highest = cardGetNumber(highestCard);
|
if(card == 0xFF) {
|
||||||
} else {
|
winner = false;
|
||||||
current = cardGetNumber(currentCard);
|
break;
|
||||||
if(current != CARD_ACE && current < highest) continue;
|
}
|
||||||
highestCard = currentCard;
|
|
||||||
highest = current;
|
// Determine high card.
|
||||||
|
number = cardGetNumber(card);
|
||||||
|
if(highNumber == 0xFF || number == CARD_ACE || number > highNumber) {
|
||||||
|
highCard = card;
|
||||||
|
highNumber = number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
winning->set[winning->setSize++] = highestCard;
|
if(!winner) continue;
|
||||||
|
left->kicker = highCard;
|
||||||
|
poker->winners[poker->winnerCount++] = i;
|
||||||
}
|
}
|
||||||
cardHandSort(winning->set, winning->setSize);
|
}
|
||||||
}
|
|
||||||
|
@ -73,6 +73,12 @@ void pokerPlayerGetWinning(
|
|||||||
poker_t *poker, pokerplayer_t *player, pokerwinning_t *winning
|
poker_t *poker, pokerplayer_t *player, pokerwinning_t *winning
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fills the remaining cards for a given poker player winning hand.
|
||||||
|
* @param winning Pointer to the poker winning to fill out.
|
||||||
|
*/
|
||||||
|
void pokerPlayerWinningFillRemaining(pokerwinning_t *winning);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares two winning sets. The returned card is the kicker if the LEFT side
|
* Compares two winning sets. The returned card is the kicker if the LEFT side
|
||||||
* is the winner. If LEFT is not a winner then 0xFF will be returned.
|
* is the winner. If LEFT is not a winner then 0xFF will be returned.
|
||||||
@ -84,7 +90,9 @@ void pokerPlayerGetWinning(
|
|||||||
card_t pokerPlayerCompareWinning(pokerwinning_t *left, pokerwinning_t *right);
|
card_t pokerPlayerCompareWinning(pokerwinning_t *left, pokerwinning_t *right);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the remaining cards for a given poker player winning hand.
|
* Determines the winning player for the game. Values will be stored back into
|
||||||
* @param winning Pointer to the poker winning to fill out.
|
* the poker winning state.
|
||||||
|
*
|
||||||
|
* @param poker Poker game instance.
|
||||||
*/
|
*/
|
||||||
void pokerPlayerWinningFillRemaining(pokerwinning_t *winning);
|
void pokerPlayerWinnerDetermine(poker_t *poker);
|
@ -24,14 +24,14 @@ void pokerInit(poker_t *poker, engine_t *engine) {
|
|||||||
pokerTalkInit(poker);
|
pokerTalkInit(poker);
|
||||||
|
|
||||||
// Hand over to the deal for the first time.
|
// Hand over to the deal for the first time.
|
||||||
pokerMatchInit(poker);
|
pokerMatchInit(poker, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerUpdate(poker_t *poker, engine_t *engine) {
|
void pokerUpdate(poker_t *poker, engine_t *engine) {
|
||||||
// Game Logic
|
// Game Logic
|
||||||
switch(poker->round) {
|
switch(poker->round) {
|
||||||
case POKER_ROUND_MATCH:
|
case POKER_ROUND_MATCH:
|
||||||
pokerMatchUpdate(poker);
|
pokerMatchUpdate(poker, engine);
|
||||||
break;
|
break;
|
||||||
case POKER_ROUND_BET0:
|
case POKER_ROUND_BET0:
|
||||||
case POKER_ROUND_BET1:
|
case POKER_ROUND_BET1:
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include "look.h"
|
#include "look.h"
|
||||||
|
|
||||||
void pokerLookAtPlayer(camera_t *camera, uint8_t seat) {
|
void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance) {
|
||||||
float x, z, angle;
|
float x, z, angle;
|
||||||
angle = POKER_SEAT_ANGLE(seat);
|
angle = POKER_SEAT_ANGLE(seat);
|
||||||
x = sin(angle) * 0.8;
|
x = sin(angle) * (0.8);
|
||||||
z = cos(angle) * 0.8;
|
z = cos(angle) * (0.8 + distance);
|
||||||
cameraLookAt(camera,
|
cameraLookAt(camera,
|
||||||
x, 0.3, z,
|
x, 0.3, z,
|
||||||
-x, 0.3, -z
|
-x, 0.3, -z
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* @param camera Camera to adjust.
|
* @param camera Camera to adjust.
|
||||||
* @param seat Seat to look at.
|
* @param seat Seat to look at.
|
||||||
*/
|
*/
|
||||||
void pokerLookAtPlayer(camera_t *camera, uint8_t seat);
|
void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look at a specific seats' hand.
|
* Look at a specific seats' hand.
|
||||||
|
@ -10,10 +10,10 @@ void pokerDealInit(poker_t *poker) {
|
|||||||
poker->round = POKER_ROUND_DEAL;
|
poker->round = POKER_ROUND_DEAL;
|
||||||
|
|
||||||
// Hard look at the dealer
|
// Hard look at the dealer
|
||||||
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER);
|
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER, 0);
|
||||||
|
|
||||||
// Shuffle the deck
|
// Shuffle the deck
|
||||||
arrayShuffle(sizeof(card_t), poker->deck, CARD_DECK_SIZE);
|
cardShuffle(poker->deck, CARD_DECK_SIZE);
|
||||||
|
|
||||||
// Deal 2 card to each player
|
// Deal 2 card to each player
|
||||||
pokerPlayerDealAll(poker, POKER_DEAL_CARD_EACH);
|
pokerPlayerDealAll(poker, POKER_DEAL_CARD_EACH);
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
*/
|
*/
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
|
|
||||||
void pokerMatchInit(poker_t *poker) {
|
void pokerMatchInit(poker_t *poker, engine_t *engine) {
|
||||||
uint8_t x;
|
uint8_t x;
|
||||||
|
|
||||||
// Look at the dealer
|
// Look at the dealer
|
||||||
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER);
|
poker->matchStart = engine->time.current;
|
||||||
|
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER, 100);
|
||||||
|
|
||||||
// Reset the main game state. This does not init the round.
|
// Reset the main game state. This does not init the round.
|
||||||
poker->blindBig = POKER_BLIND_BIG_DEFAULT;
|
poker->blindBig = POKER_BLIND_BIG_DEFAULT;
|
||||||
@ -24,8 +25,9 @@ void pokerMatchInit(poker_t *poker) {
|
|||||||
poker->players[x].chips = POKER_PLAYER_CHIPS_DEFAULT;
|
poker->players[x].chips = POKER_PLAYER_CHIPS_DEFAULT;
|
||||||
}
|
}
|
||||||
printf("Match Start\n");
|
printf("Match Start\n");
|
||||||
pokerStartInit(poker);
|
// pokerStartInit(poker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerMatchUpdate(poker_t *poker) {
|
void pokerMatchUpdate(poker_t *poker, engine_t *engine) {
|
||||||
|
float matchDiff = poker->matchStart - engine->time.current;
|
||||||
}
|
}
|
@ -14,11 +14,12 @@
|
|||||||
/**
|
/**
|
||||||
* Init the poker match round.
|
* Init the poker match round.
|
||||||
* @param poker The poker game context.
|
* @param poker The poker game context.
|
||||||
|
* @param engine The engine context.
|
||||||
*/
|
*/
|
||||||
void pokerMatchInit(poker_t *poker);
|
void pokerMatchInit(poker_t *poker, engine_t *engine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the poker match round.
|
* Update the poker match round.
|
||||||
* @param poker The poker match to update for.
|
* @param poker The poker match to update for.
|
||||||
*/
|
*/
|
||||||
void pokerMatchUpdate(poker_t *poker);
|
void pokerMatchUpdate(poker_t *poker, engine_t *engine);
|
@ -6,75 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "winner.h"
|
#include "winner.h"
|
||||||
|
|
||||||
int32_t _pokerWinnersSorter(void *left, void* right) {
|
|
||||||
return ((pokerwinning_t *)right)->type - ((pokerwinning_t *)left)->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokerWinnersSort(pokerwinning_t *winnings, int32_t length) {
|
|
||||||
arraySort(sizeof(pokerwinning_t),
|
|
||||||
winnings, length, (arraysort_t *)&_pokerWinnersSorter
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void pokerWinnerInit(poker_t *poker) {
|
void pokerWinnerInit(poker_t *poker) {
|
||||||
uint8_t i, j, number, highNumber;
|
pokerPlayerWinnerDetermine(poker);
|
||||||
pokerwinning_t *left, *right;
|
|
||||||
pokerplayer_t *player;
|
|
||||||
card_t card, highCard;
|
|
||||||
bool winner;
|
|
||||||
|
|
||||||
poker->winnerCount = 0;
|
|
||||||
|
|
||||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
|
||||||
left = poker->winnings + i;
|
|
||||||
left->type = POKER_WINNING_TYPE_NULL;
|
|
||||||
player = poker->players + i;
|
|
||||||
if(!pokerPlayerIsAlive(player)) continue;
|
|
||||||
|
|
||||||
// Get the players' full hand.
|
|
||||||
pokerPlayerGetWinning(poker, player, left);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
|
||||||
left = poker->winnings + i;
|
|
||||||
if(left->type == POKER_WINNING_TYPE_NULL) continue;
|
|
||||||
|
|
||||||
winner = true;
|
|
||||||
highNumber = 0xFF;
|
|
||||||
|
|
||||||
for(j = 0; j < POKER_PLAYER_COUNT; j++) {
|
|
||||||
if(i == j) continue;
|
|
||||||
|
|
||||||
right = poker->winnings + j;
|
|
||||||
if(right->type == POKER_WINNING_TYPE_NULL) continue;
|
|
||||||
|
|
||||||
// Am I the better hand?
|
|
||||||
if(left->type < right->type) continue;
|
|
||||||
if(left->type > right->type) {
|
|
||||||
// No
|
|
||||||
winner = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Equal, compare hands.
|
|
||||||
card = pokerPlayerCompareWinning(left, right);
|
|
||||||
if(card == 0xFF) {
|
|
||||||
winner = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
number = cardGetNumber(card);
|
|
||||||
if(highNumber == 0xFF || number == CARD_ACE || number > highNumber) {
|
|
||||||
highCard = card;
|
|
||||||
highNumber = number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!winner) continue;
|
|
||||||
left->kicker = highCard;
|
|
||||||
poker->winners[poker->winnerCount++] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Winner Count %u\n", poker->winnerCount);
|
printf("Winner Count %u\n", poker->winnerCount);
|
||||||
}
|
}
|
@ -9,6 +9,4 @@
|
|||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "../player.h"
|
#include "../player.h"
|
||||||
|
|
||||||
int32_t _pokerWinnersSorter(void *left, void* right);
|
|
||||||
void pokerWinnersSort(pokerwinning_t *winnings, int32_t length);
|
|
||||||
void pokerWinnerInit(poker_t *poker);
|
void pokerWinnerInit(poker_t *poker);
|
Reference in New Issue
Block a user