forked from Stevoisiak/JavaFX-Online-Chess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiece.java
65 lines (51 loc) · 1.34 KB
/
Piece.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
61
62
63
64
65
import javafx.scene.image.Image;
public abstract class Piece
{
protected boolean hasMoved;
protected Image image;
protected boolean color;
// validMoves
public Piece(boolean color)
{
this.color = color;
//for pawn double move and castling(?)
hasMoved = false;
String location = "assets/pieces/";
String filename = this.getColor() + "_" + this.getName() + ".png";
this.image = new Image(location + filename);
//getPieceMoves(), usesSingleMove(), getName() defined in classes
}
public boolean getHasMoved()
{
return this.hasMoved;
}
public void setHasMoved(boolean shouldBeTrue)
{
this.hasMoved = shouldBeTrue;
}
// Returns image of chess piece
public Image getImage()
{
return this.image;
}
// Get piece color as string
public String getColor()
{
if (this.color == true)
return "white";
else
return "black";
}
// returns true if color is white
public boolean isWhite()
{
return this.color;
}
public String toString()
{
return (this.getName() + " " + this.getColor());
}
protected abstract MoveList[] getPieceMoves();
protected abstract boolean usesSingleMove();
protected abstract String getName();
}