Fixed / added positional awareness in pawn movements
This commit is contained in:
parent
32446d4652
commit
616ed129a1
@ -17,14 +17,13 @@ public class Pawn extends Piece {
|
||||
|
||||
@Override
|
||||
public boolean isValidMove(Move move) {
|
||||
// TODO: Positioning, en passant
|
||||
if (getColor() == Color.WHITE)
|
||||
return ((move.xDist == 0 && move.yDist > 0 && move.yDist <= 2) || (move.xDist == 1 && move.yDist == 1))
|
||||
&& move.ySign == -1 && isFreePath(move);
|
||||
else return ((move.xDist == 0 && move.yDist > 0 && move.yDist <= 2) || (move.xDist == 1 && move.yDist == 1))
|
||||
&& move.ySign == 1
|
||||
&& isFreePath(move);
|
||||
|
||||
// TODO: en passant
|
||||
boolean step = move.isVertical() && move.yDist == 1;
|
||||
boolean doubleStep = move.isVertical() && move.yDist == 2;
|
||||
boolean strafe = move.isDiagonal() && move.xDist == 1;
|
||||
if (getColor() == Color.WHITE) doubleStep &= move.yPos == 6;
|
||||
else doubleStep &= move.yPos == 1;
|
||||
return (step ^ doubleStep ^ strafe) && move.ySign == (getColor() == Color.WHITE ? -1 : 1) && isFreePath(move);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user