king, copy board logic, getPseudoMoves
This commit is contained in:
22
Board.java
22
Board.java
@@ -13,6 +13,10 @@ public class Board {
|
||||
}
|
||||
}
|
||||
|
||||
public Board(boolean isCopy) {
|
||||
board = new Piece[8][8];
|
||||
}
|
||||
|
||||
public void draw(Graphics g) {
|
||||
for (Piece[] row : board) {
|
||||
for (Piece p : row) {
|
||||
@@ -32,4 +36,22 @@ public class Board {
|
||||
public Piece getPiece(Position pos) {
|
||||
return this.board[pos.x][pos.y];
|
||||
}
|
||||
|
||||
public Piece getPiece(int x, int y) {
|
||||
return this.board[x][y];
|
||||
}
|
||||
|
||||
public static Board copy(Board b) {
|
||||
Board newBoard = new Board();
|
||||
|
||||
for (int i = 0; i <= 7; i++) {
|
||||
for (int j = 0; j <= 7; j++) {
|
||||
Piece p = b.getPiece(i, j);
|
||||
if (p == null) continue;
|
||||
newBoard.board[i][j] = p.copy();
|
||||
}
|
||||
}
|
||||
|
||||
return newBoard;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user