#!/usr/bin/perl ########################################################## # CGI Casino Blackjack v 2.4 # # Copyright Jason C Fleming GFI Internet Design Group # # www.gfinternet.com € slpypete@bellsouth.net # # cannabalized from a blackjack program by Andru Luvisi # # http://andru.sonoma.edu/~luvisi # # This program is shareware; if you like it and use it # # on your website, please send $10 to GFI Internet, P.O. # # Box 82, Antioch, TN 37011-0082. # # # # Revision History # # v2.4 reduced size of playing area because a lot of # # you folks dont have high res monitors. # # -- fixed bug in html table in play area # # -- fixed bug in banner display routine # # v2.3 included real card image option # # -- fixed spacing on dealer blackjack # # v2.2 # # -- included check url routine to block remote posts # # -- option to use cookies to prevent the user from # # using browser back button to influence play # # -- checks bet and deck input for numeric only data # # -- displays number of decks with shoe # # -- reduced max bet from 99999 to 9999 # # -- option to place ad banner on output # # # # v2.1 removes delimiters and html tags from input in # # high score routine that allowed users to enter # # hyperlinks and replace their score with comments # # Thanks to James Crasta, jcrasta@optonline.net # # for spotting v2.0 bugs and suggesting solutions # # # # v2.0 added statistics on quit to rate strategy # # -- added split option and reconfigured logic to # # support multiple hands # # -- added instant blackjack for both dealer and player # # -- added bets on each hand and remember last bet # # -- fixed bug on double routine making it possible # # for dealer to bust # # -- simplified soft ace algorithm # # -- changed html output to be more game-friendly # # -- added insurance on dealer ace showing # # -- added display of deck as it is depleted # # -- other little tweaks - too many to mention # # # # Upcoming features in v 3.0 include multi player online # # bet in escrow will subtract bet before game # # and standard chip increments on bets # # # ########################################################## #--------- CUSTOMIZE HERE ------------ $home_page = "http://GameTeaser.com/"; #the page that launches this script $cgi_location = "GameTeaser.com/cgi/games/21/"; #the domain and directory of 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. If you wish to use the cookie routine, #you will need to get cookie.lib from Matts Script Archive and install it in the #directory with this script. require 'cookie.lib'; #comment this line if not using cookies $use_cards = 'yes'; #set this to 'no' if you do not want to use the card images $image_url = 'images'; #if you use the cards, set this to the folder they are in #before you add a banner, please remember how annoying they are, esp. if slow . . . #also note that the banner gets placed at the bottom of the play screen # (where people will be clicking anyway) $banner_image = ''; #if you want to place a banner ad, put the image location here $banner_link = ''; #if you are placing a banner, put the link here $banner_height = ""; #enter the height of the banner here $banner_width = ""; #enter the width of the banner here $banner_alt = ''; #enter alternate text here) $banner_comment = ''; #enter alternate text here) #---------- END OF CUSTOMIZATION ------------------- @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 = ($home_page, $cgi_location); # Check Referring URL - must be either the home page or the script itself &check_url; #------------------------------------- MAIN ROUTINE ------------------------------- if($ENV{'REQUEST_METHOD'} eq "POST") { for ($i=0; $i<$ENV{'CONTENT_LENGTH'}; $i++) { $form .= getc; } if($form) { %form = &parseForm($form); } } if($ENV{'REQUEST_METHOD'} ne "POST" || !$form{'action'}) { # --------------------------- DISPLAY WELCOME SCREEN -------------------------------------- #print header and set up table print "Content-type: text/html\nPragma: no-cache\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!
Casino Blackjack
Basic Rules:
  • Beat the dealer by getting as close to 21 as possible without "busting."
  • If the dealer shows an ace, you can pay an "insurance fee" (1/2 of your bet). Then, if the dealer draws a blackjack, insured players do not lose their bet, only the fee.
  • Dealer automatically wins with a blackjack (unless the player was dealt a Blackjack, which is a push).'
  • A Blackjack (Ace and a Ten or Face Card) pays 3-2.
You can also:
  • Split hands on doubles (matching your bet)
  • Double down (double your bet and get one more card).
