From 01083ef011143eef36f8f83ecbdae8da6e948021 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Fri, 12 Jan 2018 17:55:56 +0000 Subject: Implement symmetrical hash for cards --- src/main/game/card.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/game/card.h') diff --git a/src/main/game/card.h b/src/main/game/card.h index 4cab774..0c09043 100644 --- a/src/main/game/card.h +++ b/src/main/game/card.h @@ -37,7 +37,6 @@ private: bool operator==(const card&, const card&); bool operator!=(const card&, const card&); -std::size_t hash_value(card const&); #endif //SOLITAIRE_PIP_CARD_H -- cgit v1.2.1 From 81a0a3cd68fb9d1a0e5eeab44fa1c9eec9f38018 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 18 Jan 2018 13:43:19 +0000 Subject: Chance suit from enum to uint8_t for bit packing --- src/main/game/card.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/main/game/card.h') 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; }; -- cgit v1.2.1