-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWizard.java
More file actions
60 lines (45 loc) · 1.21 KB
/
Wizard.java
File metadata and controls
60 lines (45 loc) · 1.21 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
/**
*
* @author Sanjeeb Sangraula
* This class represents a Wizard in a game
*
*/
public class Wizard extends GameCharacter {
/**
*
* @param name the name of the Wizard
* @param x the initial x-coordinate of the wizard
* @param y the initial y-coordinate of the wizard
*/
public Wizard(String name, int x, int y) {
super(name, x, y, "Wizard");
}
/**
* Causes the Wizard to attack the { @code target }
* @param target the target to attack
*/
@Override
public boolean attack(GameCharacter target) {
if (this.isInActive()) {
return false;
}
double distance = this.getDistanceFrom(target);
if (distance <= 50) {
target.decreaseHealthPoints(30);
return true;
}
return false;
}
/**
* Causes the Wizard to move in { @code direction } for { @code distance }
* @param direction the direction to move. Could be 'N', 'S', 'E', 'W' for North, South, East and West
* @param distance the distance for the Wizard to move
*/
@Override
public void move(char direction, int distance) {
if (distance < 0) {
distance = 0;
}
super.move(direction, distance);
}
}