The server generates a "shoe" of cards, depending on how many decks you decide to use.
Every game draws unique cards, just as if it were a casino. As the game progresses, the deck will diminish, automatically re-shuffling when it hits the "marker" (3/4 through the deck).
You start the game with \$1000, and you can carry a negative balance.
Statistics will be shown when you quit. Top ten high scorers are displayed. EOT print "
\n"; print "How many decks would you like to play with:\n"; print "\n", "

", "", "How much for your initial bet?\n", "\n", "\n", "\n", "\n", "\n", "      \n", "

"; print <<"EOF";
EOF exit; } # ------------------------------ PARSE HIDDEN VARIABLES -------------------------------------- # get form input and set up variables and arrays if ($use_cookies eq 'yes') { if (&GetCookies()) { #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'}) { print "Content-type: text/html\nPragma: no-cache\n\n"; print < Casino Blackjack!
An attempt was made to trick the dealer.
Cheating will not be tolerated in this casino.
EOT print "

"; print <<"EOF";
EOF exit; } } } @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]); } @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; @bet = split (/,/, $form{'bet'}); $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); #---------------------------- QUIT/STATS ROUTINE --------------------------- if ($form{'action'} eq 'quit') { print "Content-type: text/html\nPragma: no-cache\n"; if ($use_cookies eq 'yes') { &SetCookies('pageid',$page_id) } #sets time stamp on quit routine if ($form{'name'} eq 'jrrjrhere') {print "Location: http://www.gfinternet.com/easteregg.html\n"} print "\n"; print < Casino Blackjack!
\n"; print "
Casino Blackjack
EOT $fontstring = ''; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
",$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]," 
"; open (SCORES, ") { $scores[$count] = $_; chomp($scores[$count]); $count++; } close (SCORES); if ($form{'name'}) { #insert player high score into array $form{'name'} =~ s/\`/ /g; $form{'name'} =~ s/[<>]/ /g; if ($form{'name'} =~ /href/) {$form{'name'} = 'No unsolicited links, please.'} $entry = $form{'name'} . "\`" . $form{'bank'}; $this_row = $form{'location'}; #locates position in hall of fame while ($this_row < 10) { push (@temp_scores, $scores[$this_row]); #moves everything from player score down to new array $this_row++; } unshift (@temp_scores, $entry); #move player score into new array $this_row = $form{'location'}; while ($this_row) { unshift (@temp_scores, $scores[$this_row-1]); #moves any higher scores into new array $this_row--; } open (SCORES, ">high_scores.txt") || die ("High Scores Database has spontaneously combusted!"); for ($count = 0; $count < 10; $count++) { print SCORES $temp_scores[$count],"\n"} close (SCORES); @scores = @temp_scores } for ($count = 0; $count < 10; $count++) { #displays high scores @name_num = split(/\`/,$scores[$count]); $name[$count] = $name_num[0]; $score[$count] = $name_num[1]; print "\n"; #flags location of player highscore if (!$form{'name'} && !$replace && $form{'bank'} > $score[$count]) {$replace++;$location = $count;} } print "
",$fontstring,"High Scores:
",$fontstring,$name[$count],"",$fontstring,"\$",$score[$count],"
\n"; print "
\n"; print &get_hidden; if ($replace) { print $fontstring,"You achieved a high score!
\n"; print "Your Name: \n"; print "\n"; print "\n"; print "\n"; print "
\n"; } else { print "\n"; print "\n"; print "\n"; } print "

\n"; print <<"EOF";
EOF exit; } #---------------------------- PLAY ROUTINE --------------------------- elsif ($form{'action'} eq "Play"){ if($#acards > $form{'decks'}*39) { $form{'shuffled'} = 1; @acards = (); %acards = (); } #deal the first round of cards $form{'inplay'} = 0; $form{'splits'} = 0; $bet[0] = $form{'lastbet'}; @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]; } else{ $stats[3]++; $hand_status[0] = "Push" } $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"; $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"){ $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"){ #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"){ @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!"; $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); $form{'status'} = "new_game"; $stats[1]++; $stats[6]++; &DispScr; } $form{'status'} = "inplay"; &DispScr; exit; } elsif ($form{'action'} eq "noinsure"){ @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]; } else{ $stats[3]++; $hand_status[0] = "Push" } $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"; $stats[6]++; &DispScr; } $form{'status'} = "inplay"; &DispScr; exit; } else{ exit; } #--------------- END OF MAIN ROUTINE -------------------------------- sub check_url { # Localize the check_referer flag which determines if user is valid. # local($check_referer) = 0; # If a referring URL was specified, for each valid referer, make sure # # that a valid referring URL was passed. # if ($ENV{'HTTP_REFERER'}) { foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) { $check_referer = 1; last; } } } else { $check_referer = 1; } # If the HTTP_REFERER was invalid, send back an error. # if ($check_referer != 1) { print "Content-type: text/html\nPragma: no-cache\n\n"; print < Casino Blackjack!
Click here to play 21.
EOT print "

