-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.js
More file actions
28 lines (27 loc) · 726 Bytes
/
game.js
File metadata and controls
28 lines (27 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
confirm("do you really want to play this game and kill a dragon?"){
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 = true)
{
console.log("You hit the dragon!");
totalDamage += damageThisRound;
if(totalDamage >= 4) {
console.log("You have killed the dragon!");
slaying = false;
}
else {
youHit = Math.floor(Math.random() * 2);
}
}
else {
console.log("The dragon incinerated you!");
}
slaying = false;
}
}
else {
console.log("Then go away.");
}