Class Command

java.lang.Object
VASSAL.command.Command
Direct Known Subclasses:
AddPiece, AddSecretNoteCommand, AlertCommand, BasicLogger.LogCommand, BoardPicker.SetBoards, ChangePiece, ChangePropertyCommand, Chatter.DisplayText, ConditionalCommand, Deck.LoadDeckCommand, EventLog.StoreEvents, GameState.SetupCommand, GlobalProperty.SetGlobalProperty, InviteCommand, LOS_Thread.LOSCommand, ModuleExtension.RegCmd, MovePiece, NewGameIndicator.MarkGameNotNew, NotesWindow.SetPublicNote, NotesWindow.SetScenarioNote, NullCommand, ObscurableOptions.SetAllowed, PlayAudioClipCommand, PlayerRoster.Add, PrivMsgCommand, RemovePiece, SetPersistentPropertyCommand, SetPrivateTextCommand, SoundEncoder.Cmd, SpecialDiceButton.ShowResults, SynchCommand, TextClient.ShowText, TurnTracker.SetTurn

public abstract class Command
extends Object
Command is an abstract class that does something. Any action that takes place during a game should be encapsulated in a Command object. When performing actions during a game, corresponding Commands will be logged in the current logfile and/or sent to other players on the server. Commands can be strung together into compound commands with the append(VASSAL.command.Command) method.
See Also:
CommandEncoder
  • Constructor Details

  • Method Details

    • getSubCommands

      public Command[] getSubCommands()
    • execute

      public void execute()
      Execute this command by first invoking executeCommand(), then invoking execute() recursively on all subcommands.
    • executeCommand

      protected abstract void executeCommand()
      Perform the action which this Command represents
    • myUndoCommand

      protected abstract Command myUndoCommand()
      If the action can be undone, return a Command that performs the inverse action. The Command returned should only undo executeCommand(), not the actions of subcommands
    • stripSubCommands

      public void stripSubCommands()
      Remove all subcommands.
    • isNull

      public boolean isNull()
      Returns:
      true if this command does nothing
    • isLoggable

      public boolean isLoggable()
      Returns:
      true if this command should be stored in a logfile
    • hasNullSubcommands

      @Deprecated protected boolean hasNullSubcommands()
      Deprecated.
    • isAtomic

      protected boolean isAtomic()
      Return true if this command has no sub-commands attached to it (other than null commands).
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDetails

      public String getDetails()
      Detailed information for toString()
    • append

      public Command append​(Command c)
      Append a subcommand to this Command.
    • getUndoCommand

      public Command getUndoCommand()
      Returns:
      a Command that undoes not only this Command's action, but also the actions of all its subcommands.