wyvern.lib.commands
Class OrderCommand

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

public class OrderCommand
extends java.lang.Object
implements BuiltInCommand

Lets you order something from a tavern menu.

Version:
1.0, Apr 28, 1998
Author:
Steve Yegge

Field Summary
static int ORDER_DELAY
           
 
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 an Order event.
 boolean execute(CommandEvent event)
          Implements Command.execute()
static OrderCommand getImpl()
           
static boolean handleConsume(int value, GameObject obj, Commandable agent, CommandEvent event)
          Handles consuming something.
 boolean knowsCommand(java.lang.String command)
          Returns true if this Command wants to handle the command.
 boolean showMenu(CommandEvent event, Commandable agent)
          Shows the contents of the tavern menu.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORDER_DELAY

public static int ORDER_DELAY
Method Detail

getImpl

public static OrderCommand 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 an Order event.

Sets various error messages in the event (you can query them dynamically to see their current values). Looks for an object with a "menu" property nearby.

Specified by:
createEvent in interface Command
Parameters:
initial - the initial, raw event
Returns:
a new event containing everything a hook callback would need in order to modify or veto the event.

execute

public boolean execute(CommandEvent event)
Implements Command.execute()

Specified by:
execute in interface Command
Parameters:
event - the event to execute
Returns:
true if it executed successfully

showMenu

public boolean showMenu(CommandEvent event,
                        Commandable agent)
Shows the contents of the tavern menu.


handleConsume

public static boolean handleConsume(int value,
                                    GameObject obj,
                                    Commandable agent,
                                    CommandEvent event)
Handles consuming something.

Parameters:
value - the value of the object's "drinkable" or "edible" property i.e. the object's food value
obj - the target object
agent - the agent drinking the object
event - the event, complete with success-messages, etc. In particular, it must have the "tooMuchMsg" set properly, for if the player can't order or drink that much.