jfreerails.move
Class WorldDiffMove

java.lang.Object
  extended by jfreerails.move.WorldDiffMove
All Implemented Interfaces:
java.io.Serializable, MapUpdateMove, Move, FreerailsSerializable

public class WorldDiffMove
extends java.lang.Object
implements Move, MapUpdateMove

A move that makes a number of changes to the map and to the lists. WARNING: This class currently only handles the most common cases. A UnsupportedOperationException is thrown if an appropriate move cannot be generated.

Author:
Luke
See Also:
Serialized Form

Nested Class Summary
static class WorldDiffMove.Cause
           
(package private) static class WorldDiffMove.MapDiff
           
 
Field Summary
private  WorldDiffMove.Cause cause
           
private  ImList<WorldDiffMove.MapDiff> diffs
           
private  int h
           
private  CompositeMove listChanges
           
private static java.util.logging.Logger logger
           
private static long serialVersionUID
           
private  int w
           
private  int x
           
private  int y
           
 
Constructor Summary
WorldDiffMove(ReadOnlyWorld world, WorldDiffs worldDiffs, WorldDiffMove.Cause cause)
           
 
Method Summary
private  void doMove(World world, boolean undo)
           
 MoveStatus doMove(World world, FreerailsPrincipal p)
          Executes this move on the specifed world object.
 boolean equals(java.lang.Object o)
           
static WorldDiffMove generate(WorldDiffs diffs, WorldDiffMove.Cause cause)
           
 WorldDiffMove.Cause getCause()
           
 CompositeMove getListChanges()
           
 java.awt.Rectangle getUpdatedTiles()
           
 int hashCode()
           
 int listDiffs()
           
 MoveStatus tryDoMove(World world, FreerailsPrincipal p)
          Tests whether this Move can be executed on the specifed world object, this method should leave the world object unchanged.
private  MoveStatus tryMapChanges(World world, boolean undo)
           
 MoveStatus tryUndoMove(World world, FreerailsPrincipal p)
          Tests whether this Move can be undone on the specifed world object, this method should leave the world object unchanged.
 MoveStatus undoMove(World world, FreerailsPrincipal p)
          If doMove has just been executed on the specified world object, calling this method changes the state of the world object back to how it was before doMove was called.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cause

private final WorldDiffMove.Cause cause

logger

private static final java.util.logging.Logger logger

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

diffs

private final ImList<WorldDiffMove.MapDiff> diffs

listChanges

private final CompositeMove listChanges

x

private final int x

y

private final int y

w

private final int w

h

private final int h
Constructor Detail

WorldDiffMove

public WorldDiffMove(ReadOnlyWorld world,
                     WorldDiffs worldDiffs,
                     WorldDiffMove.Cause cause)
              throws java.lang.UnsupportedOperationException
Throws:
java.lang.UnsupportedOperationException
Method Detail

generate

public static WorldDiffMove generate(WorldDiffs diffs,
                                     WorldDiffMove.Cause cause)

doMove

private void doMove(World world,
                    boolean undo)

doMove

public MoveStatus doMove(World world,
                         FreerailsPrincipal p)
Description copied from interface: Move
Executes this move on the specifed world object.

Specified by:
doMove in interface Move

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getUpdatedTiles

public java.awt.Rectangle getUpdatedTiles()
Specified by:
getUpdatedTiles in interface MapUpdateMove

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

tryDoMove

public MoveStatus tryDoMove(World world,
                            FreerailsPrincipal p)
Description copied from interface: Move
Tests whether this Move can be executed on the specifed world object, this method should leave the world object unchanged.

Specified by:
tryDoMove in interface Move

tryMapChanges

private MoveStatus tryMapChanges(World world,
                                 boolean undo)

tryUndoMove

public MoveStatus tryUndoMove(World world,
                              FreerailsPrincipal p)
Description copied from interface: Move
Tests whether this Move can be undone on the specifed world object, this method should leave the world object unchanged.

Specified by:
tryUndoMove in interface Move

listDiffs

public int listDiffs()

undoMove

public MoveStatus undoMove(World world,
                           FreerailsPrincipal p)
Description copied from interface: Move
If doMove has just been executed on the specified world object, calling this method changes the state of the world object back to how it was before doMove was called.

Specified by:
undoMove in interface Move

getCause

public WorldDiffMove.Cause getCause()

getListChanges

public CompositeMove getListChanges()