From 77a7aeba7854d15b140cc6dc3c69b15ed5f3b936 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 3 Jan 2018 12:30:14 +0000 Subject: Major refactor, putting pile logic into game_state Much of the logic that was in the pile class was beginning to seem out of place. A lot of the rules have fairly arbitrary interactons *between* piles, which weren't best represented in the pile classes themselves, which were getting unweildy and inefficient. Hence, much of this logic has been moved to the game state class. --- src/main/game/card.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/game/card.h') diff --git a/src/main/game/card.h b/src/main/game/card.h index cc5a993..9c43350 100644 --- a/src/main/game/card.h +++ b/src/main/game/card.h @@ -14,6 +14,8 @@ public: enum class colour_t {Black, Red}; typedef uint8_t rank_t; + static suit_t to_suit(uint8_t); + // A card can either be created using two int values (rank & suit), or // using a string (e.g. "AS") card(suit_t, rank_t); -- cgit v1.2.1 From c70a063f407534ac3d8997b9f1bc58d23c9360b8 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 3 Jan 2018 13:03:26 +0000 Subject: Tidy up card class --- src/main/game/card.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main/game/card.h') diff --git a/src/main/game/card.h b/src/main/game/card.h index 9c43350..3a1c6b0 100644 --- a/src/main/game/card.h +++ b/src/main/game/card.h @@ -10,16 +10,18 @@ class card { public: + // Types & typedefs enum class suit_t {Clubs, Diamonds, Hearts, Spades}; enum class colour_t {Black, Red}; typedef uint8_t rank_t; + // Converts a number (0-3) to a suit (Clubs-Spades) static suit_t to_suit(uint8_t); // A card can either be created using two int values (rank & suit), or // using a string (e.g. "AS") card(suit_t, rank_t); - card(const char*); + explicit card(const char*); suit_t get_suit() const; colour_t get_colour() const; -- cgit v1.2.1 From 66545273423eae0d8f945f7c3ac5871b6955ff94 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 3 Jan 2018 15:27:47 +0000 Subject: Move card printing into dedicated class --- 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 3a1c6b0..8aaa50d 100644 --- a/src/main/game/card.h +++ b/src/main/game/card.h @@ -35,7 +35,6 @@ private: rank_t rank : 4; }; -std::ostream & operator<<(std::ostream &, card const &); bool operator==(const card&, const card&); std::size_t hash_value(card const&); -- cgit v1.2.1 From 067152f57ced18c5f706144909345125754e8664 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Mon, 8 Jan 2018 19:02:36 +0000 Subject: Add game logic for built pile (AA) and refactor --- src/main/game/card.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/game/card.h') diff --git a/src/main/game/card.h b/src/main/game/card.h index 8aaa50d..4cab774 100644 --- a/src/main/game/card.h +++ b/src/main/game/card.h @@ -36,6 +36,7 @@ private: }; bool operator==(const card&, const card&); +bool operator!=(const card&, const card&); std::size_t hash_value(card const&); -- cgit v1.2.1