-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokerHands.groovy
More file actions
207 lines (186 loc) · 5.04 KB
/
pokerHands.groovy
File metadata and controls
207 lines (186 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
int a
int b
int c
int d
int e
int card1
int card2
int card3
int card4
int card5
int pairsCounter
int twoPairsCounter
int threePairsCounter
int fourPairsCounter
int consecutive
println "Please enter a card number or letter: "
String str = System.console().readLine()
if(str == "J"){
a = 11
} else if(str == "Q"){
a = 12
} else if(str == "K"){
a = 13
} else {
a = Integer.parseInt(str)
}
println "and now please enter a suit: "
str = System.console().readLine()
if(str == "hearts"||str == "Hearts"){
card1 = 1
} else if(str == "spades" || str == "Hearts"){
card1 = 2
} else if(str == "diamonds" || str == "Diamonds"){
card1 = 3
} else if(str == "clubs" || str == "Clubs"){
card1 = 4
}
println "Please enter a card number or letter: "
str = System.console().readLine()
if(str == "J"){
b = 11
} else if(str == "Q"){
b = 12
} else if(str == "K"){
b = 13
} else {
b = Integer.parseInt(str)
}
if(a == b){
pairsCounter += 1
}
if(a == b+1 || a == b-1){
consecutive = consecutive + 1
}
println "and now please enter a suit: "
str = System.console().readLine()
if(str == "hearts"||str == "Hearts"){
card2 = 1
} else if(str == "spades" || str == "Hearts"){
card2 = 2
} else if(str == "diamonds" || str == "Diamonds"){
card2 = 3
} else if(str == "clubs" || str == "Clubs"){
card2 = 4
}
println "Please enter a card number or letter: "
str = System.console().readLine()
if(str == "J"){
c = 11
} else if(str == "Q"){
c = 12
} else if(str == "K"){
c = 13
} else {
c = Integer.parseInt(str)
}
if(a == c){
pairsCounter += 1
} else if(b == c){
twoPairsCounter +=1
}
if(a == c+1 || a == c-1 || b == c+1 || b == c-1){
consecutive = consecutive + 1
}
println "and now please enter a suit: "
str = System.console().readLine()
if(str == "hearts"||str == "Hearts"){
card3 = 1
} else if(str == "spades" || str == "Hearts"){
card3 = 2
} else if(str == "diamonds" || str == "Diamonds"){
card3 = 3
} else if(str == "clubs" || str == "Clubs"){
card3 = 4
}
println "Please enter a card number or letter: "
str = System.console().readLine()
if(str == "J"){
d = 11
} else if(str == "Q"){
d = 12
} else if(str == "K"){
d = 13
} else {
d = Integer.parseInt(str)
}
if(a == d){
pairsCounter += 1
} else if(b == d){
twoPairsCounter += 1
} else if(c == d){
threePairsCounter += 1
}
if(a == d+1 || a == d-1 || b == d+1 || b == d-1 || c == d+1 || c == d-1){
consecutive = consecutive + 1
}
println "and now please enter a suit: "
str = System.console().readLine()
if(str == "hearts"||str == "Hearts"){
card4 = 1
} else if(str == "spades" || str == "Hearts"){
card4 = 2
} else if(str == "diamonds" || str == "Diamonds"){
card4 = 3
} else if(str == "clubs" || str == "Clubs"){
card4 = 4
}
println "Please enter a card number or letter: "
str = System.console().readLine()
if(str == "J"){
e = 11
} else if(str == "Q"){
e = 12
} else if(str == "K"){
e = 13
} else {
e = Integer.parseInt(str)
}
if(a == e){
pairsCounter +=1
} else if(b == e){
twoPairsCounter +=1
} else if(c == e){
threePairsCounter +=1
} else if(d == e){
fourPairsCounter += 1
}
if(a == e+1 || a == e-1 || b == e+1 || b == e-1 || c == e+1 || a == e-1 || d == e+1 || d == e-1){
consecutive = consecutive + 1
}
println "and now please enter a suit: "
str = System.console().readLine()
if(str == "hearts"||str == "Hearts"){
card5 = 1
} else if(str == "spades" || str == "Hearts"){
card5 = 2
} else if(str == "diamonds" || str == "Diamonds"){
card5 = 3
} else if(str == "clubs" || str == "Clubs"){
card5 = 4
}
println pairsCounter
println twoPairsCounter
println threePairsCounter
println fourPairsCounter
if(consecutive == 4 && card1 == card2 && card3 == card4 && card1 == card5){
println "Way to go man! You totally got a Straight Flush! THATS THE BEST HAND IN THE GAME!!!!"
} else if((pairsCounter + twoPairsCounter == 3) || (pairsCounter + threePairsCounter == 3) || (pairsCounter + fourPairsCounter == 3) || (twoPairsCounter + threePairsCounter == 3) || (twoPairsCounter + fourPairsCounter == 3) || (threePairsCounter + fourPairsCounter ==3)){
println "Full House"
} else if(card1 == card2 && card3 == card4 && card1 == card5 && card1 == card3){
println "You have a flush!"
} else if(pairsCounter == 3 || twoPairsCounter == 3){
println "Four of a Kind"
} else if(pairsCounter == 2 || twoPairsCounter == 2 || threePairsCounter == 2){
println "Three of a Kind"
} else if((pairsCounter == 1 && twoPairsCounter == 1) || (pairsCounter == 1 && threePairsCounter == 1) || (pairsCounter == 1 && fourPairsCounter == 1) || (twoPairsCounter == 1 && threePairsCounter == 1) || (twoPairsCounter ==1 && fourPairsCounter == 1) || (threePairsCounter ==1 & fourPairsCounter ==1)){
println "you have a two pair"
} else if(pairsCounter == 1 || twoPairsCounter == 1 || threePairsCounter == 1 || fourPairsCounter == 1){
println "Pair"
} else if(pairsCounter == 5 || twoPairsCounter == 5 || threePairsCounter == 5 || fourPairsCounter == 5){
println "Nice try, you are clearly cheating, you will now be ejected from the hotel"
} else if(consecutive == 4){
println "Way to go man! You totally got a Straight!"
} else {
println "Sorry chachi, no dice."
}