-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathEvazquez1.java
More file actions
58 lines (50 loc) · 1.56 KB
/
Evazquez1.java
File metadata and controls
58 lines (50 loc) · 1.56 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
package esi18;
import battleship.core.*;
import java.util.List;
/*
* SimpleShip
* @author Your Name
*/
public class Evazquez1 extends Ship {
public Evazquez1() {
this.initializeName("SS.Spongebob");
this.initializeOwner("Evelyn");
this.initializeHull(3);
this.initializeFirepower(4);
this.initializeSpeed(2);
this.initializeRange(1);
}
//boats start on the left side(west) boats will be moving west to east
//arena size 15 x 8
/*
* 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) {
this.move(arena, Direction.EAST);
List<Ship> nearby = this.getNearbyShips(arena);
for(int i = 0; i<nearby.size(); i++){
if (this.isSameTeamAs(nearby.get(i))){
}else{
Coord location = this.getCoord();
int x = location.getX();
int y = location.getY();
this.fire(arena, x+1, y);
}
}
for (int index = 0; index < nearby.size(); index += 1) {
Ship shipInfo = nearby.get(index);
// System.out.println("One nearby ship has " + shipInfo.getHealth() + " HP left.");
Coord location = shipInfo.getCoord();
int x = location.getX();
int y = location.getY();
// buggy code
// if(ship (arena,x + 1, y )){
this.fire(arena, x + 1, y);
// buggy code
// } else{}
}
}
}