wyvern.lib.commands
Class AppraiseCommand

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

public class AppraiseCommand
extends java.lang.Object
implements BuiltInCommand

Handles expert appraisal of various items. In most cases, players won't be able to tell anything special about an item, but the command implements various skills that allow you to get more info if you have them.

Version:
1.0, Nov 8, 2000
Author:
Steve Yegge

Field Summary
static int APPRAISE_DELAY
          How long it takes to appraise something.
 
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.
 void appraiseArmor(Armor armor, Commandable agent)
          Appraises a piece of armor.
 java.lang.String appraiseDamage(GameObject item, Commandable agent, int level)
          Appraises armor or weapon for damage level.
 boolean appraiseGem(GameObject item, Commandable agent)
          Attempts to appraise a gem.
 void appraiseWeapon(Weapon item, Commandable agent)
          Appraises a weapon.
 int computeTotalAC(Armor armor)
          Adds up built-in ACs for the armor.
 int computeTotalWC(Weapon weapon)
          Adds up built-in WCs for the weapon.
 CommandEvent createEvent(CommandEvent initial)
          Creates an Appraisal event.
 boolean execute(CommandEvent ev)
          Executes the specified CommandEvent.
static AppraiseCommand 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
 

Field Detail

APPRAISE_DELAY

public static int APPRAISE_DELAY
How long it takes to appraise something.

Method Detail

getImpl

public static AppraiseCommand 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 Appraisal 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 ev)
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:
ev - the CommandEvent to execute
Returns:
true if the event completed successfully, else false.

appraiseWeapon

public void appraiseWeapon(Weapon item,
                           Commandable agent)
Appraises a weapon.

Parameters:
item - the armor or weapon
agent - the identifier

computeTotalWC

public int computeTotalWC(Weapon weapon)
Adds up built-in WCs for the weapon.


appraiseArmor

public void appraiseArmor(Armor armor,
                          Commandable agent)
Appraises a piece of armor.

Parameters:
armor - the armor or weapon
agent - the identifier

computeTotalAC

public int computeTotalAC(Armor armor)
Adds up built-in ACs for the armor.


appraiseDamage

public java.lang.String appraiseDamage(GameObject item,
                                       Commandable agent,
                                       int level)
Appraises armor or weapon for damage level.

Parameters:
item - the armor or weapon
agent - the identifier
level - their level in the skill
Returns:
a one-liner summarizing the damage

appraiseGem

public boolean appraiseGem(GameObject item,
                           Commandable agent)
Attempts to appraise a gem.

Parameters:
item - the gem
agent - the appraiser
Returns:
true if successful