Advertisement
illpastethat

eCasino Blackjack JammyPear

Dec 18th, 2012
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 8.51 KB | None | 0 0
  1. ;Blackjack, against bot, !bj (start) !hm (hit me) !stand (stand/hold);
  2. ;Made By nick1 for eCasino/JammyPear Original: Weasel/Twango severe edits but I probably still have your shell.
  3. on $*:text:/^[!](bj|blackjack)(\s|$)/Si:#eCasino.blackjack: {
  4.   var %Balance = $read(CasinoChips.txt, s, $nick))
  5.   if ($($+(%,bj.,$nick,.cards),2)) {
  6.     msg $chan $+($nick,$chr(44)) 2you still have a game in progress!
  7.     msg $chan $+($nick,$chr(44)) 2your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
  8.   }
  9.   elseif ($2 !isnum) {
  10.     msg $chan $nick $+ , 2that is not a valid bet, try $1 10
  11.   }
  12.   elseif ($2 < 10) {
  13.     msg $chan $nick $+ , 2the minimum bet is 10 chips.
  14.   }
  15.   elseif ($2 > 500) {
  16.     msg $chan $nick $+ , 2the maximum bet is 500 chips.
  17.   }
  18.   elseif (!%Balance) {
  19.     msg $chan $nick $+ , 2you don't have any chips, contact an operator.
  20.   }
  21.   elseif ($2 < 10) {
  22.     msg $chan $nick $+ , 2the minimum bet is 10 chips.
  23.   }
  24.   elseif ($left($2,1) == $chr(45)) {
  25.     msg $chan $nick $+ , 2you can not use negative numbers.
  26.   }
  27.   elseif ($2 <= 0) {
  28.     msg $chan $nick $+ , 2please use a positive number.
  29.   }
  30.   elseif ($2) && (%Balance < $2) {
  31.     msg $chan $nick $+ , 2you can not wager that much because you only have %Balance chips.
  32.   }
  33.   else {
  34.     unset $+(%,bj.,$nick,.*)
  35.     set $+(%,bj.,$nick,.bet) $2
  36.     set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
  37.     set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
  38.     set $+(%,bj.,$nick,.ctotal) $gettotal($($+(%,bj.,$nick,.cards),2))
  39.     set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
  40.     set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
  41.     set $+(%,bj.,$nick,.btotal) $gettotal($($+(%,bj.,$nick,.bcards),2))
  42.     msg $chan $+($nick,$chr(44)) 2your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
  43.     ;In regular blackjack at this point the game would show you the dealers face card (use $gettok to get the last card)
  44.   }
  45.   if ($($+(%,bj.,$nick,.ctotal),2) > 21) {
  46.     msg $chan $+(2,$nick) has gone bust and [eCasino] wins ([eCasino] $+ 's score:3 $($+(%,bj.,$nick,.btotal),2) 2- $nick $+ 's score:4 $($+(%,bj.,$nick,.ctotal),2) $+ )
  47.     msg $chan $+(2,$nick) you lose $($+(%,bj.,$nick,.bet),2) chips.
  48.     var %chips $calc($read(CasinoChips.txt, s, $nick) - $($+(%,bj.,$nick,.bet),2))
  49.     write -ds $nick CasinoChips.txt
  50.     write CasinoChips.txt $nick %chips
  51.     unset $+(%,bj.,$nick,.*)
  52.   }
  53.   elseif ($($+(%,bj.,$nick,.ctotal),2) == 21) {
  54.     botHits
  55.     msg $chan $+(2,$nick) got 11,01B10,01l13,01a10,01c11,01k09,01j08,01a7,01c04,01k! 2([eCasino] $+ 's score:4 $($+(%,bj.,$nick,.btotal),2) 2- $+($nick,'s) score:3 $($+(%,bj.,$nick,.ctotal),2) $+ )
  56.     if ($($+(%,bj.,$nick,.btotal),2) == 21) {
  57.       var %Chips $calc($read(CasinoChips.txt, s, $nick) - $($+(%,bj.,$nick,.bet),2))
  58.       write -ds $nick CasinoChips.txt
  59.       write CasinoChips.txt $nick %chips
  60.       msg $chan 2[eCasino] got 11,01B10,01l13,01a10,01c11,01k09,01j08,01a7,01c04,01k! 2[eCasino] $+ 's cards:3 $($+(%,bj.,$nick,.bcards),2)
  61.       msg $chan $+(2,$nick) you lose $($+(%,bj.,$nick,.bet),2) chips.
  62.       unset $+(%,bj.,$nick,.*)
  63.     }
  64.     else {
  65.       var %chips $calc($read(CasinoChips.txt, s, $nick) + $($+(%,bj.,$nick,.bet),2) * 2)
  66.       write -ds $+ $nick CasinoChips.txt
  67.       write CasinoChips.txt $nick %Chips
  68.       msg $chan $+(2,$nick) you win $($+(%,bj.,$nick,.bet),2) chips.
  69.       unset $+(%,bj.,$nick,.*)
  70.     }
  71.   }
  72. }
  73. alias getcard {
  74.   var %r $r(1,13)
  75.   if (%r = 1) {
  76.     return Ace
  77.   }
  78.   elseif (%r >= 10) {
  79.     return 10
  80.   }
  81.   else {
  82.     return %r
  83.   }
  84. }
  85. alias gettotal {
  86.   var %x 1
  87.   while (%x <= $numtok($1-,43)) {
  88.     var %tok $gettok($1-,%x,43)
  89.     if (%tok !isnum) {
  90.       var %t $calc(%t + 11)
  91.     }
  92.     else {
  93.       var %t $calc(%t + %tok)
  94.     }
  95.     inc %x
  96.   }
  97.   return %t
  98. }
  99. on $*:text:/^[!](hit)(\s|$)/Si:#eCasino.blackjack: {
  100.   if (!$($+(%,bj.,$nick,.ctotal),2)) { msg # $nick $+ , 2to start a game type !Blackjack <bet> to start a new game | halt }
  101.   set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
  102.   set $+(%,bj.,$nick,.ctotal) $gettotal($($+(%,bj.,$nick,.cards),2))
  103.   msg $chan $+($nick,$chr(44)) 2your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
  104.   ;Could run a check at this point to see if they got a five card charlie
  105.   if ($($+(%,bj.,$nick,.ctotal),2) >= 22) {
  106.     var %chips $calc($read(CasinoChips.txt, s, $nick) - $($+(%,bj.,$nick,.bet),2))
  107.     write -ds $nick CasinoChips.txt
  108.     write CasinoChips.txt $nick %chips
  109.     msg $chan $+(2,$nick) has gone bust and [eCasino] wins ([eCasino] $+ 's score:3 $($+(%,bj.,$nick,.btotal),2) 2- $nick $+ 's score:4 $($+(%,bj.,$nick,.ctotal),2) $+ )
  110.     msg $chan $+(2,$nick) you lose $($+(%,bj.,$nick,.bet),2) chips.
  111.     unset $+(%,bj.,$nick,.*)
  112.   }
  113.   elseif ($($+(%,bj.,$nick,.ctotal),2) == 21) {
  114.     msg $chan $+(2,$nick) got 11,01B10,01l13,01a10,01c11,01k09,01j08,01a7,01c04,01k! 2([eCasino] $+ 's score:4 $($+(%,bj.,$nick,.btotal),2) 2- $+($nick,'s) score:3 $($+(%,bj.,$nick,.ctotal),2) $+ )
  115.     botHits
  116.     if ($($+(%,bj.,$nick,.btotal),2) == 21) {
  117.       var %Chips $calc($read(CasinoChips.txt, s, $nick) - $($+(%,bj.,$nick,.bet),2))
  118.       write -ds $nick CasinoChips.txt
  119.       write CasinoChips.txt $nick %chips
  120.       msg $chan 2[eCasino] got 11,01B10,01l13,01a10,01c11,01k09,01j08,01a7,01c04,01k! 2[eCasino] $+ 's cards:3 $($+(%,bj.,$nick,.bcards),2)
  121.       msg $chan $+(2,$nick) you lose $($+(%,bj.,$nick,.bet),2) chips.
  122.       unset $+(%,bj.,$nick,.*)
  123.     }
  124.     else {
  125.       var %chips $calc($read(CasinoChips.txt, s, $nick) + $($+(%,bj.,$nick,.bet),2) * 2)
  126.       write -ds $+ $nick CasinoChips.txt
  127.       write CasinoChips.txt $nick %Chips
  128.       msg $chan $+(2,$nick) you win $($+(%,bj.,$nick,.bet),2) chips.
  129.       unset $+(%,bj.,$nick,.*)
  130.     }
  131.   }
  132. }
  133. on $*:text:/^[!](stand)(\s|$)/Si:#eCasino.blackjack: {
  134.   if (!$($+(%,bj.,$nick,.ctotal),2)) { msg # $nick $+ , 2to start a game type !Blackjack <bet> to start a new game | halt }
  135.   botHits
  136.   msg $chan $+($nick,$chr(44)) 2your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2) [eCasino] $+ 's cards: $($+(%,bj.,$nick,.bcards),2) = $($+(%,bj.,$nick,.btotal),2)
  137.   if ($($+(%,bj.,$nick,.btotal),2) >= 22) {
  138.     var %Chips $calc($read(CasinoChips.txt, s, $nick) + $($+(%,bj.,$nick,.bet),2))
  139.     write -ds $nick CasinoChips.txt
  140.     write CasinoChips.txt $nick %chips
  141.     msg $chan 2[eCasino] has gone bust and $nick wins! ([eCasino] $+ 's score:4 $($+(%,bj.,$nick,.btotal),2) 2- $nick $+ 's score:3 $($+(%,bj.,$nick,.ctotal),2) $+ )
  142.     msg $chan $+(2,$nick) you win $($+(%,bj.,$nick,.bet),2) chips.
  143.     unset $+(%,bj.,$nick,.*)
  144.   }
  145.   elseif ($($+(%,bj.,$nick,.btotal),2) == 21) {
  146.     var %Chips $calc($read(CasinoChips.txt, s, $nick) - $($+(%,bj.,$nick,.bet),2))
  147.     write -ds $nick CasinoChips.txt
  148.     write CasinoChips.txt $nick %chips
  149.     msg $chan 2[eCasino] got 11,01B10,01l13,01a10,01c11,01k09,01j08,01a7,01c04,01k! 2([eCasino] $+ 's score:3 $($+(%,bj.,$nick,.btotal),2) 2- $+($nick,'s) score:4 $($+(%,bj.,$nick,.ctotal),2) $+ )
  150.     msg $chan $+(2,$nick) you lose $($+(%,bj.,$nick,.bet),2) chips.
  151.     unset $+(%,bj.,$nick,.*)
  152.   }
  153.   elseif ($($+(%,bj.,$nick,.btotal),2) >= $($+(%,bj.,$nick,.ctotal),2)) {
  154.     var %Chips $calc($read(CasinoChips.txt, s, $nick) - $($+(%,bj.,$nick,.bet),2))
  155.     write -ds $nick CasinoChips.txt
  156.     write CasinoChips.txt $nick %chips
  157.     msg $chan $+($nick,2) stands and [eCasino] wins 2([eCasino] $+ 's score:3 $($+(%,bj.,$nick,.btotal),2) 2- $+($nick,'s) score:4 $($+(%,bj.,$nick,.ctotal),2) $+ )
  158.     msg $chan $+(2,$nick) you lose $($+(%,bj.,$nick,.bet),2) chips.
  159.     unset $+(%,bj.,$nick,.*)
  160.   }
  161.   else {
  162.     msg $chan $+($nick,2) stands and wins 2([eCasino] $+ 's score:4 $($+(%,bj.,$nick,.btotal),2) 2- $+($nick,'s) score:3 $($+(%,bj.,$nick,.ctotal),2) $+ )
  163.     msg $chan $+(2,$nick) you win $($+(%,bj.,$nick,.bet),2) chips.
  164.     var %chips $calc($read(CasinoChips.txt, s, $nick) + $($+(%,bj.,$nick,.bet),2))
  165.     write -ds $+ $nick CasinoChips.txt
  166.     write CasinoChips.txt $nick %Chips
  167.     unset $+(%,bj.,$nick,.*)
  168.   }
  169. }
  170. alias botHits {
  171.   while ($($+(%,bj.,$nick,.btotal),2) < 17) {
  172.     set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
  173.     set $+(%,bj.,$nick,.btotal) $gettotal($($+(%,bj.,$nick,.bcards),2))
  174.   }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement