Moved GUI out of GUI.
This commit is contained in:
		| @@ -11,10 +11,9 @@ | |||||||
| #include "display/animation/queue.h" | #include "display/animation/queue.h" | ||||||
| #include "display/animation/timeline.h" | #include "display/animation/timeline.h" | ||||||
|  |  | ||||||
| #include "display/gui/bitmapfont.h" | #include "display/bitmapfont.h" | ||||||
| #include "display/gui/font.h" |  | ||||||
|  |  | ||||||
| #include "display/camera.h" | #include "display/camera.h" | ||||||
|  | #include "display/font.h" | ||||||
| #include "display/framebuffer.h" | #include "display/framebuffer.h" | ||||||
| #include "display/matrix.h" | #include "display/matrix.h" | ||||||
| #include "display/primitive.h" | #include "display/primitive.h" | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| #include "../../libs.h" | #include "../libs.h" | ||||||
| 
 | 
 | ||||||
| /** Which is the first character within the font tilemap */ | /** Which is the first character within the font tilemap */ | ||||||
| #define BITMAP_FONT_CHAR_START 33 | #define BITMAP_FONT_CHAR_START 33 | ||||||
| @@ -6,8 +6,8 @@ | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| #include "../../libs.h" | #include "../libs.h" | ||||||
| #include "../texture.h" | #include "texture.h" | ||||||
| 
 | 
 | ||||||
