Date: 2018/02/14 10:37:02 UTC-08:00
Type: Denizen Script
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
Dice_Assignment:
type: assignment
debug: false
actions:
on assignment:
- trigger name:click state:true
- trigger name:proximity state:true radius:3
on click:
- run Dice_PlayGame instantly
on enter proximity:
- narrate "<&6>Welcome! Come try your luck at Dice Poker! <&b>$100<&6> buy-in!"
- narrate "<&e>Roll the dice for the best combination, you get <&b>2<&e> chances to hold and improve your result!"
- run Dice_ResetFlags instantly
########################################Main Gameplay Section####################################
# Define which stage of the game the player is in by their 'phase'. #
# Which phase you are in determines how many more times you can hold/reroll the dice. #
# Each phase assumes that the dice desired have been held already, and instantly rolls. #
# Phase 1 and 2 only check for Jackpot because We assume no one wants to troll themselves and #
# reroll that. Anything else might want to be rerolled for a better shot at the Jackpot. #
# If they win, end the game. Check if the game isn't over before giving an option to reroll. #
# Indicate that they are moving on to the next reroll, and give them a chance to hold. #
# The roll, jackpotcheck, phase-assignment could probably be compartmentalized, but I'm lazy. #
# If they are in phase 3 and haven't hit Jackpot, check the others. The others require the hand #
# to be sorted first, but that's ok since the player won't be holding anymore, won't see them. #
# Finally, if the phase is undefined or invalid, try to start the game anew. Reset and Restart.#
#################################################################################################
Dice_PlayGame:
type: task
debug: false
script:
- if <player.flag[dice_phase]||0> == 1 {
- run Dice_Roll_Hand instantly
- if <proc[Dice_CheckFive]> {
- run Dice_Payout def:<global.flag[FivePay]>
- narrate "JACKPOT! 5 in a row!"
- run Dice_ResetFlags instantly
}
- if <player.flag[dice_phase]||0> == 1 {
- flag player dice_phase:2
- inventory open d:in@Dice_Hand_Inventory
}
} else if <player.flag[dice_phase]||0> == 2 {
- run Dice_Roll_Hand instantly
- if <proc[Dice_CheckFive]> {
- run Dice_Payout def:<global.flag[FivePay]>
- narrate "JACKPOT! 5 in a row!"
- run Dice_ResetFlags instantly
}
- if <player.flag[dice_phase]||0> == 2 {
- flag player dice_phase:3
- inventory open d:in@Dice_Hand_Inventory
}
} else if <player.flag[dice_phase]||0> == 3 {
- run Dice_Roll_Hand instantly
- narrate "<&2>You have <&e><player.flag[dice_hand].comma_separated> in hand!"
- run Dice_SortHand instantly
- flag global DiceGames:+:1
- if <proc[Dice_CheckFive]> {
- narrate "<&5>JACKPOT! <&d>5 <&4>in <&b>a <&a>row!"
- run Dice_Payout def:<global.flag[FivePay]>
- flag global FiveWins:+:1
} else if <proc[Dice_CheckFour]> {
- narrate "<&c>Got 4 of a Kind!"
- run Dice_Payout def:<global.flag[FourPay]>
- flag global FourWins:+:1
} else if <proc[Dice_CheckFullHouse]> {
- narrate "<&e>Got a Full House!"
- run Dice_Payout def:<global.flag[FullHousePay]>
- flag global FullWins:+:1
} else if <proc[Dice_CheckThree]> {
- narrate "<&a>Got 3 of a Kind!"
- run Dice_Payout def:<global.flag[ThreePay]>
- flag global ThreeWins:+:1
} else if <proc[Dice_CheckStraight]> {
- narrate "<&b>Got a Straight!"
- run Dice_Payout def:<global.flag[StraightPay]>
- flag global StraightWins:+:1
} else {
- narrate "<&6>Better Luck Next Time!"
}
- narrate "<global.flag[DiceGames].as_int> ever. <global.flag[FiveWins].as_int> 5s hit. <global.flag[FourWins].as_int> 4s hit. <global.flag[ThreeWins].as_int> 3s hit. <global.flag[FullWins].as_int> FH hit. <global.flag[StraightWins].as_int> Str8s hit."
- run Dice_ResetFlags instantly
} else {
- run Dice_ResetFlags instantly
- if <player.money> >= <global.flag[dice_cost]> {
- money take quantity:<global.flag[dice_cost]>
- run Dice_Initialize instantly
- run Dice_PlayGame instantly
} else {
- narrate "<&c>You don't have that much? Get out of here, vagrant."
}
}
#####################################Inventory Management Section################################
# Inv has 5 dice and a Continue/Done button. Dice are Emerald_Ore or #
# Redstone_Ore to indicate if they are held or not. #
# Placement of Dice in Inv View is based on the mouse getting centered each time it opens. #
#################################################################################################
Dice_One:
type: item
material: <player.flag[dice_held].get[1]>
display name: <&6><player.flag[dice_hand].get[1]>
lore:
- "Your first die"
- "Click to HOLD"
- "Red means REROLL"
Dice_Two:
type: item
material: <player.flag[dice_held].get[2]>
display name: <&6><player.flag[dice_hand].get[2]>
lore:
- "Your first die"
- "Click to HOLD"
- "Red means REROLL"
Dice_Three:
type: item
material: <player.flag[dice_held].get[3]>
display name: <&6><player.flag[dice_hand].get[3]>
lore:
- "Your first die"
- "Click to HOLD"
- "Red means REROLL"
Dice_Four:
type: item
material: <player.flag[dice_held].get[4]>
display name: <&6><player.flag[dice_hand].get[4]>
lore:
- "Your first die"
- "Click to HOLD"
- "Red means REROLL"
Dice_Five:
type: item
material: <player.flag[dice_held].get[5]>
display name: <&6><player.flag[dice_hand].get[5]>
lore:
- "Your first die"
- "Click to HOLD"
- "Red means REROLL"
Dice_Done:
type: item
material: GOLD_BLOCK
display name: <&6><player.flag[dice_hand].get[5]>
lore:
- "Click to REROLL!"
Dice_Hand_Inventory_Listener:
type: world
debug: false
events:
on player clicks in Dice_Hand_Inventory:
- determine cancelled
on player drags in Dice_Hand_Inventory:
- determine cancelled
on player clicks Dice_One in Dice_Hand_Inventory:
- if <player.flag[dice_held].get[1]> == REDSTONE_ORE {
- flag player dice_held[1]:EMERALD_ORE
} else {
- flag player dice_held[1]:REDSTONE_ORE
}
- inventory open d:in@Dice_Hand_Inventory
on player clicks Dice_Two in Dice_Hand_Inventory:
- if <player.flag[dice_held].get[2]> == REDSTONE_ORE {
- flag player dice_held[2]:EMERALD_ORE
} else {
- flag player dice_held[2]:REDSTONE_ORE
}
- inventory open d:in@Dice_Hand_Inventory
on player clicks Dice_Three in Dice_Hand_Inventory:
- if <player.flag[dice_held].get[3]> == REDSTONE_ORE {
- flag player dice_held[3]:EMERALD_ORE
} else {
- flag player dice_held[3]:REDSTONE_ORE
}
- inventory open d:in@Dice_Hand_Inventory
on player clicks Dice_Four in Dice_Hand_Inventory:
- if <player.flag[dice_held].get[4]> == REDSTONE_ORE {
- flag player dice_held[4]:EMERALD_ORE
} else {
- flag player dice_held[4]:REDSTONE_ORE
}
- inventory open d:in@Dice_Hand_Inventory
on player clicks Dice_Five in Dice_Hand_Inventory:
- if <player.flag[dice_held].get[5]> == REDSTONE_ORE {
- flag player dice_held[5]:EMERALD_ORE
} else {
- flag player dice_held[5]:REDSTONE_ORE
}
- inventory open d:in@Dice_Hand_Inventory
on player clicks Dice_Done in Dice_Hand_Inventory:
- inventory close
- run Dice_PlayGame instantly
Dice_Hand_Inventory:
type: inventory
title: ""
size: 27
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
- "[] [] [i@Dice_One[quantity=<player.flag[dice_hand].get[1].as_int>]] [i@Dice_Two[quantity=<player.flag[dice_hand].get[2].as_int>]] [i@Dice_Three[quantity=<player.flag[dice_hand].get[3].as_int>]] [i@Dice_Four[quantity=<player.flag[dice_hand].get[4].as_int>]] [i@Dice_Five[quantity=<player.flag[dice_hand].get[5].as_int>]] [] [i@Dice_Done]"
#####################################Utility Functions/Tasks#####################################
# Roll_Hand only randomizes dice that do not have Emerald_Ore in the parallel List #
# SortHand is only used before the final win check, so Held dice don't matter #
# Payout takes an integer as a parameter, and gives the player money in that amount #
# Initialize sets all flags needed for the player to play the game correctly. #
# ResetFlags makes everything blank, as if the player intends to walk away. #
# It also serves as a convenient spot to store global variables (flags) #
#################################################################################################
Dice_Roll_Hand:
type: task
debug: false
script:
- foreach <li@1|2|3|4|5> {
- if <player.flag[dice_held].get[%value%]> == REDSTONE_ORE {
- flag player dice_hand[%value%]:<util.random.int[1].to[6]>
}
}
Dice_SortHand:
type: task
debug: false
script:
- flag player dice_temp:!
- flag player dice_temp:|:<player.flag[dice_hand].numerical.as_list>
- flag player dice_hand:!
- flag player dice_hand:|:<player.flag[dice_temp].numerical.as_list>
Dice_Payout:
type: task
definitions: pay
debug: false
script:
- give money quantity:%pay%
- narrate "<&e>You now have <&a>$<&6><player.money.as_int||0>"
Dice_Initialize:
type: task
debug: false
script:
- flag player dice_hand:|:0|0|0|0|0
- flag player dice_held:|:REDSTONE_ORE|REDSTONE_ORE|REDSTONE_ORE|REDSTONE_ORE|REDSTONE_ORE
- flag player dice_phase:1
Dice_ResetFlags:
type: task
debug: false
script:
- flag player dice_hand:!
- flag player dice_held:!
- flag player dice_phase:!
- flag player dice_temp:!
- flag global dice_cost:100
- flag global FivePay:2000
- flag global FourPay:300
- flag global FullHousePay:150
- flag global ThreePay:100
- flag global StraightPay:400
######################################Dice Win Check Conditions##################################
# These checks assume that the Hand is a sorted list of numbers, and are independent. #
#################################################################################################
Dice_CheckFullHouse:
type: procedure
debug: false
script:
- if <player.flag[dice_hand].get[1].as_int> == <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> != <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> == <player.flag[dice_hand].get[5].as_int> {
- determine true
} else if <player.flag[dice_hand].get[1].as_int> == <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> != <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> == <player.flag[dice_hand].get[5].as_int> {
- determine true
} else {
- determine false
}
Dice_CheckThree:
type: procedure
debug: false
script:
- if <player.flag[dice_hand].get[1].as_int> == <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> != <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> != <player.flag[dice_hand].get[5].as_int> {
- determine true
} else if <player.flag[dice_hand].get[1].as_int> != <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> != <player.flag[dice_hand].get[5].as_int> {
- determine true
} else if <player.flag[dice_hand].get[1].as_int> != <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> != <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> == <player.flag[dice_hand].get[5].as_int> {
- determine true
} else {
- determine false
}
Dice_CheckFour:
type: procedure
debug: false
script:
- if <player.flag[dice_hand].get[1].as_int> == <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> != <player.flag[dice_hand].get[5].as_int> {
- determine true
} else if <player.flag[dice_hand].get[1].as_int> != <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> == <player.flag[dice_hand].get[5].as_int> {
- determine true
} else {
- determine false
}
Dice_CheckStraight:
type: procedure
debug: false
script:
- if <player.flag[dice_hand].get[1].as_int> == <player.flag[dice_hand].get[2].as_int.sub_int[1]> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int.sub_int[1]> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int.sub_int[1]> && <player.flag[dice_hand].get[4].as_int> == <player.flag[dice_hand].get[5].as_int.sub_int[1]> {
- determine true
} else {
- determine false
}
Dice_CheckFive:
type: procedure
debug: false
script:
- if <player.flag[dice_hand].get[1].as_int> == <player.flag[dice_hand].get[2].as_int> && <player.flag[dice_hand].get[2].as_int> == <player.flag[dice_hand].get[3].as_int> && <player.flag[dice_hand].get[3].as_int> == <player.flag[dice_hand].get[4].as_int> && <player.flag[dice_hand].get[4].as_int> == <player.flag[dice_hand].get[5].as_int> {
- determine true
} else {
- determine false
}