Class MovePiece

java.lang.Object
VASSAL.command.Command
VASSAL.command.MovePiece

public class MovePiece extends Command
Command that moves a piece to a new location and position within a stack. While this can be accomplished with a ChangePiece command, this command is safer in terms of recovering from changes to the game state that may have occurred since the command was created. For instance, A ChangePiece command that adds a piece to a Stack will cause the piece to disappear if the stack has been deleted. This Command will recover more gracefully.
  • Constructor Details

    • MovePiece

      public MovePiece(String id, String newMapId, Point newPosition, String newUnderneathId, String oldMapId, Point oldPosition, String oldUnderneathId, String playerId)
      Parameters:
      id - The id of the piece being moved
      newMapId - The id of the map being moved to
      newPosition - the new position
      newUnderneathId - The id of the piece which will be immediately beneath this piece in any containing Stack. May be null
      oldMapId - The id of the map being moved from
      oldPosition - the old position
      oldUnderneathId - The id of the piece which was immediately beneath this piece in its original containing Stack.
      playerId - the id of the player making this move
  • Method Details

    • getId

      public String getId()
    • getNewMapId

      public String getNewMapId()
    • getOldMapId

      public String getOldMapId()
    • getNewPosition

      public Point getNewPosition()
    • getOldPosition

      public Point getOldPosition()
    • getNewUnderneathId

      public String getNewUnderneathId()
    • getOldUnderneathId

      public String getOldUnderneathId()
    • getPlayerId

      public String getPlayerId()
    • executeCommand

      protected void executeCommand()
      Description copied from class: Command
      Perform the action which this Command represents
      Specified by:
      executeCommand in class Command
    • myUndoCommand

      protected Command myUndoCommand()
      Description copied from class: Command
      If the action can be undone, return a Command that performs the inverse action. The Command returned should only undo Command.executeCommand(), not the actions of subcommands
      Specified by:
      myUndoCommand in class Command
    • createMergeFinder

      protected PieceVisitorDispatcher createMergeFinder(Map map, GamePiece p, Point pt)
      Creates a new PieceVisitorDispatcher that will create a Command object to merge the target piece with any applicable pieces at the target location
      Parameters:
      map -
      p -
      pt -
      Returns:
    • getDetails

      public String getDetails()
      Description copied from class: Command
      Detailed information for toString()
      Overrides:
      getDetails in class Command