Advertisement
Logikos

Adam's Blackjack slightly modified by Jared

Feb 9th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.58 KB | None | 0 0
  1. ;Coded by Illpastethat, Adam, Illjustinthat, and modified noobishly by Chromatic
  2. ;Blackjack, against bot, !bj (start) !hm (hit me) !stand (stand/hold);
  3. on $*:text:/^[!](bj|blackjack)(\s|$)/Si:#qi_interesting: {
  4. var %Balance = $readini( casino.ini, $nick, Money)
  5. if ($($+(%,bj.,$nick,.cards),2)) {
  6. msg $chan $+($caps($nick),$chr(44)) you still have a game in progress!
  7. describe $chan $+($caps($nick),$chr(44)) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
  8. }
  9. elseif ($2 !isnum) {
  10. msg $chan $caps($nick) $+ , that is not a valid bet, try $1 10
  11. }
  12. elseif ($2 < 10) {
  13. msg $chan $caps($nick) $+ , the minimum bet is 10 Dollars.
  14. }
  15. elseif ($2 > 5000) {
  16. msg $chan $caps($nick) $+ , the maximum bet is 5000 Dollars.
  17. }
  18. elseif ($readini( casino.ini, $nick, Money ) == $null) {
  19. describe $chan $caps($nick) , You have not registered yet. Please have some complimentary Money. Type: !ATM
  20. halt
  21. }
  22. elseif %Balance == 0 {
  23. msg $chan $caps($nick) $+ , you don't have any Money, Ask someone for a loan, or for 100 Dollars type !ATM.
  24. }
  25. elseif ($2 < 10) {
  26. msg $chan $caps($nick) $+ , the minimum bet is 10 Dollars.
  27. }
  28. elseif ($left($2,1) == $chr(45)) {
  29. msg $chan $caps($nick) $+ , you can not use negative numbers.
  30. }
  31. elseif ($2 <= 0) {
  32. msg $chan $caps($nick) $+ , please use a positive number.
  33. }
  34. elseif ($2) && (%Balance < $2) {
  35. msg $chan $caps($nick) $+ , you can not wager that much because you only have $bytes(%Balance,b) Dollars.
  36. }
  37. else {
  38. unset $+(%,bj.,$nick,.*)
  39. set $+(%,bj.,$nick,.bet) $2
  40. set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
  41. set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
  42. set $+(%,bj.,$nick,.ctotal) $gettotal($($+(%,bj.,$nick,.cards),2))
  43. set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
  44. set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
  45. set $+(%,bj.,$nick,.btotal) $gettotal($($+(%,bj.,$nick,.bcards),2))
  46. describe $chan $+($caps($nick),) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
  47. ;In regular blackjack at this point the game would show you the dealers face card (use $gettok to get the last card)
  48. }
  49. if ($($+(%,bj.,$nick,.ctotal),2) > 21) {
  50. describe $chan $+(,$caps($nick)) has Busted and [Qi_bot] wins ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $nick $+ 's score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  51. msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
  52. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  53. ; You should notice it's using a different file and an .Ini file at that.. I still used your algorithm, just had it write to Casino.Ini which simply outputs
  54. ; [Nick] on line 1, then next line is Money=their money for each person who plays.
  55. writeini casino.ini $nick Money %Dollars
  56. unset $+(%,bj.,$nick,.*)
  57. }
  58. elseif ($($+(%,bj.,$nick,.ctotal),2) == 21) {
  59. botHits
  60. describe $chan $+(,$caps($nick)) got ,[||[B-L-A-C-K-J-A-C-K!]||] ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  61. if ($($+(%,bj.,$nick,.btotal),2) == 21) {
  62. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  63. writeini casino.ini $nick Money %Dollars
  64. describe $chan [Qi_bot] got ,[||[B-L-A-C-K-J-A-C-K!]||] [Qi_bot] $+ 's cards: $($+(%,bj.,$nick,.bcards),2)
  65. msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
  66. unset $+(%,bj.,$nick,.*)
  67. }
  68. else {
  69. var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
  70. writeini casino.ini $nick Money %Dollars
  71. msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
  72. unset $+(%,bj.,$nick,.*)
  73. }
  74. }
  75. }
  76. alias getcard {
  77. ;Experimented here with the [ and ] Characters which are $chr(91) and $chr(93)... I tried to put those $chr(91) and 93 after the Return surrounding the card description..
  78. ; I thought maybe making them Variables.. then putting the %beg before the Ace and %end after the $Suit would somehow work.. no go.
  79. ;var %beg $chr(91)
  80. ;var %end $chr(93)
  81. var %r $r(1,13)
  82. if (%r == 1) { return Ace of $suit }
  83. elseif (%r == 10) { return 10 of $suit }
  84. elseif (%r == 11) { return Jack of $suit }
  85. elseif (%r == 12) { return Queen of $suit }
  86. elseif (%r == 13) { return King of $suit }
  87. else { return %r of $suit }
  88. }
  89. alias suit {
  90. ; I also tried to do it here..
  91. var %r $r(1,4)
  92. ;Added the spades, hearts, diamonds, and clubs ascii here.. surprised it actually worked.
  93. if (%r == 1) { return ♠Spades♠ }
  94. elseif (%r == 2) { return ♥Hearts♥ }
  95. elseif (%r == 3) { return ♦Diamonds♦ }
  96. elseif (%r == 4) { return ♣Clubs♣ }
  97. }
  98. alias gettotal {
  99. ; I started to do it here, then realized this was nothing but calculation of the amount. :)
  100. var %x 1
  101. while (%x <= $numtok($1-,43)) {
  102. var %tok $gettok($gettok($1-,%x,43),1,32)
  103. ; Is there any smart way to give the user an option to use both Values of the Ace during a game?
  104. if (%tok == Ace) { var %t $calc(%t + 11) }
  105. elseif (%tok == Jack) { var %t $calc(%t + 10) }
  106. elseif (%tok == Queen) { var %t $calc(%t + 10) }
  107. elseif (%tok == King) { var %t $calc(%t + 10) }
  108. else { var %t $calc(%t + %tok) }
  109. inc %x
  110. }
  111. return %t
  112. }
  113. ;Hit command during Blackjack .. Meat of the results of Busting, hitting Blackjack, etc.
  114. on $*:text:/^[!](hit)(\s|$)/Si:#qi_interesting: {
  115. if (!$($+(%,bj.,$nick,.ctotal),2)) { msg # $nick $+ , to start a game type !Blackjack <bet> to start a new game | halt }
  116. set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
  117. set $+(%,bj.,$nick,.ctotal) $gettotal($($+(%,bj.,$nick,.cards),2))
  118. describe $chan $+($caps($nick),$chr(44)) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
  119. ;Could run a check at this point to see if they got a five card charlie
  120. if ($($+(%,bj.,$nick,.ctotal),2) >= 22) {
  121. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  122. writeini casino.ini $nick Money %Dollars
  123. msg $chan $+(,$caps($nick)) has gone bust and [Qi_bot] wins ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $nick $+ 's score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  124. msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
  125. unset $+(%,bj.,$nick,.*)
  126. }
  127. elseif ($($+(%,bj.,$nick,.ctotal),2) == 21) {
  128. msg $chan $+(,$caps($nick)) got - [||[B-L-A-C-K-J-A-C-K!]||] ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  129. botHits
  130. if ($($+(%,bj.,$nick,.btotal),2) == 21) {
  131. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  132. writeini casino.ini $nick Money %Dollars
  133. msg $chan [Qi_bot] got [||[B-L-A-C-K-J-A-C-K!]||] [Qi_bot] $+ 's cards: $($+(%,bj.,$nick,.bcards),2)
  134. msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
  135. unset $+(%,bj.,$nick,.*)
  136. }
  137. else {
  138. var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
  139. writeini casino.ini $nick Money %Dollars
  140. msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
  141. unset $+(%,bj.,$nick,.*)
  142. }
  143. }
  144. }
  145. ; Stand/Stay portion -- Similar to above. -- I changed the code to include a "PUSH" result.. if Dealer and user have equal values then it's a push, bet it given back and that's that.
  146. on $*:text:/^[!](stand|stay)(\s|$)/Si:#qi_interesting: {
  147. if (!$($+(%,bj.,$nick,.ctotal),2)) { msg # $nick $+ , to start a game type !Blackjack <bet> to start a new game | halt }
  148. botHits
  149. describe $chan $+($caps($nick),$chr(44)) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2) [Qi_bot] $+ 's cards: $($+(%,bj.,$nick,.bcards),2) = $($+(%,bj.,$nick,.btotal),2)
  150. if ($($+(%,bj.,$nick,.btotal),2) >= 22) {
  151. var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
  152. writeini casino.ini $nick Money %Dollars
  153. msg $chan [Qi_bot] has gone bust and $nick wins! ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $nick $+ 's score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  154. msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
  155. unset $+(%,bj.,$nick,.*)
  156. }
  157. elseif ($($+(%,bj.,$nick,.btotal),2) == 21) {
  158. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  159. writeini casino.ini $nick Money %Dollars
  160. msg $chan [Qi_bot] got [||[B-L-A-C-K-J-A-C-K!]||] ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  161. msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
  162. unset $+(%,bj.,$nick,.*)
  163. }
  164. elseif ($($+(%,bj.,$nick,.btotal),2) > $($+(%,bj.,$nick,.ctotal),2)) {
  165. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  166. writeini casino.ini $nick Money %Dollars
  167.  
  168. msg $chan $+($caps($nick),) stands and [Qi_bot] wins ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  169. msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
  170. unset $+(%,bj.,$nick,.*)
  171. }
  172. ; Here is the PUSH section of code I added. I'm not sure it works yet, because I haven't had it happen again in chat.
  173. elseif ($($+(%,bj.,$nick,.btotal),2) == $($+(%,bj.,$nick,.ctotal),2)) {
  174. var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
  175. msg $chan It's a PUSH, $caps($nick)! No-one Wins or Loses this hand. Try Again.
  176. msg $chan Neither one of us Wins or Loses that Hand. Try Again, $Caps($nick). [Qi-Bot] hands $caps($nick) back $($+(%,bj.,$nick,.bet),2) Dollars.
  177. unset $+(%,bj.,$nick,.*)
  178. }
  179. else {
  180. msg $chan $+($caps($nick),) stands and wins ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
  181. msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
  182. var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
  183. writeini casino.ini $nick Money %Dollars
  184. unset $+(%,bj.,$nick,.*)
  185. }
  186. }
  187. alias botHits {
  188. while ($($+(%,bj.,$nick,.btotal),2) < 17) {
  189. set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
  190. set $+(%,bj.,$nick,.btotal) $gettotal($($+(%,bj.,$nick,.bcards),2))
  191. }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement