org.vizzini.game.boardgame.action
Class MoveCaptureAction

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.action.MoveCaptureAction
All Implemented Interfaces:
Serializable, Comparable, IAction, IGridBoardAction, IMoveAction

public class MoveCaptureAction
extends AbstractMoveAction

Provides an action for movement of a token from a position to another, occupied position. The token at the 'to' position is captured or removed.

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

Constructor Summary
protected MoveCaptureAction(IGridBoard gridBoard, IAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          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 MoveCaptureAction get(IGridBoard gridBoard, IAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return an instance of this class using the given parameters.
 IntegerPosition getFromPosition()
           
 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(IGridBoard gridBoard, IAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          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

MoveCaptureAction

protected MoveCaptureAction(IGridBoard gridBoard,
                            IAgent agent,
                            IntegerPosition fromPosition,
                            IntegerPosition toPosition)
Construct this object.

Since:
v0.2
Method Detail

get

public static MoveCaptureAction get(IGridBoard gridBoard,
                                    IAgent agent,
                                    IntegerPosition fromPosition,
                                    IntegerPosition toPosition)
Return an instance of this class using the given parameters.

Since:
v0.2

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.2

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 successful and can be undone.
Since:
v0.2

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.2

getFromPosition

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

getToPosition

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

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.2

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.2

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.2

set

protected void set(IGridBoard gridBoard,
                   IAgent agent,
                   IntegerPosition fromPosition,
                   IntegerPosition toPosition)
Set parameters on this object.

Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02