1 /*
2 * (c) Copyright 1997, Qun Zhang.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appear in all copies and
7 * that both that copyright notice and this permission notice appear in
8 * supporting documentation, and that the name of Qun Zhang not be used
9 * in advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. Qun Zhang make no
11 * representations about the suitability of this software for any purpose.
12 * It is provided "as is" without express or implied warranty.
13 *
14 * THE ABOVE-NAMED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE ABOVE-NAMED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 *
22 */
23
24 #include <iostream>
25 #include "Player.h"
26
27 //## begin module.additionalDeclarations preserve=yes
28 //## end module.additionalDeclarations
29
30
31 // Class Player
32
33
34
Player(Dealer * dealer,Seat * seat)35 Player::Player(Dealer* dealer, Seat* seat) : _dealer(dealer),
36 _seat(seat),
37 _bankroll(0),
38 _ante(0),
39 _bet(0),
40 _progressive(0),
41 _lastWinLost(0)
42 {
43 }
44
45
46 //## Other Operations (implementation)
47
NewGame()48 void Player::NewGame()
49 {
50 Hands::NewGame();
51 _bet = _ante = _progressive = 0;
52 #ifdef DEBUG
53 cout << "Money Left: " << BankRoll() << endl;
54 #endif
55
56 }
57
Progressive(int p)58 void Player::Progressive(int p)
59 {
60 _progressive = p;
61 if(p) _bankroll -=1;
62 }
63
Progressive() const64 int Player::Progressive() const
65 {
66 return _progressive;
67 }
68
Ante(int ante)69 void Player::Ante(int ante)
70 {
71 if(ante <=0 )
72 throw ("Ante amount can not be less than $0.");
73 if(ante > _bankroll/3)
74 {
75 #ifdef DEBUG
76 cout << "Ante: " << ante << endl;
77 cout << "Bankroll: " << _bankroll << endl;
78 #endif
79 throw ("Don't have enough money left for ADDITIONAL BET.");
80 }
81 _ante = ante;
82 _bankroll -= _ante;
83 }
84
Ante() const85 int Player::Ante() const
86 {
87 return _ante;
88 }
89
Check()90 void Player::Check()
91 {
92 //## begin Player::Check%849130052.body preserve=yes
93 //## end Player::Check%849130052.body
94 }
95
Bet() const96 int Player::Bet() const
97 {
98 return _bet;
99 }
100
Bet(int amount)101 void Player::Bet(int amount)
102 {
103 _bet = 2*_ante;
104 _bankroll -= _bet;
105 }
106
Fold()107 void Player::Fold()
108 {
109 Hands::NewGame();
110 }
111
Call(int)112 void Player::Call(int)
113 {
114 //## begin Player::Call%849130055.body preserve=yes
115 //## end Player::Call%849130055.body
116 }
117
Raise(int)118 void Player::Raise(int)
119 {
120 //## begin Player::Raise%849130056.body preserve=yes
121 //## end Player::Raise%849130056.body
122 }
123
Pay(int amount)124 void Player::Pay(int amount)
125 {
126 _bankroll += amount;
127 _bankroll += _bet;
128 _bankroll += _ante;
129 _lastWinLost = amount;
130 if(_progressive){
131 switch(HandValue()){
132 case FL:
133 _bankroll += 50;
134 _lastWinLost += 50;
135 break;
136 case FH:
137 _bankroll += 75;
138 _lastWinLost += 75;
139 break;
140 case K4:
141 _bankroll += 100;
142 _lastWinLost += 100;
143 break;
144 case SF:
145 _bankroll += _dealer->JackPot()/10;
146 _lastWinLost += _dealer->JackPot()/10;
147 break;
148 case RF:
149 _bankroll += _dealer->JackPot();
150 _lastWinLost += _dealer->JackPot();
151 break;
152 default:
153 break;
154 }
155 }
156 NewGame();
157 }
158
BankRoll(int amount)159 void Player::BankRoll(int amount)
160 {
161 _bankroll = amount;
162 }
163
BankRoll() const164 int Player::BankRoll() const
165 {
166 return _bankroll;
167 }
168
SortCards() const169 void Player::SortCards () const //defauld sord plus redraw;
170 {
171 Hands::SortCards();
172 // redraw
173 }
174
175
176