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 #ifndef Table_h
25 #define Table_h
26 #include "Seat.h"
27
28 class Dealer;
29
30 class Table
31 {
32
33 public:
34
35 Table(int argc, char **argv);
36 ~Table();
37
38 Seat* GetDealerSeat() const;
39 Seat* GetPlayerSeat(int i = 1) const; // start from 1
40 Dealer* GetDealer() const;
41 void SetDealer(Dealer*);
42 int NumPlayers() const;
DealerDrawingArea()43 Widget DealerDrawingArea() { return DealerHand;}
PlayerDrawingArea()44 Widget PlayerDrawingArea() { return PlayerHand;}
GetDisplay()45 Display* GetDisplay() { return _display; }
46 static void SetLabel(Widget w, char* label);
47 static void AnteScrollCB(Widget, XtPointer , XmScaleCallbackStruct*);
48 static void DealerDrawingAreaCB(Widget, XtPointer ,
49 XmDrawingAreaCallbackStruct*);
50 static void PlayerDrawingAreaCB(Widget, XtPointer ,
51 XmDrawingAreaCallbackStruct*);
52 static void BetCB ( Widget w, XtPointer client_data, caddr_t call_data);
53 static void DealCB( Widget w, XtPointer client_data, caddr_t call_data);
54 static void FoldCB( Widget w, XtPointer client_data, caddr_t call_data);
55 static void ManageHelpRulesDialogCB( Widget w, XtPointer client_data,
56 caddr_t call_data);
57 static void DoExceptionDialog(const char * exceptionMsg);
58 void Start();
59 protected:
60 void Initialize();
61 void CreateWidgets(Display *display, char *app_name, int app_argc, char **app_argv);
62 void CurrentSeat(int);
63 int NumOfSeats();
64 void AddCallbacks();
65 static void Enable ( Widget);
66 static void Disable( Widget);
67 static void PayTime(Table*);
68
69 private:
70 const Table & operator=(const Table &right);
71 int operator==(const Table &right) const;
72 int operator!=(const Table &right) const;
73 Table(const Table &right);
74
75 private:
76 int _totalSeats;
77 Dealer* _dealer;
78 int _bankroll;
79 int _betUnit;
80 int _minBet;
81 int _jackpot;
82 int _minjackpot;
83 int _players;
84 int _dealerFace;
85 static Widget toplevel;
86 static Widget Layout ;
87 static Widget PlayTable ;
88 static Widget ControlTable ;
89 static Widget DealerHand ;
90 static Widget PlayerHand ;
91 static Widget DealButton ;
92 static Widget AnteScroll ;
93 static Widget BetButton ;
94 static Widget FoldButton ;
95 static Widget ProgressiveButton ;
96 static Widget JackPotLabel;
97 static Widget ExceptionDialog;
98 static Widget YouHaveLabel[6];
99 static Widget YouHaveLabelValue[6];
100 static Widget YouWinLoseValue[6];
101 static Widget DealerTableLabel;
102
103 // Widgets for Rules...
104 static Widget HelpRulesDialog;
105 static Widget HelpRulesButton;
106 static Widget HelpRulesScrolledText;
107
108 XtAppContext app_context;
109 Display *_display;
110 Seat* _playerSeats[7];
111 };
112
SetDealer(Dealer * dealer)113 inline void Table::SetDealer(Dealer* dealer)
114 {
115 _dealer = dealer;
116 }
117
GetDealer()118 inline Dealer* Table::GetDealer() const
119 {
120 return _dealer;
121 }
122
123
GetDealerSeat()124 inline Seat* Table::GetDealerSeat() const
125 {
126 return _playerSeats[0];
127 }
128
129
GetPlayerSeat(int i)130 inline Seat* Table::GetPlayerSeat(int i) const
131 {
132 if( i<_totalSeats)
133 return _playerSeats[i];
134 else{
135 char str[50];
136 sprintf(str, "Player %d out of range.", i );
137 throw( str );
138 }
139 }
140
NumPlayers()141 inline int Table::NumPlayers() const
142 {
143 return _totalSeats;
144 }
145
146 #endif
147