remove "instanceof Pawn"
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package chess.model;
|
||||
|
||||
import chess.model.pieces.Pawn;
|
||||
import chess.model.visitor.PawnIdentifier;
|
||||
|
||||
public class Game {
|
||||
private final ChessBoard board;
|
||||
@@ -66,15 +66,15 @@ public class Game {
|
||||
*/
|
||||
private Coordinate pawnPromotePosition(Color color) {
|
||||
int enemyLineY = color == Color.White ? 0 : 7;
|
||||
PawnIdentifier identifier = new PawnIdentifier(color);
|
||||
|
||||
for (int x = 0; x < Coordinate.VALUE_MAX; x++) {
|
||||
Coordinate pieceCoords = new Coordinate(x, enemyLineY);
|
||||
Piece piece = getBoard().pieceAt(pieceCoords);
|
||||
|
||||
if (piece == null || !(piece instanceof Pawn) || piece.getColor() != color)
|
||||
continue;
|
||||
if (identifier.isPawn(piece))
|
||||
return pieceCoords;
|
||||
|
||||
return pieceCoords;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user