$title = "Your move."; $rules = "lethe.shtml#rules"; $url = "game2.php"; $win = "hmmm.shtml"; $start_coins = '24'; include("comic_header.php"); # # TODO: Put in some error checking code to make sure # we got a legal move! # $move = (isset($_GET['move']))? $_GET['move'] : $start_coins; list($coins, $take) = explode('_',$move); echo("
");
if (!isset($take)) {
echo("We start with $coins coins. ");
if ($coins <= 1) {
echo("You have no valid moves. You lose!
\n");
$mode = 1;
} else {
echo("It's your move.
\n");
$mode = 0;
}
} else {
$label = "coins";
if ($coins == 1) { $label = "coin"; }
echo("You started your turn with $coins $label on the table.
\n");
$coins = $coins - $take;
echo("You took $take coins, leaving $coins.
\n");
if ($coins <= 1) {
echo("I have no valid moves. You win!
\n");
$mode = 2;
} else if ($coins <= 4) {
echo("I take $coins coins, leaving the table empty. I win!
\n");
$coins = 0;
$mode = 1;
} else if ($coins == 5) {
echo("I take 4 coins, leaving 1. I win!
\n");
$coins = 1;
$mode = 1;
} else {
$mod = $coins % 6;
if ($mod >= 2 && $mod <= 4) {
$take = $mod;
} else if ($mod == 5) {
$take = 4;
} else {
$take = rand(2,4);
}
$coins = $coins - $take;
echo("I take $take coins, leaving $coins. Your move.
\n");
$mode = 0;
}
}
if ($mode == 0) {
?>
Will you Review the rules? or Try again?"); } else { echo("
Will you Claim your prize? or Play again?"); } echo("
");
for ($i = 0; $i < $coins; $i++) {
echo("");
if (($i % 5) == 4) { echo("
"); }
}
$credit="Nero coin: Bob Wister, Seton Hall University";
include("comic_footer.php");
?>