org.vizzini.game.boardgame.action
Class MoveAction

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

public class MoveAction
extends AbstractMoveAction

Provides an action for movement of a token from a position to another position.

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

Constructor Summary
protected MoveAction(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.
static MoveAction get(IGridBoard gridBoard, IAgent agent, IntegerPosition fromPosition, IntegerPosition toPosition)
          Return an instance of this class using the given parameters.
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, equals, getFromPosition, hashCode, prettyPrint, setFromPosition
 
Methods inherited from class org.vizzini.game.boardgame.action.AbstractGridBoardAction
getGridBoard, getToPosition, 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, getToPosition
 
Methods inherited from interface org.vizzini.game.action.IAction
getAgent, getRating, setAgent, setRating
 

Constructor Detail

MoveAction

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

Since:
v0.2
Method Detail

get

public static MoveAction 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

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