#!/usr/local/bin/perl # CGI Casino Blackjack v 3.0 6/24/00 # Copyright Jason C Fleming Croesus Design Group (Formerly GFI Internet Design Group) # # The following License Terms govern your use of the accompanying # Software unless you have a separate written agreement with Croesus # Design and Promotion. # License Grant # Croesus Design grants you a license to Use one copy of the Software. # "Use" means storing, loading, installing, executing or displaying # the Software. You may not modify the Software or disable any # licensing or control features of the Software. # Ownership # The Software is owned and copyrighted by Croesus Design and Promotion. # Your license confers no title or ownership in the Software and is not \ # a sale of any rights in the Software. Croesus Design and Promotion will # protect all rights in the event of any violation of these License Terms. # Copies and Adaptations # You may only make copies or adaptations of the Software for archival # purposes or when copying or adaptation is an essential step in the # authorized Use of the Software. You must reproduce all copyright # notices in the original Software on all copies or adaptations. You # may not copy the Software onto any bulletin board or similar system. # Warranty # This program is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # IN NO EVENT WILL CROESUS DESIGN AND PROMOTION, THE AUTHOR OF THIS PRODUCT, # OR ANY REPRESENTATIVE OF CROESUS DESIGN BE LIABLE FOR LOSS OF DATA OR FOR # DIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL (INCLUDING LOST PROFIT), # OR OTHER DAMAGE, WHETHER BASED IN CONTRACT, TORT, OR OTHERWISE. #--------------------- CUSTOMIZE HERE ------------------- $home_page = 'http://www.marijuanagirls.com/blackjack.html'; #the page that launches this script $use_cookies = 'yes'; # enter 'no' if you do not wish to include cookies. the cookie #routine prevents the user from using the browser buttons to repost form data if he #or she does not like the way the cards were dealt. $use_cards = 'yes'; #set this to 'no' if you do not want to use the card images #if you use the cards, set $image_url to the folder they are in #NOTE--this must be a public directory! $use_chat = 'yes'; #enter yes if you want to enable chat w/other players $image_url = 'http://www.marijuanagirls.com/pictures'; $maxbet = '5000'; #max bet allowed $minbank = '-2500'; #max amount of loss before busting $form{decks} = '6'; #number of decks in shoe $message = 'You achieved a high score!'; #message when player gets high score $label = 'Your Name'; #what you want the player to see when they get high score $label2 = 'Your Email'; #what you want to record in the database that is not seen $expletives='bitch|damn'; #words to be filtered out--we left the colorful ones for you to add #add words separated by pipes (|) #------------------- BANNER AD INFO ------------------- # the following variables refer advertisements you may want to run on your game console $banner_code = ''; $button_code = ''; #enter your affiliate code between the single quotes #if you do not want to customize your ads #otherwise, customize your ads with the variables below: #or enter null strings if you don't want a banner i.e. $banner_link = ''; etc. $banner_image = 'http://marijuanagirls.com'; #if you want to place a banner ad, put the image location here $banner_link = 'http://marijuanagirls.com'; #if you are placing a banner, put the link here $banner_height = '60'; #enter the height of the banner here $banner_width = '468'; #enter the width of the banner here $banner_alt = 'Click Here to visit no where'; #enter alternate text here) $banner_comment = 'ValueClick'; #enter comment text here) $button_image = 'http://marijuanagirls.com'; #if you want to place a BUTTON ad, put the image location here $button_link = 'http://marijuanagirls.com'; #if you are placing a BUTTON, put the link here $button_height = '33'; #enter the height of the BUTTON here $button_width = '88'; #enter the width of the BUTTON here $button_alt = 'Blackjack for $$'; #enter alternate text here $button_comment = 'CGI Blackjack'; #enter comment text here #------------------ END OF CUSTOMIZATION ------------------- #=========================================================== # (modify below at your own risk) @SUITS = ("Clubs", "Hearts", "Spades", "Diamonds"); @NAMES = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"); @VALUES = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10); $page_id = time(); #creates a time stamp each time the script is initiated @referers = ($ENV{HTTP_HOST}, $ENV{SCRIPT_NAME}, $ENV{SERVER_NAME}, $home_page); open (FILE, ">>high_scores.txt"); $chatfile = 'chat.dat'; open (CHAT, ">>$chatfile"); #------------------------------------- MAIN ROUTINE ------------------------------- #get form data read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #get form input &ParseData($buffer); $form{nick} =~ s/$expletives/**/gi; unless ($form{nick} && ($form{action} || $form{chat})) { # --------------------------- DISPLAY WELCOME SCREEN -------------------------------------- #print header and set up table &PrintHeader('#FFFFFF'); print <   Casino Blackjack Basic Rules:\n"; print "
\n"; print " Name

