wyvern.lib.commands
Class FireCommand

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

public class FireCommand
extends java.lang.Object
implements BuiltInCommand

"Fires" the currently readied Readyable item (spell, range weapon, etc.) Supports more than one syntax: "fire direction", "fire x y" where (x,y) is a map location.

Version:
1.0, Nov 17, 1999
Author:
Steve Yegge

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 initial)
          Creates fire-targetable event.
 boolean execute(CommandEvent event)
          Executes the specified CommandEvent.
static FireCommand getImpl()
           
 boolean knowsCommand(java.lang.String command)
          Returns true if this Command wants to handle the command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImpl

public static FireCommand 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 command)
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:
command - the entire command string, including arguments
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent initial)
Creates fire-targetable event. If a valid direction was specified, sets an int "direction" property on the event. If instead a valid (x,y) map position was specified, sets a "target-loc" property whose value is a Point with that (x,y). Sets the target of the event to the player's currently readied Targetable object.

Specified by:
createEvent in interface Command
Parameters:
initial - the initial, raw event
Returns:
a new containing various new properties (need to document).

execute

public boolean execute(CommandEvent event)
Description copied from interface: Command
Executes the specified CommandEvent. The CommandEvent contains all the parameters and state required to execute the command; the parameters have been filtered through hook objects, so they may not be the same as when the event was created.

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