Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var slaying = true;
- var youHit = Math.floor(Math.random() * 2);
- var damageThisRound = Math.floor(Math.random() * 5 + 1);
- var totalDamage = 0;
- while(slaying) {
- if(youHit) {
- console.log("Nice! You hit the dragon!");
- totalDamage += damageThisRound;
- if(totalDamage >= 4) {
- console.log("Kablamo! You have slain the dragon!");
- slaying = false;
- } else {
- youHit = Math.floor(Math.random() * 2);
- }
- } else {
- console.log("Smooth move Ferguson. You missed and have been burnt to a crisp by the dragon");
- slaying = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement