-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCard.h
executable file
·131 lines (108 loc) · 5.14 KB
/
Card.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef BLACK_JACK_CARD_H
#define BLACK_JACK_CARD_H
#include <algorithm>
#include <cstdio>
#include <unordered_map>
#include <string>
#include <vector>
#include <allegro5/drawing.h>
#include "util.h"
//-----------------------------------------------------------------------------
// Purpose: Card in blackjack that has a Suit and a Value that correspond with
// the matching bitmap image that it is set by default to load.
//-----------------------------------------------------------------------------
class Card {
public:
//-----------------------------------------------------------------------------
// Purpose: Corresponds to the numeric value of the card as well as the
// sequential order that the cards appear in the image used to render the cards
// themselves
//-----------------------------------------------------------------------------
typedef enum {
ACE = 0,
TWO = 1,
THREE = 2,
FOUR = 3,
FIVE = 4,
SIX = 5,
SEVEN = 6,
EIGHT = 7,
NINE = 8,
TEN = 9,
JACK = 10,
QUEEN = 11,
KING = 12,
V_ERROR
} Value;
//-----------------------------------------------------------------------------
// Purpose: Corresponding with the Value Enum, this enum has all the suits a
// card has and is used to render the cards by enumerating the suits in order
// of when they appear in the image they are rendered from.
//-----------------------------------------------------------------------------
typedef enum {
CLUBS = 0,
DIAMONDS = 1,
HEARTS = 2,
SPADES = 3,
BACK = 4,
S_ERROR
} Suit;
Card(Suit suit, Value val, int x = 0, int y = 0);
virtual ~Card();
//-----------------------------------------------------------------------------
// Purpose: Renders the object, called once per draw tick
//-----------------------------------------------------------------------------
void Render();
//-----------------------------------------------------------------------------
// Purpose: returns Value of the Card
//-----------------------------------------------------------------------------
Value GetValue();
//-----------------------------------------------------------------------------
// Purpose: returns Suit of the Card
//-----------------------------------------------------------------------------
Suit GetSuit();
//-----------------------------------------------------------------------------
// Purpose: returns Suit Value as an integer
//-----------------------------------------------------------------------------
static Suit IntToSuit(unsigned int suit);
//-----------------------------------------------------------------------------
// Purpose: returns Value as an integer
//-----------------------------------------------------------------------------
static Value IntToValue(unsigned int value);
//-----------------------------------------------------------------------------
// Purpose: A simple typedef for a vector of card pointers
//-----------------------------------------------------------------------------
typedef std::vector<Card*> Cards;
//-----------------------------------------------------------------------------
// Purpose: A boolean value of if the card was used or not in the current deck
//-----------------------------------------------------------------------------
bool Played;
//-----------------------------------------------------------------------------
// Purpose: The location that the card will be rendered
//-----------------------------------------------------------------------------
float Coords[2];
//-----------------------------------------------------------------------------
// Purpose: The Height of the card's bitmap
//-----------------------------------------------------------------------------
static float CardHeight;
//-----------------------------------------------------------------------------
// Purpose: The Width of the card's bitmap
//-----------------------------------------------------------------------------
static float CardWidth;
protected:
//-----------------------------------------------------------------------------
// Purpose: Store the value of the card which also corresponds with the
// location of the according card in the reference image.
//-----------------------------------------------------------------------------
Value _Value;
//-----------------------------------------------------------------------------
// Purpose: Store the suit of the card which also corresponds with the
// location of the according card in the reference image.
//-----------------------------------------------------------------------------
Suit _Suit;
//-----------------------------------------------------------------------------
// Purpose: The bitmap of the entire deck
//-----------------------------------------------------------------------------
static ALLEGRO_BITMAP* _Deck;
};
#endif // BLACK_JACK_CARD_H