I’m trying to make a battle simulator where you can select classes to fight each other. I can’t for the life of me understand what i’m doing wrong!
[code]
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<!–[if IE]>
<script src=”http://html5shiv.googlecode.com/svn/trunk/html5.js”></script>
<![endif]–>
<link href=”CSS/styles.css” type=”text/css” rel=”stylesheet” />
<script type=”text/javascript”>
var monsters = {
reaper : { hitpoints: 250, strength : 17, luck : 3 },
dragon : { hitpoints: 1000, strength: 50, luck : 5},
orc : { hitpoints: 100, strength: 12, luck : 2 },
ogre: { hitpoints: 50, strength: 10, luck: 1 }
}
function startFight()
{
charFightHP = charHP;
beastFightHP = beastHP;
fightTrue = 1;
charDmg = charStr – beastDef;
beastDmg = beastStr – charDef;
beastName = document.getElementById(“theBName”).innerHTML;
if (charDmg < 0)
{
charDmg = 0;
}
else if (beastDmg < 0)
{
beastDmg = 0;
}
while (fightTrue != 0)
{
if (charFightHP > 0 && beastFightHP > 0)
{
charFightHP = beastDmg – charFightHP;
beastFightHP = charDmg – beastFightHP;
alert(“You do “+charDmg+” damage to “+beastName+”. “+beastName+” does “+beastDmg+” damage to you.”);
document.getElementById(“theHP”).innerHTML = charFightHP;
document.getElementById(“theBHP”).innerHTML = beastFightHP;
}
else{
fightTrue = 0;
}
}
if (beastFightHP < 0 && charFightHP > 0)
{
fightWin();
}
if (charFightHP < 0)
{
alert(“You are dead”);
createChar();
}
}
</script>
</head>
<header>
<div style=”clear:both;”></div>
</header>
<body>
<div id=”content”>
<form class=”form”>
<h2>Simulator</h2>
<field name=”fieldName” static=”true” type=”FieldType” value=”code”>Strength</field>
<input type = “text” value=”300″ disabled=”disable” id=”hitpoints” />
<input type = “text” value=”100″ disabled=”disable” id=”strength” />
<input type = “text” value=”100″ disabled=”disable” id=”luck” />
<select>
<option>Dragon</option>
<option>Orc</option>
<option>Ogre</option>
<option>Reaper</option>
</select>
<input type=”button” value=”Fight” onclick=”startFight()”;/>
</form>
</div>
</body>
<footer>
</footer>
</html>