Adding assert tools back
This commit is contained in:
59
src/dawn/poker/Card.hpp
Normal file
59
src/dawn/poker/Card.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "dawnlibs.hpp"
|
||||
|
||||
enum CardSuit {
|
||||
CLUBS = 0,
|
||||
DIAMONDS = 1,
|
||||
HEARTS = 2,
|
||||
SPADES = 3
|
||||
};
|
||||
|
||||
enum CardValue {
|
||||
TWO = 0,
|
||||
THREE = 1,
|
||||
FOUR = 2,
|
||||
FIVE = 3,
|
||||
SIX = 4,
|
||||
SEVEN = 5,
|
||||
EIGHT = 6,
|
||||
NINE = 7,
|
||||
TEN = 8,
|
||||
JACK = 9,
|
||||
QUEEN = 10,
|
||||
KING = 11,
|
||||
ACE = 12
|
||||
};
|
||||
|
||||
/** Count of cards in each suit */
|
||||
#define CARD_COUNT_PER_SUIT 13
|
||||
|
||||
/** Count of suits */
|
||||
#define CARD_SUIT_COUNT 4
|
||||
|
||||
/** Standard Card Deck Size */
|
||||
#define CARD_DECK_SIZE CARD_COUNT_PER_SUIT*CARD_SUIT_COUNT
|
||||
|
||||
struct Card {
|
||||
uint8_t cardValue;
|
||||
|
||||
Card(CardSuit suit, CardValue num) :
|
||||
cardValue((suit * CARD_COUNT_PER_SUIT) + num)
|
||||
{
|
||||
}
|
||||
|
||||
Card(uint8_t cv) : cardValue(cv) {
|
||||
}
|
||||
|
||||
CardValue getValue() {
|
||||
return (CardValue)(cardValue % CARD_COUNT_PER_SUIT);
|
||||
}
|
||||
|
||||
CardSuit getSuit() {
|
||||
return (CardSuit)(cardValue / CARD_COUNT_PER_SUIT);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user