Refactoring some of the poker game logic again.
This commit is contained in:
1 parent
a63c9d898b
commit
54559e761c
36 files changed
+99
-304
No files matched your search
+1
-4
@@ -36,20 +36,17 @@
|
|||||||
|
|
||||||
// Game Logic
|
// Game Logic
|
||||||
#include "game/game.h"
|
#include "game/game.h"
|
||||||
|
#include "game/poker/pokergame.h"
|
||||||
|
|
||||||
// Player Input
|
// Player Input
|
||||||
#include "input/input.h"
|
#include "input/input.h"
|
||||||
|
|
||||||
// Poker Game Logic
|
// Poker Game Logic
|
||||||
#include "poker/round/match.h"
|
|
||||||
|
|
||||||
#include "poker/bet.h"
|
#include "poker/bet.h"
|
||||||
#include "poker/card.h"
|
#include "poker/card.h"
|
||||||
#include "poker/dealer.h"
|
#include "poker/dealer.h"
|
||||||
#include "poker/player.h"
|
#include "poker/player.h"
|
||||||
#include "poker/poker.h"
|
#include "poker/poker.h"
|
||||||
#include "poker/render.h"
|
|
||||||
#include "poker/strings.h"
|
|
||||||
#include "poker/winner.h"
|
#include "poker/winner.h"
|
||||||
|
|
||||||
// Utility Objects
|
// Utility Objects
|
||||||
|
|||||||
@@ -6,11 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "../engine/engine.h"
|
#include "../engine/engine.h"
|
||||||
#include "../poker/poker.h"
|
#include "poker/pokergame.h"
|
||||||
|
|
||||||
/** Name of the current game */
|
|
||||||
#define GAME_NAME "Dawn"
|
|
||||||
|
|
||||||
|
|
||||||
/** Describes the current game */
|
/** Describes the current game */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -19,6 +15,6 @@ typedef struct {
|
|||||||
/** Engine for the game */
|
/** Engine for the game */
|
||||||
engine_t engine;
|
engine_t engine;
|
||||||
|
|
||||||
/** Poker Game State */
|
/** Poker Game */
|
||||||
poker_t poker;
|
pokergame_t pokerGame;
|
||||||
} game_t;
|
} game_t;
|
||||||
@@ -7,8 +7,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../libs.h"
|
#include "../../libs.h"
|
||||||
|
#include "../../poker/poker.h"
|
||||||
|
|
||||||
|
/** Name of the Poker Game */
|
||||||
|
#define POKER_GAME_NAME "Dawn Poker Game"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Time when match started (for fade effect)
|
/** Poker Game State */
|
||||||
float time;
|
poker_t poker;
|
||||||
} pokerroundmatch_t;
|
} pokergame_t;
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/** Blinds */
|
/** Blinds */
|
||||||
uint32_t blindSmall, blindBig;
|
uint32_t blindSmall, blindBig;
|
||||||
|
|
||||||
|
/** For Betting round, which player is currently betting */
|
||||||
|
uint8_t better;
|
||||||
|
|
||||||
/** Current pot of chips */
|
/** Current pot of chips */
|
||||||
uint32_t pot;
|
uint32_t pot;
|
||||||
|
|||||||
@@ -8,9 +8,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
#include "../display/texture.h"
|
|
||||||
#include "../display/tileset.h"
|
|
||||||
#include "../display/primitive.h"
|
|
||||||
|
|
||||||
/** How many cards the dealer can hold in their hand */
|
/** How many cards the dealer can hold in their hand */
|
||||||
#define POKER_DEALER_HAND_SIZE 5
|
#define POKER_DEALER_HAND_SIZE 5
|
||||||
@@ -31,11 +28,4 @@ typedef struct {
|
|||||||
/** Card grave (where spent cards go when burned */
|
/** Card grave (where spent cards go when burned */
|
||||||
card_t grave[POKER_DEALER_GRAVE_SIZE];
|
card_t grave[POKER_DEALER_GRAVE_SIZE];
|
||||||
uint8_t graveSize;
|
uint8_t graveSize;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Rendering assets (unfinished)
|
|
||||||
texture_t dealerTexture;
|
|
||||||
tileset_t dealerTileset;
|
|
||||||
primitive_t dealerPrimitive;
|
|
||||||
} pokerdealer_t;
|
} pokerdealer_t;
|
||||||
@@ -10,10 +10,6 @@
|
|||||||
#include "bet.h"
|
#include "bet.h"
|
||||||
#include "dealer.h"
|
#include "dealer.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
#include "../display/texture.h"
|
|
||||||
#include "../display/primitive.h"
|
|
||||||
#include "../display/tileset.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** How many cards a player can hold in their hand */
|
/** How many cards a player can hold in their hand */
|
||||||
#define POKER_PLAYER_HAND 2
|
#define POKER_PLAYER_HAND 2
|
||||||
@@ -56,12 +52,4 @@ typedef struct {
|
|||||||
|
|
||||||
/** Current bet in current round player has placed */
|
/** Current bet in current round player has placed */
|
||||||
uint32_t currentBet;
|
uint32_t currentBet;
|
||||||
|
|
||||||
|
|
||||||
// Rendering assets
|
|
||||||
texture_t bodyTexture;
|
|
||||||
primitive_t bodyPrimitive;
|
|
||||||
|
|
||||||
texture_t faceTexture;
|
|
||||||
primitive_t facePrimitive;
|
|
||||||
} pokerplayer_t;
|
} pokerplayer_t;
|
||||||
@@ -11,18 +11,8 @@
|
|||||||
#include "dealer.h"
|
#include "dealer.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
#include "render.h"
|
|
||||||
#include "winner.h"
|
#include "winner.h"
|
||||||
|
|
||||||
#include "round/match.h"
|
|
||||||
|
|
||||||
#include "../display/camera.h"
|
|
||||||
#include "../display/shader.h"
|
|
||||||
#include "../display/texture.h"
|
|
||||||
#include "../display/tileset.h"
|
|
||||||
#include "../display/framebuffer.h"
|
|
||||||
#include "../display/primitive.h"
|
|
||||||
|
|
||||||
/** Rounds that the game can be in */
|
/** Rounds that the game can be in */
|
||||||
#define POKER_ROUND_MATCH 0x00
|
#define POKER_ROUND_MATCH 0x00
|
||||||
#define POKER_ROUND_START 0x01
|
#define POKER_ROUND_START 0x01
|
||||||
@@ -37,69 +27,33 @@
|
|||||||
#define POKER_ROUND_BET3 0x0A
|
#define POKER_ROUND_BET3 0x0A
|
||||||
#define POKER_ROUND_WINNER 0x0B
|
#define POKER_ROUND_WINNER 0x0B
|
||||||
|
|
||||||
/** GUI Height fix (To keep gui scaling nicely we use a fixed height) */
|
|
||||||
#define POKER_GUI_HEIGHT 2160
|
|
||||||
|
|
||||||
/** How many cards to deal each player during the deal round */
|
/** How many cards to deal each player during the deal round */
|
||||||
#define POKER_DEAL_CARD_EACH 2
|
#define POKER_DEAL_CARD_EACH 2
|
||||||
|
|
||||||
|
/** How many cards are dealt for the flop, turn and river */
|
||||||
#define POKER_FLOP_CARD_COUNT 3
|
#define POKER_FLOP_CARD_COUNT 3
|
||||||
#define POKER_TURN_CARD_COUNT 1
|
#define POKER_TURN_CARD_COUNT 1
|
||||||
#define POKER_RIVER_CARD_COUNT 1
|
#define POKER_RIVER_CARD_COUNT 1
|
||||||
typedef struct {
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Poker Logic Variables
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
/** Poker betting state */
|
/** Poker betting state */
|
||||||
pokerbet_t bet;
|
pokerbet_t bet;
|
||||||
|
|
||||||
/** Player States */
|
/** Player States */
|
||||||
pokerdealer_t dealer;
|
pokerdealer_t dealer;
|
||||||
pokerplayer_t players[POKER_PLAYER_COUNT];
|
pokerplayer_t players[POKER_PLAYER_COUNT];
|
||||||
|
|
||||||
|
/** Winning player states */
|
||||||
pokerwinner_t winner;
|
pokerwinner_t winner;
|
||||||
|
|
||||||
/** The current player that is the dealer */
|
/** The current player that is the dealer */
|
||||||
uint8_t roundDealer;
|
uint8_t roundDealer;
|
||||||
uint8_t roundSmallBlind;
|
|
||||||
uint8_t roundBigBlind;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Round variables
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/** The current round the game is on */
|
/** The current round the game is on */
|
||||||
uint8_t round;
|
uint8_t round;
|
||||||
|
|
||||||
/** For Betting round, which player is currently betting */
|
/** Which player is the small blind for this round */
|
||||||
uint8_t roundBetCurrent;
|
uint8_t roundSmallBlind;
|
||||||
uint32_t roundTextCounter;
|
/** Which player is the big blind for this round */
|
||||||
|
uint8_t roundBigBlind;
|
||||||
pokerroundmatch_t roundMatch;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Rendering Variables
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/** Frames to hold the world and GUI render outputs */
|
|
||||||
framebuffer_t frameWorld, frameGui;
|
|
||||||
|
|
||||||
/** Game's Shader */
|
|
||||||
shader_t shader;
|
|
||||||
|
|
||||||
/** Camera for the world and the GUI */
|
|
||||||
camera_t cameraWorld, cameraGui;
|
|
||||||
|
|
||||||
/** Refer to POKER_GUI_HEIGHT */
|
|
||||||
float guiWidth;
|
|
||||||
|
|
||||||
texture_t chipTexture;
|
|
||||||
primitive_t chipPrimitive;
|
|
||||||
|
|
||||||
texture_t tableTexture;
|
|
||||||
primitive_t tablePrimitive;
|
|
||||||
|
|
||||||
texture_t cardTexture;
|
|
||||||
tileset_t cardTileset;
|
|
||||||
primitive_t cardPrimitive;
|
|
||||||
} poker_t;
|
} poker_t;
|
||||||
@@ -1,12 +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"
|
|
||||||
|
|
||||||
#define POKER_TALK_MATCH_START "The game is no-limits Texas Hold'em."
|
|
||||||
#define POKER_TALK_MATCH_BUYIN "The buy-in for this match is $10,000."
|
|
||||||
@@ -18,9 +18,9 @@ typedef struct {
|
|||||||
float x, y, z;
|
float x, y, z;
|
||||||
float yaw, pitch, roll;
|
float yaw, pitch, roll;
|
||||||
float scaleX, scaleY;
|
float scaleX, scaleY;
|
||||||
|
float blinkStart;
|
||||||
|
|
||||||
bool talking;
|
bool talking;
|
||||||
float blinkStart;
|
|
||||||
|
|
||||||
tileset_t tilesetEyes;
|
tileset_t tilesetEyes;
|
||||||
tileset_t tilesetMouth;
|
tileset_t tilesetMouth;
|
||||||
|
|||||||
+4
-14
@@ -7,20 +7,12 @@
|
|||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
testscene_t testScene;
|
|
||||||
|
|
||||||
bool gameInit(game_t *game) {
|
bool gameInit(game_t *game) {
|
||||||
// Init the game
|
|
||||||
game->name = GAME_NAME;
|
|
||||||
|
|
||||||
// Init the engine and the rendering pipeline
|
// Init the engine and the rendering pipeline
|
||||||
engineInit(&game->engine, game);
|
engineInit(&game->engine, game);
|
||||||
|
|
||||||
// Hand off to the poker logic.
|
|
||||||
testSceneInit(&testScene, game);
|
|
||||||
// pokerInit(&game->poker, &game->engine);
|
|
||||||
|
|
||||||
return true;
|
// Send off to the game instance
|
||||||
|
return pokerGameInit(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gameUpdate(game_t *game, float platformDelta) {
|
bool gameUpdate(game_t *game, float platformDelta) {
|
||||||
@@ -28,15 +20,13 @@ bool gameUpdate(game_t *game, float platformDelta) {
|
|||||||
engineUpdateStart(&game->engine, game, platformDelta);
|
engineUpdateStart(&game->engine, game, platformDelta);
|
||||||
|
|
||||||
// Hand off to the poker logic
|
// Hand off to the poker logic
|
||||||
testSceneRender(&testScene, game);
|
pokerGameUpdate(game);
|
||||||
// pokerUpdate(&game->poker, &game->engine);
|
|
||||||
|
|
||||||
|
|
||||||
// Hand back to the engine.
|
// Hand back to the engine.
|
||||||
return engineUpdateEnd(&game->engine, game);
|
return engineUpdateEnd(&game->engine, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameDispose(game_t *game) {
|
void gameDispose(game_t *game) {
|
||||||
pokerDispose(&game->poker);
|
pokerGameDispose(game);
|
||||||
engineDispose(&game->engine, game);
|
engineDispose(&game->engine, game);
|
||||||
}
|
}
|
||||||
+1
-2
@@ -6,8 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "../engine/engine.h"
|
#include "../engine/engine.h"
|
||||||
#include "../poker/poker.h"
|
#include "poker/pokergame.h"
|
||||||
#include "../test/testscene.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the game context.
|
* Initialize the game context.
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pokergame.h"
|
||||||
|
|
||||||
|
bool pokerGameInit(game_t *game) {
|
||||||
|
// Init the game
|
||||||
|
game->name = POKER_GAME_NAME;
|
||||||
|
|
||||||
|
// Hand off to the poker logic.
|
||||||
|
pokerInit(&game->pokerGame.poker, &game->engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerGameUpdate(game_t *game) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerGameDispose(game_t *game) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <dawn/dawn.h>
|
||||||
|
#include "../../poker/poker.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the game state for the poker game.
|
||||||
|
*
|
||||||
|
* @param game Game to initialize.
|
||||||
|
* @returns True if successful, otherwise false.
|
||||||
|
*/
|
||||||
|
bool pokerGameInit(game_t *game);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the poker game instance.
|
||||||
|
* @param game Game to update for.
|
||||||
|
*/
|
||||||
|
void pokerGameUpdate(game_t *game);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes a previously initialized poker game instance.
|
||||||
|
* @param game Game to initialize for.
|
||||||
|
*/
|
||||||
|
void pokerGameDispose(game_t *game);
|
||||||
@@ -15,7 +15,6 @@ bool pokerPlayerIsHuman(poker_t *poker, pokerplayer_t *player) {
|
|||||||
return (poker->players + POKER_PLAYER_HUMAN_INDEX) == player;
|
return (poker->players + POKER_PLAYER_HUMAN_INDEX) == player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pokerPlayerReset(pokerplayer_t *player) {
|
void pokerPlayerReset(pokerplayer_t *player) {
|
||||||
player->cardCount = 0;
|
player->cardCount = 0;
|
||||||
player->currentBet = 0;
|
player->currentBet = 0;
|
||||||
|
|||||||
+1
-29
@@ -7,21 +7,8 @@
|
|||||||
|
|
||||||
#include "poker.h"
|
#include "poker.h"
|
||||||
|
|
||||||
void pokerInit(poker_t *poker, engine_t *engine) {
|
void pokerInit(poker_t *poker) {
|
||||||
// Load the main shader
|
|
||||||
assetShaderLoad(&poker->shader,
|
|
||||||
"shaders/textured.vert", "shaders/textured.frag"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Initialize the render stuffs.
|
|
||||||
pokerFrameInit(poker, &engine->render);
|
|
||||||
pokerWorldInit(poker);
|
|
||||||
pokerCardInit(poker);
|
|
||||||
pokerPlayerInit(poker);
|
|
||||||
// pokerTalkInit(poker);
|
|
||||||
|
|
||||||
// Hand over to the deal for the first time.
|
|
||||||
pokerMatchInit(poker, engine);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerUpdate(poker_t *poker, engine_t *engine) {
|
void pokerUpdate(poker_t *poker, engine_t *engine) {
|
||||||
@@ -39,22 +26,7 @@ void pokerUpdate(poker_t *poker, engine_t *engine) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
shaderUse(&poker->shader);
|
|
||||||
pokerFrameWorld(poker, &engine->render);
|
|
||||||
|
|
||||||
pokerWorldRender(poker);
|
|
||||||
for(uint8_t pi = 0; pi < POKER_PLAYER_COUNT; pi++) {
|
|
||||||
uint8_t seat = pokerPlayerGetSeatForPlayer(pi);
|
|
||||||
pokerPlayerRender(poker, poker->players + pi, seat);
|
|
||||||
}
|
|
||||||
|
|
||||||
pokerFrameGui(poker, &engine->render);
|
|
||||||
// pokerTalkRender(poker, &engine->input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerDispose(poker_t * poker) {
|
void pokerDispose(poker_t * poker) {
|
||||||
// pokerTalkDispose(poker);
|
|
||||||
pokerWorldDispose(poker);
|
|
||||||
shaderDispose(&poker->shader);
|
|
||||||
}
|
}
|
||||||
+1
-13
@@ -7,25 +7,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
|
|
||||||
#include "round/match.h"
|
#include "round/match.h"
|
||||||
#include "render/frame.h"
|
|
||||||
#include "render/world.h"
|
|
||||||
#include "render/card.h"
|
|
||||||
#include "render/player.h"
|
|
||||||
#include "render/look.h"
|
|
||||||
|
|
||||||
#include "../file/asset.h"
|
|
||||||
#include "../display/shader.h"
|
|
||||||
#include "../display/camera.h"
|
|
||||||
#include "../display/gui/font.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the poker context for the first time.
|
* Initializes the poker context for the first time.
|
||||||
* @param poker Poker context to initialize.
|
* @param poker Poker context to initialize.
|
||||||
* @param engine Rendering context.
|
|
||||||
*/
|
*/
|
||||||
void pokerInit(poker_t *poker, engine_t *engine);
|
void pokerInit(poker_t *poker);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the poker context.
|
* Updates the poker context.
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
void pokerRoundBetPlayerNext(poker_t *poker) {
|
void pokerRoundBetPlayerNext(poker_t *poker) {
|
||||||
// Go to next player, keep contained.
|
// Go to next player, keep contained.
|
||||||
poker->roundBetCurrent = (poker->roundBetCurrent + 1) % POKER_PLAYER_COUNT;
|
poker->bet.better = (poker->bet.better + 1) % POKER_PLAYER_COUNT;
|
||||||
|
|
||||||
// Did we go full circle?
|
// Did we go full circle?
|
||||||
if(poker->roundBetCurrent == poker->roundSmallBlind) {
|
if(poker->bet.better == poker->roundSmallBlind) {
|
||||||
if(poker->round == POKER_ROUND_BET3) {
|
if(poker->round == POKER_ROUND_BET3) {
|
||||||
pokerWinnerInit(poker);
|
pokerWinnerInit(poker);
|
||||||
return;
|
return;
|
||||||
@@ -23,7 +23,7 @@ void pokerRoundBetPlayerNext(poker_t *poker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init the next player
|
// Init the next player
|
||||||
pokerRoundBetPlayerInit(poker, poker->players + poker->roundBetCurrent);
|
pokerRoundBetPlayerInit(poker, poker->players + poker->bet.better);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ void pokerRoundBetPlayerInit(poker_t *poker, pokerplayer_t *player) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Betting round player %u\n", poker->roundBetCurrent);
|
printf("Betting round player %u\n", poker->bet.better);
|
||||||
if(pokerPlayerIsHuman(poker, player)) {
|
if(pokerPlayerIsHuman(poker, player)) {
|
||||||
pokerRoundBetPlayerNext(poker);
|
pokerRoundBetPlayerNext(poker);
|
||||||
return;
|
return;
|
||||||
@@ -47,7 +47,6 @@ void pokerRoundBetPlayerUpdate(poker_t *poker, pokerplayer_t *player) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pokerRoundBetInit(poker_t *poker) {
|
void pokerRoundBetInit(poker_t *poker) {
|
||||||
printf("Betting round start\n");
|
printf("Betting round start\n");
|
||||||
|
|
||||||
@@ -66,11 +65,11 @@ void pokerRoundBetInit(poker_t *poker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the inital player
|
// Set the inital player
|
||||||
poker->roundBetCurrent = poker->roundSmallBlind;
|
poker->bet.better = poker->roundSmallBlind;
|
||||||
pokerRoundBetPlayerInit(poker, poker->players+poker->roundBetCurrent);
|
pokerRoundBetPlayerInit(poker, poker->players + poker->bet.better);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerRoundBetUpdate(poker_t *poker) {
|
void pokerRoundBetUpdate(poker_t *poker) {
|
||||||
// Take the current player
|
// Take the current player
|
||||||
pokerRoundBetPlayerUpdate(poker, poker->players + poker->roundBetCurrent);
|
pokerRoundBetPlayerUpdate(poker, poker->players + poker->bet.better);
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,6 @@
|
|||||||
void pokerDealInit(poker_t *poker) {
|
void pokerDealInit(poker_t *poker) {
|
||||||
poker->round = POKER_ROUND_DEAL;
|
poker->round = POKER_ROUND_DEAL;
|
||||||
|
|
||||||
// Hard look at the dealer
|
|
||||||
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER, 0);
|
|
||||||
|
|
||||||
// Shuffle the deck
|
// Shuffle the deck
|
||||||
cardShuffle(poker->dealer.deck, CARD_DECK_SIZE);
|
cardShuffle(poker->dealer.deck, CARD_DECK_SIZE);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "../../util/array.h"
|
#include "../../util/array.h"
|
||||||
#include "../render/look.h"
|
|
||||||
#include "../dealer.h"
|
#include "../dealer.h"
|
||||||
#include "../card.h"
|
#include "../card.h"
|
||||||
#include "bet.h"
|
#include "bet.h"
|
||||||
|
|||||||
+1
-10
@@ -9,13 +9,9 @@
|
|||||||
void pokerMatchInit(poker_t *poker, engine_t *engine) {
|
void pokerMatchInit(poker_t *poker, engine_t *engine) {
|
||||||
uint8_t x;
|
uint8_t x;
|
||||||
|
|
||||||
// Look at the dealer
|
|
||||||
poker->roundMatch.time = engine->time.current;
|
|
||||||
|
|
||||||
// Reset the main game state. This does not init the round.
|
// Reset the main game state. This does not init the round.
|
||||||
pokerBetInit(&poker->bet);
|
pokerBetInit(&poker->bet);
|
||||||
poker->roundDealer = POKER_PLAYER_COUNT-2;
|
poker->roundDealer = POKER_PLAYER_COUNT-2;
|
||||||
poker->roundTextCounter = 0;
|
|
||||||
poker->round = POKER_ROUND_MATCH;
|
poker->round = POKER_ROUND_MATCH;
|
||||||
|
|
||||||
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
||||||
@@ -23,13 +19,8 @@ void pokerMatchInit(poker_t *poker, engine_t *engine) {
|
|||||||
poker->players[x].chips = POKER_BET_PLAYER_CHIPS_DEFAULT;
|
poker->players[x].chips = POKER_BET_PLAYER_CHIPS_DEFAULT;
|
||||||
}
|
}
|
||||||
printf("Match Start\n");
|
printf("Match Start\n");
|
||||||
// pokerStartInit(poker);
|
pokerStartInit(poker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerMatchUpdate(poker_t *poker, engine_t *engine) {
|
void pokerMatchUpdate(poker_t *poker, engine_t *engine) {
|
||||||
// Ease into the game.
|
|
||||||
float t = easeTimeToEase(poker->roundMatch.time, engine->time.current, 5);
|
|
||||||
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_PLAYER0, (
|
|
||||||
t < 1 ? 1 - easeOutQuart(t) : 0
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "start.h"
|
#include "start.h"
|
||||||
#include "../render/look.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the poker match round.
|
* Init the poker match round.
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ void testSceneInit(testscene_t *scene, game_t *game) {
|
|||||||
|
|
||||||
// Add some conversation peices.
|
// Add some conversation peices.
|
||||||
vnConversationTalk(&scene->conversation, "Hello World", &scene->character1);
|
vnConversationTalk(&scene->conversation, "Hello World", &scene->character1);
|
||||||
queueDelay(&scene->conversation.actionQueue, 3);
|
queueDelay(&scene->conversation.actionQueue, 1);
|
||||||
vnConversationTalk(&scene->conversation, "What?", &scene->character1);
|
vnConversationTalk(&scene->conversation, "What?", &scene->character2);
|
||||||
queueNext(&scene->conversation.actionQueue);
|
queueNext(&scene->conversation.actionQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,18 @@
|
|||||||
void _vnConversationTalkStart(queue_t *queue,queueaction_t *action,uint8_t i) {
|
void _vnConversationTalkStart(queue_t *queue,queueaction_t *action,uint8_t i) {
|
||||||
vnconversationitemdata_t *data;
|
vnconversationitemdata_t *data;
|
||||||
data = (vnconversationitemdata_t *)action->data;
|
data = (vnconversationitemdata_t *)action->data;
|
||||||
|
|
||||||
vnTextBoxSetText(&data->conversation->textbox, data->text);
|
vnTextBoxSetText(&data->conversation->textbox, data->text);
|
||||||
if(data->character != NULL) data->character->talking = true;
|
|
||||||
|
if(data->character != NULL) {
|
||||||
|
data->character->talking = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _vnConversationTalkUpdate(queue_t *queue,queueaction_t *action,uint8_t i) {
|
void _vnConversationTalkUpdate(queue_t *queue,queueaction_t *action,uint8_t i) {
|
||||||
vnconversationitemdata_t *data;
|
vnconversationitemdata_t *data;
|
||||||
data = (vnconversationitemdata_t *)action->data;
|
data = (vnconversationitemdata_t *)action->data;
|
||||||
|
|
||||||
if(data->conversation->textbox.state & VN_TEXTBOX_STATE_CLOSED) {
|
if(data->conversation->textbox.state & VN_TEXTBOX_STATE_CLOSED) {
|
||||||
if(data->character != NULL) data->character->talking = false;
|
if(data->character != NULL) data->character->talking = false;
|
||||||
queueNext(queue);
|
queueNext(queue);
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-63
@@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2021 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "talk.h"
|
|
||||||
|
|
||||||
void pokerTalkInit(poker_t *poker) {
|
|
||||||
poker->talkText = NULL;
|
|
||||||
poker->talkTextInfo = NULL;
|
|
||||||
poker->textLastWidth = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokerTalkDispose(poker_t *poker) {
|
|
||||||
if(poker->talkTextInfo == NULL) return;
|
|
||||||
fontTextInfoDispose(poker->talkTextInfo);
|
|
||||||
primitiveDispose(&poker->talkPrimitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokerTalkTextRebuffer(poker_t *poker) {
|
|
||||||
// Check if we need to force a redraw or not.
|
|
||||||
if(poker->talkText == NULL || poker->textLastWidth != poker->guiWidth) {
|
|
||||||
if(poker->talkTextInfo != NULL) {
|
|
||||||
fontTextInfoDispose(poker->talkTextInfo);
|
|
||||||
primitiveDispose(&poker->talkPrimitive);
|
|
||||||
poker->talkTextInfo = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(poker->talkText == NULL) return;
|
|
||||||
|
|
||||||
// Rebuffer
|
|
||||||
poker->talkTextInfo = fontTextClamp(&poker->font, poker->talkText, poker->guiWidth);
|
|
||||||
fontTextInit(&poker->font, &poker->talkPrimitive, poker->talkTextInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokerTalkRender(poker_t *poker, input_t *input) {
|
|
||||||
pokerTalkTextRebuffer(poker);
|
|
||||||
if(poker->talkTextInfo == NULL) return;
|
|
||||||
|
|
||||||
// Render text
|
|
||||||
shaderUsePosition(&poker->shader,
|
|
||||||
0,POKER_GUI_HEIGHT-poker->talkTextInfo->height,0,
|
|
||||||
0,0,0
|
|
||||||
);
|
|
||||||
shaderUseTexture(&poker->shader, &poker->font.texture);
|
|
||||||
primitiveDraw(&poker->talkPrimitive, 0, -1);
|
|
||||||
|
|
||||||
if(inputIsPressed(input, INPUT_ACCEPT)) {
|
|
||||||
poker->talkText = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokerTalk(poker_t *poker, char *text) {
|
|
||||||
poker->talkText = text;
|
|
||||||
poker->roundTextCounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pokerTalkIsTalking(poker_t *poker) {
|
|
||||||
return poker->talkText != NULL || poker->talkTextInfo != NULL;
|
|
||||||
}
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2021 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <dawn/dawn.h>
|
|
||||||
#include "../../display/gui/font.h"
|
|
||||||
#include "../../display/primitive.h"
|
|
||||||
#include "../../display/shader.h"
|
|
||||||
#include "../../input/input.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the talk manager.
|
|
||||||
* @param poker The poker game context.
|
|
||||||
*/
|
|
||||||
void pokerTalkInit(poker_t *poker);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disposes and cleans the talk manager context.
|
|
||||||
* @param poker Poker instance.
|
|
||||||
*/
|
|
||||||
void pokerTalkDispose(poker_t *poker);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method. Checks for changes and rebuffers the talk text information
|
|
||||||
* when scene changes occur.
|
|
||||||
* @param poker Poker game context to buffer for.
|
|
||||||
*/
|
|
||||||
void pokerTalkTextRebuffer(poker_t *poker);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tick render method for the poker talk manager.
|
|
||||||
* @param poker Poker manager context.
|
|
||||||
* @param input Input manager to listen to.
|
|
||||||
*/
|
|
||||||
void pokerTalkRender(poker_t *poker, input_t *input);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Requests the talk manager to begin speaking some text.
|
|
||||||
* @param poker Poker game context
|
|
||||||
* @param text Text to speak. Please ensure this is kept alive during talk.
|
|
||||||
*/
|
|
||||||
void pokerTalk(poker_t *poker, char *text);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the poker text manager is still running the talk.
|
|
||||||
* @param poker Poker manager.
|
|
||||||
* @returns True while the game is still running active text.
|
|
||||||
*/
|
|
||||||
bool pokerTalkIsTalking(poker_t *poker);
|
|
||||||
Reference in new issue
Block a user