blob: aec6a88ca588680bc5d867215d4d11537c2b914c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
//
// Created by thecharlesblake on 10/11/17.
//
#ifndef SOLITAIRE_PIP_CARD_H
#define SOLITAIRE_PIP_CARD_H
#include <string>
#include <map>
class card {
public:
// Types & typedefs
typedef uint8_t rank_t;
typedef uint8_t suit_t;
typedef uint8_t colour_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")
card(suit_t, rank_t);
explicit card(const char*);
suit_t get_suit() const;
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 : 4;
rank_t rank : 4;
};
bool operator==(const card&, const card&);
bool operator!=(const card&, const card&);
#endif //SOLITAIRE_PIP_CARD_H
|