-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathGoblin.java
More file actions
30 lines (24 loc) · 921 Bytes
/
Goblin.java
File metadata and controls
30 lines (24 loc) · 921 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
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 Goblin extends Enemy {
private static final double CRITICAL_CHANCE = 0.1;
public Goblin(int hp, int mp, Weapon weapon) {
super(hp, mp, weapon);
}
@Override
public void attack(Entity target) {
Random rand = new Random();
for (int i = 0; i < 2; i++) { // دو بار حمله میکند
int damage = (weapon != null) ? weapon.getDamage() / 2 : 5;
if (i == 0 && rand.nextDouble() < CRITICAL_CHANCE) {
damage *= 2;
System.out.println("💥 Goblin lands a CRITICAL HIT!");
}
System.out.println("⚔️ Goblin attacks for " + damage + " damage!");
target.takeDamage(damage);
}
}
}