} elseif (isset($_POST["spell"])) {
if (! is_numeric($_POST["spellid"])) { err("Wrong input."); }
$isavailable = 0;
for ($i = 1; $i < 11; $i++) {
if ($userrow["spell".$i."id"] == $_POST["spellid"]) { $isavailable = 1; }
}
if ($isavailable == 0) { err("You don't have that spell!"); }
include("spells.php");
$castspell = $spells[$_POST["spellid"]]["fname"]($_POST["spellid"]);
$userrow["currentmonsterhp"] -= ($fightrow["playerphysdamage"] + $fightrow["playermagicdamage"] + $fightrow["playerfiredamage"] + $fightrow["playerlightdamage"]);
if ($userrow["currentmonsterhp"] <= 0) { youwin(); }
monsterturn();
if ($userrow["currenthp"] <= 0) { youlose(); }
updateuserrow();
$pagerow = array(
"message"=>$castspell,
"monstername"=>$monsterrow["name"],
"monsterhp"=>$userrow["currentmonsterhp"],
"playerphysdamage"=>$fightrow["playerphysdamage"],
"playermagicdamage"=>$fightrow["playermagicdamage"],
"playerfiredamage"=>$fightrow["playerfiredamage"],
"playerlightdamage"=>$fightrow["playerlightdamage"],
"monsterphysdamage"=>$fightrow["monsterphysdamage"],
"monstermagicdamage"=>$fightrow["monstermagicdamage"],
"monsterfiredamage"=>$fightrow["monsterfiredamage"],
"monsterlightdamage"=>$fightrow["monsterlightdamage"],
"track"=>$fightrow["track"]);
$pagerow["spells"] = dospellslist();
display("Fighting",parsetemplate(gettemplate("fight_turn"),$pagerow));