"; print <<"EOF";
EOF exit; } } 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"; } 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) { for ($count = 0; $count <= $form{'splits'}; $count++) { if ($hand_status[$count] eq "BUST!") { $stats[4]++; $form{'bank'} -= $bet[$count]; $hand_status[$count] .= "
Lose \$".$bet[0]; $stats[0]++; $stats[6]++; } elsif ($hand_status[$count] eq "BLACKJACK!") { $stats[1]++; $stats[2]++; $form{'bank'} += int($bet[$count]*1.5); $hand_status[$count] .= "
Win \$".int($bet[0]*1.5); $stats[6]++; } else { while(&get_total(@dcards) < 17){ @dcards = (@dcards, &get_card) } @this_hand = @{@pcards[$count]}; if (&get_total(@dcards) > 21) { $stats[1]++; $form{'bank'} += $bet[$count]; $hand_status[$count] = "WIN \$".$bet[$count]."!"; $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]."!"; $stats[6]++; } elsif (&get_total(@this_hand) < &get_total(@dcards)) { $stats[0]++; $form{'bank'} -= $bet[$count]; $hand_status[$count] = "Lose \$".$bet[$count]; $stats[6]++; } else { $stats[3]++; $hand_status[$count] = "Push"; $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) } } # ---------- Standard Parsing Routine (Used with permission) ---------- # %form = &parseForm($form) # # takes the encoded output from a form and decodes them # into an associative array. # # $form # The encoded output from an HTML form # # %form # An associative array where: # keys: item names # values: item values # sub parseForm { local($input) = @_; local($one_item, $key, $value); @input = split(/&/,$input); foreach $one_item (@input) { $one_item =~ s/\+/ /g; ($key, $value) = split(/=/,$one_item); $key =~ s/%(..)/pack("c",hex($1))/ge; $value =~ s/%(..)/pack("c",hex($1))/ge; $form{$key} = $value } return %form; } # ------------------------------- DISPLAY PLAY SCREEN -------------------------------------- sub DispScr { #print header and set up table print "Content-type: text/html\nPragma: no-cache\n"; if ($use_cookies eq 'yes') { &SetCookies('pageid',$page_id) } #sets time stamp on play routine print "\n"; print <<"EOF"; Casino Blackjack!
Casino Blackjack
Dealer
EOF # --------------------------insert dealer display card routine here ---------------------------- #if dealer_show, show all cards otherwise just upcard 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)) * 25); #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 print "\$", $form{'bank'}, "
\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 if ($form{'status'} ne "ace_show"){ #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""; for ($count = 0; $count <= $form{'splits'}; $count++) { 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
"; } else { print "Insurance\?"; } 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 ($form{'status'} eq "ace_show") { print <<"EOF"; Yes No EOF print "\n"; } # replay routine elsif ($form{'status'} eq "new_game" || $form{'status'} eq "deal_show") { print "Bet "; print "\n

"; print "Play\n"; print "Quit\n"; print "\n"; } else { print "Hit \n", "Stand \n"; @this_hand = @{@pcards[$form{'inplay'}]}; if ($num_cards[$form{'inplay'}] < 2 && &get_value($this_hand[0]) == &get_value($this_hand[1])) { print "Split \n"; } print"Double \n"; print "\n"; } #give link back to website print "\n"; # -----------------------------------print footer ------------------------------------------------ if ($banner_link) { print "

\"",$banner_alt,"\"

"} print <<"EOF";
EOF exit; } # ------------------------------END OF PLAY SCREEN -------------------------------------- 1;