-
Notifications
You must be signed in to change notification settings - Fork 0
/
two-girl.html
58 lines (53 loc) · 1.34 KB
/
two-girl.html
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
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Document</title>
<link rel="stylesheet" href="">
<<script type="text/javascript">
var zeng={
name:"Xing-dog",
attack:80,
hp:600,
speed:80,
skill:["bite you","high jump","book touch"],
birth:1997
};
var he={
name:"Bear-sisiter",
attack:60,
hp:800,
speed:50,
skill:["angry","big push","qinqin"],
birth:1997
};
function whoFirst(){
if (zeng.speed*Math.random()>he.speed*Math.random()) {
return [zeng, he];
}
else{
return [he, zeng]
}
}
function game(){
var arr=whoFirst();
var attacker=arr[0];
var defender=arr[1];
defender.hp=defender.hp-attacker.attack;
var skills=attacker.skill;
var attackskill=skills[Math.floor(Math.random()*skills.length)];
document.write(attacker.name + ' use a skill <b>' + attackskill + "</b><br/>");
document.write(defender.name + ' left hp ' + defender.hp + "<br/>");
document.write(attacker.name + ' left hp ' + attacker.hp + "<br/><hr/>");
var out=setTimeout("game()",1500)//run game per 1500ms
if (defender.hp<=0) {
document.write(attacker.name + " win!")
clearTimeout(out);
}
}
</script>
</head>
<body onload="game()">
</body>
</html>