\n"; print " Bet \n \n \n \n"; print " \n

"; print <<"EOF"; EOF exit; } # ------------------------------ PARSE HIDDEN VARIABLES -------------------------------------- # get form input and set up variables and arrays # Check Referring URL - must be either the home page or the script itself &check_url; if ($use_cookies eq 'yes') { if (&GetCookies('pageid')) { #gets the time stamp cookie and checks against post data. #if they dont match, the user must be trying to use the browser buttons if ($Cookies{'pageid'} ne $form{'new_pageid'}) { $error='An attempt was made to trick the dealer.
Cheating will not be tolerated in this casino.'; &error($error); } } } @bet = split (/,/, $form{'bet'}); @all_hands = split(/,/, $form{"pcards"}); for ($count=0; $count <= $form{'splits'}; $count++) { #breaks hands and bets for splits @this_hand = split(/\|/, $all_hands[$count]); push(@pcards, [@this_hand]); $betsout += $bet[$count]; } @ptotal = split (/,/, $form{'ptotal'}); @stats = split (/,/, $form{'stats'}); #stats: 0=losses, 1=wins, 2=blackjacks, 3=pushes, 4=busts, 5=dealer blackjacks, 6=games #remove nonnumeric input and set to default if 0 $form{'lastbet'} =~ s/\D//g; if ($form{lastbet} <= 0 || $form{lastbet} > $maxbet) {$form{lastbet} = $maxbet} $form{'decks'} =~ s/\D//g; @hand_status = split(/,/, $form{'hand_status'}); @num_cards = split (/,/, $form{'num_cards'}); @dcards = split(/,/, $form{"dcards"}); $dealer_status = $form{'dealer_status'}; @acards = split(/,/, $form{"acards"}); grep($acards{$_}++, @acards); if ($use_chat eq 'yes') { open(CHAT, $chatfile) || &error("File Error: $chatfile"); flock (CHAT, 2); @chats=; close (CHAT); if ($form{chat}) { $form{chat} =~ s/$expletives/**/gi; push (@chats, "$form{nick}: $form{chat}
\n"); } if (length(join("",@chats) ) > 512 || $#chats > 5) {$null = shift(@chats)} open(CHAT, ">$chatfile") || &error("File Error: $chatfile"); print CHAT @chats; close (CHAT); flock (CHAT, 8); } #---------------------------- QUIT/STATS ROUTINE --------------------------- if ($form{'action'} eq 'Quit' || $form{bank} <= $minbank ) { &PrintHeader('#FFFFFF'); print <   Casino Blackjack EOT $fontstring = ''; if ($form{bank} <= $minbank ) { print "";} print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$fontstringSorry, you busted.
",$fontstring,"Game Statistics:
",$fontstring,"Hands:",$fontstring,$stats[6]+0,"",$fontstring,"Percentage
",$fontstring,"Wins:",$fontstring,$stats[1]+0,"",$fontstring,int($stats[1]/$stats[6]*100+.5), "\%
",$fontstring,"Losses:",$fontstring,$stats[0]+0,"",$fontstring,int($stats[0]/$stats[6]*100+.5), "\%
",$fontstring,"Pushes:",$fontstring,$stats[3]+0,"",$fontstring,int($stats[3]/$stats[6]*100+.5), "\%
",$fontstring,"Busts:",$fontstring,$stats[4]+0,"",$fontstring,int($stats[4]/$stats[6]*100+.5), "\%
",$fontstring,"Blackjacks:",$fontstring,$stats[2]+0,"",$fontstring,int($stats[2]/$stats[6]*100+.5), "\%
",$fontstring,"High Bank:\$",$fontstring,$stats[7]," 
",$fontstring,"Low Bank:\$",$fontstring,$stats[8]," 
\n"; print ""; open (SCORES, "); close (SCORES); $lowscore=$scores[9]; (@lscore) = split (/\|/,$lowscore); if ($form{bank} > $lscore[0]) {$replace=1} if ($form{name}) { #insert player high score into array $form{name} =~ /[\|$expletives]/gi; $form{info} =~ /[\|$expletives]/gi; $thisbank = sprintf("%010.0f","00000000000000$form{bank}"); if ($form{'name'} =~ /href/) {$form{'name'} = 'No unsolicited links, please.'} $entry = "$thisbank\|$form{name}"; if ($label2) {$entry .= "\|$form{info}"} $entry .= "\n"; unshift (@scores,$entry); if ($#scores > 9) { $null = pop (@scores) } @scores = reverse sort (@scores); open (SCORES, ">high_scores.txt") || die ("High Scores Database has spontaneously combusted!"); print SCORES @scores; close (SCORES); $replace=0; } foreach $this_score (@scores) { @name_num = split(/\|/,$this_score); $name_num[0] += 0; print "\n"; } print "
",$fontstring,"High Scores:
$fontstring$name_num[1]$fontstring\$$name_num[0]
\n"; print "
\n"; print &get_hidden; if ($replace) { print $fontstring,"$message
\n"; print "$label: \n"; if ($label2) { print "
$label2: \n" } print "\n"; print "\n"; print "
\n"; } else { print "\n"; if ($form{bank} <= $minbank) { print ""; } else { print " Bet "; print "\n"; print ""; } print "\n"; } print "

\n"; print <<"EOF"; EOF exit; } #---------------------------- PLAY ROUTINE --------------------------- elsif ($form{'action'} eq "Play"){ $bet[0] = $form{'lastbet'}; if ($form{bank} - $bet[0] < $minbank) {$bet[0]=0;$nobet=1;&DispScr} $betsout += $bet[0]; if($#acards > $form{'decks'}*39) { $form{'shuffled'} = 1; @acards = (); %acards = (); } #deal the first round of cards $form{'inplay'} = 0; $form{'splits'} = 0; @pcards = (); @dcards = (); @num_cards = (); @hand_status = (); $dealer_status = ""; $pcards[0][0] = (&get_card()); @dcards = (&get_card()); $pcards[0][1] = (&get_card()); @dcards = (@dcards, &get_card()); $num_cards[0] = 1; @this_hand = @{@pcards[0]}; $ptotal[0] = &get_total(@this_hand); $dtotal = &get_total(@dcards); #check for ace showing if (&get_value($dcards[0]) == 1) { $form{'status'} = "ace_show"; &DispScr; } #check if dealer got blackjack if($dtotal == 21) { $dealer_status = "BLACKJACK!"; if ($ptotal[0] < 21) { $stats[5]++; $stats[0]++; $hand_status[0] = "Lose \$".$bet[0]; $form{'bank'} -= $bet[0]; $bet[0] = 0; } else{ $stats[3]++; $hand_status[0] = "Push"; $bet[0] = 0; } $form{'status'} = "new_game"; $stats[6]++; &DispScr; } if($ptotal[0] == 21) { $stats[2]++; $stats[1]++; $hand_status[0] = "BLACKJACK!
Win \$".int($bet[0]*1.5); $form{'bank'} += int($bet[0]*1.5); $form{'status'} = "new_game"; $bet[0] = 0; $stats[6]++; &DispScr; } $form{'status'} = "inplay"; &DispScr; exit; } # ---------------------------HIT ROUTINE------------------------------- elsif ($form{'action'} eq "Hit"){ $num_cards[$form{'inplay'}]++; $hcard = &get_card(); $pcards[$form{'inplay'}][$num_cards[$form{'inplay'}]] = $hcard; @this_hand = @{@pcards[$form{'inplay'}]}; $ptotal[$form{'inplay'}] = &get_total(@this_hand); if ($ptotal[$form{'inplay'}] > 21){ $hand_status[$form{'inplay'}] = "BUST!"; if (&lasthand) { &stand } else { $form{'inplay'}++; if (&check_blackjack($form{'inplay'})) { if (&lasthand) { &stand } } } } $form{'status'} = "inplay"; &DispScr; exit; } # --------------------------STAND ROUTINE ---------------------------- elsif ($form{'action'} eq "Stand"){ &stand } #------------------------DOUBLE ROUTINE -------------------------------- elsif ($form{'action'} eq "Double"){ if ($form{bank} - $betsout - $bet[$form{inplay}] < $minbank) {$nobet=1;&DispScr} $bet[$form{'inplay'}] *= 2; $num_cards[$form{'inplay'}]++; $hcard = &get_card(); $pcards[$form{'inplay'}][$num_cards[$form{'inplay'}]] = $hcard; @this_hand = @{@pcards[$form{'inplay'}]}; $ptotal[$form{'inplay'}] = &get_total(@this_hand); if ($ptotal[$form{'inplay'}] > 21){ $hand_status[$form{'inplay'}] = "BUST!"; if (&lasthand) { &stand } else { $form{'inplay'}++; if (&check_blackjack($form{'inplay'})) { if (&lasthand) { &stand } } } } $hand_status[$form{'inplay'}] = "Double"; &stand; exit; } # -------------------------- SPLIT ROUTINE --------------------------------- #this routine inserts a new hand into play after current hand and checks for blackjacks elsif ($form{'action'} eq "Split"){ if ($form{bank} - $betsout - $bet[$form{inplay}] < $minbank) {$nobet=1;&DispScr} #increment number of hands $form{'splits'}++; #move array after current hand one row down $this_row = $form{'inplay'} + 1; while ($this_row < $form{'splits'}) { #moves any split hands over @this_hand = @{@pcards[$this_row]}; push (@temp_array, [@this_hand]); push (@temp_bets, $bet[$this_row]); push (@temp_num_cards, $num_cards[$this_row]); push (@temp_ptotal, $ptotal[$this_row]); $this_row++; } #move one card to new hand (row) $temp_hand[0] = $pcards[$form{'inplay'}][1]; #deal one card to each hand $hcard = &get_card(); $pcards[$form{'inplay'}][1] = $hcard; $hcard = &get_card(); $temp_hand[1] = $hcard; $num_cards[$form{'inplay'} +1 ] = 1; $bet[$form{'inplay'} + 1] = $bet[$form{'inplay'}]; unshift(@temp_array, [@temp_hand]); unshift(@temp_bets, $bet[$form{'inplay'}]); unshift(@temp_num_cards, $num_cards[$form{'inplay'}]); unshift(@temp_ptotal, &get_total(@this_hand)); $this_row = $form{'inplay'} + 1; while ($this_row) { @this_hand = @{@pcards[$this_row-1]}; unshift(@temp_array, [@this_hand]); unshift(@temp_bets, $bet[$this_row - 1]); unshift(@temp_num_cards, $num_cards[$this_row - 1]); unshift(@temp_ptotal, $ptotal[$this_row - 1]); $this_row--; } @pcards = @temp_array; @bet = @temp_bets; @num_cards = @temp_num_cards; @ptotal = @temp_ptotal; @this_hand = @{@pcards[$this_row]}; $ptotal[$form{'inplay'}] = &get_total(@this_hand); #perl gurus, if there is an easier way to do this ^^ please let me know... &check_blackjack($form{'inplay'}+1); if (&check_blackjack($form{'inplay'})) { $form{'inplay'}++; if (&check_blackjack($form{'inplay'})) {&stand} } &DispScr; } # -------------------------INSURANCE ROUTINE ---------------------------------- elsif ($form{'action'} eq "Insurance"){ if ($form{bank} - $betsout - ($bet[$form{inplay}]*.5) < $minbank) {$nobet=1;&DispScr} @this_hand = @{@pcards[0]}; $ptotal[0] = &get_total(@this_hand); $dtotal = &get_total(@dcards); $form{'bank'} -= int($bet[0]/2); #check if dealer got blackjack if($dtotal == 21) { $stats[5]++; $stats[3]++; $dealer_status = "BLACKJACK!"; $bet[0] = 0; $hand_status[0] = "Push"; $form{'status'} = "new_game"; $stats[6]++; &DispScr; } if($ptotal[0] == 21) { $hand_status[0] = "BLACKJACK!
Win \$".$bet[0]*1.5; $form{'bank'} += int($bet[0]*1.5); $bet[0] = 0; $form{'status'} = "new_game"; $stats[1]++; $stats[6]++; &DispScr; } $form{'status'} = "inplay"; &DispScr; exit; } elsif ($form{'action'} eq "No Insurance"){ @this_hand = @{@pcards[0]}; $ptotal[0] = &get_total(@this_hand); $dtotal = &get_total(@dcards); #check if dealer got blackjack if($dtotal == 21) { $stats[5]++; $dealer_status = "BLACKJACK!"; if ($ptotal[0] < 21) { $stats[0]++; $hand_status[0] = "Lose
\$".$bet[0]; $form{'bank'} -= $bet[0]; $bet[0] = 0; } else{ $stats[3]++; $hand_status[0] = "Push"; $bet[0] = 0; } $form{'status'} = "new_game"; $stats[6]++; &DispScr; } if($ptotal[0] == 21) { $stats[2]++; $stats[1]++; $hand_status[0] = "BLACKJACK!
Win \$".int($bet[0]*1.5); $form{'bank'} += int($bet[0]*1.5); $bet[0] = 0; $form{'status'} = "new_game"; $stats[6]++; &DispScr; } $form{'status'} = "inplay"; &DispScr; exit; } else{ &DispScr; exit; } #--------------- END OF MAIN ROUTINE -------------------------------- sub check_url { local($check_referer) = 0; if ($ENV{'HTTP_REFERER'}) { foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) { $check_referer = 1; last; } } } if ($check_referer != 1) { &error('An attempt was made to post data from a remote address.')} } sub get_name { return $NAMES[ ($_[0] % 13) ]." of ".$SUITS[ ($_[0] % 4) ]; } sub get_card_image { return $NAMES[ ($_[0] % 13) ].$SUITS[ ($_[0] % 4) ].".gif"; } sub get_value { return $VALUES[ ($_[0] % 13) ]; } sub get_hidden { #returns hidden input # hidden stuff $form{"dcards"} = join(",", @dcards); for ($counter = 0; $counter <= $form{'splits'}; $counter++){ #puts all cards in hand in a array @this_hand = @{@pcards[$counter]}; $handstring[$counter] = join("|",@this_hand); } $form{"ptotal"} = join(",", @ptotal); $form{"stats"} = join(",", @stats); $form{"pcards"} = join(",", @handstring); $form{"acards"} = join(",", keys(%acards)); $form{'bet'} = join(",", @bet); $form{'hand_status'} = join(",", @hand_status); $form{'num_cards'} = join(",", @num_cards); $form{'dealer_status'} = $dealer_status; return # the totals of each hand "\n". # statistics of the game "\n". # the number of decks, an intiger "\n". # the current play status "\n". # the size of the player's bank. an intiger. "\n". #the users last bet input "\n". # the current bets on each hand. "\n". # the deck was just shuffled. "\n". # the status of the dealers hand. "\n". # the status of each hand. "\n". # the size of the player's hands, an intiger. "\n". # the number of hands from splits (if splits is 0, only one hand in play). "\n". # the the current hand in play. "\n". # the list of the dealer's cards. an array of intigers. "\n". # the list of the player's cards. a two dimensional array of intigers (hand,card). "\n". # the list of all cards. an array of intigers. "\n" . # player name. "\n"; } sub get_card { #returns a card from the deck and eliminates it local($card); srand(time|$$); $card = int(rand($form{"decks"} * 52)); while($acards{$card}){ $card = int(rand($form{"decks"} * 52)); } $acards{$card} = 1; return $card; } sub get_total { #calculates the total of a hand local(@this_hand, $aces, $card, $cardval, $total); @this_hand = @_; $total = 0; $aces = 0; foreach $card (@this_hand) { $cardval = &get_value($card); if ($cardval == 1){ $aces++;} $total += $cardval; } if ($aces && $total < 12) { $total += 10 } return $total; } sub check_blackjack { #checks next hand on a split for instant blackjack $check = $_[0]; @this_hand = @{@pcards[$check]}; if (&get_total(@this_hand) == 21 && $num_cards[$check] == 1 ) { $hand_status[$check] = "BLACKJACK!"; return (1) } else { return (0) } } sub stand { @this_hand = @{@pcards[$form{'inplay'}]}; $ptotal[$form{'inplay'}] = &get_total(@this_hand); if (&lasthand) { while(&get_total(@dcards) < 17){ @dcards = (@dcards, &get_card) } for ($count = 0; $count <= $form{'splits'}; $count++) { @this_hand = @{@pcards[$count]}; if (&get_total(@this_hand) > 21) { $stats[4]++; $form{'bank'} -= $bet[$count]; $hand_status[$count] .= "
Lose \$".$bet[$count]; $bet[$count] = 0; $stats[0]++; $stats[6]++; } elsif ($hand_status[$count] =~ /BLACKJACK!/gi) { $stats[1]++; $stats[2]++; $form{'bank'} += int($bet[$count]*1.5); $hand_status[$count] .= "
Win \$".int($bet[$count]*1.5); $bet[$count] = 0; $stats[6]++; } else { if (&get_total(@dcards) > 21) { $stats[1]++; $form{'bank'} += $bet[$count]; $hand_status[$count] = "WIN \$".$bet[$count]."!"; $bet[$count] = 0; $dealer_status = "BUST!"; $stats[6]++; } elsif (&get_total(@this_hand) > &get_total(@dcards)) { $stats[1]++; $form{'bank'} += $bet[$count]; $hand_status[$count] = "WIN \$".$bet[$count]."!"; $bet[$count] = 0; $stats[6]++; } elsif (&get_total(@this_hand) < &get_total(@dcards)) { $stats[0]++; $form{'bank'} -= $bet[$count]; $hand_status[$count] = "Lose \$".$bet[$count]; $bet[$count] = 0; $stats[6]++; } else { $stats[3]++; $hand_status[$count] = "Push"; $bet[$count] = 0; $stats[6]++; } } } $form{'status'} = "new_game"; &DispScr; } else { if ($hand_status[$form{'inplay'}] ne "BLACKJACK!") {$hand_status[$form{'inplay'}] = "Stand"} $form{'inplay'}++; if (&check_blackjack($form{'inplay'})) { &stand } $form{'status'} = "inplay"; &DispScr; exit; } } sub lasthand { if ($form{'inplay'} >= $form{'splits'}) { return (1) } else { return (0) } } sub ParseData { #parse form data my $form_string = $_[0]; @namevalues = split(/&/, $form_string); foreach $namevalue (@namevalues) { ($name, $value) = split(/=/, $namevalue); $name =~ tr/+/ /; $value =~ tr/+/ /; $name =~ s/%(..)/pack("C", hex($1))/eg; $value =~ s/%(..)/pack("C", hex($1))/eg; $value =~ s/[\r\n\t\f]/ /g; #removes tabs and line breaks (IE) $value =~ s/( )+/ /g; #removes multiple spaces $value =~ s/([;<>\*\`&\$#\(\)\[\]\{\}'"])//ge; #filters offending characters $form{$name} = $value; } } # ------------------------------- DISPLAY PLAY SCREEN -------------------------------------- sub DispScr { &PrintHeader('#000000'); if ($banner_code) { print $banner_code . "\n" } elsif ($banner_link) { print "
\"",$banner_alt,"\"

