-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
48 lines (30 loc) · 1.41 KB
/
scripts.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var playerTurn = 1;
var enemyTurn = 0;
var txt = 'Gaan met die banaan! <br />';
var enemyDead = 0;
function battle() {
var weapon = player.currentWeapon;
if(playerTurn == 1 && enemy_ferri.health > 0){
var attackPower = player.attack + fists.attackBonus;
var enemyHealth = enemy_ferri.health;
var attackBonus = fists.attackBonus;
var hit = Math.floor(Math.random() * attackPower) + attackBonus;
if(enemy_ferri.health - hit > 0 && enemyDead != 1){
enemy_ferri.health -= hit
txt += "You hit " + hit + " to " + enemy_ferri.name + ". He now has " + enemy_ferri.health + "HP left. <br />";
} else {
txt += "You hit " + hit + " to " + enemy_ferri.name + ". He's dead now, good job. <br />";
enemyDead = 1;
}
document.getElementById('tester').innerHTML = txt;
playerTurn = 0;
enemyTurn = 1;
} if(playerTurn != 1 && player.health > 0 && enemyDead != 1) {
var hit = Math.floor(Math.random() * enemy_ferri.attack) + 1;
player.health -= hit
txt += "You got hit for " + hit + ". You now have " + player.health + "HP left. <br />";
document.getElementById('tester').innerHTML = txt;
playerTurn = 1;
enemyTurn = 0;
}
}