-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathRgandhi.java
More file actions
48 lines (41 loc) · 1.16 KB
/
Rgandhi.java
File metadata and controls
48 lines (41 loc) · 1.16 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 RGandhi extends Ship {
public RGandhi() {
this.initializeName("The Mahatma");
this.initializeOwner("Raj");
this.initializeHull(2);
this.initializeFirepower(4);
this.initializeSpeed(2);
this.initializeRange(2);
}
/*
* 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 {
Ship enemy = nearby.get(i);
Coord target = enemy.getCoord();
int x = target.getX();
int y = target.getY();
this.fire(arena, x, y);
this.fire(arena, x, y);
this.fire(arena, x, y);
this.fire(arena, x, y);
}
}
}
}