-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstanceEntity.java
More file actions
63 lines (56 loc) · 1.89 KB
/
InstanceEntity.java
File metadata and controls
63 lines (56 loc) · 1.89 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
import java.util.ArrayList;
import java.util.List;
public class InstanceEntity extends Entity {
private int currentHealth;
private List<Attack> selectedAttacks;
// Constructors
public InstanceEntity(Entity entity) {
this(null, entity);
// Roll for attacks in the entity to add to the InstanceEnemy's attacks.
selectedAttacks = new ArrayList<>();
int length = getAttacks().size();
if (length > 3)
length = 3;
while(selectedAttacks.size() < length) {
Attack selectedAttack = super.attack();
if (!selectedAttacks.contains(selectedAttack))
selectedAttacks.add(selectedAttack);
}
}
public InstanceEntity(List<Attack> selectedAttacks, Entity entity) {
this(entity.getMaxHealth(), selectedAttacks, entity);
}
public InstanceEntity(int currentHealth, List<Attack> selectedAttacks, Entity entity) {
super(entity.getName(), entity.getMaxHealth(), entity.getElement(), entity.getAttacks(), entity.getDefaultPose(), entity.getAttackPose());
this.currentHealth = currentHealth;
this.selectedAttacks = selectedAttacks;
}
/* Changes current health by the specified amount.
* Returns false if currentHealth <= 0, else returns true. */
public boolean changeCurrentHealth(int change) {
currentHealth += change;
return currentHealth <= 0;
}
@Override
public Attack attack() {
return selectedAttacks.get(roll(0, selectedAttacks.size() - 1));
}
// Getters/Setters
public int getCurrentHealth() {
return currentHealth;
}
public void setCurrentHealth(int currentHealth) {
this.currentHealth = currentHealth;
}
public List<Attack> getSelectedAttacks() {
return selectedAttacks;
}
public void setSelectedAttacks(List<Attack> selectedAttacks) {
this.selectedAttacks = selectedAttacks;
}
// toString
@Override
public String toString() {
return "InstanceEntity [currentHealth=" + currentHealth + ", selectedAttacks=" + selectedAttacks + ", entity=" + super.toString() + "]";
}
}