package ru.sbulygin.chees;

import ru.sbulygin.exeptions.ImpossibleMoveException;

/**
 * Class Pawn.
 *
 * @author ru.sbulygin.start.
 * @since 15.03.2017.
 * @version 1.0.
 */
public class Pawn extends Figure {

    /**
     * An array field of the movement of an pawn.
     */
    private Cell[] direction;

    /**
     * The first stroke of the figure.
     */
    private int firstMove;

    /**
     * The constructor of the Pawn class generates the class object.
     * @param position position of the figure on the Board.
     */
    public Pawn(Cell position) {
        super(position);
    }

    /**
     * Way overridden method of the abstract class Figure.
     * @param distance the specified cell on the Board.
     * @return array of the path of movement of the pawn.
     * @throws ImpossibleMoveException error of the impossibility of motion pawn.
     */
    @Override
    public Cell[] way(Cell distance) throws ImpossibleMoveException {

        int posX = getPosition().getPivotX();
        int posY = getPosition().getPivotY();
        int distX = distance.getPivotX();
        int distY = distance.getPivotY();

        if (firstMove == 2 || firstMove == 1) {
            if (posX == distX && posY != distY) {
                direction = motionDirection(distance);
            } else {
                throw new ImpossibleMoveException("Pawn can't walk.");
            }

        }
        return direction;
    }
}

@@ -371,19 +371,23 @@
 private 
-int
+boolean
  firstMo
@@ -388,16 +388,23 @@
 irstMove
+ = true
 ;%0A%0A    /
@@ -1154,63 +1154,72 @@
    i
-f (firstMove == 2 %7C%7C firstMove == 1) %7B%0A            if (
+nt vectorY =  Math.abs(distY - posY);%0A%0A        if (firstMove && 
 posX
@@ -1235,29 +1235,42 @@
  && 
-posY != distY) %7B%0A    
+(vectorY == 2 %7C%7C vectorY == 1)) %7B%0A
     
@@ -1316,24 +1316,51 @@
 tance);%0A    
+        firstMove = false;%0A
         %7D el
@@ -1364,20 +1364,16 @@
  else %7B%0A
-    
         
@@ -1435,23 +1435,8 @@
 %22);%0A
-            %7D%0A%0A
     

add Pawn class