Javascript: Dragon game
var slaying = true;
var youHit = Math.floor(Math.random()*2);
var damageThisRound = Math.floor(Math.random()*2);
var totalDamage = 0;
while(slaying)
{
if(youHit)
{
console.log("Nice - you've just hit black dragon");
totalDamage += damageThisRound;
if(totalDamage>=4)
{
console.log("HOLY SHIT - YOU JUST KILL A DRAGON")
slaying = false;
}
else
{
youHit = Math.floor(Math.random() * 2);
}
}
else
{
console.log("You missed the dragon - that means you dead")
}
slaying = false;
}
console.log(youHit);