public ArrayList<Piece> getListByColor(Color color) { ArrayList<Piece> piecesList = new ArrayList<Piece>(); for (Piece piece : row) { if (piece.getColor() == color) piecesList.add(piece); } return piecesList; }
private String shortName(Piece p) { if (p == null) { return ""; } String ret = "" + p.getColor().toString().charAt(0); Type t = p.getType(); switch (t) { case PAWN: ret += "P"; break; case ROOK: ret += "R"; break; case KNIGHT: ret += "N"; break; case BISHOP: ret += "B"; break; case QUEEN: ret += "Q"; break; case KING: ret += "K"; break; } return ret; }
public int getNumberOfPiecesFromRow(Piece pieceToFind) { int count = 0; for (Piece piece : row) { if (piece.equals(pieceToFind)) ++count; } return count; }
public double getScoreFromRow(Color color) { double score = 0; for (Piece piece : row) { if (piece.getColor() == color) { score += piece.getScore(); } } return score; }
void setBlackKQRBN() { // 한줄을 검정색 킹퀸룩비숍나이트로 바꾸는 메서드 row.set(0, Piece.createBlackRook()); row.set(1, Piece.createBlackKnight()); row.set(2, Piece.createBlackBishop()); row.set(3, Piece.createBlackQueen()); row.set(4, Piece.createBlackKing()); row.set(5, Piece.createBlackBishop()); row.set(6, Piece.createBlackKnight()); row.set(7, Piece.createBlackRook()); }
void setWhiteKQRBN() { // 한줄을 흰색 킹퀸룩비숍나이트로 바꾸는 메서드 row.set(0, Piece.createWhiteRook()); row.set(1, Piece.createWhiteKnight()); row.set(2, Piece.createWhiteBishop()); row.set(3, Piece.createWhiteQueen()); row.set(4, Piece.createWhiteKing()); row.set(5, Piece.createWhiteBishop()); row.set(6, Piece.createWhiteKnight()); row.set(7, Piece.createWhiteRook()); }
void setBlackPawn() { // 한줄을 검정색 폰으로 바꾸는 메서드 for (int i = 0; i < COL_NUM; i++) { row.set(i, Piece.createBlackPawn()); } }
void setWhitePawn() { // 한줄을 흰색 폰으로 바꾸는 메서드 for (int i = 0; i < COL_NUM; i++) { row.set(i, Piece.createWhitePawn()); } }
void initEmpty() { for (int i = 0; i < COL_NUM; i++) { row.add(Piece.createEmptyPiece()); } }