working on board
This commit is contained in:
parent
dc00037eaa
commit
dff0d5c704
|
|
@ -6,46 +6,51 @@ public class Board {
|
||||||
|
|
||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
|
public ArrayList<Piece> pieces = new ArrayList<>();
|
||||||
|
public int TurnNumber;
|
||||||
|
|
||||||
public Board(int colNum, int lineNum) {
|
public Board(int colNum, int lineNum) {
|
||||||
//TODO
|
|
||||||
this.width = colNum;
|
this.width = colNum;
|
||||||
this.height = lineNum;
|
this.height = lineNum;
|
||||||
|
this.TurnNumber=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
//TODO
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
//TODO
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTurnNumber() {
|
public int getTurnNumber() {
|
||||||
//TODO
|
return TurnNumber;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTurnWhite() {
|
public boolean isTurnWhite() {
|
||||||
//TODO
|
return (TurnNumber % 2 == 0);;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPiece(boolean isWhite, PieceType type, int x, int y) {
|
public void setPiece(boolean isWhite, PieceType type, int x, int y) {
|
||||||
//TODO
|
pieces.removeIf(p -> p.getX() == x && p.getY() == y);
|
||||||
|
pieces.add(new Piece(x, y, isWhite, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateBoard() {
|
public void populateBoard() {
|
||||||
//TODO
|
if (pieces==null) {
|
||||||
|
pieces = new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanBoard() {
|
public void cleanBoard() {
|
||||||
//TODO
|
if (pieces != null) {
|
||||||
|
pieces.clear();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pieces = new Arraylist<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue