suicideChess
Class Move

java.lang.Object
  extended by suicideChess.Move

public class Move
extends java.lang.Object

This class is used for moves representation.

Version:
$LastChangedRevision$, $LastChangedDate$
Author:
Jean-Baptiste Hétier

Nested Class Summary
 class Move.NotAValidMoveException
           
 
Constructor Summary
Move(Square fromSquare, Square toSquare, Piece movingPiece, Piece capturePiece, Piece promotionPiece)
          This is the constructor of the class.
Move(Square fromSquare, Square toSquare, Square enPassantSquare, Piece movingPiece, boolean isCapture)
          This is the constructor of the class.
Move(java.lang.String move, Board board)
          This is the constructor of the class.
 
Method Summary
 void display()
          Displays a move in great details.
 boolean enablesEnPassant()
          Returns a boolean saying is a Move makes 'en passant' move possible.
 Square fromSquare()
          Returns the Square to move from in a Move
 Piece getCapturedPiece()
          Returns the Piece to be captured in a Move
 Square getEnPassantSquare()
          Returns the enPassant Square for a move.
 Piece getMovingPiece()
          Returns the moving Piece of a Move.
 Piece getPromotionPiece()
          Returns the promotion Piece of a Move
 boolean isCaptureMove()
          Returns a boolean saying if a Move is a capture move
 boolean isEnPassant()
          Returns a boolean saying is a Move is an 'en passant' move.
 boolean isPromotionMove()
          Returns a boolean saying if a Move is a promotion or not.
 boolean isSimpleEqual(Move that)
          Tests the equality of two moves by just looking at the fromSquare and the toSquare
 Square toSquare()
          Returns the Square to move to in a Move
 java.lang.String toString()
          Converts a Move into a String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Move

public Move(java.lang.String move,
            Board board)
     throws Move.NotAValidMoveException,
            Square.NotAValidSquare
This is the constructor of the class.

Parameters:
move - A String containing of type "e2e4" (4 chars), "b7b8q" (5 chars) for promotions. It is the standard algebraic notation used for chess.
board - A Board to be able to locate the pieces.
Throws:
Move.NotAValidMoveException - When the String is not legal (too long or too short).
Square.NotAValidSquare - It the String is not legal (not standard algebraic notation).
See Also:
Board

Move

public Move(Square fromSquare,
            Square toSquare,
            Piece movingPiece,
            Piece capturePiece,
            Piece promotionPiece)
     throws Square.NotAValidSquare
This is the constructor of the class.

Parameters:
fromSquare - The Square to move from.
toSquare - The Square to move to.
movingPiece - The Piece to be moved.
capturePiece - The Piece to be captured. Piece.NONE if none.
promotionPiece - The {link Piece} to be promoted to. Piece.NONE if none.
Throws:
Square.NotAValidSquare - If Squares are not valid.
See Also:
Square, Piece

Move

public Move(Square fromSquare,
            Square toSquare,
            Square enPassantSquare,
            Piece movingPiece,
            boolean isCapture)
     throws Square.NotAValidSquare
This is the constructor of the class. It should be used only for moves that enable or are 'en passant' capture.

Parameters:
fromSquare - The Square to move from.
toSquare - The Square to move to.
enPassantSquare - The 'en passant' Square.
movingPiece - The Piece to be moved.
isCapture - This boolean is used to differenciate 'en passant' captures from moves that simply enable 'en passant' capture.
Throws:
Square.NotAValidSquare - If Squares are not valid.
See Also:
Square, Piece
Method Detail

fromSquare

public Square fromSquare()
Returns the Square to move from in a Move

Returns:
Square
See Also:
Square

toSquare

public Square toSquare()
Returns the Square to move to in a Move

Returns:
Square
See Also:
Square

isPromotionMove

public boolean isPromotionMove()
Returns a boolean saying if a Move is a promotion or not.

Returns:
boolean

getPromotionPiece

public Piece getPromotionPiece()
Returns the promotion Piece of a Move

Returns:
Piece
See Also:
Piece

getMovingPiece

public Piece getMovingPiece()
Returns the moving Piece of a Move.

Returns:
Piece
See Also:
Piece

isCaptureMove

public boolean isCaptureMove()
Returns a boolean saying if a Move is a capture move

Returns:
boolean

getCapturedPiece

public Piece getCapturedPiece()
Returns the Piece to be captured in a Move

Returns:
Piece

enablesEnPassant

public boolean enablesEnPassant()
Returns a boolean saying is a Move makes 'en passant' move possible.


isEnPassant

public boolean isEnPassant()
Returns a boolean saying is a Move is an 'en passant' move.


getEnPassantSquare

public Square getEnPassantSquare()
Returns the enPassant Square for a move.


toString

public java.lang.String toString()
Converts a Move into a String.

Overrides:
toString in class java.lang.Object
Returns:
String

isSimpleEqual

public boolean isSimpleEqual(Move that)
Tests the equality of two moves by just looking at the fromSquare and the toSquare

Parameters:
that - A move to test
Returns:
boolean

display

public void display()
Displays a move in great details.