-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealer.java
More file actions
56 lines (44 loc) · 1.72 KB
/
Healer.java
File metadata and controls
56 lines (44 loc) · 1.72 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
public class Healer extends Hero {
public Healer() {
super("Healer", Details.getHealerDetails());
}
public void heal() {
int hp;
int[] healRange = Details.getHealerDetails().getHealRange();
hp = (int) (Math.random() * (healRange[1] - healRange[0] + 1)) + healRange[0];
System.out.println(super.getName() + " added [" + hp + "] points.");
super.addHitPoints(hp);
System.out.println();
}
public void Attack(DungeonCharacter opponent) {
if (opponent == null)
throw new IllegalArgumentException("Opponent passed as null...");
System.out.println(super.getName() + " brings a mace down to smite " + opponent.getName() + ":");
super.attack(opponent);
}
public void battleChoices(DungeonCharacter opponent) {
if (opponent == null)
throw new IllegalArgumentException("Opponent passed as null...");
super.battleChoices(opponent);
int choice;
do {
System.out.println("1) Attack Opponent");
System.out.println("2) Cast Heal");
System.out.print("Choose an option: ");
choice = Keyboard.readInt();
System.out.println("--------------------------------------------------\n");
switch (choice)
{
case 1: this.attack(opponent);
break;
case 2: this.heal();
break;
default:
System.out.println("invalid choice!");
}//end switch
super.setNumTurns(super.getNumTurns() - 1);
if (super.getNumTurns() > 0)
System.out.println("Number of turns remaining is: " + super.getNumTurns());
} while (super.getNumTurns() > 0);
}
}