aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/card.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/game/card.h')
-rw-r--r--src/main/game/card.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main/game/card.h b/src/main/game/card.h
index 0c09043..aec6a88 100644
--- a/src/main/game/card.h
+++ b/src/main/game/card.h
@@ -11,12 +11,21 @@
class card {
public:
// Types & typedefs
- enum class suit_t {Clubs, Diamonds, Hearts, Spades};
- enum class colour_t {Black, Red};
typedef uint8_t rank_t;
+ typedef uint8_t suit_t;
+ typedef uint8_t colour_t;
- // Converts a number (0-3) to a suit (Clubs-Spades)
- static suit_t to_suit(uint8_t);
+ struct suit {
+ static const suit_t Clubs = 0;
+ static const suit_t Hearts = 1;
+ static const suit_t Spades = 2;
+ static const suit_t Diamonds = 3;
+ };
+
+ struct colour {
+ static const colour_t Black = 0;
+ static const colour_t Red = 1;
+ };
// A card can either be created using two int values (rank & suit), or
// using a string (e.g. "AS")
@@ -27,11 +36,13 @@ public:
colour_t get_colour() const;
rank_t get_rank() const;
+ std::string to_string() const;
+
private:
static suit_t suit_from_str(const char* c);
static rank_t rank_from_str(const char* c);
- suit_t suit;
+ suit_t suit : 4;
rank_t rank : 4;
};