/** * Russian Web Roulette * * (c) Copyright Leon Blackwell 2004/2006 * * Feel free to pick on my code :) */ // The maximum number of bullets define('MAX_BULLETS', 6); // Grab the important POST var $m = $_POST['m']; // Title and heading $heading = $title = 'Russian Web Roulette'; // If we have a bullets param if(isSet($_POST['b'])) { // Set the number of bullets $bullets = $_POST['b']; // Enforce maximum if($bullets > MAX_BULLETS) { $bullets = MAX_BULLETS; } } else { // Assume no bullets $bullets = 0; } // They're not dead (yet) $dead = false; // Do we have an argument if(isSet($m) && ($m != '')) { // We won't need our header unset($heading); // If we're loading a bullet if($m == 'Load Bullet') { // If we have space for another bullet if($bullets < MAX_BULLETS) { // Load another bullet $bullets++; // Add a comment to convince the user to pull the trigger $content = "
Feeling lucky, punk?
\n"; } else { // Inform the user that they can't do this $content = "Your gun is already full.
\n"; } } else if($m == 'Pull Trigger') { // If we have bullets loaded if($bullets > 0) { // Randomly decide if they're dead now if(rand(1, MAX_BULLETS) <= $bullets) { $content = "BLAM!!
\n" . "Now who's going to clean up that mess?
\n"; $bullets--; $dead = true; } else { $content = "click
\n" . "Guess this is your lucky day
\n"; } } else { // Inform the user that they might like to load first $content = "Not very risky with an empty gun, is it?
\n"; } } } // If they're dead if($dead) { // Link back so they can start again $content .= "\n"; } else { // Produce a form for input $content .= "\n" ."\n"; } echo "\n"; ?>
# If we have a heading
if(isSet($heading))
{
echo "$heading\n"; echo "A product of The Lost Realm. "; } ?> =$content?> |