Compare commits
2 Commits
3eda7a98d2
...
0449c8220a
| Author | SHA1 | Date |
|---|---|---|
|
|
0449c8220a | |
|
|
c0dc7d7b59 |
|
|
@ -308,10 +308,11 @@ public class Board {
|
|||
|
||||
/* The following methods require more work ! */
|
||||
|
||||
/*private void highlightedPossibleMoves(Piece piece) {
|
||||
private void highlightedPossibleMoves(Piece piece) {
|
||||
highlightedSquares.clear();
|
||||
highlightedSquares.addAll(MoveHighlighter.getPossibleMoves(piece, this));
|
||||
}*/
|
||||
MoveHighlighter highlighter= new MoveHighlighter();
|
||||
highlightedSquares.addAll(highlighter.getPossibleMoves(piece, this));
|
||||
}
|
||||
|
||||
public boolean isHighlighted(int x, int y) {
|
||||
for(int i=0; i<highlightedSquares.size();i++) { //loops through list of highlighted squares
|
||||
|
|
@ -375,18 +376,6 @@ return false; }
|
|||
this.highlightedSquares.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateTurnLabel() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void repaint() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*public Board(Board board) {
|
||||
//TODO
|
||||
|
||||
|
|
@ -394,55 +383,12 @@ return false; }
|
|||
|
||||
public void playMove(Move move) {
|
||||
//TODO
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/** Expose the raw 2D array for testing or drawing. */
|
||||
public Piece[][] getBoardArray() {
|
||||
return board;
|
||||
|
||||
}
|
||||
|
||||
public void highlightedPossibleMoves(Piece piece) {
|
||||
highlightedSquares.clear();
|
||||
MovePiece move = new MovePiece(piece, this);
|
||||
int x = piece.getX();
|
||||
int y = piece.getY();
|
||||
|
||||
for (int newX = 0; newX < width; newX++) {
|
||||
for (int newY = 0; newY < height; newY++) {
|
||||
boolean isValid = false;
|
||||
|
||||
switch (piece.getType()) {
|
||||
case Pawn:
|
||||
isValid = move.movePawnSimulate(newX, newY);
|
||||
break;
|
||||
case Rook:
|
||||
isValid = move.moveRookSimulate(newX, newY);
|
||||
break;
|
||||
case Knight:
|
||||
isValid = move.moveKnightSimulate(newX, newY);
|
||||
break;
|
||||
case Bishop:
|
||||
isValid = move.moveBishopSimulate(newX, newY);
|
||||
break;
|
||||
case Queen:
|
||||
isValid = move.moveQueenSimulate(newX, newY);
|
||||
break;
|
||||
case King:
|
||||
isValid = move.moveKingSimulate(newX, newY);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
highlightedSquares.add(new int[]{newX, newY});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package backend;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class MoveHighlighter {
|
||||
public static ArrayList<int[]> getPossibleMoves(Piece piece, Board board){
|
||||
public ArrayList<int[]> getPossibleMoves(Piece piece, Board board){
|
||||
ArrayList<int[]> validMoves = new ArrayList<int[]>();
|
||||
MovePiece movement = new MovePiece(piece, board);
|
||||
PieceType type= piece.getType();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public class MovePiece {
|
|||
this.board = board;
|
||||
}
|
||||
|
||||
/* i honestly dont know if i change it to that or not #keshini
|
||||
/*alternative
|
||||
* public boolean validateMove(int x, int y, boolean simulate) {
|
||||
PieceType type = piece.getType();
|
||||
switch(type) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue