forked from Blasman/mIRC-Twitch-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blackjack.mrc
332 lines (299 loc) · 13.5 KB
/
blackjack.mrc
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; VARIABLES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/*
HEY! LOOK HERE! This is what you need to change in this script...
Change the %bj_minbet and %bj_maxbet to the minimum and maximum
amount of points that must be spent in order to use !blackjack. The
%bj_cd variable is the per user cooldown time (in seconds) that a user
must wait before being able to use !blackjack again.
You will need to UNLOAD and RE-LOAD this script for any changes to the
variables below to take effect. This can be done by pressing ALT-R in
mIRC > Select "View" > Select "blackjack.mrc" > Click on "File" > "Unload."
Then, click on "File" and "Load..." and select the blackjack.mrc file again.
Have fun!!!
*/
ON *:LOAD: {
SET %bj_minbet 1
SET %bj_maxbet 500
SET %bj_cd 300
}
ON *:UNLOAD: { UNSET %bj_* }
ON *:CONNECT: {
IF ($server == tmi.twitch.tv) {
UNSET %bj.*
UNSET %BJ_CD.*
}
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;; BLACKJACK GAME ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ON $*:TEXT:/^!blackjack\s(on|off)/iS:%mychan: {
IF ($nick isop $chan) {
IF ($2 == on) {
IF (!%GAMES_BJ_ACTIVE) {
SET %GAMES_BJ_ACTIVE On
MSG $chan $twitch_name($nick) $+ , the BlackJack game is now enabled! Type !blackjack for more info! Have fun! PogChamp
}
ELSE MSG $chan $twitch_name($nick) $+ , !blackjack is already enabled. FailFish
}
ELSEIF ($2 == off) {
IF (%GAMES_BJ_ACTIVE) {
UNSET %GAMES_BJ_ACTIVE
MSG $chan $twitch_name($nick) $+ , the BlackJack game is now disabled.
}
ELSE MSG $chan $twitch_name($nick) $+ , !blackjack is already disabled. FailFish
}
}
}
ON $*:TEXT:/^!blackjack(\s|$)/iS:%mychan: {
IF (($($+(%,floodBJ.,$nick),2)) || (%bj.name) || (%ActiveGame) || ($isfile(roulbets.txt)) || (%rr.p1)) halt
SET -u3 %floodBJ. $+ $nick On
IF (!%GAMES_BJ_ACTIVE) {
IF ((%floodBJ_ACTIVE) || ($($+(%,floodBJ_ACTIVE.,$nick),2))) halt
SET -u15 %floodBJ_ACTIVE On
SET -u120 %floodBJ_ACTIVE. $+ $nick On
MSG $chan $twitch_name($nick) $+ , the BlackJack game is currently disabled.
halt
}
ELSEIF ($2 isnum %bj_minbet - %bj_maxbet) {
IF ($($+(%,BJ_CD.,$nick),2)) MSG $nick $twitch_name($nick) $+ , please wait for your cooldown to expire in $duration(%BJ_CD. [ $+ [ $nick ] ]) before trying to play BlackJack again.
ELSEIF ($checkpoints($nick, $2) == false) MSG $chan $twitch_name($nick) $+ , you don't have enough %curname to play. FailFish
ELSE $start_blackjack($nick,$2)
}
ELSE {
IF (%floodBJinfo) halt
SET -u6 %floodBJinfo On
MSG $chan Try your luck at a game of BlackJack in this channel. It is an infinite decks game. %botname always stands on 17 or higher. Type "!blackjack $chr(91) $+ %bj_minbet $+ - $+ %bj_maxbet $+ $chr(93) $+ " to play. ▌ Example: !blackjack %bj_maxbet
}
}
alias start_blackjack {
SET %bj.name $twitch_name($1)
SET %bj.bet $floor($2)
SET %ActiveGame
REMOVEPOINTS %bj.name %bj.bet
blackjacktimer
MSG $nick %bj.name $+ , you have just spent %bj.bet %curname on a hand of BlackJack. Good luck! BloodTrail
bjdeal
IF ((( %bj.ccard1 == A ) && (( %bj.ccard2 == 10 ) || ( %bj.ccard2 == J ) || ( %bj.ccard2 == Q ) || ( %bj.ccard2 == K ))) || (( %bj.ccard2 == A ) && (( %bj.ccard1 == 10 ) || ( %bj.ccard1 == J ) || ( %bj.ccard1 == Q ) || ( %bj.ccard1 == K )))) VAR %bj.dealer yes
IF (( %bj.hcard1 == A ) || ( %bj.hcard2 == A )) SET %bj.aceh On
IF ((( %bj.hcard1 == A ) && (( %bj.hcard2 == 10 ) || ( %bj.hcard2 == J ) || ( %bj.hcard2 == Q ) || ( %bj.hcard2 == K ))) || (( %bj.hcard2 == A ) && (( %bj.hcard1 == 10 ) || ( %bj.hcard1 == J ) || ( %bj.hcard1 == Q ) || ( %bj.hcard1 == K )))) VAR %bj.player yes
IF (%bj.player) && (%bj.dealer) {
MSG $chan Both %bj.name and %botname have blackjack! %bj.name gets their %bj.bet %curname back!
ADDPOINTS %bj.name %bj.bet
resetblackjack
}
IF (%bj.player) {
VAR %bj.payout $floor($calc(%bj.bet * 2.5))
ADDPOINTS %bj.name %bj.payout
MSG $chan Blackjack! %bj.name wins %bj.payout %curname $+ ! PogChamp
resetblackjack
}
IF (%bj.dealer) {
MSG $chan %botname has blackjack! ▌ %bj.name loses their %bj.bet %curname wager! :tf:
resetblackjack
}
SET %bj.Ohands $+(%bj.name $+ 's hand: $chr(91) $+ %bj.hcard1 $+ $chr(93) $chr(91) $+ %bj.hcard2 $+ $chr(93), $chr(32), ▌, $chr(32), $chr(32), %botname $+ 's hand: $chr(91) $+ %bj.ccard1 $+ $chr(93) $chr(91) $+ ? $+ $chr(93), $chr(32), ▌, $chr(32) )
IF (%bj.addh != 21) {
IF ($checkpoints(%bj.name,$calc(%bj.bet * 2)) == true) {
MSG $chan %bj.Ohands %bj.name $+ , do you want to !hit, !stand, or !double?
SET %bj.double $calc(%bj.bet * 2)
}
ELSE MSG $chan %bj.Ohands %bj.name $+ , do you want to !hit or !stand?
}
}
ON *:TEXT:!double:%mychan: {
IF (%bj.double) && ($nick == %bj.name) {
REMOVEPOINTS %bj.name %bj.bet
SET %bj.bet %bj.double
hit
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh , $chr(32), ▌, $chr(32) )
IF (%bj.addh > 21) {
SET %bj.ProcessHands $+(%bj.ProcessHands, $chr(32), %bj.name loses! :tf: )
MSG $chan %bj.ProcessHands
resetblackjack
}
ELSEIF (!%bj.aceh) && (%bj.addh <= 11) {
SET %bj.addh $calc(%bj.addh + 10)
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh , $chr(32), ▌, $chr(32) )
}
stand
}
}
ON *:TEXT:!hit*:%mychan:{
IF ($nick == %bj.name) {
blackjacktimer
UNSET %bj.double
hit
IF (!%bj.aceh) {
IF (%bj.addh == 21) {
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
SET %bj.ProcessStand $+(%bj.ProcessHands)
stand
}
IF (%bj.addh > 21) {
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
MSG $chan %bj.ProcessHands %bj.name loses! :tf:
resetblackjack
}
IF (%bj.addh < 21) {
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
}
}
IF (%bj.aceh) {
IF (%bj.addh == 21) {
SET %bj.ProcessStand $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
stand
}
IF (%bj.addh == 11) {
SET %bj.addh $calc(%bj.addh + 10)
SET %bj.ProcessStand $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
stand
}
IF (%bj.addh < 11) {
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh or $calc(%bj.addh + 10) ▌, $chr(32) )
}
IF (%bj.addh isnum 12-20) {
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
}
IF (%bj.addh > 21) {
SET %bj.ProcessHands $+(%bj.name hits: $chr(91) $+ %bj.hcard3 $+ $chr(93) ▌ Total is %bj.addh ▌, $chr(32) )
MSG $chan %bj.ProcessHands %bj.name loses! :tf:
resetblackjack
}
}
MSG $chan %bj.ProcessHands %bj.name $+ , !hit or !stand? (you may type anything after !hit to bypass twitch flood protection)
}
}
ON *:TEXT:!stand:%mychan: { IF ($nick == %bj.name) stand }
alias bjdeal {
SET %bj.hcard1 $rand(0,12)
SET %bj.hcard2 $rand(0,12)
SET %bj.ccard1 $rand(0,12)
SET %bj.ccard2 $rand(0,12)
SET %bj.addh $calc( %bj.hcard1 + %bj.hcard2 )
SET %bj.addc $calc( %bj.ccard1 + %bj.ccard2 )
IF ( %bj.hcard1 == 0 ) SET %bj.addh $calc(%bj.addh + 10)
IF ( %bj.hcard2 == 0 ) SET %bj.addh $calc(%bj.addh + 10)
IF ( %bj.ccard1 == 0 ) SET %bj.addc $calc(%bj.addc + 10)
IF ( %bj.ccard2 == 0 ) SET %bj.addc $calc(%bj.addc + 10)
IF ( %bj.hcard1 == 11 ) SET %bj.addh $calc(%bj.addh - 1)
IF ( %bj.hcard2 == 11 ) SET %bj.addh $calc(%bj.addh - 1)
IF ( %bj.ccard1 == 11 ) SET %bj.addc $calc(%bj.addc - 1)
IF ( %bj.ccard2 == 11 ) SET %bj.addc $calc(%bj.addc - 1)
IF ( %bj.hcard1 == 12 ) SET %bj.addh $calc(%bj.addh - 2)
IF ( %bj.hcard2 == 12 ) SET %bj.addh $calc(%bj.addh - 2)
IF ( %bj.ccard1 == 12 ) SET %bj.addc $calc(%bj.addc - 2)
IF ( %bj.ccard2 == 12 ) SET %bj.addc $calc(%bj.addc - 2)
IF ( %bj.hcard1 == 1 ) { SET %bj.hcard1 A | SET %bj.aceh On }
IF ( %bj.hcard2 == 1 ) { SET %bj.hcard2 A | SET %bj.aceh On }
IF ( %bj.ccard1 == 1 ) { SET %bj.ccard1 A | SET %bj.acec On }
IF ( %bj.ccard2 == 1 ) { SET %bj.ccard2 A | SET %bj.acec On }
IF ( %bj.hcard1 == 0 ) SET %bj.hcard1 J
IF ( %bj.hcard2 == 0 ) SET %bj.hcard2 J
IF ( %bj.ccard1 == 0 ) SET %bj.ccard1 J
IF ( %bj.ccard2 == 0 ) SET %bj.ccard2 J
IF ( %bj.hcard1 == 11 ) SET %bj.hcard1 Q
IF ( %bj.hcard2 == 11 ) SET %bj.hcard2 Q
IF ( %bj.ccard1 == 11 ) SET %bj.ccard1 Q
IF ( %bj.ccard2 == 11 ) SET %bj.ccard2 Q
IF ( %bj.hcard1 == 12 ) SET %bj.hcard1 K
IF ( %bj.hcard2 == 12 ) SET %bj.hcard2 K
IF ( %bj.ccard1 == 12 ) SET %bj.ccard1 K
IF ( %bj.ccard2 == 12 ) SET %bj.ccard2 K
return
}
alias hit {
SET %bj.hcard3 $rand(0,12)
SET %bj.addh $calc( %bj.addh + %bj.hcard3 )
IF ( %bj.hcard3 == 0 ) SET %bj.addh $calc(%bj.addh + 10)
IF ( %bj.hcard3 == 11 ) SET %bj.addh $calc(%bj.addh - 1)
IF ( %bj.hcard3 == 12 ) SET %bj.addh $calc(%bj.addh - 2)
IF ( %bj.hcard3 == 1 ) { SET %bj.hcard3 A | /set %bj.aceh 0 }
IF ( %bj.hcard3 == 0 ) SET %bj.hcard3 J
IF ( %bj.hcard3 == 11 ) SET %bj.hcard3 Q
IF ( %bj.hcard3 == 12 ) SET %bj.hcard3 K
}
alias stand {
IF (%bj.aceh) && (%bj.addh <= 11) SET %bj.addh $calc(%bj.addh + 10)
SET %bj.ProcessStand $+(%bj.ProcessStand, $chr(32), %botname $+ 's hand: $chr(91) $+ %bj.ccard1 $+ $chr(93) $chr(91) $+ %bj.ccard2 $+ $chr(93) ▌ $chr(32))
GOTO bjfinish
:hit
SET %bj.ccard3 $rand(0,12)
SET %bj.addc $calc( %bj.addc + %bj.ccard3 )
IF ( %bj.ccard3 == 0 ) SET %bj.addc $calc(%bj.addc + 10)
IF ( %bj.ccard3 == 11 ) SET %bj.addc $calc(%bj.addc - 1)
IF ( %bj.ccard3 == 12 ) SET %bj.addc $calc(%bj.addc - 2)
IF ( %bj.ccard3 == 1 ) { SET %bj.ccard3 A | SET %bj.acec On }
IF ( %bj.ccard3 == 0 ) SET %bj.ccard3 J
IF ( %bj.ccard3 == 11 ) SET %bj.ccard3 Q
IF ( %bj.ccard3 == 12 ) SET %bj.ccard3 K
SET %bj.ProcessStand $+( $chr(32), %bj.ProcessStand, $chr(32), %botname draws $chr(91) $+ %bj.ccard3 $+ $chr(93) ▌, $chr(32) )
GOTO bjfinish
:bjfinish
IF (%bj.addc > 21) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand %botname busts! ▌ %bj.name wins $calc(%bj.bet * 2) %curname $+ ! PogChamp
IF (!%bj.double) MSG $chan %bj.ProcessStand %botname busts! ▌ %bj.name wins $calc(%bj.bet * 2) %curname $+ ! PogChamp
ADDPOINTS %bj.name $calc(%bj.bet * 2)
resetblackjack
}
IF (!%bj.acec) {
IF (%bj.addc < 17) GOTO hit
IF (%bj.addc >= 17) {
SET %bj.ProcessStand $+(%bj.ProcessStand, $chr(32), %botname Stands on %bj.addc ▌, $chr(32) )
IF (%bj.addc > %bj.addh) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand %botname wins! :tf:
IF (!%bj.double) MSG $chan %bj.ProcessStand %botname wins! :tf:
resetblackjack
}
IF (%bj.addc == %bj.addh) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand Push ▌ %bj.name wins their %bj.bet %curname back!
IF (!%bj.double) MSG $chan %bj.ProcessStand Push ▌ %bj.name wins back their %bj.bet %curname $+ !
ADDPOINTS %bj.name %bj.bet
resetblackjack
}
IF (%bj.addc < %bj.addh) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand %bj.name wins $calc(%bj.bet * 2) %curname $+ ! PogChamp
IF (!%bj.double) MSG $chan %bj.ProcessStand %bj.name wins $calc(%bj.bet * 2) %curname $+ ! PogChamp
ADDPOINTS %bj.name $calc(%bj.bet * 2)
resetblackjack
}
}
}
IF (%bj.acec) {
IF (%bj.addc isnum 7-11) SET %bj.addc $calc(%bj.addc + 10)
IF (%bj.addc < 17) GOTO hit
IF (%bj.addc >= 17) {
%bj.ProcessStand = $+(%bj.ProcessStand, $chr(32), %botname Stands on %bj.addc ▌, $chr(32) )
IF (%bj.addc > %bj.addh) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand %botname wins! :tf:
IF (!%bj.double) MSG $chan %bj.ProcessStand %botname wins! :tf:
resetblackjack
}
IF (%bj.addc == %bj.addh) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand Push ▌ %bj.name wins their %bj.bet back!
IF (!%bj.double) MSG $chan %bj.ProcessStand Push ▌ %bj.name wins back their %bj.bet points!
ADDPOINTS %bj.name %bj.bet
resetblackjack
}
IF (%bj.addc < %bj.addh) {
IF (%bj.double) MSG $chan %bj.ProcessHands %bj.ProcessStand %bj.name wins $calc(%bj.bet * 2) points! PogChamp
IF (!%bj.double) MSG $chan %bj.ProcessStand %bj.name wins $calc(%bj.bet * 2) points! PogChamp
ADDPOINTS %bj.name $calc(%bj.bet * 2)
resetblackjack
}
}
}
}
alias blackjacktimer {
.timer.blackjack.1 1 15 MSG %mychan %bj.name $+ , HURRY UP! Finish your game of BlackJack or you will automatically lose! RageFace
.timer.blackjack.2 1 25 MSG %mychan %bj.name $+ , you took too long to play BlackJack! So you GET NOTHING! YOU LOSE! Good Day, Sir! SwiftRage
.timer.blackjack.3 1 25 resetblackjack
}
alias resetblackjack {
SET -ze %BJ_CD. $+ $nick %bj_cd
IF ($timer(.blackjack.3)) .timer.blackjack.* off
UNSET %bj.*
UNSET %ActiveGame
halt
}