wyvern.lib.commands
Class TurnCommand

java.lang.Object
  extended bywyvern.lib.commands.TurnCommand
All Implemented Interfaces:
BuiltInCommand, Command

public class TurnCommand
extends java.lang.Object
implements BuiltInCommand

This built-in Command handles the "turn" command.

Version:
1.0, Jun 05, 1998
Author:
Steve Yegge

Nested Class Summary
 class TurnCommand.TurnEvent
          This event encapsulates the parameters for the "turn" command.
 
Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Tells the Command to add the commands that it wants to implement into the passed data structure.
 CommandEvent createEvent(CommandEvent init)
          Creates a TurnEvent to encapsulate the turn.
 boolean execute(CommandEvent v)
          Executes the TurnEvent.
static TurnCommand getImpl()
           
 boolean knowsCommand(java.lang.String cmd)
          Returns true if this Command wants to handle the command.
 void parseArgs(TurnCommand.TurnEvent event)
          Parses the direction argument and stores it in the event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImpl

public static TurnCommand getImpl()

addCommands

public void addCommands(java.util.Map commands,
                        CommandList list)
Description copied from interface: BuiltInCommand
Tells the Command to add the commands that it wants to implement into the passed data structure.

Specified by:
addCommands in interface BuiltInCommand
Parameters:
commands - a Map whose keys are commands, and whose values are Commands that handle those commands.
list - the CommandList the Command is being added to.

knowsCommand

public boolean knowsCommand(java.lang.String cmd)
Description copied from interface: Command
Returns true if this Command wants to handle the command. The Command can examine the arguments and determine that it doesn't actually understand the command, in which case it should return false.

This method exists to allow more than one game object to implement the same command verb, but with different expected arguments.

If two objects register for the same command and the same arguments, the object that was registered most recently gets to handle at the command.

Specified by:
knowsCommand in interface Command
Parameters:
cmd - the entire command string, including arguments
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent init)
Creates a TurnEvent to encapsulate the turn.

Specified by:
createEvent in interface Command
Parameters:
init - a "blank" CommandEvent containing only the command text and the agent who's performing the command. This initial event is created by the originator of the event (e.g. the AI or player's command preprocessor).
Returns:
a CommandEvent subclass encapsulating this command's execution parameters and state. It should copy in the fields from the passed-in event.

execute

public boolean execute(CommandEvent v)
Executes the TurnEvent.

Specified by:
execute in interface Command
Parameters:
v - the CommandEvent to execute
Returns:
true if the event completed successfully, else false.

parseArgs

public void parseArgs(TurnCommand.TurnEvent event)
Parses the direction argument and stores it in the event.