-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpell.java
More file actions
57 lines (43 loc) · 1.29 KB
/
Copy pathSpell.java
File metadata and controls
57 lines (43 loc) · 1.29 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
// abstract class for all the Items in the game
// implements the Entity interface
// Extends the Item interface
abstract class Spell extends Item {
int base_damage;
int mana_cost;
public Spell(String name, int price, int level, int base_damage, int mana_cost) {
super(name,price,level);
this.base_damage = base_damage;
this.mana_cost = mana_cost;
}
// getter methods
public int getDamage() {
return base_damage;
}
public int getManaCost() {
return mana_cost;
}
// setter
public void setDamage(int k) {
base_damage = k;
}
public void setManaCost(int k) {
mana_cost = k;
}
// additional methods
public boolean canBeUsed(HeroEntity other) {
if (other.getLevel() >= this.getLevel()) {
return true;
} else {
return false;
}
}
public boolean equals(Spell other) {
return (this.getName() == other.getName());
}
public String toString() {
String s = super.toString();
s += " Damage: " + Colors.ANSI_GREEN + Integer.toString(base_damage) + Colors.ANSI_RESET + "\n";
s += " Mana Cost: " + Colors.ANSI_BLUE + Integer.toString(mana_cost) + Colors.ANSI_RESET + "\n";
return s;
}
}