-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPieceRook.java
More file actions
66 lines (54 loc) · 1.1 KB
/
PieceRook.java
File metadata and controls
66 lines (54 loc) · 1.1 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
59
60
61
62
63
64
65
66
import javafx.scene.image.Image;
public class PieceRook extends Piece {
public String name = "Rook";
public String imgname = "rook.png";
private Piece[][] boardstate;
private int i;
private int j;
private int te;
public PieceRook(int type, int ii, int jj) {
super(type);
te=type;
i = ii;
j = jj;
}
@Override
public Image image(){
if(te==1)
return new Image("whiterookcursor.png");
else
return new Image("blackrookcursor.png");
}
@Override
public int icoord(){
if(i > 8){
return 7;}
if(i < 0){
return 0;}
else{return i;}
}
@Override
public int jcoord(){
if(j > 8){
return 7;}
if(j < 0){
return 0;}
else{return j;}
}
@Override
public String toString(){
return name;
}
@Override
public String imagefilename(){
return imgname;
}
public Piece[][] moverook(Piece r, Piece t, Piece[][] bs){
boardstate = bs;
// Move pawn
boardstate[t.icoord()][t.jcoord()] = new PieceRook(r.type(), t.icoord(), t.jcoord());
boardstate[r.icoord()][r.jcoord()] = new Empty(0, r.icoord(), r.jcoord());
// Return the new board
return boardstate;
}
}