Class Move

java.lang.Object
  extended by Move

public class Move
extends java.lang.Object

Since:
26/11/2009
Author:
Petri Tuononen

Constructor Summary
Move(Board board)
          Constructor
 
Method Summary
 boolean canKingMove(int color)
          Check if King can move.
 boolean checkSqValidity(java.lang.String sq)
          Checks if the given notation is valid.
 boolean doMove(Player player, java.lang.String srcSq, java.lang.String destSq)
          Move piece in selected square to destination square.
 HistoryOfMoves getHistoryOfMoves()
          Returns history of all piece moves.
 boolean isPieceOnSquare(int x, int y)
          Returns true if the piece is found from the given location.
 boolean isPieceOnSquare(int x, int y, int color)
          Returns true if piece with defined color is found from the given location.
 boolean isPieceOnSquare(java.lang.String notation)
          Returns true if the piece is found from the given location.
 boolean isPieceOnSquare(java.lang.String notation, int color)
          Returns true if piece with defined color is found from the given location.
 java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> possiblePieceMoves(Piece piece)
          Returns an arraylist containing two arraylists for possible coordinates the selected piece can move.
 void setHistoryOfMoves(HistoryOfMoves history)
          Set history of all piece moves.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Move

public Move(Board board)
Constructor

Parameters:
board -
Method Detail

getHistoryOfMoves

public HistoryOfMoves getHistoryOfMoves()
Returns history of all piece moves.

Returns:
HistoryOfMoves

setHistoryOfMoves

public void setHistoryOfMoves(HistoryOfMoves history)
Set history of all piece moves.

Parameters:
history -

doMove

public boolean doMove(Player player,
                      java.lang.String srcSq,
                      java.lang.String destSq)
Move piece in selected square to destination square. Returns true if the move was successful.

Parameters:
player -
srcSq -
destSq -
Returns:
boolean

checkSqValidity

public boolean checkSqValidity(java.lang.String sq)
Checks if the given notation is valid.

Parameters:
sq -
Returns:
boolean

isPieceOnSquare

public boolean isPieceOnSquare(int x,
                               int y)
Returns true if the piece is found from the given location.

Parameters:
x -
y -
Returns:
boolean

isPieceOnSquare

public boolean isPieceOnSquare(java.lang.String notation)
Returns true if the piece is found from the given location.

Parameters:
notation -
Returns:
boolean

isPieceOnSquare

public boolean isPieceOnSquare(int x,
                               int y,
                               int color)
Returns true if piece with defined color is found from the given location.

Parameters:
x -
y -
color -
Returns:
boolean

isPieceOnSquare

public boolean isPieceOnSquare(java.lang.String notation,
                               int color)
Returns true if piece with defined color is found from the given location.

Parameters:
notation -
color -
Returns:
boolean

possiblePieceMoves

public java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> possiblePieceMoves(Piece piece)
Returns an arraylist containing two arraylists for possible coordinates the selected piece can move.

Parameters:
piece -
Returns:
ArrayList>

canKingMove

public boolean canKingMove(int color)
Check if King can move.

Parameters:
color -
Returns:
boolean