[php]
if (!isset($_SESSION[‘boatperc’])) $_SESSION[‘boatperc’] = 0;
if ($_SESSION[‘hammer’] != true) {
$damage = round($_SESSION[‘boatwood’] * rand(50,80) / 100);
if ($damage > $_SESSION[‘boatwood’]) $damage = $_SESSION[‘boatwood’];
$_SESSION[‘boatwood’] = $_SESSION[‘boatwood’] – $damage;
if ($_SESSION[‘boatwood’] < 0) $_SESSION['boatwood'] = 0;
$_SESSION['boatperc'] = round($_SESSION['boatwood']/10 + $_SESSION['boatperc']);
}
else {
$damage = round($_SESSION['boatwood'] * rand(10,50) / 100);
if ($damage > $_SESSION[‘boatwood’]) $damage = $_SESSION[‘boatwood’];
$_SESSION[‘boatwood’] = $_SESSION[‘boatwood’] – $damage;
if ($_SESSION[‘boatwood’] < 0) $_SESSION['boatwood'] = 0;
$_SESSION['boatperc'] = round($_SESSION['boatwood']/10 + $_SESSION['boatperc']);
}
if ($_SESSION['boatperc'] < 100) {
if ($_SESSION['boatwood'] > 0) {
if ($_SESSION[‘hammer’] != true) {
[/php]the guru picked up a rock and tried to hammer the boat together. because he was so bad at hammering, and also because he was using a rock, he destroyed [php]echo $damage;[/php] pounds of wood. his boat was now [php]echo $_SESSION[‘boatperc’];[/php]% complete.[php]
$_SESSION[‘boatwood’] = 0;
} else {
[/php]
the guru used a hammer to build his boat. it was much better than a rock, but he still destroyed [php]echo $damage;[/php] pounds of wood. his boat was now [php]echo $_SESSION[‘boatperc’];[/php]% complete.[php]
$_SESSION[‘boatwood’] = 0;
}
} else {[/php]
the guru could not do any hammering, because he did not have any wood.[php]
}[/php]
should he go to the woods, his school, or the store?
[php]
} elseif ($_SESSION[‘boatperc’] >= 100) {[/php]
the guru made a boat.
should he drag it into the water?[php]
}[/php]