aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/card.h
blob: 8d88df852477418bd7cc608fd317ecdd77b21b42 (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
54
55
56
57
58
59
60
//
// 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;
        static const suit_t Hearts;
        static const suit_t Spades;
        static const suit_t Diamonds;
    };

    struct colour {
        static const colour_t Black;
        static const colour_t Red;
    };

    const static card divider;

    // 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*);
    card();

    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 card_suit : 4;
    rank_t card_rank : 4;
};

bool operator==(const card&, const card&);
bool operator!=(const card&, const card&);
bool operator<(const card&, const card&);
bool operator>(const card&, const card&);
bool operator<=(const card&, const card&);
bool operator>=(const card&, const card&);


#endif //SOLITAIRE_PIP_CARD_H