-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCombo.gd
103 lines (82 loc) · 1.74 KB
/
Combo.gd
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
extends Node
enum Combos {
NONE,
PAIR,
TWO_PAIR,
THREE_OF_A_KIND,
STRAIGHT,
FLUSH,
FULL_HOUSE,
FOUR_OF_A_KIND,
STRAIGHT_FLUSH,
ROYAL_FLUSH,
}
const Messages = [
"Perdu, on retente sa chance?",
"La paire sauve la mise!",
"Double paire!",
"C'est un Brelan!",
"Une Quinte!",
"Bien joué�, Flush!",
"Quelle chance! Full!",
"C'est bien un Carré�!",
"Une Quinte Flush!",
"Quinte Flush Royale! Woaw!",
]
const Bonus = [ 0, 1, 2, 3, 4, 5, 6, 9, 11, 21 ]
func get_combination_code(ids):
# get a list of values
var values = []
for n in ids:
values.append(n % 13)
# get a list of colors
var colors = []
for n in ids:
colors.append(round(n / 13))
var pairs = 0
var threes = 0
var fours = 0
# look for multiples in value
var processed_values = []
for n in values:
if not processed_values.has(n):
processed_values.append(n)
var count = values.count(n)
if count == 2:
pairs += 1
if count == 3:
threes += 1
if count == 4:
fours += 1
if fours == 1:
return Combos.FOUR_OF_A_KIND
if threes == 1 and pairs == 1:
return Combos.FULL_HOUSE
if threes == 1:
return Combos.THREE_OF_A_KIND
if pairs == 2:
return Combos.TWO_PAIR
if pairs == 1:
return Combos.PAIR
# Check if straight
var straight = false
values.sort()
var prev_value = null
for n in values:
if prev_value == null or prev_value == n - 1:
prev_value = n
straight = true
else:
straight = false
break
# Check if flush
var flush = colors.count(colors.front()) == colors.size()
if straight and flush and values.back() == 12:
return Combos.ROYAL_FLUSH
if straight and flush:
return Combos.STRAIGHT_FLUSH
if straight:
return Combos.STRAIGHT
if flush:
return Combos.FLUSH
return Combos.NONE