org.pesullivan.game.mill.engine
Class MillMove

java.lang.Object
  extended by org.pesullivan.game.mill.engine.MillMove
All Implemented Interfaces:
Move

public final class MillMove
extends java.lang.Object
implements Move

A Nine Men's Morris implementation of Move. Nine Men's Morris moves are described by two spots: moveSpot0 and moveSpot1.
Placing and taking moves are represented by moveSpot0.
Sliding and flying moves are represented by start and end spots: moveSpot0 and moveSpot1.


Constructor Summary
MillMove()
          Construct a move with MillBoard.NO_SPOT for each move spot.
MillMove(int moveSpot0)
          Construct a move at the given moveSpot0.
MillMove(int moveSpot0, int moveSpot1)
          Construct a move at the given spots.
 
Method Summary
 Move copy()
          Return a copy of the move.
 int getMoveSpot0()
          Get the spot to place a mill stone on, or to move a mill stone from.
 int getMoveSpot1()
          Get the spot to slide or fly a mill stone to.
 boolean isSame(MillMove move)
          Return true if the two moves are the same.
 boolean isSame(Move move)
          Return true if the two moves are the same.
 void setFrom(int moveSpot0)
          Set moveSpot0 based on the parameter and set moveSpot1 to MillBoard.NO_SPOT.
 void setFrom(int[] moveSpots)
          Set this move based on the parameter.
 void setFrom(int moveSpot0, int moveSpot1)
          Set this move based on the parameters.
 void setFrom(MillMove move)
          Set this move based on the parameter.
 void setFrom(Move move)
          Set this move based on the parameter.
 void setFromJSON(org.json.simple.JSONObject jsonMove)
          Set this move based on the parameter.
 org.json.simple.JSONObject toJSONObject()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MillMove

public MillMove()
Construct a move with MillBoard.NO_SPOT for each move spot.


MillMove

public MillMove(int moveSpot0)
Construct a move at the given moveSpot0. moveSpot1 is initialized with MillBoard.NO_SPOT.


MillMove

public MillMove(int moveSpot0,
                int moveSpot1)
Construct a move at the given spots.

Method Detail

setFromJSON

public void setFromJSON(org.json.simple.JSONObject jsonMove)
Description copied from interface: Move
Set this move based on the parameter.

Specified by:
setFromJSON in interface Move

toJSONObject

public org.json.simple.JSONObject toJSONObject()
Specified by:
toJSONObject in interface Move
Returns:
this move as a JSONObject.

copy

public Move copy()
Description copied from interface: Move
Return a copy of the move.

Specified by:
copy in interface Move

isSame

public boolean isSame(Move move)
Description copied from interface: Move
Return true if the two moves are the same.

Specified by:
isSame in interface Move

isSame

public boolean isSame(MillMove move)
Return true if the two moves are the same.


setFrom

public void setFrom(Move move)
Description copied from interface: Move
Set this move based on the parameter.

Specified by:
setFrom in interface Move

setFrom

public void setFrom(MillMove move)
Set this move based on the parameter.


setFrom

public void setFrom(int moveSpot0,
                    int moveSpot1)
Set this move based on the parameters.


setFrom

public void setFrom(int[] moveSpots)
Set this move based on the parameter.

Parameters:
moveSpots - holds moveSpot0 and moveSpot1.

setFrom

public void setFrom(int moveSpot0)
Set moveSpot0 based on the parameter and set moveSpot1 to MillBoard.NO_SPOT.


getMoveSpot0

public int getMoveSpot0()
Get the spot to place a mill stone on, or to move a mill stone from.


getMoveSpot1

public int getMoveSpot1()
Get the spot to slide or fly a mill stone to.