org.vizzini.game.boardgame.chess.action
Class PawnPromotionAction

java.lang.Object
  extended by org.vizzini.game.action.AbstractAction
      extended by org.vizzini.game.boardgame.action.AbstractGridBoardAction
          extended by org.vizzini.game.boardgame.action.AbstractMoveAction
              extended by org.vizzini.game.boardgame.chess.action.PawnPromotionAction
All Implemented Interfaces:
Serializable, Comparable, IAction, IGridBoardAction, IMoveAction

public class PawnPromotionAction
extends AbstractMoveAction

Provides an action for promotion of a pawn when moving from a position to another position. This action first removes the pawn, then places the new promotion token.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Constructor Summary
protected PawnPromotionAction(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, Class tokenClass)
          Construct this object.
 
Method Summary
 int compareTo(Object object)
          Compare this to the given object.
 boolean doIt()
          Perform the command encapsulated by this object.
 boolean equals(Object object)
          Return true if the given object is equal to this.
static PawnPromotionAction get(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, Class tokenClass)
          Return an instance of this class using the given parameters.
 IntegerPosition getFromPosition()
           
 Class getTokenClass()
          Return the promotion token class.
 IntegerPosition getToPosition()
           
 int hashCode()
          Returns a hash code value for the object.
static void poolReport()
          Log a statistics report.
 void release()
          Return this instance to the reusable object pool.
protected  void set(IChessEnvironment board, IChessAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition, Class tokenClass)
          Set parameters on this object.
 String toString()
          Return a string representation of this object.
 boolean undoIt()
          Undo the last invocation of doIt.
 
Methods inherited from class org.vizzini.game.boardgame.action.AbstractMoveAction
clear, prettyPrint, setFromPosition
 
Methods inherited from class org.vizzini.game.boardgame.action.AbstractGridBoardAction
getGridBoard, setGridBoard, setToPosition
 
Methods inherited from class org.vizzini.game.action.AbstractAction
getAgent, getRating, setAgent, setRating
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.boardgame.action.IGridBoardAction
getGridBoard
 
Methods inherited from interface org.vizzini.game.action.IAction
getAgent, getRating, setAgent, setRating
 

Constructor Detail

PawnPromotionAction

protected PawnPromotionAction(IChessEnvironment board,
                              IChessAgent agent,
                              IntegerPosition fromPosition,
                              IntegerPosition toPosition,
                              Class tokenClass)
Construct this object.

Parameters:
board - Chess board. (required)
agent - Agent. (required)
fromPosition - Token from position. (required)
toPosition - Token to position. (required)
tokenClass - New promotion token class. (required)
Since:
v0.3
Method Detail

get

public static PawnPromotionAction get(IChessEnvironment board,
                                      IChessAgent agent,
                                      IntegerPosition fromPosition,
                                      IntegerPosition toPosition,
                                      Class tokenClass)
Return an instance of this class using the given parameters.

Parameters:
board - Chess board. (required)
agent - Agent. (required)
fromPosition - Token from position. (required)
toPosition - Token to position. (required)
tokenClass - New promotion token class. (required)
Since:
v0.3

poolReport

public static void poolReport()
Log a statistics report.

Since:
v0.3

compareTo

public int compareTo(Object object)
Compare this to the given object.

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class AbstractMoveAction
Returns:
-1,0,1 if this is less than, equal to, greater than object.
Throws:
ClassCastException - if another is not an instance of AbstractAction.
Since:
v0.3

doIt

public boolean doIt()
Perform the command encapsulated by this object.

Specified by:
doIt in interface IAction
Overrides:
doIt in class AbstractAction
Returns:
true if sucessful and can be undone.
Since:
v0.3

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Specified by:
equals in interface IAction
Overrides:
equals in class AbstractMoveAction
Parameters:
object - The object to compare.
Since:
v0.3

getFromPosition

public IntegerPosition getFromPosition()
Specified by:
getFromPosition in interface IMoveAction
Overrides:
getFromPosition in class AbstractMoveAction
Returns:
Returns the fromPosition.
Since:
v0.3

getTokenClass

public Class getTokenClass()
Return the promotion token class.

Since:
v0.3

getToPosition

public IntegerPosition getToPosition()
Specified by:
getToPosition in interface IGridBoardAction
Overrides:
getToPosition in class AbstractGridBoardAction
Returns:
Returns the toPosition.
Since:
v0.3

hashCode

public int hashCode()
Returns a hash code value for the object.

Specified by:
hashCode in interface IAction
Overrides:
hashCode in class AbstractMoveAction
Since:
v0.3

release

public void release()
Return this instance to the reusable object pool.

Specified by:
release in interface IAction
Overrides:
release in class AbstractAction
Since:
v0.3

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class AbstractAction
Since:
v0.3

undoIt

public boolean undoIt()
Undo the last invocation of doIt.

Specified by:
undoIt in interface IAction
Overrides:
undoIt in class AbstractAction
Returns:
true if the undo was successful.
Since:
v0.3

set

protected void set(IChessEnvironment board,
                   IChessAgent agent,
                   IntegerPosition fromPosition,
                   IntegerPosition toPosition,
                   Class tokenClass)
Set parameters on this object.

Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02