Pieces are on the board <3
This commit is contained in:
parent
0738c9ded9
commit
db9efb80a6
|
|
@ -6,12 +6,13 @@ public class Board {
|
|||
|
||||
public int width;
|
||||
public int height;
|
||||
private Piece[][] board;
|
||||
|
||||
public Board(int colNum, int lineNum) {
|
||||
//TODO
|
||||
this.width = colNum;
|
||||
this.height = lineNum;
|
||||
|
||||
this.board= new Piece[width][height];
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
|
|
@ -37,8 +38,12 @@ public class Board {
|
|||
}
|
||||
|
||||
public void setPiece(boolean isWhite, PieceType type, int x, int y) {
|
||||
//TODO TEST
|
||||
if (x >= 0 && x < width && y >= 0 && y < height) {
|
||||
board[y][x] = new Piece(x, y, isWhite, type);
|
||||
}
|
||||
}
|
||||
//TODO TEST
|
||||
|
||||
|
||||
public void populateBoard() {
|
||||
cleanBoard();
|
||||
|
|
@ -67,8 +72,13 @@ public class Board {
|
|||
|
||||
public ArrayList<Piece> getPieces() {
|
||||
ArrayList<Piece> pieces = new ArrayList<>();
|
||||
//TODO
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (board[y][x] != null) {
|
||||
pieces.add(board[y][x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pieces;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue