pretty cool
This commit is contained in:
@@ -24,7 +24,12 @@ public class PiecePathChecker implements PieceVisitor<Boolean> {
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
public boolean isValidForPiece(Piece piece) {
|
||||
public boolean isValid() {
|
||||
if (this.move.getStart().equals(this.move.getFinish()))
|
||||
return false;
|
||||
Piece piece = this.board.pieceAt(move.getStart());
|
||||
if (piece == null)
|
||||
return false;
|
||||
return visit(piece);
|
||||
}
|
||||
|
||||
@@ -62,18 +67,16 @@ public class PiecePathChecker implements PieceVisitor<Boolean> {
|
||||
if (!new PermissiveRuleChecker(this.move).isValidFor(pawn))
|
||||
return false;
|
||||
|
||||
Direction moveDirection = Direction.findDirection(this.move);
|
||||
// ...
|
||||
// moveDirection = Directions(int(findDirection(move)) * pawn.multiplier())
|
||||
Direction moveDirection = Direction.fromInt(Direction.findDirection(move).getIndexOffset() * pawn.multiplier());
|
||||
|
||||
if (moveDirection == Direction.Front)
|
||||
return testPath(pawn.getColor());
|
||||
return testPath(pawn.getColor()) && this.board.pieceAt(this.move.getFinish()) == null;
|
||||
|
||||
assert moveDirection == Direction.FrontLeft || moveDirection == Direction.FrontRight;
|
||||
|
||||
Piece destPiece = this.board.pieceAt(this.move.getFinish());
|
||||
if (destPiece == null)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
return destPiece.getColor() != pawn.getColor();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user