#!/usr/bin/perl require 'subparseform.lib'; &Parse_Form; @enemycards = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); @playercards = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 7); @enemyhas = (1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1); @playerhas = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); @prizes = (100, 150, 200, 250, 300, MYSTERY, 350, 400, 450, 500, 750); @prizesleft = (1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0); print "Content-type: text/html\n\n"; print "FAMEWHORE: THE GAME"; if (exists $formdata{'gameinprogress'}) { for ($z = 0; $z < 11; ++$z) { $tempname = "playercards" . $z; $playercards[$z] = $formdata{$tempname}; $tempname = "playerhas" . $z; $playerhas[$z] = $formdata{$tempname}; $tempname = "enemycards" . $z; $enemycards[$z] = $formdata{$tempname}; $tempname = "enemyhas" . $z; $enemyhas[$z] = $formdata{$tempname}; $tempname = "prizes" . $z; $prizes[$z] = $formdata{$tempname}; $tempname = "prizesleft" . $z; $prizesleft[$z] = $formdata{$tempname}; } $enemyscore = $formdata{'enemyscore'}; $playerscore = $formdata{'playerscore'}; $roundsleft = $formdata{'roundsleft'}; for ($i = 0; $i < 11; ++$i) { $tempname = "playerpicks" . $i . "\.x"; if (exists $formdata{$tempname}) { $playerchoice = $i; $playerhas[$i] = 0; } } } else { $enemyscore = 0; $playerscore = 0; $roundsleft = 11; } ################################ ## When last we left, this piece of code didn't seem to do a very good job keeping ## the script from choosing an already chosen prize. ## ## Also it seems to be avoiding the mystery prize. $prizechosen = int(rand(11)); until ($prizesleft[$prizechosen] eq "1") { ++$prizechosen; if ($prizechosen eq "11") { $prizechosen = 0; } } $prizesleft[$prizechosen] = 0; --$roundsleft; print "
"; print ""; print ""; print ""; print ""; print ""; print "
$enemyscore
"; &drawenemycards; print "
"; &drawprizes; print ""; print ""; if ($prizes[$prizechosen] eq "mystery") { print "MYSTERY ROUND!"; } else { print "For $prizes[$prizechosen] fame points"; } print "
$playerscore
"; &drawplayercards; print "
"; for ($z = 0; $z < 11; ++$z) { $tempname = $playercards[$z]; print ""; $tempname = $playerhas[$z]; print ""; $tempname = $enemycards[$z]; print ""; $tempname = $enemyhas[$z]; print ""; $tempname = $prizes[$z]; print ""; $tempname = $prizesleft[$z]; print ""; } print ""; print ""; print ""; print ""; print "
"; print ""; sub drawenemycards { for ($i = 0; $i < 11; ++$i) { if ($enemyhas[$i] eq "1") { print " "; } else { print " "; } } } sub drawprizes { print "
"; for ($i = 0; $i < 11; ++$i) { if ($prizesleft[$i] eq "1") { print "" } else { print ""; } print "$prizes[$i]
"; } } sub drawplayercards { for ($i = 0; $i < 11; ++$i) { if ($playerhas[$i] eq "1") { print " "; } else { print " "; } } }