package li.seiji.minichess.figure;

import li.seiji.minichess.Move;
import li.seiji.minichess.Player;
import li.seiji.minichess.State;

public class Pawn implements IFigure {

    public static final char identifier = 'p';

    static boolean isMoveValid(State state, Move move) {
        if(!IFigure.isMoveValid(state, move)) return false;
        Player player = Player.parseIdentifier(move.from.getIdentifier(state));

        boolean isValidStraightMove = IFigure.isStraightMove(move) && (
                    (player == Player.WHITE && IFigure.getMoveDeltaY(move) == -1) ||
                    (player == Player.BLACK && IFigure.getMoveDeltaY(move) == 1)
                ) && IFigure.getFieldPlayer(state, move.to) == Player.NONE;

        boolean isValidDiagonalMove = (
                (player == Player.WHITE && IFigure.getMoveDeltaY(move) == 1 && IFigure.getAbsMoveDeltaX(move) == 1) ||
                (player == Player.BLACK && IFigure.getMoveDeltaY(move) == -1 && IFigure.getAbsMoveDeltaX(move) == 1)
        );

        return (isValidDiagonalMove || isValidStraightMove);
    }

}

@@ -411,24 +411,80 @@
 r(state));%0A%0A
+        int deltaY = (player == Player.WHITE) ? -1 : 1;%0A
         bool
@@ -540,18 +540,16 @@
 move) &&
- (
 %0A       
@@ -560,39 +560,8 @@
     
-     (player == Player.WHITE &&
  IFi
@@ -592,95 +592,17 @@
  == 
--1) %7C%7C%0A                    (player == Player.BLACK && IFigure.getMoveDeltaY(move) == 1)
+deltaY &&
 %0A   
@@ -617,13 +617,8 @@
     
- ) &&
  IFi

Make Pawn-Check more readable