-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCards.gd
132 lines (116 loc) Β· 5.48 KB
/
Cards.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
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
class_name Cards
enum Suit {
Hearts,
Diamonds,
Spades,
Clubs
}
enum Number {
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Queen,
King,
Ace
}
const textures = {
Suit.Hearts: {
Number.Two: preload("res://GameScreen/Card/images/Hearts_02.png"),
Number.Three: preload("res://GameScreen/Card/images/Hearts_03.png"),
Number.Four: preload("res://GameScreen/Card/images/Hearts_04.png"),
Number.Five: preload("res://GameScreen/Card/images/Hearts_05.png"),
Number.Six: preload("res://GameScreen/Card/images/Hearts_06.png"),
Number.Seven: preload("res://GameScreen/Card/images/Hearts_07.png"),
Number.Eight: preload("res://GameScreen/Card/images/Hearts_08.png"),
Number.Nine: preload("res://GameScreen/Card/images/Hearts_09.png"),
Number.Ten: preload("res://GameScreen/Card/images/Hearts_10.png"),
Number.Jack: preload("res://GameScreen/Card/images/Hearts_Jack.png"),
Number.Queen: preload("res://GameScreen/Card/images/Hearts_Queen.png"),
Number.King: preload("res://GameScreen/Card/images/Hearts_King.png"),
Number.Ace: preload("res://GameScreen/Card/images/Hearts_Ace.png"),
},
Suit.Diamonds: {
Number.Two: preload("res://GameScreen/Card/images/Diamonds_02.png"),
Number.Three: preload("res://GameScreen/Card/images/Diamonds_03.png"),
Number.Four: preload("res://GameScreen/Card/images/Diamonds_04.png"),
Number.Five: preload("res://GameScreen/Card/images/Diamonds_05.png"),
Number.Six: preload("res://GameScreen/Card/images/Diamonds_06.png"),
Number.Seven: preload("res://GameScreen/Card/images/Diamonds_07.png"),
Number.Eight: preload("res://GameScreen/Card/images/Diamonds_08.png"),
Number.Nine: preload("res://GameScreen/Card/images/Diamonds_09.png"),
Number.Ten: preload("res://GameScreen/Card/images/Diamonds_10.png"),
Number.Jack: preload("res://GameScreen/Card/images/Diamonds_Jack.png"),
Number.Queen: preload("res://GameScreen/Card/images/Diamonds_Queen.png"),
Number.King: preload("res://GameScreen/Card/images/Diamonds_King.png"),
Number.Ace: preload("res://GameScreen/Card/images/Diamonds_Ace.png"),
},
Suit.Spades: {
Number.Two: preload("res://GameScreen/Card/images/Spades_02.png"),
Number.Three: preload("res://GameScreen/Card/images/Spades_03.png"),
Number.Four: preload("res://GameScreen/Card/images/Spades_04.png"),
Number.Five: preload("res://GameScreen/Card/images/Spades_05.png"),
Number.Six: preload("res://GameScreen/Card/images/Spades_06.png"),
Number.Seven: preload("res://GameScreen/Card/images/Spades_07.png"),
Number.Eight: preload("res://GameScreen/Card/images/Spades_08.png"),
Number.Nine: preload("res://GameScreen/Card/images/Spades_09.png"),
Number.Ten: preload("res://GameScreen/Card/images/Spades_10.png"),
Number.Jack: preload("res://GameScreen/Card/images/Spades_Jack.png"),
Number.Queen: preload("res://GameScreen/Card/images/Spades_Queen.png"),
Number.King: preload("res://GameScreen/Card/images/Spades_King.png"),
Number.Ace: preload("res://GameScreen/Card/images/Spades_Ace.png"),
},
Suit.Clubs: {
Number.Two: preload("res://GameScreen/Card/images/Clubs_02.png"),
Number.Three: preload("res://GameScreen/Card/images/Clubs_03.png"),
Number.Four: preload("res://GameScreen/Card/images/Clubs_04.png"),
Number.Five: preload("res://GameScreen/Card/images/Clubs_05.png"),
Number.Six: preload("res://GameScreen/Card/images/Clubs_06.png"),
Number.Seven: preload("res://GameScreen/Card/images/Clubs_07.png"),
Number.Eight: preload("res://GameScreen/Card/images/Clubs_08.png"),
Number.Nine: preload("res://GameScreen/Card/images/Clubs_09.png"),
Number.Ten: preload("res://GameScreen/Card/images/Clubs_10.png"),
Number.Jack: preload("res://GameScreen/Card/images/Clubs_Jack.png"),
Number.Queen: preload("res://GameScreen/Card/images/Clubs_Queen.png"),
Number.King: preload("res://GameScreen/Card/images/Clubs_King.png"),
Number.Ace: preload("res://GameScreen/Card/images/Clubs_Ace.png"),
}
}
const suit_textures = {
Suit.Spades: preload("res://GameScreen/Suit/Spades.png"),
Suit.Clubs: preload("res://GameScreen/Suit/Clubs.png"),
Suit.Hearts: preload("res://GameScreen/Suit/Hearts.png"),
Suit.Diamonds: preload("res://GameScreen/Suit/Diamonds.png"),
}
static func get_label(card_type: Array) -> String:
return "%s of %s" % [get_number_label(card_type[1]), get_suit_label(card_type[0])]
static func get_suit_label(suit: Cards.Suit) -> String:
return Suit.find_key(suit)
static func get_number_label(number: Cards.Number) -> String:
return Number.find_key(number)
static func get_number_sigil(number: Cards.Number) -> String:
match number:
Number.Two: return "2"
Number.Three: return "3"
Number.Four: return "4"
Number.Five: return "5"
Number.Six: return "6"
Number.Seven: return "7"
Number.Eight: return "8"
Number.Nine: return "9"
Number.Ten: return "10"
Number.Jack: return "J"
Number.Queen: return "Q"
Number.King: return "K"
Number.Ace: return "A"
return "?"
## Check if the given `value` is in the given bounds (inclusive).
## `bounds` should be a two-element [lower_bound, upper_bound] array.
static func is_in_range(value: Number, bounds: Array):
return value >= bounds[0] and value <= bounds[1]