Slay the Dragon - game extended


#1

Hey guys, this is my version of the game.. It takes 8 damages to kill Dragon. Only 3 total hits and 3 total misses are allowed on the Dragon to be fair with the Dragon.
Any suggestions to make it better/shorter/more logical ?

var slaying = true;
var youHit = Math.floor(Math.random() * 2);
var damageThisRound = Math.floor(Math.random()*8 + 1);
var totalDamage = 0;
var hitThisRound = 0;
var totalHits = 0;
var missThisRound = 0;
var totalMiss = 0;

    while(slaying) {
        if (youHit) {
            //Calculate total hits
            var hitThisRound = 1;
            totalHits += hitThisRound;
            //Only 3 hits are allowed, after that you loose to Dragon
            if (totalHits <= 3) {
				console.log("You hit it");
				totalDamage += damageThisRound;
                if (totalDamage <= 4) {
                    console.log ("You did only " + totalDamage + " damage! hit again.");
                    youHit = Math.floor(Math.random() * 2);
                } else if (totalDamage < 8) {
                    console.log ("You did only " + totalDamage + " damage! hit again.");
                    youHit = Math.floor(Math.random() * 2);
                } else {
                    console.log ("You did " + totalDamage + " damage. Victory!");
                    slaying = false;
                };
			}	else {
					console.log ("You lost all the chances, Dragon gets to enjoy a nice toast!");
					slaying = false;
			};
  
        } 	
        // You can miss 3 times total
        else {
                if (!youHit) {
                    var missThisRound = 1;
                    totalMiss += missThisRound;
                    if (totalMiss === 1) {
                         console.log("You missed it once");
                         youHit = Math.floor(Math.random() * 2);
                    }	else if (totalMiss === 2) {
                         console.log("You missed it twice");
                         youHit = Math.floor(Math.random() * 2);
                    }	else {
                        console.log ("You missed three times and lost your life to the Dragon!");
                        slaying = false;
                    }
                };
        };
        
    };