Class Command
java.lang.Object
VASSAL.command.Command
- Direct Known Subclasses:
AddPiece
,AddSecretNoteCommand
,AlertCommand
,BasicLogger.LogCommand
,BasicLogger.UndoCommand
,BoardPicker.SetBoards
,ChangePiece
,ChangePropertyCommand
,Chatter.DisplayText
,ConditionalCommand
,Deck.LoadDeckCommand
,EventLog.StoreEvents
,FlareCommand
,GameState.SetupCommand
,GlobalProperty.SetGlobalProperty
,InviteCommand
,LOS_Thread.LOSCommand
,ModuleExtension.RegCmd
,MovePiece
,NewGameIndicator.MarkGameNotNew
,NotesWindow.SetPublicNote
,NotesWindow.SetScenarioNote
,NullCommand
,ObscurableOptions.SetAllowed
,PlayAudioClipCommand
,PlayerRoster.Add
,PlayerRoster.Remove
,PrivMsgCommand
,RemovePiece
,ScenarioPropertiesOptionTab.LockScenarioOptionsTab
,SetPersistentPropertyCommand
,SetPrivateTextCommand
,SoundEncoder.Cmd
,SpecialDiceButton.ShowResults
,SynchCommand
,TextClient.ShowText
,TurnTracker.SetTurn
A Command represents an action that needs to be transmitted from one client to another - any action that could
change the game state of a multiplayer game should be encapsulated in a Command object. When performing actions
during the game, corresponding Commands will be logged in the correct logfile and/or sent to other players through
the server.
CommandEncoder
s then serialise (CommandEncoder.encode(VASSAL.command.Command)
) and deserialise (CommandEncoder.decode(java.lang.String)
)
Commands to and from an ascii based representation. Commands are encoded by the generated client prior to being sent
across network or saved in a log or save file. Commands are decoded by the receiving client on receipt from the network
or on reading from a log or save file. Save game creation is a special case where every GameComponent
is asked to
generate a Command that when executed will cause itself to be recreated in its present state.
The execute()
method implements the execution of the command and is called by the receiving client
after building the Command using decode
. The execute
method is sometimes called on the generating client but does
not need to be if the Command is being created to encapsulate something that has already happened on the generating client.
Commands can be strung together into compound commands with the append(VASSAL.command.Command)
method. Although Commands can be linked into
compound commands this way, each CommandEncoder
need only handle single (not compound) commands.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAppend a subcommand to this Command.void
execute()
Execute this command by first invokingexecuteCommand()
, then invoking itself recursively on all subcommands.protected abstract void
Perform the action which this Command representsDetailed information for toString()Command[]
protected boolean
isAtomic()
Return true if this command has no sub-commands attached to it (other than null commands).boolean
boolean
isNull()
boolean
isNullOrContainsOnly
(Class<?> target) Return true if this Command is a NullCommand or only contains Null Commands or commands of the same type as targetprotected abstract Command
If the action can be undone, return a Command that performs the inverse action.void
Remove all subcommands.toString()
-
Constructor Details
-
Command
public Command()
-
-
Method Details
-
getSubCommands
-
execute
public void execute()Execute this command by first invokingexecuteCommand()
, then invoking itself recursively on all subcommands. -
executeCommand
protected abstract void executeCommand()Perform the action which this Command represents -
myUndoCommand
If the action can be undone, return a Command that performs the inverse action. The Command returned should only undoexecuteCommand()
, 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
-
isAtomic
protected boolean isAtomic()Return true if this command has no sub-commands attached to it (other than null commands).- Returns:
- True if this command has no sub-commands
-
toString
-
getDetails
Detailed information for toString() -
append
-
getUndoCommand
- Returns:
- a Command that undoes not only this Command's action, but also the actions of all its subcommands.
-
isNullOrContainsOnly
Return true if this Command is a NullCommand or only contains Null Commands or commands of the same type as target- Parameters:
target
- Class to inspect for- Returns:
- true if this command contains only non-null Commands target class Commands
-