User Control Panel
Advertisements

HELP US, HELP YOU!

BlackJack

 
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions
View unanswered posts
Author Message
Tony_shu
God Like
God Like


Joined: 12 Nov 2003
Posts: 624

Reputation: 42.9Reputation: 42.9Reputation: 42.9Reputation: 42.9

PostPosted: Mon Jan 05, 2004 10:18 pm    Post subject: Reply with quote

I didn't know where to post this...so I'm putting it up in AIM
I don't know if there already exists blackjack game for AIM in perl(...nor do I care)...but all i know is...I wrote this mess of a code...& it works!! Very Happy
The only thing is, is that the game only accepts Aces (A) as 11...but thats fine with me Very Happy
(I also attached the file at the end)

Code:
sub blackjack {<br /><br /> my ($victim,$msg,$aim) = (shift,shift,shift);<br /> my $reply;<br /> my $sn = $screenname;<br /><br /> $msg =~ s/(\!|\.|\/)blackjack //ig;<br /><br /> @cards = (A,K,Q,J,10,9,8,7,6,5,4,3,2);<br /><br /> if (-e "blackjack/$victim.txt" ne 1) {<br />   my ($cash,$bet,$wins,$losses,$chand,$phand) = ("50","0","0","0","","");<br />   open (BJ, ">blackjack/$victim.txt");<br />   print BJ "Cash:$cash\n";<br />   print BJ "Bet:$bet\n";<br />   print BJ "Wins:$wins\n";<br />   print BJ "Losses:$losses\n";<br />   print BJ "CPU:$chand\n";<br />   print BJ "Cards:$phand";<br />   close(BJ);<br /><br />   $reply = "\nWelcome to Godbot2003's BlackJack Game!";<br />   $reply .= "\nSo far...\nYour Wins = $wins";<br />   $reply .= "\nYour Losses = $losses";<br />   $reply .= "\nCash Available = \$$cash";<br />   $reply .= "\nYour Bet = \$$bet";<br />   $reply .= "\n";<br />   $reply .= "How much would you like to \$<a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a>?";<br /><br /> } else {<br /><br />   open (GAME, "blackjack/$victim.txt");<br />   my @game = <GAME>;<br />   close(GAME);<br />   chomp(@game);<br />   foreach my $info (@game) {<br />     my ($what,$val) = split(/\:/,$info);<br />     if ($what eq "Cash") { $cash = $val; }<br />     elsif ($what eq "Bet") { $bet = $val; }<br />     elsif ($what eq "Wins") { $wins = $val; }<br />     elsif ($what eq "Losses") { $losses = $val; }<br />     elsif ($what eq "CPU") { $chand = $val; }<br />     elsif ($what eq "Cards") { $phand = $val; }<br />   }<br /><br />   if ($msg eq "" || $msg eq " ") {<br />     $reply = "\nWelcome to Godbot2003's BlackJack Game!";<br />     $reply .= "\nSo far...\nYour Wins = $wins";<br />     $reply .= "\nYour Losses = $losses";<br />     $reply .= "\nCash Available = \$$cash";<br />     $reply .= "\nYour Bet = \$$bet";<br />     $reply .= "\n";<br />     $reply .= "How much would you like to \$<a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a>?";<br />   } <br /><br />   if ($msg =~ /bet/i) {<br />     $msg =~ s/bet \$|bet \$ |//ig;<br />     if ($msg eq "" || $msg eq " ") {<br />       $reply = "You haven't bet anything, please place a <a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a>";<br />     } elsif ($msg > $cash) {<br />       $reply = "You have bet more than you have!";<br />       $reply .= "Please place a new <a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a> ... you have \$$cash available.";<br />     } else {<br />       $bet += $msg;<br />       $cash -= $bet;<br />       $rep = "Ok...You have bet \$$bet ...now lets play!";<br />       $aim->send_im($victim,$rep);<br />       $phand = $cards[ int(rand(scalar(@cards))) ] . " " . $cards[ int(rand(scalar(@cards))) ];<br />       $chand = $cards[ int(rand(scalar(@cards))) ] . " " . $cards[ int(rand(scalar(@cards))) ];<br />     }<br />   }<br /><br />   if ($msg =~ /deal/i) {<br />     $phand = $cards[ int(rand(scalar(@cards))) ] . " " . $cards[ int(rand(scalar(@cards))) ];<br />     $chand = $cards[ int(rand(scalar(@cards))) ] . " " . $cards[ int(rand(scalar(@cards))) ];<br />   }<br /><br />   if ($msg =~ /hit/i) {<br />     $phand .= " " . $cards[ int(rand(scalar(@cards))) ];<br />   }<br /><br />   if ($msg =~ /stand/i) {<br />     $stand = 1;<br />   } else {<br />     $stand = 0;<br />   }<br /><br />   if ($msg =~ /reset/i) {<br />     ($cash,$bet,$wins,$losses,$chand,$phand) = ("50","0","0","0","","");<br />     $reply = "Your file has been reset";<br />     $reply .= "\nYour Wins = $wins";<br />     $reply .= "\nYour Losses = $losses";<br />     $reply .= "\nCash Available = \$$cash";<br />     $reply .= "\nYour Bet = \$$bet";<br />     $reply .= "\n";<br />     $reply .= "How much would you like to \$<a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a>?";<br />   }<br /><br />   if ($msg =~ /new|new game/i) {<br />     ($cash,$bet,$chand,$phand) = ("50","0","","");<br />     $reply = "You now have money again :D";<br />     $reply .= "\nYour Wins = $wins";<br />     $reply .= "\nYour Losses = $losses";<br />     $reply .= "\nCash Available = \$$cash";<br />     $reply .= "\nYour Bet = \$$bet";<br />     $reply .= "\n";<br />     $reply .= "How much would you like to \$<a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a>?";<br />   }<br /><br />   if ($msg =~ /again/i) {<br />     ($bet,$chand,$phand) = ("0","","");<br />     if ($cash == 0) {<br />       $reply = "\nYou have no more money!!";<br />       $reply .= "\nClick here to <a href=\"aim:goim?screenname=$sn&message=/blackjack reset\">reset all stats</a>";<br />       $reply .= "\n\n Or \n\nClick here to get <a href=\"aim:goim?screenname=$sn&message=/blackjack new\">new/more money</a>";<br />     } else {<br />       $reply = "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "How much would you like to \$<a href=\"aim:goim?screenname=$sn&message=/blackjack bet \$\">bet</a>?";<br />     }<br />   }<br /><br />   if ($msg =~ /quit/i) {<br />     ($bet,$chand,$phand) = ("0","","");<br />     $reply = "Thanks for playing!!!";<br />   }<br /><br />   open(BJ, ">blackjack/$victim.txt");<br />   print BJ "Cash:$cash\n";<br />   print BJ "Bet:$bet\n";<br />   print BJ "Wins:$wins\n";<br />   print BJ "Losses:$losses\n";<br />   print BJ "CPU:$chand\n";<br />   print BJ "Cards:$phand";<br />   close(BJ);<br /><br /><br />   if ($phand ne "" && $chand ne "" && $msg ne "" && $reply eq "") {<br />     ###calculate hand values###<br />     my $bphand = $phand;<br />     if ($phand =~ /A|K|Q|J/i) {<br />     $bphand =~ s/K|Q|J/10/ig;<br />     $bphand =~ s/A/11/ig;<br />    }<br />    $bphand =~ s/ /\+/ig;<br />    my $calc_phand = eval($bphand);<br /> <br />     my $bchand = $chand;<br />    if ($chand =~ /A|K|Q|J/i) {<br />     $bchand =~ s/K|Q|J/10/ig;<br />     $bchand =~ s/A/11/ig;<br />    }<br />    $bchand =~ s/ /\+/ig;<br />    my $calc_chand = eval($bchand);<br />    ###########################<br /><br />   if ($stand == 0) {<br />     $reply = off_stand($calc_phand,$calc_chand,$sn,$reply);<br />     open(BJ, ">blackjack/$victim.txt");<br />     print BJ "Cash:$cash\n";<br />     print BJ "Bet:$bet\n";<br />     print BJ "Wins:$wins\n";<br />     print BJ "Losses:$losses\n";<br />     print BJ "CPU:$chand\n";<br />     print BJ "Cards:$phand";<br />     close(BJ);<br />   } elsif ($stand == 1) {<br /><br />     if ($calc_chand < 17) {<br />       $times = 0;<br />        $chand .= " " . $cards[ int(rand(scalar(@cards))) ];<br />        ###calculate hand values###<br />        my $bchand = $chand;<br />        if ($chand =~ /A|K|Q|J/i) { <br />          $bchand =~ s/K|Q|J/10/ig;<br />          $bchand =~ s/A/11/ig;<br />        }<br />        $bchand =~ s/ /\+/ig;<br />        my $calc_chand = eval($bchand);<br />        ###########################<br />        $times++;<br />        $rep = "Dealer hits $times time(s).";<br />        $rep .= "\nYour Wins = $wins";<br />        $rep .= "\nYour Losses = $losses";<br />        $rep .= "\nCash Available = \$$cash";<br />        $rep .= "\nYour Bet = \$$bet";<br />        $rep .= "\n";<br />        $rep .= "\nMy Hand :: $chand ($calc_chand)";<br />        $rep .= "\n";<br />        $rep .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />        $rep .= "Aces (A) are counted as 11 only ... sorry";<br />        $aim->send_im($victim,$rep);<br />        $reply = on_stand($calc_phand,$calc_chand,$sn,$reply);<br />     } elsif ($calc_chand == 17 || $calc_chand > 17) {<br />       on_stand($calc_phand,$calc_chand,$sn,$reply);<br />     }<br /><br />     open(BJ, ">blackjack/$victim.txt");<br />     print BJ "Cash:$cash\n";<br />     print BJ "Bet:$bet\n";<br />     print BJ "Wins:$wins\n";<br />     print BJ "Losses:$losses\n";<br />     print BJ "CPU:$chand\n";<br />     print BJ "Cards:$phand";<br />     close(BJ);<br />   }<br />   }<br /> }<br /><br /> sleep(1);<br /><br /> return $reply;<br /><br />}<br /><br /><br />sub off_stand {<br /><br />  my ($calc_phand,$calc_chand,$sn,$reply) = (shift,shift,shift,shift);<br /><br /><br />     if ($calc_phand < 21 && $calc_chand < 21) {<br />       $reply = "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />       $reply .= "\n";<br />       $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />       $reply .= "Aces (A) are counted as 11 only ... sorry";<br />       $reply .= "\nWhat would you like to do:";<br />       $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack hit\">HIT</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack stand\">STAND</a>";<br />     } elsif ($calc_phand < 21 && $calc_chand > 21) {<br />       $reply = "Dealer busts...You win!!";<br />       $wins++;<br />       $cash += eval(2*$bet);<br />       $reply .= "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />       $reply .= "\n";<br />       $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />       $reply .= "Aces (A) are counted as 11 only ... sorry";<br />       $reply .= "\nWhat would you like to do:";<br />       $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />     } elsif ($calc_phand > 21 && $calc_chand < 21) {<br />       $reply = "You bust...I win!!";<br />       $losses++;<br />       $bet = 0;<br />       $reply .= "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />       $reply .= "\n";<br />       $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />       $reply .= "Aces (A) are counted as 11 only ... sorry";<br />       $reply .= "\nWhat would you like to do:";<br />       $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />     } elsif ($calc_phand == 21 && $calc_chand == 21) {<br />       $cash += $bet;<br />       $bet = 0;<br />       $reply = "We both have BlackJack...so I say we push";<br />       $reply .= "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />       $reply .= "\n";<br />       $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />       $reply .= "Aces (A) are counted as 11 only ... sorry";<br />       $reply .= "\nWhat would you like to do:";<br />       $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />     } elsif ($calc_phand == 21 && $calc_chand < 21 || $calc_phand == 21 && $calc_chand > 21 ) {<br />       $reply = "You have BlackJack!!!";<br />       $cash += eval(3*$bet);<br />       $wins++;<br />       $reply .= "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />       $reply .= "\n";<br />       $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />       $reply .= "Aces (A) are counted as 11 only ... sorry";<br />       $reply .= "\nWhat would you like to do:";<br />       $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />     } elsif ($calc_phand < 21 && $calc_chand == 21 || $calc_phand > 21 && $calc_chand == 21 ) {<br />       $reply = "Dealer has BlackJack!!!";<br />       $bet = 0;<br />       $losses++;<br />       $reply .= "\nYour Wins = $wins";<br />       $reply .= "\nYour Losses = $losses";<br />       $reply .= "\nCash Available = \$$cash";<br />       $reply .= "\nYour Bet = \$$bet";<br />       $reply .= "\n";<br />       $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />       $reply .= "\n";<br />       $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />       $reply .= "Aces (A) are counted as 11 only ... sorry";<br />       $reply .= "\nWhat would you like to do:";<br />       $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />     }<br /><br />  return $reply;<br />}<br /><br />sub on_stand {<br />  my ($calc_phand,$calc_chand,$sn,$reply) = (shift,shift,shift,shift);<br /><br />      if ($calc_phand < 21 && $calc_chand < 21) {<br />        if ($calc_phand < $calc_chand) {<br />          $reply = "Dealer wins!!!";<br />          $bet = 0;<br />          $losses++;<br />        } elsif ($calc_chand < $calc_phand) {<br />          $reply = "You win!!!";<br />          $cash += eval(2*$bet);<br />          $bet = 0;<br />          $wins++;<br />        } elsif ($calc_phand == $calc_chand) {<br />          $reply = "We tie...";<br />          $cash += $bet;<br />          $bet = 0;<br />        }<br />        $reply .= "\nYour Wins = $wins";<br />        $reply .= "\nYour Losses = $losses";<br />        $reply .= "\nCash Available = \$$cash";<br />        $reply .= "\nYour Bet = \$$bet";<br />        $reply .= "\n";<br />        $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />        $reply .= "\n";<br />        $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />        $reply .= "Aces (A) are counted as 11 only ... sorry";<br />        $reply .= "\nWhat would you like to do:";<br />        $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />      } elsif ($calc_phand < 21 && $calc_chand > 21) {<br />        $reply = "Dealer busts...You win!!";<br />        $wins++;<br />        $cash += eval(2*$bet);<br />        $reply .= "\nYour Wins = $wins";<br />        $reply .= "\nYour Losses = $losses";<br />        $reply .= "\nCash Available = \$$cash";<br />        $reply .= "\nYour Bet = \$$bet";<br />        $reply .= "\n";<br />        $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />        $reply .= "\n";<br />        $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />        $reply .= "Aces (A) are counted as 11 only ... sorry";<br />        $reply .= "\nWhat would you like to do:";<br />        $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />      } elsif ($calc_phand > 21 && $calc_chand < 21) {<br />        $reply = "You bust...I win!!";<br />        $losses++;<br />        $bet = 0;<br />        $reply .= "\nYour Wins = $wins";<br />        $reply .= "\nYour Losses = $losses";<br />        $reply .= "\nCash Available = \$$cash";<br />        $reply .= "\nYour Bet = \$$bet";<br />        $reply .= "\n";<br />        $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />        $reply .= "\n";<br />        $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />        $reply .= "Aces (A) are counted as 11 only ... sorry";<br />        $reply .= "\nWhat would you like to do:";<br />        $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />      } elsif ($calc_phand == 21 && $calc_chand == 21) {<br />        $reply = "We both have BlackJack...so I say we push";<br />        $cash += $bet;<br />        $bet = 0;<br />        $reply .= "\nYour Wins = $wins";<br />        $reply .= "\nYour Losses = $losses";<br />        $reply .= "\nCash Available = \$$cash";<br />        $reply .= "\nYour Bet = \$$bet";<br />        $reply .= "\n";<br />        $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />        $reply .= "\n";<br />        $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />        $reply .= "Aces (A) are counted as 11 only ... sorry";<br />        $reply .= "\nWhat would you like to do:";<br />        $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />      } elsif ($calc_phand == 21 && $calc_chand < 21 || $calc_phand == 21 && $calc_chand > 21 ) {<br />        $reply = "You have BlackJack!!!";<br />        $cash += eval(3*$bet);<br />        $bet = 0;<br />        $wins++;<br />        $reply .= "\nYour Wins = $wins";<br />        $reply .= "\nYour Losses = $losses";<br />        $reply .= "\nCash Available = \$$cash";<br />        $reply .= "\nYour Bet = \$$bet";<br />        $reply .= "\n";<br />        $reply .= "\nMy Hand :: $chand ($calc_chand)";<br />        $reply .= "\n";<br />        $reply .= "\nYour Hand :: $phand ($calc_phand)\n\n";<br />        $reply .= "Aces (A) are counted as 11 only ... sorry";<br />        $reply .= "\nWhat would you like to do:";<br />        $reply .= "\n<a href=\"aim:goim?screenname=$sn&message=/blackjack again\">Play Again</a> :: <a href=\"aim:goim?screenname=$sn&message=/blackjack quit\">QUIT</a>";<br />      } elsif ($calc_phand < 21 && $calc_chand == 21 || $calc_phand > 21 && $calc_chand == 21 ) {<br />        $reply = "Dealer has BlackJack!!!";<br />        $bet = 0;<br />        $losses++;<br />      }<br /><br />  return $reply;<br /><br />}<br />1;

_________________
Anthony Arslan
@-Squared Enterprises
MacroHard Corporation
Back to top
muahahaha46
Newbie
Newbie


Joined: 26 Jun 2005
Posts: 16

Reputation: 9.9Reputation: 9.9Reputation: 9.9Reputation: 9.9Reputation: 9.9Reputation: 9.9Reputation: 9.9Reputation: 9.9Reputation: 9.9

PostPosted: Sun Jul 03, 2005 2:14 am    Post subject: Reply with quote

It won't work for me after i try to bet it comes back to Welcome to Godbot2003's BlackJack Game!
So far...
Your Wins = 0
Your Losses = 0
Cash Available = $50
Your Bet = $0
How much would you like to $bet?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group