1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package com.openholdem.structs;
24
25 import java.util.SortedSet;
26 import java.util.TreeSet;
27
28 /***
29 * @author mattmann
30 * @version $Revision: 1.2 $
31 *
32 * <p>A set of rules that define a poker game instance.</p>
33 *
34 */
35 public class RuleSet {
36
37
38 private String fGameName = null;
39
40
41 private int fNumPlayerCards = -1;
42
43 private int fMinHandCardsUsed = -1;
44
45 private int fMaxHandCardsUsed = -1;
46
47 private int fNumCommunityCards = -1;
48
49 private SortedSet fHandRanks = null;
50
51
52 /***
53 * <p>Construct a new Rule Set with default parameters</p>
54 */
55 public RuleSet() {
56 fHandRanks = new TreeSet();
57 }
58
59 public RuleSet(int npCards, int minCards, int maxCards, int nComm, SortedSet ranks){
60 fNumPlayerCards = npCards;
61 fMinHandCardsUsed = minCards;
62 fMaxHandCardsUsed = maxCards;
63 fNumCommunityCards = nComm;
64 fHandRanks = ranks;
65 }
66
67
68
69 public class HandRank implements Comparable{
70 private int fRank = -1;
71 private String fHandName = null;
72
73 public HandRank(){
74
75 }
76
77 public int hashCode(){
78 return fRank;
79 }
80
81 public boolean equals(Object o){
82 return (this.compareTo(o) == 0);
83 }
84
85 public HandRank(int rank,String name){
86 fRank = rank;
87 fHandName = name;
88 }
89
90 public String toString(){
91 StringBuffer rStr = new StringBuffer();
92 rStr.append("["+fHandName+","+fRank+"]");
93
94 return rStr.toString();
95 }
96
97 public int compareTo(Object o){
98 int compareVal = -1;
99
100 HandRank otherRank = (HandRank)o;
101
102
103 if(otherRank.getFRank() > this.fRank){
104 compareVal = -1;
105 }
106 else if(otherRank.getFRank() < this.fRank){
107 compareVal = 1;
108 }
109 else if(otherRank.getFRank() == this.fRank){
110 compareVal = 0;
111 }
112
113 return compareVal;
114 }
115
116 /***
117 * @return Returns the fHandName.
118 */
119 public String getFHandName() {
120 return fHandName;
121 }
122
123 /***
124 * @param handName The fHandName to set.
125 */
126 public void setFHandName(String handName) {
127 fHandName = handName;
128 }
129
130 /***
131 * @return Returns the fRank.
132 */
133 public int getFRank() {
134 return fRank;
135 }
136
137 /***
138 * @param rank The fRank to set.
139 */
140 public void setFRank(int rank) {
141 fRank = rank;
142 }
143
144
145 }
146
147 /***
148 * @return Returns the fGameName.
149 */
150 public String getFGameName() {
151 return fGameName;
152 }
153
154 /***
155 * @param gameName The fGameName to set.
156 */
157 public void setFGameName(String gameName) {
158 fGameName = gameName;
159 }
160
161 /***
162 * @return Returns the fMaxHandCardsUsed.
163 */
164 public int getFMaxHandCardsUsed() {
165 return fMaxHandCardsUsed;
166 }
167
168 /***
169 * @param maxHandCardsUsed The fMaxHandCardsUsed to set.
170 */
171 public void setFMaxHandCardsUsed(int maxHandCardsUsed) {
172 fMaxHandCardsUsed = maxHandCardsUsed;
173 }
174
175 /***
176 * @return Returns the fMinHandCardsUsed.
177 */
178 public int getFMinHandCardsUsed() {
179 return fMinHandCardsUsed;
180 }
181
182 /***
183 * @param minHandCardsUsed The fMinHandCardsUsed to set.
184 */
185 public void setFMinHandCardsUsed(int minHandCardsUsed) {
186 fMinHandCardsUsed = minHandCardsUsed;
187 }
188
189 /***
190 * @return Returns the fNumCommunityCards.
191 */
192 public int getFNumCommunityCards() {
193 return fNumCommunityCards;
194 }
195
196 /***
197 * @param numCommunityCards The fNumCommunityCards to set.
198 */
199 public void setFNumCommunityCards(int numCommunityCards) {
200 fNumCommunityCards = numCommunityCards;
201 }
202
203 /***
204 * @return Returns the fNumPlayerCards.
205 */
206 public int getFNumPlayerCards() {
207 return fNumPlayerCards;
208 }
209
210 /***
211 * @param numPlayerCards The fNumPlayerCards to set.
212 */
213 public void setFNumPlayerCards(int numPlayerCards) {
214 fNumPlayerCards = numPlayerCards;
215 }
216
217 /***
218 * @return Returns the fHandRanks.
219 */
220 public SortedSet getFHandRanks() {
221 return fHandRanks;
222 }
223
224 /***
225 * @param handRanks The fHandRanks to set.
226 */
227 public void setFHandRanks(SortedSet handRanks) {
228 fHandRanks = handRanks;
229 }
230
231 }