I'm creating a combat engine for a game i'm working on and i'm have a problem wich i can't seem to figure out, one problem is that the "while" function doesn't stop.
if(isset($_POST['submit'])){
echo "You have encountered a level ".$monster['lvl']." ".$monster['monster']."<p>";
if(isset($_POST['submit']) && !isset($_POST['fight'])){
echo "<form method='post' action='".$self."'><input type='submit' name='fight' value='Attack the ".$monster['monster']."'><input type='hidden' name='submit'><input type='hidden' name='fight'></form>";
}
if(isset($_POST['fight'])){
while($stats['curhp']>=1 && $monster['curhp']>=1){
if($stats['bab']+$rand>=$monster['ac']){
echo "You penetrated the ".$monster['monster']."'s armour and took ".$damage." Hitpoints";
mysql_query("UPDATE `monster` SET `curhp`=`curhp`-'".$damage."' WHERE `monster`='".$monster['monster']."' AND `lvl`='".$monster['lvl']."' LIMIT 1");
}else{
echo "Your attack was unsuccesfull";
}
if($monster['bab']+$rand>=$stats['body']+$stats['shield']){
echo "The monster penetrated your armour and took ".$mdamage." Hitpoints";
mysql_query("UPDATE `stats` SET `curhp`=`curhp`-'".$mdamage."' WHERE `id`='".$_SESSION['id']."' LIMIT 1");
if($mdamage>$stats['curhp']){
$mdamage=$stats['hp'];
}else{
$mdamage=rand(1,4)+$monster['str'];
}
}
if($stats['curhp']<=0){
echo "You were killed by the monster";
}
if($monster['curhp']<=0){
echo "You slew the monster";
mysql_query("UPDATE `monster` SET `curhp`=`maxhp` WHERE `monster`='".$monster['monster']."' AND `lvl`='".$monster['lvl']."' LIMIT 1");
}
}
}
}