forked from excitom/vp-spades
-
Notifications
You must be signed in to change notification settings - Fork 0
/
card.h
60 lines (54 loc) · 1.46 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
#ifndef __CARDS
#define __CARDS
#define CARDS_IN_DECK 52
#define CARDS_IN_HAND (52/4)
#define NUM_PLAYERS 4
#define CLUBS 0
#define DIAMONDS 1
#define HEARTS 2
#define SPADES 3
//
// The Card class is used for a linked list of cards.
// The CardSlot class is used for an array of cards corresponding to the player's current hand,
// where the array index corresponds to the physical position of the card on the game table.
//
class Card {
private:
Card* next;
Card* tmpNext;
char suit;
char faceValue;
public:
Card(char suit, char faceValue);
~Card() {}
Card* init( Card* anchor);
Card* stack( Card* anchor);
Card* nextCard();
Card* getNext();
void setNext(Card* c);
char getSuit() { return this->suit; }
char getValue() { return this->faceValue; }
char getIndex() { return (this->suit * CARDS_IN_HAND) + this->faceValue; }
};
class CardSlot {
private:
Card* card;
char state;
// card states
#define CARD_UNPLAYED 0
#define CARD_ON_TABLE 1
#define CARD_PLAYED 2
#define CARD_NOT_PRESENT 3
public:
CardSlot() {}
~CardSlot() {}
void init(Card* card) { init(card, CARD_UNPLAYED); }
void init(Card* card, char state);
char getSuit() { return this->card->getSuit(); }
char getValue() { return this->card->getValue(); }
Card* getCard() { return this->card; }
char getState() { return this->state; }
int getIndex() { return (this->card->getIndex()); }
void setState(char s) { this->state = s; }
};
#endif