| /** Which character (ASCII) to start the font from */ | /** Which character (ASCII) to start the font from */ | ||||||
| #define FONT_FIRST_CHAR 32 | #define FONT_FIRST_CHAR 32 | ||||||
| @@ -6,7 +6,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
| #include "../../display/gui/font.h" | #include "../../display/font.h" | ||||||
| #include "../../display/shader.h" | #include "../../display/shader.h" | ||||||
| #include "../../locale/language.h" | #include "../../locale/language.h" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,7 +11,9 @@ | |||||||
| #define POKER_TURN_TYPE_OUT 0x00 | #define POKER_TURN_TYPE_OUT 0x00 | ||||||
| #define POKER_TURN_TYPE_FOLD 0x01 | #define POKER_TURN_TYPE_FOLD 0x01 | ||||||
| #define POKER_TURN_TYPE_BET 0x02 | #define POKER_TURN_TYPE_BET 0x02 | ||||||
| #define POKER_TURN_TYPE_CHECK 0x03 | #define POKER_TURN_TYPE_CALL 0x03 | ||||||
|  | #define POKER_TURN_TYPE_ALL_IN 0x04 | ||||||
|  | #define POKER_TURN_TYPE_CHECK 0x05 | ||||||
|  |  | ||||||
| /** The turn that a player/the AI decided to do for its turn */ | /** The turn that a player/the AI decided to do for its turn */ | ||||||
| typedef struct { | typedef struct { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "../libs.h" | #include "../libs.h" | ||||||
| #include "../display/primitive.h" | #include "../display/primitive.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
|  |  | ||||||
| /** Size of the border (in pixels) on each edge */ | /** Size of the border (in pixels) on each edge */ | ||||||
| #define FRAME_BORDER_SIZE 16 | #define FRAME_BORDER_SIZE 16 | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "../libs.h" | #include "../libs.h" | ||||||
| #include "../display/primitive.h" | #include "../display/primitive.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
|  |  | ||||||
| /** Representation of a Label UI Element */ | /** Representation of a Label UI Element */ | ||||||
| typedef struct { | typedef struct { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "../libs.h" | #include "../libs.h" | ||||||
| #include "../display/animation/timeline.h" | #include "../display/animation/timeline.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
| #include "../ui/frame.h" | #include "../ui/frame.h" | ||||||
| #include "../util/flags.h" | #include "../util/flags.h" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| #include <dawn/dawn.h> | #include <dawn/dawn.h> | ||||||
| #include "../spritebatch.h" | #include "spritebatch.h" | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * Get the division for a given character. |  * Get the division for a given character. | ||||||
| @@ -8,10 +8,10 @@ | |||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <dawn/dawn.h> | #include <dawn/dawn.h> | ||||||
| #include "../texture.h" | #include "texture.h" | ||||||
| #include "../primitive.h" | #include "primitive.h" | ||||||
| #include "../primitives/quad.h" | #include "primitives/quad.h" | ||||||
| #include "../../util/mem.h" | #include "../util/mem.h" | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * Initializes Font from raw TTF data. |  * Initializes Font from raw TTF data. | ||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <dawn/dawn.h> | #include <dawn/dawn.h> | ||||||
| #include "../display/shader.h" | #include "../display/shader.h" | ||||||
| #include "../display/texture.h" | #include "../display/texture.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Method to load an asset into memory as a raw string. |  * Method to load an asset into memory as a raw string. | ||||||
|   | |||||||
| @@ -34,47 +34,41 @@ void _pokerGameActionBetOnUpdate( | |||||||
|   // Now decide if we should do something. |   // Now decide if we should do something. | ||||||
|   if(!turnMade) return; |   if(!turnMade) return; | ||||||
|  |  | ||||||
|   // What happened? |   // Perform the action | ||||||
|   char *debugAction; |   pokerTurnAction(&game->poker, player, &turn); | ||||||
|   switch(turn.type) { |  | ||||||
|     // Player bets |  | ||||||
|     case POKER_TURN_TYPE_BET: |  | ||||||
|       debugAction = "betting"; |  | ||||||
|       //TODO: Is it a BET or a CALL? |  | ||||||
|       discussion.reason = POKER_DISCUSSION_REASON_PLAYER_RAISING; |  | ||||||
|       pokerBetPlayer(&game->poker, player, turn.chips); |  | ||||||
|       break; |  | ||||||
|  |  | ||||||
|     // Player folds |  | ||||||
|     case POKER_TURN_TYPE_FOLD: |  | ||||||
|       debugAction = "folding"; |  | ||||||
|       discussion.reason = POKER_DISCUSSION_REASON_PLAYER_FOLDING; |  | ||||||
|       player->state |= POKER_PLAYER_STATE_FOLDED; |  | ||||||
|       break; |  | ||||||
|  |  | ||||||
|     // Player checks |  | ||||||
|     case POKER_TURN_TYPE_CHECK: |  | ||||||
|       discussion.reason = POKER_DISCUSSION_REASON_PLAYER_CHECKING; |  | ||||||
|       debugAction = "checking"; |  | ||||||
|       break; |  | ||||||
|      |  | ||||||
|     // Player may be out |  | ||||||
|     default: |  | ||||||
|       discussion.reason = POKER_DISCUSSION_REASON_TEST; |  | ||||||
|       debugAction = "doing nothing"; |  | ||||||
|       break; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Mark as move made. |  | ||||||
|   player->state |= POKER_PLAYER_STATE_ROUND_MOVE; |  | ||||||
|  |  | ||||||
|   // Speak |   // 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_CALLING; | ||||||
|  |       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.poker = game; |   discussion.poker = game; | ||||||
|   discussion.playerCause = game->poker.bet.better; |   discussion.playerCause = game->poker.bet.better; | ||||||
|   pokerDiscussionQueue(&discussion); |   pokerDiscussionQueue(&discussion); | ||||||
|  |  | ||||||
|   // Next. |   // Next. | ||||||
|   printf("Player %i is %s.\n", game->poker.bet.better, debugAction); |  | ||||||
|   queueNext(queue); |   queueNext(queue); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,4 +32,20 @@ pokerturn_t pokerTurnGet(poker_t *poker, uint8_t playerIndex) { | |||||||
|   turn.confidence = 1; |   turn.confidence = 1; | ||||||
|  |  | ||||||
|   return turn; |   return turn; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void pokerTurnAction(poker_t *poker, pokerplayer_t *player, pokerturn_t *turn) { | ||||||
|  |   switch(turn->type) { | ||||||
|  |     case POKER_TURN_TYPE_BET: | ||||||
|  |     case POKER_TURN_TYPE_CALL: | ||||||
|  |     case POKER_TURN_TYPE_ALL_IN: | ||||||
|  |       pokerBetPlayer(poker, player, turn->chips); | ||||||
|  |       break; | ||||||
|  |  | ||||||
|  |     case POKER_TURN_TYPE_FOLD: | ||||||
|  |       player->state |= POKER_PLAYER_STATE_FOLDED; | ||||||
|  |       break; | ||||||
|  |   } | ||||||
|  |    | ||||||
|  |   player->state |= POKER_PLAYER_STATE_ROUND_MOVE; | ||||||
| } | } | ||||||
| @@ -15,4 +15,13 @@ | |||||||
|  * @param playerIndex Player index to get the turn for. |  * @param playerIndex Player index to get the turn for. | ||||||
|  * @return Some information about the move the player is trying to perform. |  * @return Some information about the move the player is trying to perform. | ||||||
|  */ |  */ | ||||||
| pokerturn_t pokerTurnGet(poker_t *poker, uint8_t playerIndex); | pokerturn_t pokerTurnGet(poker_t *poker, uint8_t playerIndex); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Perform the turn's action. | ||||||
|  |  *  | ||||||
|  |  * @param poker Poker game instance. | ||||||
|  |  * @param player Player instance. | ||||||
|  |  * @param turn Turn to action. | ||||||
|  |  */ | ||||||
|  | void pokerTurnAction(poker_t *poker, pokerplayer_t *player, pokerturn_t *turn); | ||||||
| @@ -9,10 +9,10 @@ | |||||||
| #include <dawn/dawn.h> | #include <dawn/dawn.h> | ||||||
| #include "../display/shader.h" | #include "../display/shader.h" | ||||||
| #include "../display/camera.h" | #include "../display/camera.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
| #include "../file/asset.h" | #include "../file/asset.h" | ||||||
|  |  | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
| #include "../display/texture.h" | #include "../display/texture.h" | ||||||
| #include "../vn/vncharacter.h" | #include "../vn/vncharacter.h" | ||||||
| #include "../vn/conversation/vnconversation.h" | #include "../vn/conversation/vnconversation.h" | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include "../display/shader.h" | #include "../display/shader.h" | ||||||
| #include "../display/primitive.h" | #include "../display/primitive.h" | ||||||
| #include "../display/primitives/quad.h" | #include "../display/primitives/quad.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Initialize a GUI Frame. |  * Initialize a GUI Frame. | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <dawn/dawn.h> | #include <dawn/dawn.h> | ||||||
| #include "../display/shader.h" | #include "../display/shader.h" | ||||||
| #include "../display/primitive.h" | #include "../display/primitive.h" | ||||||
| #include "../display/gui/font.h" | #include "../display/font.h" | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Initialize a Label UI Element. |  * Initialize a Label UI Element. | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| #include "../../display/primitive.h" | #include "../../display/primitive.h" | ||||||
| #include "../../display/shader.h" | #include "../../display/shader.h" | ||||||
| #include "../../display/animation/timeline.h" | #include "../../display/animation/timeline.h" | ||||||
| #include "../../display/gui/font.h" | #include "../../display/font.h" | ||||||
| #include "../../display/primitives/quad.h" | #include "../../display/primitives/quad.h" | ||||||
| #include "../../input/input.h" | #include "../../input/input.h" | ||||||
| #include "../../ui/frame.h" | #include "../../ui/frame.h" | ||||||
|   | |||||||
							
								
								
									
										45
									
								
								temp/frame.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								temp/frame.c
									
									
									
									
									
								
							| @@ -1,45 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "frame.h" |  | ||||||
|  |  | ||||||
| void pokerFrameInit(poker_t *poker, render_t *render) { |  | ||||||
|   frameBufferInit(&poker->frameWorld, render->width, render->height); |  | ||||||
|   frameBufferInit(&poker->frameGui, render->width, render->height); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerFrameWorld(poker_t *poker, render_t *render) { |  | ||||||
|   // Update the frame buffer |  | ||||||
|   frameBufferResize(&poker->frameWorld, render->width, render->height); |  | ||||||
|  |  | ||||||
|   // Correct the aspect on the perspective camera for the world |  | ||||||
|   cameraPerspective(&poker->cameraWorld, 20, |  | ||||||
|     render->width / render->height, |  | ||||||
|     0.001, 1000 |  | ||||||
|   ); |  | ||||||
|   shaderUseCamera(&poker->shader, &poker->cameraWorld); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerFrameGui(poker_t *poker, render_t *render) { |  | ||||||
|   // Update FB |  | ||||||
|   frameBufferResize(&poker->frameGui, render->width, render->height); |  | ||||||
|   poker->guiWidth = ((float)POKER_GUI_HEIGHT/render->height) * render->width; |  | ||||||
|   // frameBufferUse(&poker->frameGui, true); |  | ||||||
|  |  | ||||||
|   // Correct aspect on the ortho camera |  | ||||||
|   cameraOrtho(&poker->cameraGui, |  | ||||||
|     0, poker->guiWidth, |  | ||||||
|     POKER_GUI_HEIGHT, 0, |  | ||||||
|     0.01, 100 |  | ||||||
|   ); |  | ||||||
|   cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0); |  | ||||||
|   shaderUseCamera(&poker->shader, &poker->cameraGui); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerFrameRender(poker_t *poker, render_t *render) { |  | ||||||
|    |  | ||||||
| } |  | ||||||
							
								
								
									
										43
									
								
								temp/frame.h
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								temp/frame.h
									
									
									
									
									
								
							| @@ -1,43 +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/framebuffer.h" |  | ||||||
| #include "../../display/primitive.h" |  | ||||||
| #include "../../display/texture.h" |  | ||||||
| #include "../../display/shader.h" |  | ||||||
| #include "../../display/camera.h" |  | ||||||
| #include "../../display/primitives/quad.h" |  | ||||||
|  |  | ||||||
| #include "../../display/gui/font.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Initializes the various frame buffers for the poker game. |  | ||||||
|  *  |  | ||||||
|  * @param poker Poker game to initialize for |  | ||||||
|  * @param render Rendering context. |  | ||||||
|  */ |  | ||||||
| void pokerFrameInit(poker_t *poker, render_t *render); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Bind the world frame, this will also correct the camera angles. |  | ||||||
|  *  |  | ||||||
|  * @param poker Poker game context. |  | ||||||
|  * @param render Rendering engine context. |  | ||||||
|  */ |  | ||||||
| void pokerFrameWorld(poker_t *poker, render_t *render); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Bind the frame for GUI rendering. |  | ||||||
|  *  |  | ||||||
|  * @param poker Poker game context. |  | ||||||
|  * @param render Rendering engine context. |  | ||||||
|  */  |  | ||||||
| void pokerFrameGui(poker_t *poker, render_t *render); |  | ||||||
|  |  | ||||||
| void pokerFrameTest(poker_t *poker, render_t *render); |  | ||||||
| @@ -1,54 +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" |  | ||||||
|  |  | ||||||
| #include "../display/tileset.h" |  | ||||||
| #include "../display/primitive.h" |  | ||||||
| #include "../display/texture.h" |  | ||||||
| #include "../display/shader.h" |  | ||||||
| #include "../display/camera.h" |  | ||||||
| #include "../display/spritebatch.h" |  | ||||||
|  |  | ||||||
| /** Size of the Render frames */ |  | ||||||
| #define POKER_FRAME_HEIGHT RENDER_STATE.height |  | ||||||
| #define POKER_FRAME_LEFT_WIDTH RENDER_STATE.width*0.65 |  | ||||||
| #define POKER_FRAME_RIGHT_WIDTH (\ |  | ||||||
|   RENDER_STATE.width - POKER_FRAME_LEFT_WIDTH - 1\ |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| /** Size of the rendered card */ |  | ||||||
| #define POKER_CARD_WIDTH 0.04 |  | ||||||
| #define POKER_CARD_HEIGHT POKER_CARD_WIDTH/2.5*3.5 |  | ||||||
| #define POKER_CARD_DEPTH 0.0005 |  | ||||||
| #define POKER_CARD_PADDING 0.0125 |  | ||||||
|  |  | ||||||
| /** Macro for the angle (Yaw) that the seat has */ |  | ||||||
| #define POKER_SEAT_ANGLE(seat) mathDeg2Rad(-45 * seat) |  | ||||||
|  |  | ||||||
| /** Slots where cards can render */ |  | ||||||
| #define POKER_CARD_SLOT_HAND0 0x00 |  | ||||||
| #define POKER_CARD_SLOT_HAND1 0x01 |  | ||||||
| #define POKER_CARD_SLOT_FLOP0 0x02 |  | ||||||
| #define POKER_CARD_SLOT_FLOP1 0x03 |  | ||||||
| #define POKER_CARD_SLOT_FLOP2 0x04 |  | ||||||
| #define POKER_CARD_SLOT_FLOP3 0x05 |  | ||||||
| #define POKER_CARD_SLOT_FLOP4 0x06 |  | ||||||
|  |  | ||||||
| /** Various seats at the table that people can sit */ |  | ||||||
| #define POKER_SEAT_DEALER 0x00   |  | ||||||
| #define POKER_SEAT_PLAYER0 0x04 |  | ||||||
| #define POKER_SEAT_PLAYER1 0x06 |  | ||||||
| #define POKER_SEAT_PLAYER2 0x05 |  | ||||||
| #define POKER_SEAT_PLAYER3 0x03 |  | ||||||
| #define POKER_SEAT_PLAYER4 0x02 |  | ||||||
|  |  | ||||||
| typedef struct { |  | ||||||
|   float x, z; |  | ||||||
|   float yaw; |  | ||||||
| } pokerposition_t; |  | ||||||
| @@ -1,99 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #pragma once |  | ||||||
| #include "card.h" |  | ||||||
|  |  | ||||||
| void pokerCardInit(poker_t *poker) { |  | ||||||
|   tilesetdiv_t *cardBack; |  | ||||||
|  |  | ||||||
|   // Load Cards Texture |  | ||||||
|   assetTextureLoad(&poker->cardTexture, "cards_normal.png"); |  | ||||||
|   tilesetInit(&poker->cardTileset, |  | ||||||
|     CARD_COUNT_PER_SUIT, 6, |  | ||||||
|     poker->cardTexture.width, poker->cardTexture.height, |  | ||||||
|     0, 0, |  | ||||||
|     0, 0 |  | ||||||
|   ); |  | ||||||
|  |  | ||||||
|   // Cards Primitive |  | ||||||
|   cardBack = poker->cardTileset.divisions+(poker->cardTileset.columns * 4); |  | ||||||
|   primitiveInit(&poker->cardPrimitive, |  | ||||||
|     QUAD_VERTICE_COUNT * 2, QUAD_INDICE_COUNT * 2 |  | ||||||
|   ); |  | ||||||
|   quadBuffer(&poker->cardPrimitive, -POKER_CARD_DEPTH, |  | ||||||
|     -POKER_CARD_WIDTH, -POKER_CARD_HEIGHT, |  | ||||||
|     cardBack->x0, cardBack->y1, |  | ||||||
|     POKER_CARD_WIDTH, POKER_CARD_HEIGHT, |  | ||||||
|     cardBack->x1, cardBack->y0, |  | ||||||
|     QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT |  | ||||||
|   ); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| pokerposition_t pokerCardGetPosition(uint8_t seat, uint8_t slot) { |  | ||||||
|   pokerposition_t position; |  | ||||||
|   float t, t2; |  | ||||||
|  |  | ||||||
|   position.yaw = POKER_SEAT_ANGLE(seat); |  | ||||||
|   position.x = sin(position.yaw) * -0.75; |  | ||||||
|   position.z = cos(position.yaw) * -0.75; |  | ||||||
|  |  | ||||||
|   t = position.yaw + mathDeg2Rad(90); |  | ||||||
|  |  | ||||||
|   switch (slot) { |  | ||||||
|     case POKER_CARD_SLOT_HAND0: |  | ||||||
|     case POKER_CARD_SLOT_HAND1: |  | ||||||
|       t2 = POKER_CARD_WIDTH+POKER_CARD_PADDING; |  | ||||||
|       if(slot == POKER_CARD_SLOT_HAND0) t2 = -t2; |  | ||||||
|       t2 += 0.1; |  | ||||||
|       break; |  | ||||||
|        |  | ||||||
|     case POKER_CARD_SLOT_FLOP0: |  | ||||||
|     case POKER_CARD_SLOT_FLOP1: |  | ||||||
|     case POKER_CARD_SLOT_FLOP2: |  | ||||||
|     case POKER_CARD_SLOT_FLOP3: |  | ||||||
|     case POKER_CARD_SLOT_FLOP4: |  | ||||||
|       t2 = POKER_CARD_WIDTH*2+POKER_CARD_PADDING; |  | ||||||
|       t2 = ( |  | ||||||
|         -t2 * ( POKER_CARD_SLOT_FLOP4-POKER_CARD_SLOT_FLOP0) |  | ||||||
|       )/2 + t2*(slot-POKER_CARD_SLOT_FLOP0); |  | ||||||
|       break; |  | ||||||
|  |  | ||||||
|     default: |  | ||||||
|       break; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   position.x += t2 * sin(t); |  | ||||||
|   position.z += t2 * cos(t); |  | ||||||
|    |  | ||||||
|   return position; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerCardRender(poker_t *poker, card_t card, float x, float y, float z, |  | ||||||
|   float pitch, float yaw, float roll |  | ||||||
| ) { |  | ||||||
|   tilesetdiv_t *cardFront = poker->cardTileset.divisions + card; |  | ||||||
|   quadBuffer(&poker->cardPrimitive, POKER_CARD_DEPTH, |  | ||||||
|     -POKER_CARD_WIDTH, -POKER_CARD_HEIGHT,  |  | ||||||
|     cardFront->x0, cardFront->y1, |  | ||||||
|     POKER_CARD_WIDTH, POKER_CARD_HEIGHT, |  | ||||||
|     cardFront->x1, cardFront->y0, |  | ||||||
|     0, 0 |  | ||||||
|   ); |  | ||||||
|  |  | ||||||
|   shaderUseTexture(&poker->shader, &poker->cardTexture); |  | ||||||
|   shaderUsePosition(&poker->shader, x,y,z, pitch,yaw,roll); |  | ||||||
|   primitiveDraw(&poker->cardPrimitive, 0, -1); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerCardRenderForSeat(poker_t *poker, uint8_t seat, card_t card, uint8_t slot) { |  | ||||||
|   pokerposition_t position = pokerCardGetPosition(seat, slot); |  | ||||||
|   pokerCardRender(poker, card, |  | ||||||
|     position.x, 0, position.z, |  | ||||||
|     mathDeg2Rad(-90), position.yaw, 0 |  | ||||||
|   ); |  | ||||||
| } |  | ||||||
| @@ -1,55 +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 "../../file/asset.h" |  | ||||||
| #include "../../display/shader.h" |  | ||||||
| #include "../../display/primitive.h" |  | ||||||
| #include "../../display/primitives/quad.h" |  | ||||||
| #include "../../display/tileset.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Initializes the Card Renderer. |  | ||||||
|  * @param poker The poker game context. |  | ||||||
|  */ |  | ||||||
| void pokerCardInit(poker_t *poker); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Returns the position a card "naturally" sits at for a given seat and slot. |  | ||||||
|  *  |  | ||||||
|  * @param seat Seat that the card belongs to |  | ||||||
|  * @param slot Slot within the player/dealers' hand that the card belongs to. |  | ||||||
|  * @return A struct containing X, Z and YAW properties. |  | ||||||
|  */ |  | ||||||
| pokerposition_t pokerCardGetPosition(uint8_t seat, uint8_t slot); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Render's a given card at the specified coordinates. Card is a reused quad  |  | ||||||
|  * and is re-buffered to for every draw call. |  | ||||||
|  *  |  | ||||||
|  * @param poker The poker game context. |  | ||||||
|  * @param card Card to render. |  | ||||||
|  * @param x X Position (world space). |  | ||||||
|  * @param y Y Position (world space). |  | ||||||
|  * @param z Z Position (world space). |  | ||||||
|  * @param pitch Pitch angle. |  | ||||||
|  * @param yaw Yaw angle. |  | ||||||
|  * @param roll Roll angle. |  | ||||||
|  */ |  | ||||||
| void pokerCardRender(poker_t *poker, card_t card, float x, float y, float z, |  | ||||||
|   float pitch, float yaw, float roll |  | ||||||
| ); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Render's a card at a given seat and slot. |  | ||||||
|  * @param poker The poker game context. |  | ||||||
|  * @param seat Seat the card is for. |  | ||||||
|  * @param card Card to render. |  | ||||||
|  * @param slot Slot the card is for. |  | ||||||
|  */ |  | ||||||
| void pokerCardRenderForSeat(poker_t *poker, uint8_t seat, card_t card, uint8_t slot); |  | ||||||
| @@ -1,30 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "look.h" |  | ||||||
|  |  | ||||||
| void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance) { |  | ||||||
|   float x, z, angle; |  | ||||||
|   angle = POKER_SEAT_ANGLE(seat); |  | ||||||
|   x = sin(angle) * (0.8 + distance); |  | ||||||
|   z = cos(angle) * (0.8 + distance); |  | ||||||
|   cameraLookAt(camera, |  | ||||||
|      x, 0.3,  z, |  | ||||||
|     -x, 0.3, -z |  | ||||||
|   ); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerLookAtHand(camera_t *camera, uint8_t seat) { |  | ||||||
|   float x, z, angle; |  | ||||||
|   angle = POKER_SEAT_ANGLE(seat); |  | ||||||
|   x = sin(angle); |  | ||||||
|   z = cos(angle); |  | ||||||
|   cameraLookAt(camera, |  | ||||||
|     x*0.1, 0.8, z*0.1, |  | ||||||
|     -x*0.5, 0.2, -z*0.5 |  | ||||||
|   ); |  | ||||||
| } |  | ||||||
| @@ -1,26 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include <dawn/dawn.h> |  | ||||||
| #include "../../display/camera.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Look at a specific seats' player. |  | ||||||
|  *  |  | ||||||
|  * @param camera Camera to adjust. |  | ||||||
|  * @param seat Seat to look at. |  | ||||||
|  * @param distance Distance from the seat to look from. 0 is default. |  | ||||||
|  */ |  | ||||||
| void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Look at a specific seats' hand. |  | ||||||
|  *  |  | ||||||
|  * @param camera Camera to adjust. |  | ||||||
|  * @param seat Seats hand to look at. |  | ||||||
|  */ |  | ||||||
| void pokerLookAtHand(camera_t *camera, uint8_t seat); |  | ||||||
| @@ -1,68 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "player.h" |  | ||||||
|  |  | ||||||
| void pokerPlayerInit(poker_t *poker) { |  | ||||||
|   uint8_t i; |  | ||||||
|   pokerplayer_t *player; |  | ||||||
|   float w, h; |  | ||||||
|  |  | ||||||
|   for(i = 0; i < POKER_PLAYER_COUNT; i++) { |  | ||||||
|     player = poker->players + i; |  | ||||||
|     assetTextureLoad(&player->bodyTexture, "characters/penny/textures/body.png"); |  | ||||||
|     assetTextureLoad(&player->faceTexture, "characters/penny/textures/face.png"); |  | ||||||
|  |  | ||||||
|     w = 0.6; |  | ||||||
|     h=((float)player->faceTexture.width)/((float)player->faceTexture.height)*w; |  | ||||||
|     w = w / 2; |  | ||||||
|     h = h / 2; |  | ||||||
|     quadInit(&player->bodyPrimitive, 0, |  | ||||||
|       -w, -h, 0, 1, |  | ||||||
|        w,  h, 1, 0 |  | ||||||
|     ); |  | ||||||
|     quadInit(&player->facePrimitive, 0, |  | ||||||
|       -w, -h, 0, 1, |  | ||||||
|        w,  h, 1, 0 |  | ||||||
|     ); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| uint8_t pokerPlayerGetSeatForPlayer(uint8_t player) {  |  | ||||||
|   switch(player) { |  | ||||||
|     case 0x01: |  | ||||||
|       return POKER_SEAT_PLAYER1; |  | ||||||
|     case 0x02: |  | ||||||
|       return POKER_SEAT_PLAYER2; |  | ||||||
|     case 0x03: |  | ||||||
|       return POKER_SEAT_PLAYER3; |  | ||||||
|     case 0x04: |  | ||||||
|       return POKER_SEAT_PLAYER4; |  | ||||||
|     default: |  | ||||||
|       return POKER_SEAT_PLAYER0; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerPlayerRender(poker_t* poker, pokerplayer_t *player, uint8_t seat) { |  | ||||||
|   float x, z, angle; |  | ||||||
|   float w, h; |  | ||||||
|  |  | ||||||
|   // Determine position |  | ||||||
|   angle = POKER_SEAT_ANGLE(seat); |  | ||||||
|   x = sin(angle) * -1; |  | ||||||
|   z = cos(angle) * -1; |  | ||||||
|  |  | ||||||
|   shaderUsePosition(&poker->shader,  x,0.34,z,  0,angle,0); |  | ||||||
|  |  | ||||||
|   // Render Body |  | ||||||
|   shaderUseTexture(&poker->shader, &player->bodyTexture); |  | ||||||
|   primitiveDraw(&player->bodyPrimitive, 0, -1); |  | ||||||
|  |  | ||||||
|   // Render Face |  | ||||||
|   shaderUseTexture(&poker->shader, &player->faceTexture); |  | ||||||
|   primitiveDraw(&player->facePrimitive, 0, -1); |  | ||||||
| } |  | ||||||
| @@ -1,34 +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 "../../file/asset.h" |  | ||||||
| #include "../../display/shader.h" |  | ||||||
| #include "../../display/primitive.h" |  | ||||||
| #include "../../display/tileset.h" |  | ||||||
| #include "../../display/primitives/quad.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Initializes the player renderer. |  | ||||||
|  * @param poker Poker game context. |  | ||||||
|  */ |  | ||||||
| void pokerPlayerInit(poker_t *poker); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Returns the seat index for a given player. |  | ||||||
|  * @param player Player to get the seat for. |  | ||||||
|  * @return Seat ID for the given player. |  | ||||||
|  */ |  | ||||||
| uint8_t pokerPlayerGetSeatForPlayer(uint8_t player); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Render's a player at a seat. |  | ||||||
|  * @param poker Poker game context. |  | ||||||
|  * @param seat Seat to render the player at. |  | ||||||
|  */ |  | ||||||
| void pokerPlayerRender(poker_t *poker, pokerplayer_t *player, uint8_t seat); |  | ||||||
| @@ -1,30 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "world.h" |  | ||||||
|  |  | ||||||
| void pokerWorldInit(poker_t *poker) { |  | ||||||
|   // Poker Table |  | ||||||
|   pokerTableInit(&poker->tablePrimitive); |  | ||||||
|   assetTextureLoad(&poker->tableTexture, "pokertable.png"); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerWorldRender(poker_t *poker) { |  | ||||||
|   // Poker Table |  | ||||||
|   shaderUsePositionAndScale(&poker->shader, |  | ||||||
|     0, -0.01, 0, |  | ||||||
|     0, 0, 0, |  | ||||||
|     3.4, 3.4, 3.4 |  | ||||||
|   ); |  | ||||||
|   shaderUseTexture(&poker->shader, &poker->tableTexture); |  | ||||||
|   primitiveDraw(&poker->tablePrimitive, 0, -1); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerWorldDispose(poker_t *poker) { |  | ||||||
|   textureDispose(&poker->tableTexture); |  | ||||||
|   primitiveDispose(&poker->tablePrimitive); |  | ||||||
| } |  | ||||||
| @@ -1,32 +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 "../../assets/models/pokertable.h" |  | ||||||
| #include "../../display/shader.h" |  | ||||||
| #include "../../display/primitive.h" |  | ||||||
| #include "../../display/texture.h" |  | ||||||
| #include "../../file/asset.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Initializes the world renderer. |  | ||||||
|  * @param poker Poker scene to initialize. |  | ||||||
|  */ |  | ||||||
| void pokerWorldInit(poker_t *poker); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Renders the world. |  | ||||||
|  * @param poker Poker scene to render. |  | ||||||
|  */ |  | ||||||
| void pokerWorldRender(poker_t *poker); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Disposes a poker world. |  | ||||||
|  * @param poker Poker game to cleanup the world for. |  | ||||||
|  */ |  | ||||||
| void pokerWorldDispose(poker_t *poker); |  | ||||||
| @@ -1,75 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "bet.h" |  | ||||||
|  |  | ||||||
| void pokerRoundBetPlayerNext(poker_t *poker) { |  | ||||||
|   // Go to next player, keep contained. |  | ||||||
|   poker->bet.better = (poker->bet.better + 1) % POKER_PLAYER_COUNT; |  | ||||||
|  |  | ||||||
|   // Did we go full circle? |  | ||||||
|   if(poker->bet.better == poker->roundSmallBlind) { |  | ||||||
|     if(poker->round == POKER_ROUND_BET3) { |  | ||||||
|       pokerWinnerInit(poker); |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     pokerFlopInit(poker); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Init the next player |  | ||||||
|   pokerRoundBetPlayerInit(poker, poker->players + poker->bet.better); |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| void pokerRoundBetPlayerInit(poker_t *poker, pokerplayer_t *player) { |  | ||||||
|   // Check the player state (to see if we even can init, e.g. folded/not) |  | ||||||
|   if(!pokerPlayerIsAlive(player)) { |  | ||||||
|     pokerRoundBetPlayerNext(poker); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|    |  | ||||||
|   printf("Betting round player %u\n", poker->bet.better); |  | ||||||
|   if(pokerPlayerIsHuman(poker, player)) { |  | ||||||
|     pokerRoundBetPlayerNext(poker); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   pokerRoundBetPlayerNext(poker); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerRoundBetPlayerUpdate(poker_t *poker, pokerplayer_t *player) { |  | ||||||
|    |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerRoundBetInit(poker_t *poker) { |  | ||||||
|   printf("Betting round start\n"); |  | ||||||
|   |  | ||||||
|   if(poker->round == POKER_ROUND_DEAL) { |  | ||||||
|     poker->round = POKER_ROUND_BET0; |  | ||||||
|     printf("Betting 0\n"); |  | ||||||
|   } else if(poker->round == POKER_ROUND_FLOP) { |  | ||||||
|     poker->round = POKER_ROUND_BET1; |  | ||||||
|     printf("Betting 1\n"); |  | ||||||
|   } else if(poker->round == POKER_ROUND_TURN) { |  | ||||||
|     poker->round = POKER_ROUND_BET2; |  | ||||||
|     printf("Betting 2\n"); |  | ||||||
|   } else if(poker->round == POKER_ROUND_RIVER) { |  | ||||||
|     poker->round = POKER_ROUND_BET3; |  | ||||||
|     printf("Betting 3\n"); |  | ||||||
|   } |  | ||||||
|    |  | ||||||
|   // Set the inital player |  | ||||||
|   poker->bet.better = poker->roundSmallBlind; |  | ||||||
|   pokerRoundBetPlayerInit(poker, poker->players + poker->bet.better); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerRoundBetUpdate(poker_t *poker) { |  | ||||||
|   // Take the current player |  | ||||||
|   pokerRoundBetPlayerUpdate(poker, poker->players + poker->bet.better); |  | ||||||
| } |  | ||||||
| @@ -1,19 +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 "flop.h" |  | ||||||
| #include "winner.h" |  | ||||||
| #include "../player.h" |  | ||||||
|  |  | ||||||
| void pokerRoundBetPlayerNext(poker_t *poker); |  | ||||||
| void pokerRoundBetPlayerInit(poker_t *poker, pokerplayer_t *player); |  | ||||||
| void pokerRoundBetPlayerUpdate(poker_t *poker, pokerplayer_t *player); |  | ||||||
|  |  | ||||||
| void pokerRoundBetInit(poker_t *poker); |  | ||||||
| void pokerRoundBetUpdate(poker_t *poker); |  | ||||||
| @@ -1,19 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #pragma once |  | ||||||
| #include "blinds.h" |  | ||||||
|  |  | ||||||
| void pokerBlindsInit(poker_t *poker) { |  | ||||||
|   poker->round = POKER_ROUND_BLINDS; |  | ||||||
|  |  | ||||||
|   // Now take blinds |  | ||||||
|   pokerBetTakeBlinds(poker); |  | ||||||
|  |  | ||||||
|   printf("Blinds Taken\n"); |  | ||||||
|   pokerDealInit(poker); |  | ||||||
| } |  | ||||||
| @@ -1,16 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include <dawn/dawn.h> |  | ||||||
| #include "deal.h" |  | ||||||
| #include "../bet.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Initializes the blinds round. |  | ||||||
|  * @param poker The poker game conetxt. |  | ||||||
|  */ |  | ||||||
| void pokerBlindsInit(poker_t *poker); |  | ||||||
| @@ -1,23 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
| #include "deal.h" |  | ||||||
|  |  | ||||||
| void pokerDealInit(poker_t *poker) { |  | ||||||
|   poker->round = POKER_ROUND_DEAL; |  | ||||||
|  |  | ||||||
|   // Shuffle the deck |  | ||||||
|   cardShuffle(poker->dealer.deck, CARD_DECK_SIZE); |  | ||||||
|  |  | ||||||
|   // Deal 2 card to each player |  | ||||||
|   pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH); |  | ||||||
|    |  | ||||||
|   // Deal 2 card to each player |  | ||||||
|   pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH); |  | ||||||
|    |  | ||||||
|   printf("Cards Dealt\n"); |  | ||||||
|   pokerRoundBetInit(poker); |  | ||||||
| } |  | ||||||
| @@ -1,19 +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 "../../util/array.h" |  | ||||||
| #include "../dealer.h" |  | ||||||
| #include "../card.h" |  | ||||||
| #include "bet.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Resets a poker game for the new round. |  | ||||||
|  * @param poker Poker game to reset to a new round. |  | ||||||
|  */ |  | ||||||
| void pokerDealInit(poker_t *poker); |  | ||||||
| @@ -1,32 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "flop.h" |  | ||||||
|  |  | ||||||
| void pokerFlopInit(poker_t *poker) { |  | ||||||
|   uint8_t count; |  | ||||||
|  |  | ||||||
|   if(poker->round == POKER_ROUND_BET0) { |  | ||||||
|     printf("Poker Flop Start\n"); |  | ||||||
|     poker->round = POKER_ROUND_FLOP; |  | ||||||
|     count = POKER_FLOP_CARD_COUNT; |  | ||||||
|   } else if(poker->round == POKER_ROUND_BET1) { |  | ||||||
|     printf("Poker Turn\n"); |  | ||||||
|     poker->round = POKER_ROUND_TURN; |  | ||||||
|     count = POKER_TURN_CARD_COUNT; |  | ||||||
|   } else if(poker->round == POKER_ROUND_BET2) { |  | ||||||
|     printf("Poker River\n"); |  | ||||||
|     poker->round = POKER_ROUND_RIVER; |  | ||||||
|     count = POKER_RIVER_CARD_COUNT; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Burn and flop. |  | ||||||
|   pokerDealerBurn(&poker->dealer, 1); |  | ||||||
|   pokerDealerTurn(&poker->dealer, count); |  | ||||||
|  |  | ||||||
|   pokerRoundBetInit(poker); |  | ||||||
| } |  | ||||||
| @@ -1,14 +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 "../dealer.h" |  | ||||||
| #include "../card.h" |  | ||||||
| #include "bet.h" |  | ||||||
|  |  | ||||||
| void pokerFlopInit(poker_t *poker); |  | ||||||
| @@ -1,26 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
| #include "match.h" |  | ||||||
|  |  | ||||||
| void pokerMatchInit(poker_t *poker, engine_t *engine) { |  | ||||||
|   uint8_t x; |  | ||||||
|  |  | ||||||
|   // Reset the main game state. This does not init the round. |  | ||||||
|   pokerBetInit(&poker->bet); |  | ||||||
|   poker->roundDealer = POKER_PLAYER_COUNT-2; |  | ||||||
|   poker->round = POKER_ROUND_MATCH; |  | ||||||
|  |  | ||||||
|   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"); |  | ||||||
|   pokerStartInit(poker); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void pokerMatchUpdate(poker_t *poker, engine_t *engine) { |  | ||||||
| } |  | ||||||
| @@ -1,23 +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 "start.h" |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Init the poker match round. |  | ||||||
|  * @param poker The poker game context. |  | ||||||
|  * @param engine The engine context. |  | ||||||
|  */ |  | ||||||
| void pokerMatchInit(poker_t *poker, engine_t *engine); |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Update the poker match round. |  | ||||||
|  * @param poker The poker match to update for. |  | ||||||
|  */ |  | ||||||
| void pokerMatchUpdate(poker_t *poker, engine_t *engine); |  | ||||||
| @@ -1,57 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
|  |  | ||||||
| #include "start.h" |  | ||||||
|  |  | ||||||
| void pokerStartInit(poker_t *poker) { |  | ||||||
|   uint8_t i, indexDealer, indexSmallBlind, indexBigBlind; |  | ||||||
|   bool foundDealer, foundSmallBlind; |  | ||||||
|   pokerplayer_t *player; |  | ||||||
|  |  | ||||||
|   poker->round = POKER_ROUND_START; |  | ||||||
|  |  | ||||||
|   // Prepare the initial game state |  | ||||||
|   poker->round = POKER_ROUND_DEAL; |  | ||||||
|   pokerBetReset(&poker->bet); |  | ||||||
|   pokerDealerInit(&poker->dealer); |  | ||||||
|  |  | ||||||
|   // Reset the players |  | ||||||
|   for(i = 0; i < POKER_PLAYER_COUNT; i++) { |  | ||||||
|     pokerPlayerReset(poker->players + i); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Decide on the dealer |  | ||||||
|   poker->roundDealer = (poker->roundDealer+1) % POKER_PLAYER_COUNT; |  | ||||||
|  |  | ||||||
|   // Find the players. |  | ||||||
|   i = poker->roundDealer; |  | ||||||
|   foundDealer = false; |  | ||||||
|   foundSmallBlind = false; |  | ||||||
|   while(true) { |  | ||||||
|     player = poker->players + i; |  | ||||||
|     if(!pokerPlayerIsAlive(player)) continue; |  | ||||||
|     if(!foundDealer) { |  | ||||||
|       indexDealer = i; |  | ||||||
|       foundDealer = true; |  | ||||||
|     } else if(!foundSmallBlind) { |  | ||||||
|       indexSmallBlind = i; |  | ||||||
|       foundSmallBlind = true; |  | ||||||
|     } else { |  | ||||||
|       indexBigBlind = i; |  | ||||||
|       break; |  | ||||||
|     } |  | ||||||
|     i = (i + 1) % POKER_PLAYER_COUNT; |  | ||||||
|   } |  | ||||||
|    |  | ||||||
|   // Update players for the round. |  | ||||||
|   poker->roundDealer = indexDealer; |  | ||||||
|   poker->roundBigBlind = indexBigBlind; |  | ||||||
|   poker->roundSmallBlind = indexSmallBlind; |  | ||||||
|  |  | ||||||
|   printf("Round Start\n"); |  | ||||||
|   pokerBlindsInit(poker); |  | ||||||
| } |  | ||||||
| @@ -1,14 +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 "blinds.h" |  | ||||||
| #include "../bet.h" |  | ||||||
| #include "../player.h" |  | ||||||
|  |  | ||||||
| void pokerStartInit(poker_t *poker); |  | ||||||
| @@ -1,12 +0,0 @@ | |||||||
| /** |  | ||||||
|  * Copyright (c) 2021 Dominic Masters |  | ||||||
|  *  |  | ||||||
|  * This software is released under the MIT License. |  | ||||||
|  * https://opensource.org/licenses/MIT |  | ||||||
|  */ |  | ||||||
| #include "winner.h" |  | ||||||
|  |  | ||||||
| void pokerWinnerInit(poker_t *poker) { |  | ||||||
|   pokerWinnerCalculate(poker); |  | ||||||
|   printf("Winner Count %u\n", poker->winner.winnerCount); |  | ||||||
| } |  | ||||||
| @@ -1,13 +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 "../player.h" |  | ||||||
| #include "../winner.h" |  | ||||||
|  |  | ||||||
| void pokerWinnerInit(poker_t *poker); |  | ||||||
		Reference in New Issue
	
	Block a user