diff options
| author | thecharlesblake | 2018-01-18 13:43:19 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-01-18 13:43:19 +0000 |
| commit | 81a0a3cd68fb9d1a0e5eeab44fa1c9eec9f38018 (patch) | |
| tree | d7a97344e6dd6e96a0a8e8585439763c2ad267f6 /src/main/game/card.h | |
| parent | Implement symmetrical hash for pile vector (diff) | |
| download | metasol-81a0a3cd68fb9d1a0e5eeab44fa1c9eec9f38018.tar.gz metasol-81a0a3cd68fb9d1a0e5eeab44fa1c9eec9f38018.zip | |
Chance suit from enum to uint8_t for bit packing
Diffstat (limited to 'src/main/game/card.h')
| -rw-r--r-- | src/main/game/card.h | 21 |
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; }; |
