|
#!/usr/bin/perl
BEGIN {open (STDERR, ">error.txt");}
$|=1; ## Don't buffer output
#################################################
# thanks to Lincoln Stein for creation of CGI.pm #
#################################################
use CGI qw/:standard/;
# MAIN Loop
&getCookies();
&getParams();
&initalize();
&getTicket();
if(!$myCash) { $myCash = 10000;}
print header;
print start_html("$company\'s $progName $version $ver_date");
print "$bdy$company\'s $progName $version";
if($ticket[1] == 0) { &errors('zeroTicket'); &formBottom(); exit 0;}
if($showPaytable) { &showPaymentTable(); &formBottom(); exit 0;}
&checkLowestPay();
&checkBonus();
&checkThree();
&calcCash();
if ( ($bonusFound > 0) && ($payTable[$bonusSprite] eq "BONUSROUND") ) { &playBonus; &formBottom(); exit 0;}
&drawBoard();
print end_html;
exit 0;
# subs
sub getCookies {
$cdata = $ENV{'HTTP_COOKIE'};
@pairs = split(/~/, $cdata);
foreach $pair (@pairs) {
$pair{$pair} = $pair;
$Data[$i] = $pair;
$i += 1;
#print "$pair{$pair}
Return to Games Directory "; print " "; print "*insane laughter*";; } sub noParam { print "No Parameters"; } sub formBottom { print start_multipart_form(); #print ""; #print " "; print ""; print "Show Paytable "; print "My Checkbox "; #print ""; #print " "; print submit(-label=>'Do it :)'); print end_form; } sub calcCash () { $totalPaid = ($payTable[$lowSprite] * $low1SpritePay * $totalLowest); $totalPaid += ($payTable[$lowSprite] * $low2SpritePay * $lowestDoubles); $totalPaid += ($payTable[$lowSprite] * $low3SpritePay * $lowestTriples); if ($payTable[$bonusSprite] ne "BONUSROUND") { $totalPaid += ($payTable[$bonusSprite] * $bonusFound);} $tempCount = 0; foreach $tripFound (@tripples) { if ( $tripFound ne "") { $totalPaid += $payTable[$tripFound];} $tempCount++; } $myCash = $myCash + $totalPaid - 1; } sub mySort() { @getVars = @_; $sortString = ""; foreach $myTemp (@getVars){ $sortString = "$sortString$myTemp~";} return($sortString); } sub playBonus() { print "BONUS Round :)..."; } sub checkLowestPay { $lowestTriples = 0; $lowestDoubles = 0; $totalLowest = 0; ######################### # Find Singles # ######################### for($i=1;$i<($arrayLength+1);$i++){ if($ticket[$i] eq $lowSprite){ $totalLowest++;} } ######################### # Find Doubles # ######################### if(($ticket[1] eq $ticket[2]) && ($ticket[1] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 1 if(($ticket[2] eq $ticket[3]) && ($ticket[2] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 1 if(($ticket[4] eq $ticket[5]) && ($ticket[4] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 2 if(($ticket[5] eq $ticket[6]) && ($ticket[5] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 2 if(($ticket[7] eq $ticket[8]) && ($ticket[7] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 3 if(($ticket[8] eq $ticket[9]) && ($ticket[8] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 3 if(($ticket[1] eq $ticket[4]) && ($ticket[1] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 1 if(($ticket[4] eq $ticket[7]) && ($ticket[4] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 1 if(($ticket[2] eq $ticket[5]) && ($ticket[2] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 2 if(($ticket[5] eq $ticket[8]) && ($ticket[5] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 2 if(($ticket[3] eq $ticket[6]) && ($ticket[3] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 3 if(($ticket[6] eq $ticket[9]) && ($ticket[6] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 3 if(($ticket[1] eq $ticket[5]) && ($ticket[1] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # LDiag if(($ticket[5] eq $ticket[9]) && ($ticket[5] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # LDiag if(($ticket[3] eq $ticket[5]) && ($ticket[3] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # RDiag if(($ticket[5] eq $ticket[7]) && ($ticket[5] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # RDiag if(($ticket[1] eq $ticket[3]) && ($ticket[1] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 1 if(($ticket[1] eq $ticket[7]) && ($ticket[1] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 1 if(($ticket[1] eq $ticket[9]) && ($ticket[1] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # LDiag if(($ticket[3] eq $ticket[7]) && ($ticket[3] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # RDiag if(($ticket[4] eq $ticket[6]) && ($ticket[4] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 2 if(($ticket[2] eq $ticket[8]) && ($ticket[2] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 2 if(($ticket[7] eq $ticket[9]) && ($ticket[7] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Row 3 if(($ticket[3] eq $ticket[9]) && ($ticket[3] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # Col 3 #if(($ticket[2] eq $ticket[4]) && ($ticket[2] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # ULMiddleDiag #if(($ticket[2] eq $ticket[6]) && ($ticket[2] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # URMiddleDiag #if(($ticket[4] eq $ticket[8]) && ($ticket[4] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # LLMiddleDiag #if(($ticket[6] eq $ticket[8]) && ($ticket[6] eq $lowSprite)) { $lowestDoubles++; $totalLowest=$totalLowest-2;} # LRMiddleDiag ######################### # Find Tripples # ######################### if(($ticket[1] eq $ticket[2]) && ($ticket[2] eq $ticket[3]) && ($ticket[1] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[4] eq $ticket[5]) && ($ticket[5] eq $ticket[6]) && ($ticket[4] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[7] eq $ticket[8]) && ($ticket[8] eq $ticket[9]) && ($ticket[7] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[1] eq $ticket[4]) && ($ticket[4] eq $ticket[7]) && ($ticket[1] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[2] eq $ticket[5]) && ($ticket[5] eq $ticket[8]) && ($ticket[2] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[3] eq $ticket[6]) && ($ticket[6] eq $ticket[9]) && ($ticket[3] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[1] eq $ticket[5]) && ($ticket[5] eq $ticket[9]) && ($ticket[1] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if(($ticket[3] eq $ticket[5]) && ($ticket[5] eq $ticket[7]) && ($ticket[3] eq $lowSprite)){ $lowestTriples++; $lowestDoubles = $lowestDoubles - 3; $totalLowest = $totalLowest + 3;} if($totalLowest < 0) { $totalLowest = 0;} if($lowestDoubles < 0) { $lowestDoubles = 0;} return; } sub checkBonus { $bonusFound = 0; for($i=1;$i<($arrayLength+1);$i++){ if($ticket[$i] eq $bonusSprite){ $bonusFound++;} } } sub checkThree { # Counts made in order # @tripples = ("", "", "", "", "", "", "", "", "", "") <-- Replace 1-9 with symbol received if( ($ticket[1] eq $ticket[2]) && ($ticket[2] eq $ticket[3]) && ($ticket[1] ne $lowSprite) ){ $tripples[1] = $ticket[1]; if ($ticket[1] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # Row 1 if( ($ticket[4] eq $ticket[5]) && ($ticket[5] eq $ticket[6]) && ($ticket[4] ne $lowSprite) ){ $tripples[2] = $ticket[4]; if ($ticket[4] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # Row 2 if( ($ticket[7] eq $ticket[8]) && ($ticket[8] eq $ticket[9]) && ($ticket[7] ne $lowSprite) ){ $tripples[3] = $ticket[7]; if ($ticket[7] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # Row 3 if( ($ticket[1] eq $ticket[4]) && ($ticket[4] eq $ticket[7]) && ($ticket[1] ne $lowSprite) ){ $tripples[4] = $ticket[1]; if ($ticket[1] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # Col 1 if( ($ticket[2] eq $ticket[5]) && ($ticket[5] eq $ticket[8]) && ($ticket[2] ne $lowSprite) ){ $tripples[5] = $ticket[2]; if ($ticket[2] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # Col 2 if( ($ticket[3] eq $ticket[6]) && ($ticket[6] eq $ticket[9]) && ($ticket[3] ne $lowSprite) ){ $tripples[6] = $ticket[3]; if ($ticket[3] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # Col 3 if( ($ticket[1] eq $ticket[5]) && ($ticket[5] eq $ticket[9]) && ($ticket[1] ne $lowSprite) ){ $tripples[7] = $ticket[1]; if ($ticket[1] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # \\ if( ($ticket[3] eq $ticket[5]) && ($ticket[5] eq $ticket[7]) && ($ticket[3] ne $lowSprite) ){ $tripples[8] = $ticket[3]; if ($ticket[3] eq $bonusSprite) { $bonusFound = $bonusFound - 3}} # / return; } sub parceName { $wooper = $_[0]; $offset = 1; $bump = 0; while (($bump != 1) && ($wooper ne "") ) { $tmpString = substr ($wooper, -$offset, 1); if ($tmpString eq ".") { $bump = 1;} else { $offset++;} $retName = substr ($wooper, -$offset-1, 1 ); } return($retName); } sub getLastOfPath { $passVar = $_[0]; $count= 0; $offset = 1; $blk = 0; $tmpString = ""; $tempX = "\/"; $passVar =~ s/\\/\//g; # convert Win/Dos to UNIX $passVar =~ s/:/\//g; # convert Mac to UNIX while ($blk != 1) { $tmpString = substr ($passVar, -$offset, 1); if ($tmpString eq $tempX) { $blk =1;} else { $offset++;} $count++; if ($count > 300) { $blk =1;} } $start = ($offset-1); $retName = substr ($passVar, -$start, $start ); return ($retName); } sub showPaymentTable { $pay1Low = $payTable[$lowSprite] * $low1SpritePay; $pay2Low = $payTable[$lowSprite] * $low2SpritePay; $pay3Low = $payTable[$lowSprite] * $low3SpritePay; print "
Error WOOPERNARFLES ;)..."; } if ($error eq 'zeroTicket') { print " Ticket Error... "; print "I'm sorry; however there was an error reading the ticket :("; } if ($error eq '3') { print " Error 3 ;)..."; } if ($error eq '4') { print " Error 4 ;)..."; } if ($error eq '5') { print " Error 5 ;)..."; } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||