Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Coded by Illpastethat, Adam, Illjustinthat, and modified noobishly by Chromatic
- ;Blackjack, against bot, !bj (start) !hm (hit me) !stand (stand/hold);
- on $*:text:/^[!](bj|blackjack)(\s|$)/Si:#qi_interesting: {
- if (%flood3227) { return }
- set -u20 %flood32 On
- var %bank12 = $readini(Casino.ini, $nick, Money)
- var %moneypercent12 = $calc($2 / %bank12)
- var %moneypercentbj = $calc(%moneypercent12 * 100)
- var %Balance = $readini( casino.ini, $nick, Money)
- if ($($+(%,bj.,$nick,.cards),2)) {
- msg $chan $+($caps($nick),$chr(44)) you still have a game in progress!
- describe $chan $+($caps($nick),$chr(44)) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
- }
- elseif (%moneypercentbj > 30) { describe $chan ( $+ $Nick $+ ) Maximum Bet for Blackjack is 30 Percent of your Total Money, use !money To see your Funds. | halt }
- elseif ($2 !isnum) {
- msg $chan $caps($nick) $+ , that is not a valid bet, try $1 10
- }
- elseif ($2 < 10) {
- msg $chan $caps($nick) $+ , the minimum bet is 10 Dollars.
- }
- ; elseif ($2 > 7500) {
- ; msg $chan $caps($nick) $+ , the maximum bet is 7500 Dollars.
- ;}
- elseif ($readini( casino.ini, $nick, Money ) == $null) {
- describe $chan $caps($nick) , You have not registered yet. Please have some complimentary Money. Type: !ATM
- halt
- }
- elseif %Balance == 0 {
- msg $chan $caps($nick) $+ , you don't have any Money, Ask someone for a loan, or for 100 Dollars type !ATM.
- }
- elseif ($2 < 10) {
- msg $chan $caps($nick) $+ , the minimum bet is 10 Dollars.
- }
- elseif ($left($2,1) == $chr(45)) {
- msg $chan $caps($nick) $+ , you can not use negative numbers.
- }
- elseif ($2 <= 0) {
- msg $chan $caps($nick) $+ , please use a positive number.
- }
- elseif ($2) && (%Balance < $2) {
- msg $chan $caps($nick) $+ , you can not wager that much because you only have $bytes(%Balance,b) Dollars.
- }
- else {
- /set %housemoney $calc( $readini( house.ini, House, Money) + $2 )
- /writeini house.ini House Money %housemoney
- unset $+(%,bj.,$nick,.*)
- set $+(%,bj.,$nick,.bet) $2
- set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
- set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
- set $+(%,bj.,$nick,.ctotal) $gettotal($($+(%,bj.,$nick,.cards),2))
- set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
- set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
- set $+(%,bj.,$nick,.btotal) $gettotal($($+(%,bj.,$nick,.bcards),2))
- describe $chan $+($caps($nick),) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
- ;In regular blackjack at this point the game would show you the dealers face card (use $gettok to get the last card)
- }
- if ($($+(%,bj.,$nick,.ctotal),2) > 21) {
- 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) $+ )
- msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- ; 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
- ; [Nick] on line 1, then next line is Money=their money for each person who plays.
- writeini casino.ini $nick Money %Dollars
- unset $+(%,bj.,$nick,.*)
- }
- elseif ($($+(%,bj.,$nick,.ctotal),2) == 21) {
- botHits
- 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) $+ )
- if ($($+(%,bj.,$nick,.btotal),2) == 21) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- describe $chan [Qi_bot] got ,[||[B-L-A-C-K-J-A-C-K!]||] [Qi_bot] $+ 's cards: $($+(%,bj.,$nick,.bcards),2)
- msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- else {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- }
- }
- alias getcard {
- ;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..
- ; I thought maybe making them Variables.. then putting the %beg before the Ace and %end after the $Suit would somehow work.. no go.
- ;var %beg $chr(91)
- ;var %end $chr(93)
- var %r $r(1,13)
- if (%r == 1) { return Ace of $suit }
- elseif (%r == 10) { return 10 of $suit }
- elseif (%r == 11) { return Jack of $suit }
- elseif (%r == 12) { return Queen of $suit }
- elseif (%r == 13) { return King of $suit }
- else { return %r of $suit }
- }
- alias suit {
- ; I also tried to do it here..
- var %r $r(1,4)
- ;Added the spades, hearts, diamonds, and clubs ascii here.. surprised it actually worked.
- if (%r == 1) { return ♠Spades♠ }
- elseif (%r == 2) { return ♥Hearts♥ }
- elseif (%r == 3) { return ♦Diamonds♦ }
- elseif (%r == 4) { return ♣Clubs♣ }
- }
- alias gettotal {
- ; I started to do it here, then realized this was nothing but calculation of the amount. :)
- var %x 1
- while (%x <= $numtok($1-,43)) {
- var %tok $gettok($gettok($1-,%x,43),1,32)
- ; Is there any smart way to give the user an option to use both Values of the Ace during a game?
- if (%tok == Ace) { var %t $calc(%t + 11) }
- elseif (%tok == Jack) { var %t $calc(%t + 10) }
- elseif (%tok == Queen) { var %t $calc(%t + 10) }
- elseif (%tok == King) { var %t $calc(%t + 10) }
- else { var %t $calc(%t + %tok) }
- inc %x
- }
- return %t
- }
- ;Hit command during Blackjack .. Meat of the results of Busting, hitting Blackjack, etc.
- on $*:text:/^[!](hit)(\s|$)/Si:#qi_interesting: {
- if (!$($+(%,bj.,$nick,.ctotal),2)) { msg # $nick $+ , to start a game type !Blackjack <bet> to start a new game | halt }
- set $+(%,bj.,$nick,.cards) $instok($($+(%,bj.,$nick,.cards),2),$getcard,1,43)
- set $+(%,bj.,$nick,.ctotal) $gettotal($($+(%,bj.,$nick,.cards),2))
- describe $chan $+($caps($nick),$chr(44)) your cards are: $($+(%,bj.,$nick,.cards),2) = $($+(%,bj.,$nick,.ctotal),2)
- ;Could run a check at this point to see if they got a five card charlie
- if ($($+(%,bj.,$nick,.ctotal),2) >= 22) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- 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) $+ )
- msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- elseif ($($+(%,bj.,$nick,.ctotal),2) == 21) {
- 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) $+ )
- botHits
- if ($($+(%,bj.,$nick,.btotal),2) == 21) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- msg $chan [Qi_bot] got [||[B-L-A-C-K-J-A-C-K!]||] [Qi_bot] $+ 's cards: $($+(%,bj.,$nick,.bcards),2)
- msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- else {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- }
- }
- ; 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.
- on $*:text:/^[!](stand|stay)(\s|$)/Si:#qi_interesting: {
- if (!$($+(%,bj.,$nick,.ctotal),2)) { msg # $nick $+ , to start a game type !Blackjack <bet> to start a new game | halt }
- botHits
- 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)
- if ($($+(%,bj.,$nick,.btotal),2) >= 22) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- 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) $+ )
- msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- elseif ($($+(%,bj.,$nick,.btotal),2) == 21) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- 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) $+ )
- msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- elseif ($($+(%,bj.,$nick,.btotal),2) > $($+(%,bj.,$nick,.ctotal),2)) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- msg $chan $+($caps($nick),) stands and [Qi_bot] wins ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
- msg $chan $+(,$caps($nick)) you lose $($+(%,bj.,$nick,.bet),2) Dollars.
- unset $+(%,bj.,$nick,.*)
- }
- ; 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.
- elseif ($($+(%,bj.,$nick,.btotal),2) == $($+(%,bj.,$nick,.ctotal),2)) {
- var %Dollars $calc($readini( Casino.ini, $nick, Money) - $($+(%,bj.,$nick,.bet),2))
- msg $chan It's a PUSH, $caps($nick)! No-one Wins or Loses this hand. Try Again.
- describe $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.
- unset $+(%,bj.,$nick,.*)
- }
- else {
- msg $chan $+($caps($nick),) stands and wins ([Qi_bot] $+ 's score: $($+(%,bj.,$nick,.btotal),2) - $+($nick,'s) score: $($+(%,bj.,$nick,.ctotal),2) $+ )
- msg $chan $+(,$caps($nick)) you win $($+(%,bj.,$nick,.bet),2) Dollars.
- var %Dollars $calc($readini( Casino.ini, $nick, Money) + $($+(%,bj.,$nick,.bet),2))
- writeini casino.ini $nick Money %Dollars
- unset $+(%,bj.,$nick,.*)
- }
- }
- alias botHits {
- while ($($+(%,bj.,$nick,.btotal),2) < 17) {
- set $+(%,bj.,$nick,.bcards) $instok($($+(%,bj.,$nick,.bcards),2),$getcard,1,43)
- set $+(%,bj.,$nick,.btotal) $gettotal($($+(%,bj.,$nick,.bcards),2))
- }
- }
Add Comment
Please, Sign In to add comment