-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathSkeleton.java
More file actions
34 lines (28 loc) · 924 Bytes
/
Skeleton.java
File metadata and controls
34 lines (28 loc) · 924 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
28
29
30
31
32
33
34
package org.project.entity.enemies;
import org.project.object.armors.Armor;
import org.project.object.weapons.Weapon;
import org.project.entity.Entity;
import java.util.Random;
public class Skeleton extends Enemy {
private boolean resurrected = false;
public Skeleton(int hp, int mp, Weapon weapon) {
super(hp, mp, weapon);
}
@Override
public void takeDamage(int damage) {
int finalDamage = damage;
if (weapon != null) {
finalDamage *= 0.75;
}
super.takeDamage(finalDamage);
System.out.println("🦴 Skeleton resists some damage!");
if (getHp() == 0 && !resurrected) {
Random rand = new Random();
if (rand.nextBoolean()) {
resurrected = true;
heal(getMaxHP() / 2);
System.out.println("💀 Skeleton resurrects with half HP!");
}
}
}
}