#!/usr/bin/perl # Eat the StickTM - Copyright (C) 2008 Nathan Kennedy # Redistribution and use permitted with or without modification # or additional terms and conditions, provided that this notice # is retained. No claim made on unoriginal material or on # Eat the StickTM "trademark." open COUNT,"stickcount"; $c = ; chop($i); close(COUNT); open (RF, "/dev/urandom"); binmode(RF); sub roll { do { read(RF, $r, 1); $r = ord $r; } while ($r > 251); $r % 6 + 1; } @rolls=("a two","a three","a four","a five","a six","a seven", "an eight", "a nine","a ten","an eleven","a twelve"); @fails=("Better luck next roll.", "No stick for you.", "The Stick™ eats You.", "Having fun yet?", "Don't give up!", "Keep on rolling."); print "Content-type: text/html\n\n"; print "Eat the Stick™\n"; print "\n"; $d1 = roll(); $d2 = roll(); $s = $d1 + $d2; $sum = $rolls[$s-2]; print "

"; print "

"; print "

You rolled $sum.\n

\n"; if ($s == 9) { print "

Time to Eat the Stick.™

"; print "

\n"; $c++; open COUNT,">stickcount"; print COUNT "$c\n"; close(COUNT); } else { print "

"; print $fails[roll()-1]; print "

\n"; } print "

Try again?

\n"; print "

$c sticks eaten since November 11, 2008.

\n"; print "

Credits: Game by Nathan Kennedy. Concept by Jack McLaren and Pat Spacek. Stick courtesy of Arnold Reinhold. "; print "Die faces courtesy of Nanami Kamimura. Images licensed under GFDL v.1.2.

"; print "\n"; close(RF);