working on some render tools
This commit is contained in:
50
src/card/poker/action/action.c
Normal file
50
src/card/poker/action/action.c
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "action.h"
|
||||
|
||||
void holdemActionInit() {
|
||||
// Free up all actions
|
||||
memset(HOLDEM_GAME_STATE.actionQueue, (int32_t)NULL,
|
||||
sizeof(holdemaction_t) * HOLDEM_GAME_ACTION_QUEUE_SIZE
|
||||
);
|
||||
|
||||
// Free up all data
|
||||
memset(HOLDEM_GAME_STATE.actionData, (int32_t)NULL, sizeof(void *) *
|
||||
HOLDEM_GAME_ACTION_DATA_SIZE * HOLDEM_GAME_ACTION_QUEUE_SIZE
|
||||
);
|
||||
}
|
||||
|
||||
void holdemActionAdd(holdemaction_t action) {
|
||||
int32_t i = -1;
|
||||
int32_t j = -1;
|
||||
|
||||
for(i = 0; i < HOLDEM_GAME_ACTION_QUEUE_SIZE; i++) {
|
||||
if(HOLDEM_GAME_STATE.actionQueue[i].init != NULL) continue;
|
||||
j = i;
|
||||
break;
|
||||
}
|
||||
|
||||
HOLDEM_GAME_STATE.actionQueue[j] = action;
|
||||
action.init(j, HOLDEM_GAME_STATE.actionData + j);
|
||||
}
|
||||
|
||||
void holdemActionUpdate() {
|
||||
int32_t i;
|
||||
for(i = 0; i < HOLDEM_GAME_ACTION_QUEUE_SIZE; i++) {
|
||||
if(HOLDEM_GAME_STATE.actionQueue[i].update == NULL) continue;
|
||||
HOLDEM_GAME_STATE.actionQueue[i].update(i, HOLDEM_GAME_STATE.actionData+i);
|
||||
}
|
||||
}
|
||||
|
||||
void holdemActionDispose() {
|
||||
int32_t i;
|
||||
for(i = 0; i < HOLDEM_GAME_ACTION_QUEUE_SIZE; i++) {
|
||||
if(HOLDEM_GAME_STATE.actionQueue[i].dispose == NULL) continue;
|
||||
HOLDEM_GAME_STATE.actionQueue[i].dispose(i, HOLDEM_GAME_STATE.actionData+i);
|
||||
}
|
||||
}
|
32
src/card/poker/action/action.h
Normal file
32
src/card/poker/action/action.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
|
||||
/**
|
||||
* Initializes the action manager.
|
||||
*/
|
||||
void holdemActionInit();
|
||||
|
||||
/**
|
||||
* Adds an action to the action queue.
|
||||
*
|
||||
* @param action Action to add to the queue.
|
||||
*/
|
||||
void holdemActionAdd(holdemaction_t action);
|
||||
|
||||
/**
|
||||
* Updates the action manager, which (in turn) updates all actions that are
|
||||
* currently running.
|
||||
*/
|
||||
void holdemActionUpdate();
|
||||
|
||||
/**
|
||||
* Cleans up the action manager and all actions.
|
||||
*/
|
||||
void holdemActionDispose();
|
35
src/card/poker/action/start.c
Normal file
35
src/card/poker/action/start.c
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "start.h"
|
||||
|
||||
holdemaction_t actionStart() {
|
||||
holdemaction_t action = {
|
||||
.init = &actionStartInit,
|
||||
.update = &actionStartUpdate,
|
||||
.dispose = &actionStartDispose
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
void actionStartInit(int32_t index, void *data) {
|
||||
// holdemactionstart_t *convData = data;
|
||||
|
||||
// Prepare the match
|
||||
holdemMatchInit(&HOLDEM_GAME_STATE.match);
|
||||
holdemRoundInit(&HOLDEM_GAME_STATE.match);
|
||||
cardShuffle(HOLDEM_GAME_STATE.match.deck, HOLDEM_GAME_STATE.match.deckSize);
|
||||
holdemFlop(&HOLDEM_GAME_STATE.match);
|
||||
}
|
||||
|
||||
void actionStartUpdate(int32_t index, void *data) {
|
||||
}
|
||||
|
||||
void actionStartDispose(int32_t index, void *data) {
|
||||
|
||||
}
|
15
src/card/poker/action/start.h
Normal file
15
src/card/poker/action/start.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
|
||||
holdemaction_t actionStart();
|
||||
|
||||
void actionStartInit(int32_t index, void *data);
|
||||
void actionStartUpdate(int32_t index, void *data);
|
||||
void actionStartDispose(int32_t index, void *data);
|
Reference in New Issue
Block a user