"} print '
  Casino Blackjack
Dealer
'; # --------------------------insert dealer display card routine here ---------------------------- #if dealer_show, show all cards otherwise just upcard unless($nobet && $form{status} eq 'new_game') { if ($form{'status'} eq 'deal_show' || $form{'status'} eq 'new_game') { $dtotal = &get_total(@dcards); if ($use_cards eq 'yes') { grep(print("\n"), @dcards); print"
"; } else { print "
    "; grep(print("
  • ",&get_name($_),"\n"), @dcards); print "
\n"; } print $dtotal , "\n"; } else { #shows dealers upcard $upcard = &get_value($dcards[0]); if ($upcard == 1) {$upcard = 11} if ($use_cards eq 'yes') { print "\n"; print "\n"; print "
"; } else { print "
  • " , &get_name($dcards[0]) , "
  • (Down Card)
\n"; } print "$upcard"; } # show dealer status here if ($dealer_status) { print $dealer_status, "\n"} } # -------------------------------end of dealer display routine ---------------------------------- print <<"EOF"; # more html table stuff
EOF print $form{'decks'}, " Deck Shoe"; if ($form{'shuffled'}) { print " (Shuffled)"; $form{'shuffled'} = 0; } $disp_cards = int(((($form{'decks'} * 52) - $#acards) / ($form{'decks'} * 52)) * $form{decks}*10); #gets a number from 0-25 representing percentage of 'shoe' left print "
[]", "]"x$disp_cards; #character representation of deck print <<"EOF"; # more html table stuff
Bank
EOF $betsout=0; for ($count=0; $count <= $form{'splits'}; $count++) { $betsout += $bet[$count] } print "\$", $form{'bank'} - $betsout , "\n"; if ($form{'bank'} > $stats[7]) {$stats[7] = $form{'bank'}} if ($form{'bank'} < $stats[8]) {$stats[8] = $form{'bank'}} print <<"EOF"; # more html table stuff
EOF # ------------------------- PRINT PLAYER'S HAND(S) --------------------------- # need to set up loop for each hand and create table for all four cells # Hand # and cards,Total,Status,Bet unless($nobet && $form{status} eq 'new_game') { if ($form{status} eq 'ace_show') { print "Insurance\?"; } else { #skips this routine if this is an insurance call # note that the cell widths need to be the total 100 / total number of hands (which sets up a squished type bug, but who cares) # could be remedied by setting maximum splits on a hand at 5 # which means we need a counter for splits, if > 5 then deny split print ""; # Hand # and cards for ($count = 0; $count <= $form{'splits'}; $count++) { print "\n"; } else { print "
    \n"; grep(print("
  • ", &get_name($_), "\n"), @this_hand); print "
\n\n"; } } print""; for ($count = 0; $count <= $form{'splits'}; $count++) { print "\n"; } print""; for ($count = 0; $count <= $form{'splits'}; $count++) { print "\n"; } print""; unless ($form{status} eq 'new_game') { print ""; for ($count = 0; $count <= $form{'splits'}; $count++) { print "\n"; } print "\n"; } print"
\n"; @this_hand = @{@pcards[$count]}; if (!$form{'splits'}) { print "Your hand: \n" } else { print "Hand ", $count+1,": \n" } if ($use_cards eq 'yes') { print"
"; grep(print("\n"), @this_hand); print "
\n"; @this_hand = @{@pcards[$count]}; $ptotal[$count] = &get_total(@this_hand); print $ptotal[$count]; print "\n
\n"; if (!$hand_status[$count]) { print "\ " } print $hand_status[$count]; print "\n
\n"; print "Bet: \$", $bet[$count]; print "\n
"; } } print <<"EOF"; # more html table stuff
EOF # -------------------------------form display starts here ---------------- print "
\n"; print &get_hidden(); # lastbet can't be a cookie, because user enters it sometimes, sometimes it is hidden # insurance routine if ($nobet) { print "$fontstring Bank is too low to $form{action} with your bet!
"} if ($form{'status'} eq "ace_show") { print <<"EOF"; EOF print "\n"; } # replay routine elsif ($form{'status'} eq "new_game" || $form{'status'} eq "deal_show") { print "Bet "; print "\n
"; print "\n"; print "\n"; print "\n"; } else { print " \n", " \n"; @this_hand = @{@pcards[$form{'inplay'}]}; if ($num_cards[$form{'inplay'}] < 2 && &get_value($this_hand[0]) == &get_value($this_hand[1])) { print " \n"; } print" \n"; print "\n"; } if ($use_chat eq 'yes') { print "Chat:
\n"; print "
@chats
\n"; } print "
\n
"; # -----------------------------------print footer ------------------------------------------------ if ($button_code) { print $button_code . "\n" } elsif ($button_link) { print "
\"",$button_alt,"\"

"} else { print " " } print <<"EOF";
EOF exit; } # ------------------------------ GET COOKIE -------------------------------------- sub GetCookies { local(@ReturnCookies) = @_; local($cookie_flag) = 0; local($cookie,$value); @Cookie_Decode_Chars = ('\+', '\%3A\%3A', '\%26', '\%3D', '\%2C', '\%3B', '\%2B', '\%25'); %Cookie_Decode_Chars = ('\+',' ','\%3A\%3A','::','\%26','&','\%3D','=','\%2C',',','\%3B',';','\%2B','+','\%25','%'); if ($ENV{'HTTP_COOKIE'}) { foreach (split(/; /,$ENV{'HTTP_COOKIE'})) { ($cookie,$value) = split(/=/); foreach $char (@Cookie_Decode_Chars) { $cookie =~ s/$char/$Cookie_Decode_Chars{$char}/g; $value =~ s/$char/$Cookie_Decode_Chars{$char}/g; } foreach $ReturnCookie (@ReturnCookies) { if ($ReturnCookie eq $cookie) { $Cookies{$cookie} = $value; $cookie_flag = 1; } } } } return $cookie_flag; } # ----------------------------- SET COOKIE -------------------------------------- sub SetCookies { local(@cookies) = @_; local($cookie,$value,$char); @Cookie_Encode_Chars = ('\%', '\+', '\;', '\,', '\=', '\&', '\:\:', '\s'); %Cookie_Encode_Chars = ('\%','%25','\+','%2B','\;','%3B','\,','%2C','\=','%3D','\&','%26','\:\:','%3A%3A','\s','+'); while( ($cookie,$value) = @cookies ) { foreach $char (@Cookie_Encode_Chars) { $cookie =~ s/$char/$Cookie_Encode_Chars{$char}/g; $value =~ s/$char/$Cookie_Encode_Chars{$char}/g; } print 'Set-Cookie: ' . $cookie . '=' . $value . ';'; print "\n"; shift(@cookies); shift(@cookies); } } # ----------------------------- PRINT HEADER -------------------------------------- sub PrintHeader { $textcol=shift(@_); print "Content-type: text/html\n"; if ($use_cookies eq 'yes') { &SetCookies('pageid',$page_id) } #sends time stamp as a cookie print "\n"; #necessary second newline for header print " Casino Blackjack! "; } #-------------------------------------------------------------------------------------------------------------------------------- sub error{ #this routine is for system errors only. $error = $_[0]; &PrintHeader; print "

". "

We're Sorry.

There was a problem processing the last request.
". "Please notify the webmaster at "; print "$youmail
and include the message below.

We apologize for any inconvenience this may cause.\n"; print "

Error: $error
$!


\n"; print "\n"; exit; }