2 // CardLib - Card class
5 // Copyright J Brown 2001
11 enum eSuit
{ Clubs
= 0, Diamonds
= 1, Hearts
= 2, Spades
= 3 };
12 enum eValue
{ Ace
= 1, Two
= 2, Three
= 3, Four
= 4, Five
= 5, Six
= 6, Seven
= 7,
13 Eight
= 8, Nine
= 9, Ten
= 10, Jack
= 11, Queen
= 12, King
= 13 };
15 inline int MAKE_CARD(int Value
, int Suit
)
17 if(Value
< 1) Value
= 1;
18 if(Value
== 14) Value
= 1;
19 if(Value
> 13) Value
= 13;
21 if(Suit
< 0) Suit
= 0;
22 if(Suit
> 3) Suit
= 3;
24 return ((Value
- 1) * 4 + Suit
);
29 friend class CardStack
;
35 nValue
= 0; //ace of spades by default
39 Card(int value
, int suit
) //specify a face value [1-13] and suit [0-3]
41 nValue
= MAKE_CARD(value
, suit
);
45 Card(int index
) //specify a 0-51 index
47 if(index
< 0) index
= 0;
48 if(index
> 51) index
= 51;
61 return (nValue
/ 4) + 1;
66 return ((nValue
< 4) ? 14 : (nValue
/ 4) + 1);
69 int Idx() const //unique value (0-51 etc)
84 void SetFaceUp(bool fTrue
)
91 return Suit() == 0 || Suit() == 3;