Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 public int getNumberOfPiecesFromRow(Piece pieceToFind) {
   int count = 0;
   for (Piece piece : row) {
     if (piece.equals(pieceToFind)) ++count;
   }
   return count;
 }
Esempio n. 4
0
 public double getScoreFromRow(Color color) {
   double score = 0;
   for (Piece piece : row) {
     if (piece.getColor() == color) {
       score += piece.getScore();
     }
   }
   return score;
 }
Esempio n. 5
0
 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());
 }
Esempio n. 6
0
 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());
 }
Esempio n. 7
0
 void setBlackPawn() { // 한줄을 검정색 폰으로 바꾸는 메서드
   for (int i = 0; i < COL_NUM; i++) {
     row.set(i, Piece.createBlackPawn());
   }
 }
Esempio n. 8
0
 void setWhitePawn() { // 한줄을 흰색 폰으로 바꾸는 메서드
   for (int i = 0; i < COL_NUM; i++) {
     row.set(i, Piece.createWhitePawn());
   }
 }
Esempio n. 9
0
 void initEmpty() {
   for (int i = 0; i < COL_NUM; i++) {
     row.add(Piece.createEmptyPiece());
   }
 }