-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathDragon.java
More file actions
70 lines (58 loc) · 1.98 KB
/
Dragon.java
File metadata and controls
70 lines (58 loc) · 1.98 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
package org.project.entity.enemies;
import org.project.object.armors.Armor;
import org.project.object.weapons.Weapon;
import org.project.entity.Entity;
public class Dragon extends Enemy {
private static final int FIREBALL_DAMAGE = 30;
private static final int FIREBALL_MANA_COST = 20;
public Dragon(int hp, int mp, Weapon weapon) {
super(hp, mp, weapon);
}
@Override
public void attack(Entity target) {
if (getMp() >= FIREBALL_MANA_COST) {
System.out.println("🔥 Dragon breathes fire!");
target.takeDamage(FIREBALL_DAMAGE);
fillMana(-FIREBALL_MANA_COST);
} else {
super.attack(target);
}
}
@Override
public void takeDamage(int damage) {
int reducedDamage = damage / 2;
super.takeDamage(reducedDamage);
System.out.println("🛡️ Dragon's tough scales reduce damage!");
}
public void fly() {
System.out.println("🐉 Dragon flies into the sky, preparing for a powerful attack!");
}
}
package org.project.entity.enemies;
import org.project.object.weapons.Weapon;
public class Dragon extends Enemy {
private static final int FIREBALL_DAMAGE = 30;
private static final int FIREBALL_MANA_COST = 20;
public Dragon(int hp, int mp, Weapon weapon) {
super(hp, mp, weapon);
}
@Override
public void attack(Entity target) {
if (getMp() >= FIREBALL_MANA_COST) {
System.out.println("🔥 Dragon breathes fire!");
target.takeDamage(FIREBALL_DAMAGE);
fillMana(-FIREBALL_MANA_COST);
} else {
super.attack(target);
}
}
@Override
public void takeDamage(int damage) {
int reducedDamage = damage / 2;
super.takeDamage(reducedDamage);
System.out.println("🛡️ Dragon's tough scales reduce damage!");
}
public void fly() {
System.out.println("🐉 Dragon flies into the sky, preparing for a powerful attack!");
}
}