-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComputerPlayer.java
59 lines (51 loc) · 1.01 KB
/
ComputerPlayer.java
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
package Maestus.Porkyman;
/**
* An instance of Player that randomly generates its own actions
* @author Oracle
*
*/
public class ComputerPlayer extends Player {
/**
* The player may have only one pockymon
*/
private final Pockymon pokeball;
/**
* The player may have only one item
*/
private IItem tool;
/**
* Construct a new computer pockymon trainer and their kit
* @param pockymon
* @param item
*/
public ComputerPlayer(Pockymon pokeball, IItem tool) {
super(false);
this.pokeball = pokeball;
this.tool = tool;
}
/**
* Retrieves the player's pockymon
*/
@Override
public Pockymon getPockymon() {
return pokeball;
}
/**
* Retrieves the player's item
*/
@Override
public IItem getItem() {
if (tool.depleteItem()) {
tool = new NullItem();
}
return tool;
}
/**
* Running away effectively ends the battle by defeating all pockymon in possession
*/
@Override
public void run() {
pokeball.modHP(-999);
System.out.println("The other player ran away!");
}
}