blackjack.txt 11 KB

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