/* Powerstone php3 script
Copyright 2003 by Jeff Wilson
v1.0 Jan 30 2003
*/
?>
Powerstone Analysis
Powerstone Analysis
mt_srand((double)microtime()*1000000);
$carats=100;
$castings=0;
$quirks=0;
$successes=0;
$size=0;
$lastquirk=0;
$destroyed=0;
$stunted=0;
while (($size<$carats) and ($destroyed==0) and ($stunted==0)) {
$castings+=1;
$dietotal=0;
$diestring="";
for ($i=1; $i<=3; $i++) {
$thisdie=mt_rand(1,6);
$dietotal=$dietotal+$thisdie;
$diestring=$diestring."$thisdie,";
}
$diestring=substr($diestring,0,strlen($diestring)-1);
if ($dietotal<6):
$result="Critical Success!";
$successes+=1;
$size+=1;
$lastquirk=0;
elseif ($dietotal<16):
$result="success";
$successes+=1;
$size+=1;
$lastquirk=0;
elseif ($dietotal==16):
$result="Failure!";
$quirks+=1;
if ($lastquirk):
$stunted=1;
$result="Failure! - Stunted!";
else:
$lastquirk=1;
endif;
else:
$result="Critical Failure!";
$destroyed=1;
endif;
echo "$diestring - $dietotal - $result
\n";
}
echo "
\n";
echo "carats=$carats
\n";
echo "castings=$castings
\n";
echo "quirks=$quirks
\n";
echo "successes=$successes
\n";
echo "size=$size
\n";
echo "lastquirk=$lastquirk
\n";
echo "destroyed=$destroyed
\n";
echo "stunted=$stunted
\n";
?>
View script source.