-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathEzamudio.java
More file actions
48 lines (42 loc) · 1.34 KB
/
Ezamudio.java
File metadata and controls
48 lines (42 loc) · 1.34 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
package esi18;
import battleship.core.*;
import java.util.List;
/*
* SimpleShip
* @author Your Name
*/
public class Ezamudio extends Ship {
public Ezamudio() {
this.initializeName("Dig Bick");
this.initializeOwner("Edwin Zamudio");
this.initializeHull(4);
this.initializeFirepower(4);
this.initializeSpeed(2);
this.initializeRange(3);
}
/*
* Determines what actions the ship will take on a given turn
* @param arena (Arena) the battlefield for the match
* @return void
*/
@Override
protected void doTurn(Arena arena) {
List<Ship> targets = this.getNearbyShips(arena);
for (int index = 0; index < targets.size(); index += 1) {
Ship other = targets.get(index);
boolean isOnMyTeam = this.isSameTeamAs(other);
if (isOnMyTeam == false) {
if((other.getFirepower()>this.getHealth()&&other.getHealth()<this.getFirepower()))
{
Coord coord = this.getCoord();
int x = coord.getX();
int y = coord.getY();
coord = other.getCoord();
int x2 = coord.getX();
int y2 = coord.getY();
this.move(arena,Direction.EAST);
}
}
}
}
}