A bit more code cleanup
This commit is contained in:
15
src/games/pokerbackup/actions/action.c
Normal file
15
src/games/pokerbackup/actions/action.c
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "action.h"
|
||||
|
||||
queueaction_t * pokerGameActionAdd(pokergame_t *game) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(&game->scene.conversation.actionQueue);
|
||||
action->data = (void *)game;
|
||||
return action;
|
||||
}
|
19
src/games/pokerbackup/actions/action.h
Normal file
19
src/games/pokerbackup/actions/action.h
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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/animation/queue.h"
|
||||
#include "../pokergame.h"
|
||||
|
||||
/**
|
||||
* Adds an action to the poker game scene's queue.
|
||||
*
|
||||
* @param game Game to add the action to.
|
||||
* @return Action that was added to the game.
|
||||
*/
|
||||
queueaction_t * pokerGameActionAdd(pokergame_t *game);
|
89
src/games/pokerbackup/actions/bet.c
Normal file
89
src/games/pokerbackup/actions/bet.c
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "bet.h"
|
||||
|
||||
void _pokerGameActionBetOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
bool isHuman;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// Reset the UI state.
|
||||
isHuman = game->poker.better == POKER_WORLD_HUMAN_INDEX;
|
||||
// if(isHuman) pokerUiBetShow(&game->ui);
|
||||
}
|
||||
|
||||
void _pokerGameActionBetOnUpdate(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
// Restack
|
||||
bool isHuman;
|
||||
bool turnMade = false;
|
||||
pokerturn_t turn;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
pokerdiscussiondata_t discussion;
|
||||
|
||||
// Are they human?
|
||||
isHuman = game->poker.better == POKER_WORLD_HUMAN_INDEX;
|
||||
|
||||
// Handle as an AI
|
||||
if(isHuman) {
|
||||
// turn = game->ui.betTurn;
|
||||
// turnMade = game->ui.betTurnMade;
|
||||
turn = pokerTurnGetForPlayer(&game->poker, game->poker.better);
|
||||
turnMade = true;
|
||||
} else {
|
||||
turn = pokerTurnGetForPlayer(&game->poker, game->poker.better);
|
||||
turnMade = true;
|
||||
}
|
||||
|
||||
// Now decide if we should do something.
|
||||
if(!turnMade) return;
|
||||
|
||||
// Perform the action
|
||||
pokerTurnAction(&game->poker, game->poker.better, turn);
|
||||
|
||||
// Speak
|
||||
discussion.reason = pokerDiscussionGetTypeFromTurnType(turn.type);
|
||||
discussion.poker = game;
|
||||
discussion.playerCause = game->poker.better;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
// Next.
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
void _pokerGameActionBetOnEnd(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// // Get which player is remaining to move.
|
||||
game->poker.better = pokerBetGetNextPlayer(&game->poker);
|
||||
|
||||
// Restack
|
||||
pokerGameActionRestackAdd(game);
|
||||
|
||||
// Are we waiting on any players?
|
||||
if(game->poker.better != 0xFF) {
|
||||
pokerGameActionLookAdd(game, game->poker.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not waiting, do next action.
|
||||
pokerGameActionFlopAdd(game);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionBetAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionBetOnStart;
|
||||
action->onUpdate = &_pokerGameActionBetOnUpdate;
|
||||
action->onEnd = &_pokerGameActionBetOnEnd;
|
||||
return action;
|
||||
}
|
34
src/games/pokerbackup/actions/bet.h
Normal file
34
src/games/pokerbackup/actions/bet.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/bet.h"
|
||||
#include "../../../poker/turn.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "action.h"
|
||||
#include "restack.h"
|
||||
#include "winner.h"
|
||||
#include "flop.h"
|
||||
|
||||
/** Callback when the bet action is updated. */
|
||||
void _pokerGameActionBetOnUpdate(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/** Callback for when the bet action ends. */
|
||||
void _pokerGameActionBetOnEnd(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/**
|
||||
* Queues the bet action to the queue.
|
||||
*
|
||||
* @param game Game to queue onto.
|
||||
* @return The action that was queued.
|
||||
*/
|
||||
queueaction_t * pokerGameActionBetAdd(pokergame_t *game);
|
81
src/games/pokerbackup/actions/flop.c
Normal file
81
src/games/pokerbackup/actions/flop.c
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "flop.h"
|
||||
|
||||
void _pokerGameActionFlopOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
pokerdiscussiondata_t discussion;
|
||||
bool hasDoneFlop;
|
||||
|
||||
// Prep convo
|
||||
discussion.poker = game;
|
||||
|
||||
// Get how many players are left in the round.
|
||||
if(pokerInRoundGetCount(&game->poker) > 1) {// Still more than 1
|
||||
// Reset all the players
|
||||
pokerResetBettingRound(&game->poker);
|
||||
|
||||
// Do actual flop action
|
||||
hasDoneFlop = true;
|
||||
switch(game->poker.communitySize) {
|
||||
case 0x00:
|
||||
pokerDealerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerDealerTurn(&game->poker, POKER_FLOP_CARD_COUNT);
|
||||
break;
|
||||
case POKER_FLOP_CARD_COUNT:
|
||||
pokerDealerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerDealerTurn(&game->poker, POKER_TURN_CARD_COUNT);
|
||||
break;
|
||||
case POKER_FLOP_CARD_COUNT+POKER_TURN_CARD_COUNT:
|
||||
pokerDealerBurn(&game->poker, POKER_FLOP_BURN_COUNT);
|
||||
pokerDealerTurn(&game->poker, POKER_RIVER_CARD_COUNT);
|
||||
break;
|
||||
default:
|
||||
hasDoneFlop = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Is there any flop "left to do" ?
|
||||
if(hasDoneFlop) {
|
||||
// Talk about it.
|
||||
discussion.reason = POKER_DISCUSSION_REASON_FLOP;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
// Now, get the count of players left to bet. If "everyone is all in" then
|
||||
// this will be 0 and no actual betting needs to happen.
|
||||
if(pokerBetGetRemainingBetterCount(&game->poker) > 0x01) {
|
||||
// Begin betting.
|
||||
game->poker.better = pokerBetGetNextPlayer(&game->poker);
|
||||
pokerGameActionLookAdd(game, game->poker.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
} else {
|
||||
//No actual players to bet, so add the following flop instead.
|
||||
pokerGameActionFlopAdd(game);
|
||||
}
|
||||
|
||||
// Do next action.
|
||||
queueNext(queue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Done betting
|
||||
pokerGameActionRestackAdd(game);
|
||||
pokerGameActionWinnerAdd(game);
|
||||
|
||||
// Do next action
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionFlopAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionFlopOnStart;
|
||||
return action;
|
||||
}
|
27
src/games/pokerbackup/actions/flop.h
Normal file
27
src/games/pokerbackup/actions/flop.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "action.h"
|
||||
#include "restack.h"
|
||||
#include "winner.h"
|
||||
#include "bet.h"
|
||||
|
||||
/** Callback that is fired when the flop action starts */
|
||||
void _pokerGameActionFlopOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/**
|
||||
* Queues a flop action on to the queue.
|
||||
*
|
||||
* @param game Game to queue on to.
|
||||
* @return queueaction_t*
|
||||
*/
|
||||
queueaction_t * pokerGameActionFlopAdd(pokergame_t *game);
|
24
src/games/pokerbackup/actions/look.c
Normal file
24
src/games/pokerbackup/actions/look.c
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "look.h"
|
||||
|
||||
void _pokerGameActionLookOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
pokergameactiondata_t *data = game->actionData + i;
|
||||
pokerWorldLookAtPlayer(&game->scene, data->lookAtPlayer);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionLookAdd(pokergame_t *game, uint8_t playerIndex) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionLookOnStart;
|
||||
game->actionData[action->index].lookAtPlayer = playerIndex;
|
||||
return action;
|
||||
}
|
26
src/games/pokerbackup/actions/look.h
Normal file
26
src/games/pokerbackup/actions/look.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "action.h"
|
||||
#include "../../../libs.h"
|
||||
#include "../../../display/animation/queue.h"
|
||||
#include "../pokerworld.h"
|
||||
|
||||
/** Callback when the look action starts. */
|
||||
void _pokerGameActionLookOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/**
|
||||
* Queues a look action to the poker game.
|
||||
*
|
||||
* @param game Game to add to.
|
||||
* @param playerIndex The player index to look at.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerGameActionLookAdd(pokergame_t *game, uint8_t playerIndex);
|
22
src/games/pokerbackup/actions/restack.c
Normal file
22
src/games/pokerbackup/actions/restack.c
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "restack.h"
|
||||
|
||||
void _pokerGameActionRestackOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
pokerGameQueueRestack(game);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionRestackAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionRestackOnStart;
|
||||
return action;
|
||||
}
|
26
src/games/pokerbackup/actions/restack.h
Normal file
26
src/games/pokerbackup/actions/restack.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../util/math.h"
|
||||
#include "action.h"
|
||||
#include "../pokergame.h"
|
||||
#include "../../../display/animation/queue.h"
|
||||
|
||||
/** Callback for when the queue restack action stars. */
|
||||
void _pokerGameActionRestackOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/**
|
||||
* Adds a restack action to the queue.
|
||||
*
|
||||
* @param game Game to restack.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerGameActionRestackAdd(pokergame_t *game);
|
51
src/games/pokerbackup/actions/round.c
Normal file
51
src/games/pokerbackup/actions/round.c
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "round.h"
|
||||
|
||||
void _pokerGameActionRoundOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
||||
pokerdiscussiondata_t data;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// Start the round
|
||||
pokerResetRound(&game->poker);
|
||||
pokerDealerNew(&game->poker);
|
||||
pokerTakeBlinds(&game->poker);
|
||||
|
||||
// Speak
|
||||
data.poker = game;
|
||||
data.reason = POKER_DISCUSSION_REASON_ROUND_START;
|
||||
pokerDiscussionQueue(&data);
|
||||
|
||||
// Speak
|
||||
data.reason = POKER_DISCUSSION_REASON_BLINDS_TAKEN;
|
||||
pokerDiscussionQueue(&data);
|
||||
|
||||
// Deal
|
||||
cardShuffle(game->poker.deck, CARD_DECK_SIZE);
|
||||
pokerDealAllPlayers(&game->poker, POKER_PLAYER_HAND_SIZE_MAX);
|
||||
|
||||
// Speak
|
||||
data.reason = POKER_DISCUSSION_REASON_DEAL;
|
||||
pokerDiscussionQueue(&data);
|
||||
|
||||
// Begin Betting Round
|
||||
pokerGameActionBetAdd(game);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionRoundAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionRoundOnStart;
|
||||
action->onEnd = &_pokerGameActionRoundOnEnd;
|
||||
return action;
|
||||
}
|
29
src/games/pokerbackup/actions/round.h
Normal file
29
src/games/pokerbackup/actions/round.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2021 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/player.h"
|
||||
#include "../../../poker/dealer.h"
|
||||
#include "../../../poker/poker.h"
|
||||
#include "action.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "bet.h"
|
||||
|
||||
/** Callback that is fired when the round start event starts. */
|
||||
void _pokerGameActionRoundOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/** Callback that is fired when the round action ends. */
|
||||
void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i);
|
||||
|
||||
/**
|
||||
* Queues the round starting action onto the game. Handles talking VN logic.
|
||||
*
|
||||
* @param game Game to add to.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerGameActionRoundAdd(pokergame_t *game);
|
46
src/games/pokerbackup/actions/start.c
Normal file
46
src/games/pokerbackup/actions/start.c
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "start.h"
|
||||
|
||||
void _pokerGameActionStartOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
void _pokerGameActionStartOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
||||
pokerdiscussiondata_t data;
|
||||
uint8_t j, k;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
//TODO: Init Players betterer.
|
||||
pokerInit(&game->poker);
|
||||
pokerSetBlinds(
|
||||
&game->poker, POKER_BET_BLIND_SMALL_DEFAULT, POKER_BET_BLIND_BIG_DEFAULT
|
||||
);
|
||||
for(j = 0; j < POKER_PLAYER_COUNT_MAX; j++) {
|
||||
k = pokerPlayerAdd(&game->poker);
|
||||
pokerPlayerChipsAdd(game->poker.players+k, POKER_BET_PLAYER_CHIPS_DEFAULT);
|
||||
}
|
||||
pokerDealerSet(&game->poker, game->poker.playerCount/2);
|
||||
|
||||
// Say that.
|
||||
data.poker = game;
|
||||
data.reason = POKER_DISCUSSION_REASON_MATCH_START;
|
||||
pokerDiscussionQueue(&data);
|
||||
|
||||
// Begin Round.
|
||||
pokerGameActionRoundAdd(game);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionStartAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionStartOnStart;
|
||||
action->onEnd = &_pokerGameActionStartOnEnd;
|
||||
return action;
|
||||
}
|
31
src/games/pokerbackup/actions/start.h
Normal file
31
src/games/pokerbackup/actions/start.h
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/conversation/talk.h"
|
||||
#include "../../../display/animation/queue.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "round.h"
|
||||
#include "action.h"
|
||||
|
||||
/** Callback fired when the game action first starts */
|
||||
void _pokerGameActionStartOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/** Callback fired when the game start action ends */
|
||||
void _pokerGameActionStartOnEnd(queue_t *queue,queueaction_t *action,uint8_t i);
|
||||
|
||||
/**
|
||||
* Queues a match starting action onto the queue, also handles game logic for
|
||||
* speaking VN style.
|
||||
*
|
||||
* @param game Game to add to.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerGameActionStartAdd(pokergame_t *game);
|
41
src/games/pokerbackup/actions/winner.c
Normal file
41
src/games/pokerbackup/actions/winner.c
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "winner.h"
|
||||
|
||||
void _pokerGameActionWinnerOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
) {
|
||||
pokerdiscussiondata_t discussion;
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// Calculate the winners
|
||||
// TODO: Calculate Winners
|
||||
// pokerWinnerCalculate(
|
||||
// &game->poker.winner,
|
||||
// &game->poker.dealer,
|
||||
// game->poker.players
|
||||
// );
|
||||
|
||||
// Action
|
||||
// pokerGameWin(&game->poker);
|
||||
|
||||
// Say stuff
|
||||
discussion.reason = POKER_DISCUSSION_REASON_BETTING_DONE;
|
||||
discussion.poker = game;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
// Begin next round.
|
||||
pokerGameActionRoundAdd(game);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerGameActionWinnerAdd(pokergame_t *game) {
|
||||
queueaction_t *action = pokerGameActionAdd(game);
|
||||
action->onStart = &_pokerGameActionWinnerOnStart;
|
||||
return action;
|
||||
}
|
25
src/games/pokerbackup/actions/winner.h
Normal file
25
src/games/pokerbackup/actions/winner.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
#include "action.h"
|
||||
#include "round.h"
|
||||
|
||||
/** Callback to fire when the winner starts */
|
||||
void _pokerGameActionWinnerOnStart(
|
||||
queue_t *queue, queueaction_t *action, uint8_t i
|
||||
);
|
||||
|
||||
/**
|
||||
* Queue a winning game action.
|
||||
*
|
||||
* @param game Game to queue for.
|
||||
* @return The queued winning action.
|
||||
*/
|
||||
queueaction_t * pokerGameActionWinnerAdd(pokergame_t *game);
|
45
src/games/pokerbackup/characters/characters.c
Normal file
45
src/games/pokerbackup/characters/characters.c
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "characters.h"
|
||||
|
||||
pokercharacterdefinition_t POKER_CHARACTER_DEFINITIONS[] = {
|
||||
{
|
||||
"Lucy",
|
||||
POKER_CHARACTER_LUCY_TEXTURE,
|
||||
&pokerCharacterLucyInit
|
||||
},
|
||||
|
||||
{
|
||||
"Julie",
|
||||
POKER_CHARACTER_JULIE_TEXTURE,
|
||||
&pokerCharacterJulieInit
|
||||
},
|
||||
|
||||
{
|
||||
"Penny",
|
||||
POKER_CHARACTER_PENNY_TEXTURE,
|
||||
&pokerCharacterPennyInit
|
||||
},
|
||||
|
||||
{
|
||||
"Sammy",
|
||||
POKER_CHARACTER_SAMMY_TEXTURE,
|
||||
&pokerCharacterSammyInit
|
||||
},
|
||||
|
||||
{
|
||||
"Jenny",
|
||||
POKER_CHARACTER_JENNY_TEXTURE,
|
||||
&pokerCharacterJennyInit
|
||||
}
|
||||
};
|
||||
|
||||
void pokerCharacterInit(vncharacter_t *crctr, texture_t *txtr, uint8_t i) {
|
||||
vnCharacterInit(crctr, txtr);
|
||||
POKER_CHARACTER_DEFINITIONS[i].init(crctr);
|
||||
}
|
29
src/games/pokerbackup/characters/characters.h
Normal file
29
src/games/pokerbackup/characters/characters.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/vncharacter.h"
|
||||
#include "../../../display/texture.h"
|
||||
#include "jenny.h"
|
||||
#include "julie.h"
|
||||
#include "lucy.h"
|
||||
#include "penny.h"
|
||||
#include "sammy.h"
|
||||
|
||||
typedef void pokercharacterinitmethod_t(vncharacter_t *c);
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *fileTexture;
|
||||
pokercharacterinitmethod_t *init;
|
||||
} pokercharacterdefinition_t;
|
||||
|
||||
#define POKER_CHARACTER_DEFINITIONS_COUNT 0x05
|
||||
extern pokercharacterdefinition_t POKER_CHARACTER_DEFINITIONS[];
|
||||
|
||||
void pokerCharacterInit(vncharacter_t *crctr, texture_t *txtr, uint8_t i);
|
28
src/games/pokerbackup/characters/jenny.c
Normal file
28
src/games/pokerbackup/characters/jenny.c
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "jenny.h"
|
||||
|
||||
void pokerCharacterJennyInit(vncharacter_t *vnc) {
|
||||
// Base Layer
|
||||
vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1095, 2029);
|
||||
|
||||
// Layers
|
||||
vnCharacterLayerAdd(vnc, 3,
|
||||
1095, 0,
|
||||
608, 250,
|
||||
280, 123
|
||||
);
|
||||
|
||||
vnCharacterLayerAdd(vnc, 3,
|
||||
1095, 123,
|
||||
608, 250,
|
||||
280, 123
|
||||
);
|
||||
|
||||
vnc->breathing = false;
|
||||
}
|
16
src/games/pokerbackup/characters/jenny.h
Normal file
16
src/games/pokerbackup/characters/jenny.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/vncharacter.h"
|
||||
#include "../../../display/texture.h"
|
||||
#include "../../../file/asset.h"
|
||||
|
||||
#define POKER_CHARACTER_JENNY_TEXTURE "poker/characters/jenny.png"
|
||||
|
||||
void pokerCharacterJennyInit(vncharacter_t *vnc);
|
38
src/games/pokerbackup/characters/julie.c
Normal file
38
src/games/pokerbackup/characters/julie.c
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "julie.h"
|
||||
|
||||
void pokerCharacterJulieInit(vncharacter_t *vnc) {
|
||||
// Base Layer
|
||||
vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1053, 1961);
|
||||
|
||||
// Layers
|
||||
vnc->layerEyes = vnCharacterLayerAdd(vnc, 4,
|
||||
1053, 0,
|
||||
353, 119,
|
||||
344, 351
|
||||
);
|
||||
|
||||
vnc->layerMouth = vnCharacterLayerAdd(vnc, 12,
|
||||
1053, 351,
|
||||
353, 119,
|
||||
344, 351
|
||||
);
|
||||
|
||||
vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 4,
|
||||
1053, 702,
|
||||
353, 119,
|
||||
344, 351
|
||||
);
|
||||
|
||||
vnCharacterLayerAdd(vnc, 2,
|
||||
1053, 1053,
|
||||
353, 119,
|
||||
344, 351
|
||||
);
|
||||
}
|
16
src/games/pokerbackup/characters/julie.h
Normal file
16
src/games/pokerbackup/characters/julie.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/vncharacter.h"
|
||||
#include "../../../display/texture.h"
|
||||
#include "../../../file/asset.h"
|
||||
|
||||
#define POKER_CHARACTER_JULIE_TEXTURE "poker/characters/julie.png"
|
||||
|
||||
void pokerCharacterJulieInit(vncharacter_t *vnc);
|
33
src/games/pokerbackup/characters/lucy.c
Normal file
33
src/games/pokerbackup/characters/lucy.c
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
|
||||
#include "lucy.h"
|
||||
|
||||
void pokerCharacterLucyInit(vncharacter_t *vnc) {
|
||||
// Base Layer
|
||||
vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1440, 2240);
|
||||
|
||||
// Layers
|
||||
vnc->layerEyes = vnCharacterLayerAdd(vnc, 5,
|
||||
1440, 0,
|
||||
675, 327,
|
||||
295, 235
|
||||
);
|
||||
|
||||
vnc->layerMouth = vnCharacterLayerAdd(vnc, 12,
|
||||
1440, 235,
|
||||
675, 327,
|
||||
295, 235
|
||||
);
|
||||
|
||||
vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 5,
|
||||
1440, 470,
|
||||
675, 327,
|
||||
295, 235
|
||||
);
|
||||
}
|
16
src/games/pokerbackup/characters/lucy.h
Normal file
16
src/games/pokerbackup/characters/lucy.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/vncharacter.h"
|
||||
#include "../../../display/texture.h"
|
||||
#include "../../../file/asset.h"
|
||||
|
||||
#define POKER_CHARACTER_LUCY_TEXTURE "poker/characters/lucy.png"
|
||||
|
||||
void pokerCharacterLucyInit(vncharacter_t *vnc);
|
32
src/games/pokerbackup/characters/penny.c
Normal file
32
src/games/pokerbackup/characters/penny.c
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "penny.h"
|
||||
|
||||
void pokerCharacterPennyInit(vncharacter_t *vnc) {
|
||||
// Base Layer
|
||||
vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1000, 1920);
|
||||
|
||||
// Layers
|
||||
vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 5,
|
||||
1000, 0,
|
||||
367, 256,
|
||||
280, 280
|
||||
);
|
||||
|
||||
vnc->layerEyes = vnCharacterLayerAdd(vnc, 4,
|
||||
1000, 280,
|
||||
367, 256,
|
||||
280, 280
|
||||
);
|
||||
|
||||
vnc->layerMouth = vnCharacterLayerAdd(vnc, 12,
|
||||
1000, 560,
|
||||
367, 256,
|
||||
280, 280
|
||||
);
|
||||
}
|
16
src/games/pokerbackup/characters/penny.h
Normal file
16
src/games/pokerbackup/characters/penny.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/vncharacter.h"
|
||||
#include "../../../display/texture.h"
|
||||
#include "../../../file/asset.h"
|
||||
|
||||
#define POKER_CHARACTER_PENNY_TEXTURE "poker/characters/penny.png"
|
||||
|
||||
void pokerCharacterPennyInit(vncharacter_t *vnc);
|
32
src/games/pokerbackup/characters/sammy.c
Normal file
32
src/games/pokerbackup/characters/sammy.c
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "sammy.h"
|
||||
|
||||
void pokerCharacterSammyInit(vncharacter_t *vnc) {
|
||||
// Base Layer
|
||||
vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 731, 2122);
|
||||
|
||||
// Layers
|
||||
vnc->layerEyes = vnCharacterLayerAdd(vnc, 4,
|
||||
731, 0,
|
||||
215, 264,
|
||||
307, 213
|
||||
);
|
||||
|
||||
vnc->layerMouth = vnCharacterLayerAdd(vnc, 12,
|
||||
731, 213,
|
||||
215, 264,
|
||||
307, 213
|
||||
);
|
||||
|
||||
vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 5,
|
||||
731, 426,
|
||||
215, 264,
|
||||
307, 213
|
||||
);
|
||||
}
|
16
src/games/pokerbackup/characters/sammy.h
Normal file
16
src/games/pokerbackup/characters/sammy.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../vn/vncharacter.h"
|
||||
#include "../../../display/texture.h"
|
||||
#include "../../../file/asset.h"
|
||||
|
||||
#define POKER_CHARACTER_SAMMY_TEXTURE "poker/characters/sammy.png"
|
||||
|
||||
void pokerCharacterSammyInit(vncharacter_t *vnc);
|
83
src/games/pokerbackup/game.c
Normal file
83
src/games/pokerbackup/game.c
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
|
||||
bool pokerGameInit(pokergame_t *game) {
|
||||
// Begin to load the assets.
|
||||
pokerGameAssetsInit(&game->assets);
|
||||
loadingSceneInit(&game->loadingScene, &game->assets.manager);
|
||||
loadingSceneStart(&game->loadingScene);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void pokerGameUpdate(pokergame_t *game) {
|
||||
bool t;
|
||||
if(!game->loadingScene.manager->finished) {
|
||||
t = loadingSceneUpdate(&game->loadingScene);
|
||||
if(t) {
|
||||
// Initialize the Visual Novel Engine.
|
||||
vnSceneInit(&game->scene,
|
||||
&game->assets.font,
|
||||
&game->assets.testTexture
|
||||
);
|
||||
|
||||
// Initialize the world
|
||||
pokerWorldInit(&game->world, &game->scene, &game->assets);
|
||||
|
||||
// Initialize the UI.
|
||||
pokerUiInit(&game->ui);
|
||||
|
||||
// Add the first action, the game action, and then start the action queue.
|
||||
pokerGameActionStartAdd(game);
|
||||
queueNext(&game->scene.conversation.actionQueue);
|
||||
} else {
|
||||
loadingSceneRender(&game->loadingScene);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the VN Engine.
|
||||
vnSceneUpdate(&game->scene, &game->engine);
|
||||
|
||||
// Update the UI
|
||||
pokerUiUpdate(
|
||||
&game->ui,
|
||||
&game->engine,
|
||||
&game->assets.shader,
|
||||
game->scene.characters,
|
||||
game->poker.players
|
||||
);
|
||||
|
||||
// Bind the shader.
|
||||
shaderUse(&game->assets.shader);
|
||||
|
||||
// Render the visual novel scene.
|
||||
vnSceneRenderWorld(&game->scene, &game->engine, &game->assets.shader);
|
||||
|
||||
pokerWorldRender(&game->world, &game->assets);
|
||||
vnSceneRenderCharacters(&game->scene, &game->assets.shader);
|
||||
|
||||
// Render the UI
|
||||
vnSceneRenderGui(&game->scene, &game->engine, &game->assets.shader);
|
||||
pokerUiRender(&game->ui, &game->engine, &game->assets, &game->poker);
|
||||
}
|
||||
|
||||
void pokerGameDispose(pokergame_t *game) {
|
||||
//Cleanup the UI
|
||||
pokerUiDispose(&game->ui);
|
||||
|
||||
// Cleanup the world
|
||||
pokerWorldDispose(&game->world);
|
||||
|
||||
// Destroy the Visual Novel engine.
|
||||
vnSceneDispose(&game->scene);
|
||||
|
||||
// Unload all assets
|
||||
pokerGameAssetsDispose(&game->assets);
|
||||
}
|
41
src/games/pokerbackup/game.h
Normal file
41
src/games/pokerbackup/game.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "../../vn/conversation/talk.h"
|
||||
#include "../../vn/vnscene.h"
|
||||
#include "../../util/array.h"
|
||||
#include "../../engine/thread.h"
|
||||
#include "../../scene/loadingscene.h"
|
||||
#include "pokergame.h"
|
||||
#include "pokergameassets.h"
|
||||
#include "pokerui.h"
|
||||
#include "pokerworld.h"
|
||||
#include "pokergameaction.h"
|
||||
#include "actions/start.h"
|
||||
|
||||
/**
|
||||
* Initializes the game state for the poker game.
|
||||
*
|
||||
* @param game Game to initialize.
|
||||
* @returns True if successful, otherwise false.
|
||||
*/
|
||||
bool pokerGameInit(pokergame_t *game);
|
||||
|
||||
/**
|
||||
* Updates the poker game instance.
|
||||
* @param game Poker game to update for.
|
||||
*/
|
||||
void pokerGameUpdate(pokergame_t *game);
|
||||
|
||||
/**
|
||||
* Disposes a previously initialized poker game instance.
|
||||
* @param game Game to dispose.
|
||||
*/
|
||||
void pokerGameDispose(pokergame_t *game);
|
140
src/games/pokerbackup/pokerdiscussion.c
Normal file
140
src/games/pokerbackup/pokerdiscussion.c
Normal file
@ -0,0 +1,140 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokerdiscussion.h"
|
||||
|
||||
void pokerDiscussionGet(
|
||||
pokerdiscussion_t *discussion, pokerdiscussiondata_t *data
|
||||
) {
|
||||
discussion->count = 0;
|
||||
memset(discussion->players, 0xFF,
|
||||
sizeof(uint8_t) * POKER_DISCUSSION_MESSAGE_COUNT_MAX
|
||||
);
|
||||
|
||||
switch(data->reason) {
|
||||
// Match Start Conversations
|
||||
case POKER_DISCUSSION_REASON_MATCH_START:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Match Start";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
|
||||
// Round Start Conversations
|
||||
case POKER_DISCUSSION_REASON_ROUND_START:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Round Start";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
|
||||
// Round Start Conversations
|
||||
case POKER_DISCUSSION_REASON_BLINDS_TAKEN:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Blinds\nhave been taken.";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
|
||||
// Deal
|
||||
case POKER_DISCUSSION_REASON_DEAL:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Cards dealt.";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
|
||||
// Betting conversations
|
||||
case POKER_DISCUSSION_REASON_PLAYER_FOLDING:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "I fold.";
|
||||
discussion->players[0] = data->playerCause;
|
||||
break;
|
||||
|
||||
case POKER_DISCUSSION_REASON_PLAYER_CHECKING:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "I check.";
|
||||
discussion->players[0] = data->playerCause;
|
||||
break;
|
||||
|
||||
case POKER_DISCUSSION_REASON_PLAYER_CALLING:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "I call.";
|
||||
discussion->players[0] = data->playerCause;
|
||||
break;
|
||||
|
||||
case POKER_DISCUSSION_REASON_PLAYER_RAISING:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "I raise.";
|
||||
discussion->players[0] = data->playerCause;
|
||||
break;
|
||||
|
||||
case POKER_DISCUSSION_REASON_PLAYER_ALL_IN:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "All in.";
|
||||
discussion->players[0] = data->playerCause;
|
||||
break;
|
||||
|
||||
// Flops
|
||||
case POKER_DISCUSSION_REASON_FLOP:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Doing the flop.";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
|
||||
case POKER_DISCUSSION_REASON_BETTING_DONE:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Winner Winner Chicken Dinner";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
|
||||
// Fallback
|
||||
default:
|
||||
discussion->count++;
|
||||
discussion->messages[0] = "Hmm, this seems to be an error message.";
|
||||
discussion->players[0] = POKER_WORLD_DEALER_INDEX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType) {
|
||||
switch(winningType) {
|
||||
case POKER_TURN_TYPE_BET:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_RAISING;
|
||||
|
||||
case POKER_TURN_TYPE_CALL:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_CALLING;
|
||||
|
||||
case POKER_TURN_TYPE_ALL_IN:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_ALL_IN;
|
||||
|
||||
case POKER_TURN_TYPE_FOLD:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_FOLDING;
|
||||
break;
|
||||
|
||||
case POKER_TURN_TYPE_CHECK:
|
||||
return POKER_DISCUSSION_REASON_PLAYER_CHECKING;
|
||||
|
||||
default:
|
||||
return POKER_DISCUSSION_REASON_TEST;
|
||||
}
|
||||
}
|
||||
|
||||
void pokerDiscussionQueue(pokerdiscussiondata_t *data) {
|
||||
pokerdiscussion_t discussion;
|
||||
uint8_t i, player;
|
||||
|
||||
// Fetch the discussion item for the given data.
|
||||
pokerDiscussionGet(&discussion, data);
|
||||
|
||||
// Now for each discussion item, queue a task.
|
||||
for(i = 0; i < discussion.count; i++) {
|
||||
player = discussion.players[i];
|
||||
|
||||
pokerGameActionLookAdd(data->poker, player);
|
||||
vnConversationTalk(&data->poker->scene.conversation,
|
||||
discussion.messages[i],
|
||||
data->poker->scene.characters + player
|
||||
);
|
||||
}
|
||||
}
|
64
src/games/pokerbackup/pokerdiscussion.h
Normal file
64
src/games/pokerbackup/pokerdiscussion.h
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../vn/conversation/vnconversation.h"
|
||||
#include "../../vn/conversation/talk.h"
|
||||
#include "actions/look.h"
|
||||
|
||||
/** Maximum number of messages that the discussion buffer can hold */
|
||||
#define POKER_DISCUSSION_MESSAGE_COUNT_MAX 32
|
||||
|
||||
/** Why the discussion is happening */
|
||||
#define POKER_DISCUSSION_REASON_TEST 0x00
|
||||
#define POKER_DISCUSSION_REASON_MATCH_START 0x01
|
||||
#define POKER_DISCUSSION_REASON_ROUND_START 0x02
|
||||
#define POKER_DISCUSSION_REASON_BLINDS_TAKEN 0x03
|
||||
#define POKER_DISCUSSION_REASON_PLAYER_FOLDING 0x04
|
||||
#define POKER_DISCUSSION_REASON_PLAYER_CHECKING 0x05
|
||||
#define POKER_DISCUSSION_REASON_PLAYER_CALLING 0x06
|
||||
#define POKER_DISCUSSION_REASON_PLAYER_RAISING 0x07
|
||||
#define POKER_DISCUSSION_REASON_PLAYER_ALL_IN 0x08
|
||||
#define POKER_DISCUSSION_REASON_FLOP 0x09
|
||||
#define POKER_DISCUSSION_REASON_DEAL 0x0A
|
||||
#define POKER_DISCUSSION_REASON_BETTING_DONE 0x0B
|
||||
|
||||
typedef struct {
|
||||
pokergame_t *poker;
|
||||
uint8_t reason;
|
||||
uint8_t playerCause;
|
||||
uint8_t playerTarget;
|
||||
} pokerdiscussiondata_t;
|
||||
|
||||
typedef struct {
|
||||
char *messages[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
|
||||
uint8_t players[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
|
||||
uint8_t count;
|
||||
} pokerdiscussion_t;
|
||||
|
||||
/**
|
||||
* Retreives the discussion based on some discussion data.
|
||||
* @param disc The discussion data to buffer into.
|
||||
* @param data The discussion data.
|
||||
*/
|
||||
void pokerDiscussionGet(pokerdiscussion_t *disc, pokerdiscussiondata_t *data);
|
||||
|
||||
/**
|
||||
* Fetch the discussion type from a turn type.
|
||||
*
|
||||
* @param winningType Winning type
|
||||
* @return Relevant discussion type.
|
||||
*/
|
||||
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType);
|
||||
|
||||
/**
|
||||
* Queue a discussion data result onto the conversation stack.
|
||||
*
|
||||
* @param data The discussion data.
|
||||
*/
|
||||
void pokerDiscussionQueue(pokerdiscussiondata_t *data);
|
19
src/games/pokerbackup/pokergame.c
Normal file
19
src/games/pokerbackup/pokergame.c
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokergame.h"
|
||||
|
||||
void pokerGameQueueRestack(pokergame_t *pokerGame) {
|
||||
arrayRewind(
|
||||
sizeof(pokergameactiondata_t),
|
||||
pokerGame->actionData,
|
||||
ANIMATION_QUEUE_ITEM_MAX,
|
||||
pokerGame->scene.conversation.actionQueue.current,
|
||||
pokerGame->scene.conversation.actionQueue.count
|
||||
);
|
||||
queueRestack(&pokerGame->scene.conversation.actionQueue);
|
||||
}
|
52
src/games/pokerbackup/pokergame.h
Normal file
52
src/games/pokerbackup/pokergame.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "../../vn/conversation/talk.h"
|
||||
#include "../../vn/vnscene.h"
|
||||
#include "../../util/array.h"
|
||||
#include "../../scene/loadingscene.h"
|
||||
#include "pokergameassets.h"
|
||||
#include "pokerui.h"
|
||||
#include "pokerworld.h"
|
||||
#include "pokergameaction.h"
|
||||
|
||||
typedef struct {
|
||||
loadingscene_t loadingScene;
|
||||
|
||||
|
||||
|
||||
/** Game Engine Instance */
|
||||
engine_t engine;
|
||||
|
||||
/** Poker Game State */
|
||||
poker_t poker;
|
||||
|
||||
/** Visual Novel Engine */
|
||||
vnscene_t scene;
|
||||
|
||||
/** Assets (Files) for the game. */
|
||||
pokergameassets_t assets;
|
||||
|
||||
/** Poker Game World. */
|
||||
pokerworld_t world;
|
||||
|
||||
/** UI For the Game */
|
||||
pokerui_t ui;
|
||||
|
||||
/** Data for the actions */
|
||||
pokergameactiondata_t actionData[ANIMATION_QUEUE_ITEM_MAX];
|
||||
} pokergame_t;
|
||||
|
||||
/**
|
||||
* Restacks the poker game's stack.
|
||||
*
|
||||
* @param game Poker game to restack
|
||||
*/
|
||||
void pokerGameQueueRestack(pokergame_t *game);
|
14
src/games/pokerbackup/pokergameaction.h
Normal file
14
src/games/pokerbackup/pokergameaction.h
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
|
||||
/** Representation of data that poker game actions can have access to. */
|
||||
typedef struct {
|
||||
uint8_t lookAtPlayer;
|
||||
} pokergameactiondata_t;
|
54
src/games/pokerbackup/pokergameassets.c
Normal file
54
src/games/pokerbackup/pokergameassets.c
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#include "pokergameassets.h"
|
||||
|
||||
bool pokerGameAssetsInit(pokergameassets_t *assets) {
|
||||
uint8_t i;
|
||||
assetManagerInit(&assets->manager);
|
||||
|
||||
// Initialize the language buffer.
|
||||
languageInit(&assets->language, "locale/language/en-US.csv");
|
||||
|
||||
|
||||
assetManagerLoadShader(&assets->manager, &assets->shader,
|
||||
"shaders/textured.vert", "shaders/textured.frag"
|
||||
);
|
||||
|
||||
assetManagerLoadFont(&assets->manager, &assets->font,
|
||||
"fonts/opensans/OpenSans-Bold.ttf"
|
||||
);
|
||||
|
||||
// Load the world textures.
|
||||
assetManagerLoadTexture(&assets->manager, &assets->testTexture,
|
||||
"textures/test_texture.png"
|
||||
);
|
||||
assetManagerLoadTexture(&assets->manager, &assets->cardTexture,
|
||||
"poker/cards.png"
|
||||
);
|
||||
assetManagerLoadTexture(&assets->manager, &assets->roomTexture,
|
||||
"poker/pub_skywall.png"
|
||||
);
|
||||
|
||||
// Load character textures.
|
||||
for(i = 0; i < POKER_CHARACTER_DEFINITIONS_COUNT; i++) {
|
||||
assetManagerLoadTexture(&assets->manager, assets->characterTextures + i,
|
||||
POKER_CHARACTER_DEFINITIONS[i].fileTexture
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void pokerGameAssetsDispose(pokergameassets_t *assets) {
|
||||
// Now we unload in what is essentially the reverse of the above.
|
||||
textureDispose(&assets->roomTexture);
|
||||
textureDispose(&assets->testTexture);
|
||||
textureDispose(&assets->cardTexture);
|
||||
fontDispose(&assets->font);
|
||||
shaderDispose(&assets->shader);
|
||||
languageDispose(&assets->language);
|
||||
}
|
45
src/games/pokerbackup/pokergameassets.h
Normal file
45
src/games/pokerbackup/pokergameassets.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../file/asset.h"
|
||||
#include "../../file/assetmanager.h"
|
||||
#include "../../locale/language.h"
|
||||
#include "../../display/texture.h"
|
||||
#include "../../vn/vncharacter.h"
|
||||
#include "../../poker/common.h"
|
||||
#include "characters/characters.h"
|
||||
|
||||
typedef struct {
|
||||
assetmanager_t manager;
|
||||
|
||||
font_t font;
|
||||
shader_t shader;
|
||||
language_t language;
|
||||
|
||||
texture_t testTexture;
|
||||
texture_t roomTexture;
|
||||
texture_t cardTexture;
|
||||
|
||||
texture_t characterTextures[POKER_CHARACTER_DEFINITIONS_COUNT];
|
||||
} pokergameassets_t;
|
||||
|
||||
/**
|
||||
* Load and initializes all the assets used by the poker game.
|
||||
*
|
||||
* @param assets Assets instance to initailize.
|
||||
* @return True if successful, otherwise false.
|
||||
*/
|
||||
bool pokerGameAssetsInit(pokergameassets_t *assets);
|
||||
|
||||
/**
|
||||
* Cleans a previously initialized game assets set.
|
||||
*
|
||||
* @param assets Assets to dispose.
|
||||
*/
|
||||
void pokerGameAssetsDispose(pokergameassets_t *assets);
|
230
src/games/pokerbackup/pokerui.c
Normal file
230
src/games/pokerbackup/pokerui.c
Normal file
@ -0,0 +1,230 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokerui.h"
|
||||
|
||||
void pokerUiInit(pokerui_t *ui) {
|
||||
uint8_t i;
|
||||
|
||||
// Initialize card render(s)
|
||||
imageInit(&ui->card);
|
||||
|
||||
// Initialize the player face quad.
|
||||
quadInit(&ui->quad, 0,
|
||||
0, 0, 0, 1,
|
||||
POKER_UI_PLAYER_IMAGE_SIZE, POKER_UI_PLAYER_IMAGE_SIZE, 1, 0
|
||||
);
|
||||
|
||||
// Initialize the grid
|
||||
gridInit(&ui->grid);
|
||||
|
||||
ui->grid.gutterX = POKER_UI_PLAYER_PADDING;
|
||||
ui->grid.columns = 2;
|
||||
ui->grid.rows = 2;
|
||||
ui->grid.columnDefinitions[1] = POKER_UI_PLAYER_IMAGE_SIZE;
|
||||
ui->grid.rowDefinitions[0] = POKER_UI_PLAYER_IMAGE_SIZE / 2.0f;
|
||||
ui->grid.rowDefinitions[1] = POKER_UI_PLAYER_IMAGE_SIZE / 2.0f;
|
||||
|
||||
gridResize(&ui->grid, POKER_UI_PLAYER_WIDTH, POKER_UI_PLAYER_HEIGHT);
|
||||
|
||||
// Initialize the label
|
||||
labelInit(&ui->label);
|
||||
|
||||
// Initialize the frames for each player.
|
||||
for(i = 0; i < POKER_PLAYER_COUNT_MAX; i++) {
|
||||
frameBufferInit(ui->frames + i,
|
||||
POKER_UI_PLAYER_IMAGE_RESOLUTION,
|
||||
POKER_UI_PLAYER_IMAGE_RESOLUTION
|
||||
);
|
||||
}
|
||||
|
||||
// Rest the betting ui
|
||||
ui->betShow = false;
|
||||
}
|
||||
|
||||
void pokerUiUpdate(
|
||||
pokerui_t *ui, engine_t *engine, shader_t *shader,
|
||||
vncharacter_t *characters, pokerplayer_t *players
|
||||
) {
|
||||
uint8_t i, j;
|
||||
camera_t camera;
|
||||
uint8_t seat;
|
||||
float x, y, z;
|
||||
pokerplayer_t *player;
|
||||
|
||||
// Set up the camera perspective
|
||||
cameraPerspective(&camera, 45,
|
||||
(float)POKER_UI_PLAYER_IMAGE_SIZE / (float)POKER_UI_PLAYER_IMAGE_SIZE,
|
||||
0.03f, 100.0f
|
||||
);
|
||||
|
||||
// Render the face of each player.
|
||||
j = 0;
|
||||
shaderUse(shader);
|
||||
for(i = 0; i < POKER_PLAYER_COUNT_MAX; i++) {
|
||||
player = players + j;
|
||||
|
||||
// Locate the XYZ position of the camera to look at the player
|
||||
seat = pokerWorldSeatFromIndex(i);
|
||||
x = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||
y = POKER_UI_PLAYER_IMAGE_Y;
|
||||
z = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||
|
||||
cameraLookAt(&camera,
|
||||
x * POKER_UI_PLAYER_IMAGE_DIST, y, z * POKER_UI_PLAYER_IMAGE_DIST,
|
||||
x, y, z
|
||||
);
|
||||
|
||||
// Bind the frame buffer
|
||||
frameBufferUse(ui->frames + j, true);
|
||||
|
||||
// Render the VN character
|
||||
shaderUseCamera(shader, &camera);
|
||||
// shaderUsePosition(shader, 0,0,0, 0,0,0);
|
||||
vnCharacterRender(characters + i, shader);
|
||||
|
||||
// Increment
|
||||
j++;
|
||||
}
|
||||
|
||||
renderResetFramebuffer(&engine->render);
|
||||
}
|
||||
|
||||
void pokerUiRender(
|
||||
pokerui_t *ui, engine_t *engine, pokergameassets_t *assets, poker_t *poker
|
||||
) {
|
||||
// uint8_t i, j;
|
||||
// pokerplayer_t *player;
|
||||
float scale;
|
||||
// align_t align;
|
||||
// float gx, gy, gw, gh, x, y;
|
||||
// char message[128];
|
||||
|
||||
// Get the default font scale size.
|
||||
scale = fontGetScale(FONT_SIZE_DEFAULT);
|
||||
|
||||
// <testing>
|
||||
// if(poker->state >= POKER_STATE_DEALING) {
|
||||
// for(j = 0; j < POKER_PLAYER_COUNT_MAX; j++) {
|
||||
// player = poker->players + j;
|
||||
// for(i = 0; i < player->cardCount; i++) {
|
||||
// pokerUiSetImageToCard(&ui->card,&assets->cardTexture,player->cards[i]);
|
||||
// imageRender(&ui->card, &assets->shader, i * 64.0f, j * 100.0f);
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(j = 0; j < poker->communitySize; j++) {
|
||||
// pokerUiSetImageToCard(
|
||||
// &ui->card, &assets->cardTexture, poker->community[j]
|
||||
// );
|
||||
// imageRender(&ui->card, &assets->shader, 200, j * 100.0f);
|
||||
// }
|
||||
// // }
|
||||
|
||||
// // Betting UI
|
||||
// if(ui->betShow) {
|
||||
// sprintf(message, "Press down to fold, up to raise, right to check/call.");
|
||||
// labelSetText(&ui->label, &assets->font, message);
|
||||
// labelRender(&ui->label, &assets->shader, 300, 100);
|
||||
|
||||
// if(inputIsPressed(&engine->input, INPUT_DOWN)) {
|
||||
// ui->betTurn = pokerTurnFold(poker, poker->bet.better);
|
||||
// ui->betTurnMade = true;
|
||||
// } else if(inputIsPressed(&engine->input, INPUT_RIGHT)) {
|
||||
// if(pokerTurnCanPlayerCheck(poker, poker->bet.better)) {
|
||||
// ui->betTurn = pokerTurnCheck(poker, poker->bet.better);
|
||||
// } else {
|
||||
// ui->betTurn = pokerTurnCall(poker, poker->bet.better);
|
||||
// }
|
||||
// ui->betTurnMade = true;
|
||||
// }
|
||||
|
||||
// if(ui->betTurnMade) ui->betShow = false;
|
||||
// }
|
||||
|
||||
// // Player UI
|
||||
// j = 0;
|
||||
// for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
// // Get the player.
|
||||
// player = poker->players + i;
|
||||
|
||||
// // Position the grid itself.
|
||||
// x = engine->render.width - POKER_UI_PLAYER_WIDTH;
|
||||
// y = (float)(POKER_UI_PLAYER_HEIGHT * j);
|
||||
|
||||
// // Render face
|
||||
// gridGetChild(&ui->grid, 1, 0, 1, 2, &gx, &gy, &gw, &gh);
|
||||
// shaderUseTexture(&assets->shader, &(ui->frames + j)->texture);
|
||||
// shaderUsePosition(&assets->shader, x + gx, y + gy, 0, 0,0,0);
|
||||
// primitiveDraw(&ui->quad, 0, -1);
|
||||
|
||||
// // Render chips
|
||||
// sprintf(message, "$%i", player->chips);
|
||||
// ui->label.maxWidth = -1;
|
||||
// labelSetText(&ui->label, &assets->font, message);
|
||||
// align = gridGetAndAlignChild(
|
||||
// &ui->grid, 0, 0, 1, 1,
|
||||
// ALIGN_POS_END|ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER|ALIGN_SIZE_ORIGINAL,
|
||||
// ui->label.info.width, ui->label.info.height
|
||||
// );
|
||||
// labelRender(&ui->label, &assets->shader, x+align.x, y+align.y);
|
||||
|
||||
// // Render state
|
||||
// if(player->state & POKER_PLAYER_STATE_OUT) {
|
||||
// sprintf(message, "Out");
|
||||
// } else if(player->state & POKER_PLAYER_STATE_FOLDED) {
|
||||
// sprintf(message, "Folded");
|
||||
// } else if(player->state & POKER_PLAYER_STATE_SHOWING) {
|
||||
// sprintf(message, "Showing");
|
||||
// } else if(poker->bet.better == j) {
|
||||
// sprintf(message, "Thinking");
|
||||
// } else {
|
||||
// sprintf(message, "Whatever");
|
||||
// }
|
||||
// labelSetText(&ui->label, &assets->font, message);
|
||||
// align = gridGetAndAlignChild(
|
||||
// &ui->grid, 0, 1, 1, 1,
|
||||
// ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL,
|
||||
// ui->label.info.width, ui->label.info.height
|
||||
// );
|
||||
// labelRender(&ui->label, &assets->shader, x+align.x, y+align.y);
|
||||
|
||||
// // Increment.
|
||||
// j++;
|
||||
// }
|
||||
}
|
||||
|
||||
void pokerUiDispose(pokerui_t *ui) {
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT_MAX; i++) {
|
||||
frameBufferDispose(ui->frames + i);
|
||||
}
|
||||
labelDispose(&ui->label);
|
||||
primitiveDispose(&ui->quad);
|
||||
imageDispose(&ui->card);
|
||||
}
|
||||
|
||||
void pokerUiSetImageToCard(image_t *image, texture_t *texture, card_t card) {
|
||||
uint8_t cardImageIndex = (
|
||||
cardGetNumber(card) == CARD_ACE ? (
|
||||
card - CARD_COUNT_PER_SUIT + 1
|
||||
) : card+0x01
|
||||
);
|
||||
|
||||
imageSetTextureAndCrop(
|
||||
image, texture,
|
||||
cardGetNumber(cardImageIndex) * 71.0f,
|
||||
cardGetSuit(card) * 96.0f,
|
||||
71, 96
|
||||
);
|
||||
}
|
||||
|
||||
void pokerUiBetShow(pokerui_t *ui) {
|
||||
ui->betShow = true;
|
||||
ui->betTurnMade = false;
|
||||
}
|
109
src/games/pokerbackup/pokerui.h
Normal file
109
src/games/pokerbackup/pokerui.h
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../ui/label.h"
|
||||
#include "../../ui/image.h"
|
||||
#include "../../display/framebuffer.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/primitives/quad.h"
|
||||
#include "../../display/primitives/cube.h"
|
||||
#include "../../display/shader.h"
|
||||
#include "../../engine/engine.h"
|
||||
#include "../../input/input.h"
|
||||
#include "../../display/camera.h"
|
||||
#include "../../vn/vncharacter.h"
|
||||
#include "../../ui/grid.h"
|
||||
#include "../../ui/align.h"
|
||||
#include "../../vn/vnscene.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "pokerworld.h"
|
||||
#include "pokergameassets.h"
|
||||
|
||||
#define POKER_UI_PLAYER_IMAGE_SIZE 64
|
||||
#define POKER_UI_PLAYER_WIDTH 300
|
||||
#define POKER_UI_PLAYER_HEIGHT POKER_UI_PLAYER_IMAGE_SIZE
|
||||
|
||||
#define POKER_UI_PLAYER_IMAGE_RESOLUTION POKER_UI_PLAYER_IMAGE_SIZE * 2
|
||||
#define POKER_UI_PLAYER_IMAGE_DIST 0.7f
|
||||
#define POKER_UI_PLAYER_IMAGE_Y 0.1f
|
||||
#define POKER_UI_PLAYER_PADDING 8
|
||||
#define POKER_UI_PLAYER_CHIPS_ANIMATION_SPEED 0.5f
|
||||
|
||||
#define POKER_UI_BET_ACTION_NONE 0x00
|
||||
#define POKER_UI_BET_ACTION_FOLD 0x01
|
||||
#define POKER_UI_BET_ACTION_BET 0x02
|
||||
|
||||
typedef struct {
|
||||
primitive_t quad;
|
||||
label_t label;
|
||||
grid_t grid;
|
||||
image_t card;
|
||||
framebuffer_t frames[POKER_PLAYER_COUNT_MAX];
|
||||
|
||||
/** Betting UI */
|
||||
bool betShow;
|
||||
pokerturn_t betTurn;
|
||||
bool betTurnMade;
|
||||
} pokerui_t;
|
||||
|
||||
/**
|
||||
* Initializes the UI Module.
|
||||
*
|
||||
* @param ui UI to initialize.
|
||||
*/
|
||||
void pokerUiInit(pokerui_t *ui);
|
||||
|
||||
/**
|
||||
* Update the Poker Game UI.
|
||||
*
|
||||
* @param ui UI to update.
|
||||
* @param engine Engine to use for updating.
|
||||
* @param shader Shader to use for rendering.
|
||||
* @param characters Visual Novel characters to render.
|
||||
* @param players Array of poker players.
|
||||
*/
|
||||
void pokerUiUpdate(
|
||||
pokerui_t *ui, engine_t *engine, shader_t *shader,
|
||||
vncharacter_t *characters, pokerplayer_t *players
|
||||
);
|
||||
|
||||
/**
|
||||
* Render the Poker Game UI.
|
||||
*
|
||||
* @param ui UI to render.
|
||||
* @param engine Engine to use for the render.
|
||||
* @param assets Poker game assets.
|
||||
* @param poker Poker instance.
|
||||
*/
|
||||
void pokerUiRender(
|
||||
pokerui_t *ui, engine_t *engine, pokergameassets_t *assets, poker_t *poker
|
||||
);
|
||||
|
||||
/**
|
||||
* Cleanup only the UI elements for a poker game.
|
||||
*
|
||||
* @param ui UI to dispose.
|
||||
*/
|
||||
void pokerUiDispose(pokerui_t *ui);
|
||||
|
||||
/**
|
||||
* Updates the given image to represent a card UI image.
|
||||
*
|
||||
* @param image Image to update.
|
||||
* @param texture Texture to use.
|
||||
* @param card Card to set to.
|
||||
*/
|
||||
void pokerUiSetImageToCard(image_t *image, texture_t *texture, card_t card);
|
||||
|
||||
/**
|
||||
* Show and reset the betting UI.
|
||||
*
|
||||
* @param ui UI to reset the bet state for.
|
||||
*/
|
||||
void pokerUiBetShow(pokerui_t *ui);
|
65
src/games/pokerbackup/pokerworld.c
Normal file
65
src/games/pokerbackup/pokerworld.c
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokerworld.h"
|
||||
|
||||
void pokerWorldInit(
|
||||
pokerworld_t *world,
|
||||
vnscene_t *scene,
|
||||
pokergameassets_t *assets
|
||||
) {
|
||||
vncharacter_t *character;
|
||||
texture_t *texture;
|
||||
uint8_t i;
|
||||
|
||||
world->seat = POKER_WORLD_SEAT_DEALER;
|
||||
world->seatTime = 0;
|
||||
|
||||
// Initialize the skywal
|
||||
skywallInit(&world->skywall);
|
||||
|
||||
// Initialize the players
|
||||
for(i = 0x00; i < POKER_PLAYER_COUNT_MAX; i++) {
|
||||
character = scene->characters + scene->characterCount;
|
||||
texture = assets->characterTextures + i;
|
||||
pokerCharacterInit(character, texture, i);
|
||||
pokerWorldSitCharacter(character, POKER_WORLD_SEAT_FOR_PLAYER(i));
|
||||
scene->characterCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void pokerWorldSitCharacter(vncharacter_t *character, uint8_t seat) {
|
||||
character->x = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||
character->y = POKER_WORLD_SEAT_POSITION_Y;
|
||||
character->z = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||
character->yaw = POKER_WORLD_SEAT_ROTATION(seat);
|
||||
}
|
||||
|
||||
void pokerWorldLookAtPlayer(
|
||||
vnscene_t *scene, uint8_t playerIndex
|
||||
) {
|
||||
vncharacter_t *character = scene->characters + playerIndex;
|
||||
vnSceneLookAt(scene,
|
||||
scene->cameraLook.x,
|
||||
scene->cameraLook.y,
|
||||
scene->cameraLook.z,
|
||||
character->x,
|
||||
scene->cameraLook.lookY,
|
||||
character->z
|
||||
);
|
||||
}
|
||||
|
||||
void pokerWorldRender(pokerworld_t *world, pokergameassets_t *assets) {
|
||||
// Render the wall
|
||||
shaderUseTexture(&assets->shader, &assets->roomTexture);
|
||||
shaderUsePosition(&assets->shader, 0,2,0, 0,0,0);
|
||||
primitiveDraw(&world->skywall, 0, -1);
|
||||
}
|
||||
|
||||
void pokerWorldDispose(pokerworld_t *world) {
|
||||
primitiveDispose(&world->skywall);
|
||||
}
|
115
src/games/pokerbackup/pokerworld.h
Normal file
115
src/games/pokerbackup/pokerworld.h
Normal file
@ -0,0 +1,115 @@
|
||||
/**
|
||||
* 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/shader.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/animation/easing.h"
|
||||
#include "../../display/primitives/skywall.h"
|
||||
#include "../../vn/vnscene.h"
|
||||
#include "../../vn/vncharacter.h"
|
||||
#include "../../engine/engine.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "pokergameassets.h"
|
||||
|
||||
/** How far away from the camera are the characters distanced */
|
||||
#define POKER_WORLD_SEAT_DISTANCE -1.25f
|
||||
|
||||
/** How rotated is the player at a given seat */
|
||||
#define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f))
|
||||
|
||||
/** World X position of a given seat */
|
||||
#define POKER_WORLD_SEAT_POSITION_X(n) ( \
|
||||
POKER_WORLD_SEAT_DISTANCE * (float)sin(POKER_WORLD_SEAT_ROTATION(n)) \
|
||||
)
|
||||
/** Y Position of seats */
|
||||
#define POKER_WORLD_SEAT_POSITION_Y -0.2f
|
||||
/** World Z position of a given seat */
|
||||
#define POKER_WORLD_SEAT_POSITION_Z(n) ( \
|
||||
POKER_WORLD_SEAT_DISTANCE * (float)cos(POKER_WORLD_SEAT_ROTATION(n)) \
|
||||
)
|
||||
|
||||
/** Count of seats in the world */
|
||||
#define POKER_WORLD_SEAT_COUNT 8
|
||||
|
||||
/** The seat index for a given player index */
|
||||
#define POKER_WORLD_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT_MAX/2))
|
||||
|
||||
/** The seat that the dealer occupies */
|
||||
#define POKER_WORLD_SEAT_DEALER POKER_WORLD_SEAT_FOR_PLAYER(\
|
||||
POKER_WORLD_DEALER_INDEX\
|
||||
)
|
||||
|
||||
/** The seat index for a given character index */
|
||||
#define pokerWorldSeatFromIndex(i) (\
|
||||
i == POKER_WORLD_DEALER_INDEX ? \
|
||||
POKER_WORLD_SEAT_DEALER : \
|
||||
POKER_WORLD_SEAT_FOR_PLAYER(i) \
|
||||
)
|
||||
|
||||
// Penny Defs.
|
||||
#define POKER_WORLD_PENNY_BASE_WIDTH 1000
|
||||
#define POKER_WORLD_PENNY_BASE_HEIGHT 1920
|
||||
#define POKER_WORLD_PENNY_FACE_X 367
|
||||
#define POKER_WORLD_PENNY_FACE_Y 256
|
||||
#define POKER_WORLD_PENNY_FACE_WIDTH 280
|
||||
#define POKER_WORLD_PENNY_FACE_HEIGHT 280
|
||||
|
||||
typedef struct {
|
||||
primitive_t skywall;
|
||||
|
||||
/** Which seat the game should look at */
|
||||
uint8_t seat;
|
||||
float seatTime;
|
||||
} pokerworld_t;
|
||||
|
||||
/**
|
||||
* Initialize the poker renderer.
|
||||
*
|
||||
* @param world Pointer to the world to initialize.
|
||||
* @param scene Visual Novel Engine scene to initialize.
|
||||
* @param assets Assets to use for initialization.
|
||||
*/
|
||||
void pokerWorldInit(
|
||||
pokerworld_t *world,
|
||||
vnscene_t *scene,
|
||||
pokergameassets_t *assets
|
||||
);
|
||||
|
||||
/**
|
||||
* Adjusts a specific VN player to sit at the given index
|
||||
*
|
||||
* @param character Character to place in the seat.
|
||||
* @param seat Seat to put the character in.
|
||||
*/
|
||||
void pokerWorldSitCharacter(vncharacter_t *character, uint8_t seat);
|
||||
|
||||
/**
|
||||
* Adjusts the camera to look at a specific player. You can use this to look at
|
||||
* the dealer by referencing the POKER_PLAYER_HUMAN_INDEX as the index.
|
||||
*
|
||||
* @param scene Visual Novel Engine scene.
|
||||
* @param playerIndex Player index to look at.
|
||||
*/
|
||||
void pokerWorldLookAtPlayer(
|
||||
vnscene_t *scene, uint8_t playerIndex
|
||||
);
|
||||
|
||||
/**
|
||||
* Render the poker world.
|
||||
*
|
||||
* @param world Poker Game World.
|
||||
* @param assets Assets to use.
|
||||
*/
|
||||
void pokerWorldRender(pokerworld_t *world, pokergameassets_t *assets);
|
||||
|
||||
/**
|
||||
* Cleanup the poker world.
|
||||
* @param world World to clean up.
|
||||
*/
|
||||
void pokerWorldDispose(pokerworld_t *world);
|
Reference in New Issue
Block a user