diff options
| author | Charlie Blake | 2018-01-18 23:57:52 +0000 |
|---|---|---|
| committer | GitHub | 2018-01-18 23:57:52 +0000 |
| commit | bcaff64bdeaab93ff0d40dfd039b4b43ff689b1c (patch) | |
| tree | 7882812349716607773458b1c830579de802793f /src/main/game/card.h | |
| parent | Merge pull request #29 from thecharlesblake/refactor-improve-debug (diff) | |
| parent | Removes unnecessary assert statement bug (diff) | |
| download | metasol-bcaff64bdeaab93ff0d40dfd039b4b43ff689b1c.tar.gz metasol-bcaff64bdeaab93ff0d40dfd039b4b43ff689b1c.zip | |
Merge pull request #30 from thecharlesblake/symmetrical-hash
Symmetrical hash
Diffstat (limited to 'src/main/game/card.h')
| -rw-r--r-- | src/main/game/card.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/main/game/card.h b/src/main/game/card.h index 4cab774..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,17 +36,18 @@ 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; }; bool operator==(const card&, const card&); bool operator!=(const card&, const card&); -std::size_t hash_value(card const&); #endif //SOLITAIRE_PIP_CARD_H |
