1 | //===== eAthena Script ======================================= |
---|
2 | //= Black Jack |
---|
3 | //===== By: ================================================== |
---|
4 | //= kobra_k88 |
---|
5 | //===== Current Version: ===================================== |
---|
6 | //= 1.0 |
---|
7 | //===== Compatible With: ===================================== |
---|
8 | //= |
---|
9 | //===== Description: ========================================= |
---|
10 | //= Black Jack card game. Gameplay based off standard casino |
---|
11 | //= black jack rules. Dealer must have at least 17 to stay and will |
---|
12 | //= automatically stay at 17 and up. Player must have at least |
---|
13 | //= 13 to stay. Aces counted as 11 or 1. Option to "Double Down". |
---|
14 | //= Currently does not allow for "insurance", or "splitting" |
---|
15 | //= of pairs. |
---|
16 | //===== Additional Comments: ================================= |
---|
17 | //= |
---|
18 | //============================================================ |
---|
19 | |
---|
20 | |
---|
21 | cmd_in02,188,89,1 script Black Jack Dealer 57,{ |
---|
22 | |
---|
23 | mes "[Dealer]"; |
---|
24 | mes "Hello there! Would you like to play a game of Black Jack?"; |
---|
25 | M_Menu: |
---|
26 | next; |
---|
27 | menu "What are the rules?",M_0, "I want to play.",L_Play, "No thanks.",M_End; |
---|
28 | |
---|
29 | M_0: |
---|
30 | mes "[Dealer]"; |
---|
31 | mes "What would you like to know?"; |
---|
32 | sM_Menu0: |
---|
33 | next; |
---|
34 | menu "The basics.",sM_0a, "Winning and loosing.",sM_0b, "'Double Down'.",sM_0c, |
---|
35 | "Ace value.",sM_0d, "Nothing.",M_Menu; |
---|
36 | |
---|
37 | sM_0a: |
---|
38 | mes "[Dealer]"; |
---|
39 | mes "Black Jack is a card game in which the goal is to get 21, or as"; |
---|
40 | mes "close to 21 points as possible, without going over 21."; |
---|
41 | next; |
---|
42 | mes "[Dealer]"; |
---|
43 | mes "Before the game starts, the player must make a bet. Once the bet"; |
---|
44 | mes "has been made, both the dealer and the player are dealt 2 cards"; |
---|
45 | mes "each. Depending on what cards you have, you can choose to ^5533FF'stay'^000000,"; |
---|
46 | mes "or you can choose to ^5533FF'pull'^000000."; |
---|
47 | next; |
---|
48 | mes "[Dealer]"; |
---|
49 | mes "When you choose to 'stay', you are telling the dealer that you don't"; |
---|
50 | mes "need anymore cards. This allows the dealer to pull if he/she"; |
---|
51 | mes "wants to. In order to stay, you must have ^FF3355at least 13 points^000000. The"; |
---|
52 | mes "dealer can only stay when he/she has^FF3355 17 points or more^000000."; |
---|
53 | next; |
---|
54 | mes "[Dealer]"; |
---|
55 | mes "When you choose to 'pull', you are telling the dealer that you want"; |
---|
56 | mes "another card. By pulling more cards you can increase your point"; |
---|
57 | mes "total. As long has you have ^FF3355less than 21^000000 points you can pull a"; |
---|
58 | mes "card from the deck."; |
---|
59 | goto sM_Menu0; |
---|
60 | sM_0b: |
---|
61 | mes "[Dealer]"; |
---|
62 | mes "There are 3 ways to win and loose at Black Jack."; |
---|
63 | next; |
---|
64 | mes "[Dealer]"; |
---|
65 | mes "1.) At the end of a Black Jack round, if you have more points"; |
---|
66 | mes "than the dealer you will win the round. Conversely if you have"; |
---|
67 | mes "less points than the dealer you will loose."; |
---|
68 | next; |
---|
69 | mes "[Dealer]"; |
---|
70 | mes "2.) If you pull a card that makes your point total go over 21 you"; |
---|
71 | mes "will automatically loose the round. This is called a ^5533FF'bust'^000000. If"; |
---|
72 | mes "the dealer busts then you will win the round."; |
---|
73 | next; |
---|
74 | mes "[Dealer]"; |
---|
75 | mes "3.) If you have a point total of 21 with the first 2 cards, you"; |
---|
76 | mes "will automatically win the round. This is called a ^5533FF'Black Jack'^000000"; |
---|
77 | mes "and happens when you get an 'Ace' and a '10 valued' card. If the"; |
---|
78 | mes "dealer gets a Black Jack he/she will automatically win the round."; |
---|
79 | next; |
---|
80 | mes "[Dealer]"; |
---|
81 | mes "4.) Besides winning and loosing, you can tie with the dealer. If"; |
---|
82 | mes "both you and the dealer have the same point total at the end of a"; |
---|
83 | mes "round, this will result in a tie with no winner and no loss or gain"; |
---|
84 | mes "in money."; |
---|
85 | next; |
---|
86 | mes "[Dealer]"; |
---|
87 | mes "This is called a ^5533FF'push'^000000 with the dealer. This also"; |
---|
88 | mes "applies to both you and the dealer having Black Jack at the same"; |
---|
89 | mes "time."; |
---|
90 | goto sM_Menu0; |
---|
91 | sM_0c: |
---|
92 | mes "[Dealer]"; |
---|
93 | mes "The 'Double Down' option allows you to double your current bet,"; |
---|
94 | mes "but with the drawback that you will only be able to pull one"; |
---|
95 | mes "additional card. This option is only available at the beggining of"; |
---|
96 | mes "each round."; |
---|
97 | next; |
---|
98 | mes "[Dealer]"; |
---|
99 | mes "An example of when doubling down is useful, is when"; |
---|
100 | mes "your first 2 cards give you a point total of 11. You have a good"; |
---|
101 | mes "chance of getting 21 or 20 with the next card that you draw. This"; |
---|
102 | mes "would be a good hand to double down on."; |
---|
103 | goto sM_Menu0; |
---|
104 | sM_0d: |
---|
105 | mes "[Dealer]"; |
---|
106 | mes "The 'Ace' card is a unique card in the game of Black Jack because"; |
---|
107 | mes "it can have 2 values. An Ace can be counted as either 11 points,"; |
---|
108 | mes "or just 1 point. For example if you had an Ace and a 4, that would"; |
---|
109 | mes "give you either 15 or 5 points."; |
---|
110 | next; |
---|
111 | mes "[Dealer]"; |
---|
112 | mes "If you decided to stay, the Ace would automatically be counted as"; |
---|
113 | mes "11 points to give you 15 points total."; |
---|
114 | next; |
---|
115 | mes "[Dealer]"; |
---|
116 | mes "If you had decided to pull and received a 9, the ace would"; |
---|
117 | mes "automatically be counted as 1 point to give you a total of 14"; |
---|
118 | mes "points. If the Ace was counted as 11 points, you would have a"; |
---|
119 | mes "point total over 21 and would have lost."; |
---|
120 | next; |
---|
121 | mes "[Dealer]"; |
---|
122 | mes "It is because of the flexibilty you have with the 'Ace' that makes"; |
---|
123 | mes "it the most powerfull card in the game."; |
---|
124 | goto sM_Menu0; |
---|
125 | M_End: |
---|
126 | mes "[Dealer]"; |
---|
127 | mes "Feel free to come back anytime"; |
---|
128 | close; |
---|
129 | |
---|
130 | //================ |
---|
131 | L_Play: |
---|
132 | mes "[Dealer]"; |
---|
133 | mes "Please place your bets..."; |
---|
134 | next; |
---|
135 | menu "2z",M_1a, "10z",M_1b, "20z",M_1c, "100z",M_1d, "Too rich for my blood....",M_End; |
---|
136 | |
---|
137 | M_1a: |
---|
138 | if(Zeny < 2) goto sL_NotEnuf; |
---|
139 | set @bet, 2; |
---|
140 | goto L_Cont0; |
---|
141 | M_1b: |
---|
142 | if(Zeny < 10) goto sL_NotEnuf; |
---|
143 | set @bet, 10; |
---|
144 | goto L_Cont0; |
---|
145 | M_1c: |
---|
146 | if(Zeny < 20) goto sL_NotEnuf; |
---|
147 | set @bet, 20; |
---|
148 | goto L_Cont0; |
---|
149 | M_1d: |
---|
150 | if(Zeny < 100) goto sL_NotEnuf; |
---|
151 | set @bet, 100; |
---|
152 | goto L_Cont0; |
---|
153 | |
---|
154 | sL_NotEnuf: |
---|
155 | mes "[Dealer]"; |
---|
156 | mes "I'm sorry but you don't have enough zeny to make that bet."; |
---|
157 | close; |
---|
158 | |
---|
159 | L_Cont0: |
---|
160 | mes "(the cards are being dealt)"; |
---|
161 | next; |
---|
162 | deletearray $@card[0],13; |
---|
163 | set @dealerTurn, 0; |
---|
164 | set @numP, 0; |
---|
165 | set @numD, 0; |
---|
166 | set @pAce, 0; |
---|
167 | set @dAce, 0; |
---|
168 | callsub sF_GetCards, @numP, @playCard[@numP], @playCard$[@numP], @pAce; |
---|
169 | callsub sF_GetCards, @numP, @playCard[@numP], @playCard$[@numP], @pAce; |
---|
170 | callsub sF_GetCards, @numD, @dealCard[@numD], @dealCard$[@numD], @dAce; |
---|
171 | callsub sF_GetCards, @numD, @dealCard[@numD], @dealCard$[@numD], @dAce; |
---|
172 | |
---|
173 | //============== |
---|
174 | L_Start: |
---|
175 | callsub sF_GetTot; |
---|
176 | |
---|
177 | mes "- Here are the ^FF5533DEALER'S^000000 cards:"; |
---|
178 | if (@numD==2) callsub sF_D2cards; |
---|
179 | if (@numD==3) callsub sF_D3cards; |
---|
180 | if (@numD==4) callsub sF_D4cards; |
---|
181 | if (@numD==5) callsub sF_D5cards; |
---|
182 | mes " The DEALER has: ^FF5533"+@dealTot+"^000000"; |
---|
183 | mes " "; |
---|
184 | mes "- Here are ^5533FFYOUR^000000 cards:"; |
---|
185 | if (@numP==2) callsub sF_P2cards; |
---|
186 | if (@numP==3) callsub sF_P3cards; |
---|
187 | if (@numP==4) callsub sF_P4cards; |
---|
188 | if (@numP==5) callsub sF_P5cards; |
---|
189 | if(@pAce != 1 || @playTot == 21) mes " YOU have: ^5533FF" +@playTot+ "^000000"; |
---|
190 | if(@pAce == 1 && @playTot != 21) mes " You have: ^5533FF" +@playTot+ "^000000, or ^5533FF" +(@playTot-10)+ "^000000"; |
---|
191 | next; |
---|
192 | if(@playTot==21 && @dealTot==21) goto sL_Push; |
---|
193 | if(@numP==2 && @playTot == 21) goto sL_Win; |
---|
194 | if(@numD==2 && @dealTot == 21) goto sL_Lose; |
---|
195 | if(@playTot > 21) goto sL_Lose; |
---|
196 | if(@dealTot > 21) goto sL_Win; |
---|
197 | if(@numP==2 && @dealerTurn==0) menu "Hit me(pull)",M_Hit, "Stay",M_Stay, "Double Down",M_Double; |
---|
198 | if(@dealerTurn == 0) menu "Hit me(pull)",M_Hit, "Stay",M_Stay; |
---|
199 | |
---|
200 | M_Stay: |
---|
201 | mes "[Dealer]"; |
---|
202 | if(@playTot < 13) goto sL_PlayToLow; |
---|
203 | if(@dealTot > 16) mes "The Dealer stays."; |
---|
204 | if(@dealTot > 16 || @numD == 5) goto L_Check; |
---|
205 | mes "The Dealer is going to pull"; |
---|
206 | next; |
---|
207 | callsub sF_GetCards, @numD, @dealCard[@numD], @dealCard$[@numD], @dAce; |
---|
208 | set @dealerTurn, 1; |
---|
209 | goto L_Start; |
---|
210 | |
---|
211 | sL_PlayToLow: |
---|
212 | mes "I'm sorry but you do not have a high enough total to stay. You must pull."; |
---|
213 | next; |
---|
214 | goto M_Hit; |
---|
215 | |
---|
216 | M_Hit: |
---|
217 | if(@numP == 5) goto M_Stay; |
---|
218 | callsub sF_GetCards, @numP, @playCard[@numP], @playCard$[@numP], @pAce; |
---|
219 | goto L_Start; |
---|
220 | M_Double: |
---|
221 | mes "[Dealer]"; |
---|
222 | mes "Player has chosen to Double Down. You're current bet will be"; |
---|
223 | mes "doubled, and you will only be able to pull 1 extra card."; |
---|
224 | next; |
---|
225 | set @dealerTurn, 1; |
---|
226 | set @bet, @bet*2; |
---|
227 | callsub sF_GetCards, @numP, @playCard[@numP], @playCard$[@numP], @pAce; |
---|
228 | goto L_Start; |
---|
229 | |
---|
230 | //============= |
---|
231 | L_Check: |
---|
232 | next; |
---|
233 | if(@playTot < @dealTot) goto sL_Lose; |
---|
234 | if(@playTot == @dealTot) goto sL_Push; |
---|
235 | |
---|
236 | sL_Win: |
---|
237 | mes "[Dealer]"; |
---|
238 | mes "Congratulations, you've won!"; |
---|
239 | next; |
---|
240 | set Zeny, Zeny + @bet; |
---|
241 | goto L_Play; |
---|
242 | sL_Lose: |
---|
243 | mes "[Dealer]"; |
---|
244 | mes "I'm sorry but you've lost."; |
---|
245 | set Zeny, Zeny - @bet; |
---|
246 | next; |
---|
247 | goto L_Play; |
---|
248 | sL_Push: |
---|
249 | mes "[Dealer]"; |
---|
250 | mes "Its a push. You tied with the Dealer."; |
---|
251 | next; |
---|
252 | goto L_Play; |
---|
253 | |
---|
254 | |
---|
255 | //================================== |
---|
256 | // Sub function for dealing/pulling the cards |
---|
257 | sF_GetCards: |
---|
258 | set @rnd, rand(1,13); |
---|
259 | if($@card[@rnd] == 4) goto sF_GetCards; |
---|
260 | set $@card[@rnd], $@card[@rnd] + 1; |
---|
261 | set getarg(1), @rnd; |
---|
262 | if(getarg(1) > 10) set getarg(1), 10; |
---|
263 | if(getarg(1) == 1 && getarg(3) < 1) set getarg(1), 11; |
---|
264 | if(getarg(1) == 11) set getarg(3), 1; |
---|
265 | set getarg(2), " " + getarg(1) + " "; |
---|
266 | if(@rnd == 10) set getarg(2), getarg(1); |
---|
267 | if(@rnd == 1) set getarg(2), " A "; |
---|
268 | if(@rnd == 11) set getarg(2), " J "; |
---|
269 | if(@rnd == 12) set getarg(2), " Q "; |
---|
270 | if(@rnd == 13) set getarg(2), " K "; |
---|
271 | set getarg(0), getarg(0) + 1; |
---|
272 | return; |
---|
273 | |
---|
274 | //================================== |
---|
275 | // Sub function for getting the total score for each hand |
---|
276 | sF_GetTot: |
---|
277 | set @i, 0; |
---|
278 | set @dealTot, 0; |
---|
279 | set @playTot, 0; |
---|
280 | |
---|
281 | GetDealTot: |
---|
282 | set @dealTot, @dealTot + @dealCard[@i]; |
---|
283 | set @i, @i + 1; |
---|
284 | if(@i < @numD) goto GetDealTot; |
---|
285 | if(@dAce == 1 && @dealTot > 21) set @dealTot, @dealTot - 10; |
---|
286 | set @i, 0; |
---|
287 | GetPlayTot: |
---|
288 | set @playTot, @playTot + @playCard[@i]; |
---|
289 | set @i, @i + 1; |
---|
290 | if(@i < @numP) goto GetPlayTot; |
---|
291 | if(@pAce == 1 && @playTot > 21) set @pAce, 2; |
---|
292 | if(@pAce > 0 && @playTot > 21) set @playTot, @playTot - 10; |
---|
293 | return; |
---|
294 | |
---|
295 | //======================================= |
---|
296 | // Sub function for displaying the Cards |
---|
297 | sF_D2cards: |
---|
298 | mes " .-----. .-----. "; |
---|
299 | mes " | "+@dealCard$[0]+" | | "+@dealCard$[1]+" | "; |
---|
300 | mes " '-----' '-----' "; |
---|
301 | return; |
---|
302 | sF_P2cards: |
---|
303 | mes " .-----. .-----. "; |
---|
304 | mes " | "+@playCard$[0]+" | | "+@playCard$[1]+" | "; |
---|
305 | mes " '-----' '-----' "; |
---|
306 | return; |
---|
307 | sF_D3cards: |
---|
308 | mes " .-----. .-----. .-----. "; |
---|
309 | mes " | "+@dealCard$[0]+" | | "+@dealCard$[1]+" | | "+@dealCard$[2]+" | "; |
---|
310 | mes " '-----' '-----' '-----' "; |
---|
311 | return; |
---|
312 | sF_P3cards: |
---|
313 | mes " .-----. .-----. .-----. "; |
---|
314 | mes " | "+@playCard$[0]+" | | "+@playCard$[1]+" | | "+@playCard$[2]+" | "; |
---|
315 | mes " '-----' '-----' '-----' "; |
---|
316 | return; |
---|
317 | sF_D4cards: |
---|
318 | mes " .-----. .-----. .-----. "; |
---|
319 | mes " | "+@dealCard$[0]+" | | "+@dealCard$[1]+" | | "+@dealCard$[2]+" | "; |
---|
320 | mes " '-----' '-----' '-----' "; |
---|
321 | mes " .-----. "; |
---|
322 | mes " | "+@dealCard$[3]+" |"; |
---|
323 | mes " '-----' "; |
---|
324 | return; |
---|
325 | sF_P4cards: |
---|
326 | mes " .-----. .-----. .-----. "; |
---|
327 | mes " | "+@playCard$[0]+" | | "+@playCard$[1]+" | | "+@playCard$[2]+" |"; |
---|
328 | mes " '-----' '-----' '-----' "; |
---|
329 | mes " .-----. "; |
---|
330 | mes " | "+@playCard$[3]+" |"; |
---|
331 | mes " '-----' "; |
---|
332 | return; |
---|
333 | sF_D5cards: |
---|
334 | mes " .-----. .-----. .-----. "; |
---|
335 | mes " | "+@dealCard$[0]+" | | "+@dealCard$[1]+" | | "+@dealCard$[2]+" | "; |
---|
336 | mes " '-----' '-----' '-----' "; |
---|
337 | mes " .-----. .-----. "; |
---|
338 | mes " | "+@dealCard$[3]+" | | "+@dealCard$[4]+" | "; |
---|
339 | mes " '-----' '-----' "; |
---|
340 | return; |
---|
341 | sF_P5cards: |
---|
342 | mes " .-----. .-----. .-----. "; |
---|
343 | mes " | "+@playCard$[0]+" | | "+@playCard$[1]+" | | "+@playCard$[2]+" | "; |
---|
344 | mes " '-----' '-----' '-----' "; |
---|
345 | mes " .-----. .-----. "; |
---|
346 | mes " | "+@playCard$[3]+" | | "+@playCard$[4]+" | "; |
---|
347 | mes " '-----' '-----' "; |
---|
348 | return; |
---|
349 | } |
---|