What if I write totalDamage+=damageThisRound outside the if statement?


#1

What if I write totalDamage+=damageThisRound outside the if statement???


#2

Depends on where you move it to. Currently the idea is that if you hit the dragon you add the damage dealt this round to the total damage and if this value exceeds a certain value you killed the dragon. So it's kind of like HP for the dragon. If you put it before the while loop you'll have one hit without condition but will than not be able to hit again.