Restored some of the rendering

This commit is contained in:
2021-05-22 14:18:23 -07:00
parent 58e86d160e
commit d84e760c34
36 changed files with 813 additions and 331 deletions

15
temp/poker/card.c Normal file
View File

@ -0,0 +1,15 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "card.h"
void cardDeal(card_t *deck, card_t *hand, uint8_t deckSize, uint8_t handSize) {
card_t card;
card = deck[deckSize-1];
deck[deckSize-1] = 0x00;
hand[handSize] = card;
}

34
temp/poker/card.h Normal file
View 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 <dawn/dawn.h>
/**
* Fills a deck with a standard set of cards (unshuffled)
*
* @param deck Deck to fill. Must be at least 52 elements.
*/
void cardDeckFill(card_t *deck);
/**
* Shuffles the given hand or deck.
*
* @param hand The hand/deck to shuffle.
* @param cardCount The amount of cards that are in that deck/hand.
*/
void cardShuffle(card_t *hand, uint8_t cardCount);
/**
* Deals a card of the top of the deck into the given hand.
*
* @param deck Deck to take from.
* @param hand Hand to put into.
* @param deckSize Size of the current deck.
* @param handSize Size of the current hand.
*/
void cardDeal(card_t *deck, card_t *hand, uint8_t deckSize, uint8_t handSize);

42
temp/poker/poker.c Normal file
View File

@ -0,0 +1,42 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "poker.h"
void pokerInit(poker_t *poker) {
uint8_t x;
// Prepare the initial game state
poker->round = POKER_ROUND_DEAL;
poker->roundPlayer = 0x00;
poker->roundDealer = 0x00;
poker->blindSmall = 0;
poker->blindBig = 0;
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
poker->players[x].state = 0x00;
poker->players[x].chips = 0;
poker->players[x].cardCount = 0;
poker->players[x].currentBet = 0;
}
pokerRoundInit(poker);
}
void pokerRoundInit(poker_t *poker) {
uint8_t x;
// Refill the deck
cardDeckFill(poker->deck);
poker->deckSize = CARD_DECK_SIZE;
// Reset the players
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
poker->players[x].cardCount = 0;
poker->players[x].currentBet = 0;
}
}

25
temp/poker/poker.h Normal file
View 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 <dawn/dawn.h>
#include "card.h"
/**
* Initializes the poker match for the first time.
*
* @param poker Poker game to init.
*/
void pokerInit(poker_t *poker);
/**
* Initializes the round for a poker game.
*
* @param poker Poker game to init a new round for.
*/
void pokerRoundInit(poker_t *poker);