aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorthecharlesblake2018-01-03 13:03:26 +0000
committerthecharlesblake2018-01-03 13:03:26 +0000
commitc70a063f407534ac3d8997b9f1bc58d23c9360b8 (patch)
tree9c1f4dc83752de2f76768b351d4453b99cab6045 /src/main
parentRefactor sol_rules into seperate parser class (diff)
downloadmetasol-c70a063f407534ac3d8997b9f1bc58d23c9360b8.tar.gz
metasol-c70a063f407534ac3d8997b9f1bc58d23c9360b8.zip

Tidy up card class

Diffstat (limited to 'src/main')
-rw-r--r--src/main/game/card.h4
-rw-r--r--src/main/game/game_state.cpp2
-rw-r--r--src/main/input-output/deal_parser.cpp2
3 files changed, 5 insertions, 3 deletions
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;
diff --git a/src/main/game/game_state.cpp b/src/main/game/game_state.cpp
index 14867f8..b45cc11 100644
--- a/src/main/game/game_state.cpp
+++ b/src/main/game/game_state.cpp
@@ -87,7 +87,7 @@ game_state::game_state(const sol_rules& s_rules, int seed) :
// If there is a hole, moves the ace of spades to it
if (rules.hole) {
deck.erase(find(begin(deck), end(deck), card("AS")));
- piles[hole].place("AS");
+ piles[hole].place(card("AS"));
}
// If there is a stock, deals to it and set up a waste pile too
diff --git a/src/main/input-output/deal_parser.cpp b/src/main/input-output/deal_parser.cpp
index 8637649..1746603 100644
--- a/src/main/input-output/deal_parser.cpp
+++ b/src/main/input-output/deal_parser.cpp
@@ -76,7 +76,7 @@ void deal_parser::parse_cells(game_state &gs, const Document& doc) {
auto json_card = p.first;
assert(json_card->IsString());
- gs.piles[*p.second].place(json_card->GetString());
+ gs.piles[*p.second].place(card(json_card->GetString()));
}
}
}