-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMonster.java
More file actions
86 lines (83 loc) · 3.93 KB
/
Monster.java
File metadata and controls
86 lines (83 loc) · 3.93 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
public class Monster extends Character implements AttackJudge {
Monster(String name, int HPMax, int attack, int define, int equipNum) {
this.name = name;
this.HPMax = HPMax;
this.attack = attack;
this.HP = HPMax;
this.define = define;
switch (equipNum) {
case 0:
this.equip = equip1.name;
this.attack += equip1.attack;
this.define += equip1.define;
break;
case 1 :
this.equip = equip2.name;
this.attack += equip2.attack;
this.define += equip2.define;
break;
case 2 :
this.equip = equip3.name;
this.attack += equip3.attack;
this.define += equip3.define;
break;
case 3 :
this.equip = equip4.name;
this.attack += equip4.attack;
this.define += equip4.define;
break;
case 4 :
this.equip = equip5.name;
this.attack += equip5.attack;
this.define += equip5.define;
}
}
@Override
public void attack(Player p, Monster m) {
System.out.println("现在是【" + m.getName() + "】的回合:");
int randNum = (int) (Math.random() * 6);
int finalAttack = this.attack;
String attackName = null;
switch (randNum) {
case 0 :
finalAttack += skill1_monster.attack;
attackName = skill1_monster.name;
break;
case 1 :
finalAttack += skill2_monster.attack;
attackName = skill2_monster.name;
break;
case 2 :
finalAttack += skill3_monster.attack;
attackName = skill3_monster.name;
break;
case 3 :
finalAttack += skill4_monster.attack;
attackName = skill4_monster.name;
break;
case 4 :
finalAttack += skill5_monster.attack;
attackName = skill5_monster.name;
break;
case 5 :
attackName = "重力一击";
}
finalAttack -= p.getDefine();
if (finalAttack > 0) {
p.setHP(p.getHP() - finalAttack);
System.out.println("【" + m.getName() + "】对【" + p.getName() + "】使用了@@" + attackName + "@@,造成了" + finalAttack + "点伤害");
} else System.out.println(m.getName() + "对你没有造成伤害");
System.out.println(m.getName() + "的回合结束。");
}
/*
**显示怪物的血量
*/
@Override
public void show() {
int j;
System.out.print("【" + getName() + "】的血量为:");
for (j = 0; j < getHP() / bloodGrid; j++) System.out.print("■");
for (j = 0; j < (getHPMax() - getHP()) / bloodGrid; j++) System.out.print("□");
System.out.println();
}
}