-
Notifications
You must be signed in to change notification settings - Fork 0
/
Locust.java
60 lines (51 loc) · 1.34 KB
/
Locust.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
60
import utils.Players;
public class Locust extends Piece {
public Locust(int x, int y, Players player) {
super(x, y, player);
this.name = "l";
}
@Override
public boolean isCoordinateAvailable(int lastX, int lastY, int x, int y) {
while (Game.boarder.pieces[lastX-2][lastY]!=null){
lastX-=2;
}
if(lastX-2==x && lastY==y){
return true;
}
while (Game.boarder.pieces[lastX-1][lastY+1]!=null){
lastX--;
lastY++;
}
if(lastX-1==x && lastY+1==y){
return true;
}
while (Game.boarder.pieces[lastX+1][lastY+1]!=null){
lastX++;
lastY++;
}
if(lastX+1==x && lastY+1==y){
return true;
}
while (Game.boarder.pieces[lastX+2][lastY]!=null){
lastX+=2;
}
if(lastX+2==x && lastY==y){
return true;
}
while (Game.boarder.pieces[lastX+1][lastY-1]!=null){
lastX++;
lastY--;
}
if(lastX+1==x && lastY-1==y){
return true;
}
while (Game.boarder.pieces[lastX-1][lastY-1]!=null){
lastX--;
lastY--;
}
if(lastX-1==x && lastY-1==y){
return true;
}
return false;
}
}