wyvern.lib.commands
Class PickupCommand

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

public class PickupCommand
extends java.lang.Object
implements BuiltInCommand

Handles "get {item}" and "get all" commands. Creates a PickupEvent to encapsulate what happened during the event.

Version:
1.0, Sep 02, 1997
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 a PickupEvent from a user command.
 boolean execute(CommandEvent e)
          Executes the PickupEvent.
static PickupCommand getImpl()
           
 boolean knowsCommand(java.lang.String command)
          We only handle straight pickup & get commands; the GetFrom command handles removing things from containers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImpl

public static PickupCommand 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)
We only handle straight pickup & get commands; the GetFrom command handles removing things from containers.

Specified by:
knowsCommand in interface Command
Parameters:
command - the original text of the command
Returns:
true if we're going to handle it. Returns false if it's of the form: "get xxx from yyy"; it'll be delegated to the GetFromCommand.

createEvent

public CommandEvent createEvent(CommandEvent initial)
Creates a PickupEvent from a user command.

Specified by:
createEvent in interface Command
Parameters:
initial - the initial event wrapping the command
Returns:
a PickupEvent

execute

public boolean execute(CommandEvent e)
Executes the PickupEvent. After executing the event, calls event.setFinalTarget(), passing in whatever object was ultimately added to the player's inventory.

Specified by:
execute in interface Command
Parameters:
e - a PickupEvent to execute
Returns:
true if the object was picked up successfully