[CRT] spawn: define a unicode environment when needed
[reactos.git] / sdk / lib / 3rdparty / cardlib / card.h
1 //
2 // CardLib - Card class
3 //
4 // Freeware
5 // Copyright J Brown 2001
6 //
7
8 #ifndef _CARD_INCLUDED
9 #define _CARD_INCLUDED
10
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 };
14
15 inline int MAKE_CARD(int Value, int Suit)
16 {
17 if(Value < 1) Value = 1;
18 if(Value == 14) Value = 1;
19 if(Value > 13) Value = 13;
20
21 if(Suit < 0) Suit = 0;
22 if(Suit > 3) Suit = 3;
23
24 return ((Value - 1) * 4 + Suit);
25 }
26
27 class Card
28 {
29 friend class CardStack;
30
31 public:
32
33 Card()
34 {
35 nValue = 0; //ace of spades by default
36 fFaceUp = true;
37 }
38
39 Card(int value, int suit) //specify a face value [1-13] and suit [0-3]
40 {
41 nValue = MAKE_CARD(value, suit);
42 fFaceUp = true;
43 }
44
45 Card(int index) //specify a 0-51 index
46 {
47 if(index < 0) index = 0;
48 if(index > 51) index = 51;
49
50 nValue = index;
51 fFaceUp = true;
52 }
53
54 int Suit() const
55 {
56 return (nValue % 4);
57 }
58
59 int LoVal() const
60 {
61 return (nValue / 4) + 1;
62 }
63
64 int HiVal() const
65 {
66 return ((nValue < 4) ? 14 : (nValue / 4) + 1);
67 }
68
69 int Idx() const //unique value (0-51 etc)
70 {
71 return nValue;
72 }
73
74 bool FaceUp() const
75 {
76 return fFaceUp;
77 }
78
79 bool FaceDown() const
80 {
81 return !fFaceUp;
82 }
83
84 void SetFaceUp(bool fTrue)
85 {
86 fFaceUp = fTrue;
87 }
88
89 bool IsBlack() const
90 {
91 return Suit() == 0 || Suit() == 3;
92 }
93
94 bool IsRed() const
95 {
96 return !IsBlack();
97 }
98
99 private:
100
101 int nValue;
102 bool fFaceUp;
103 };
104
105 #endif /* _CARD_INCLUDED */