wyvern.lib.commands
Class LockPickCommand

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

public class LockPickCommand
extends java.lang.Object
implements BuiltInCommand

Implements the "pick-locks" thieving skill.

Version:
1.0, Jan 3, 2000
Author:
Steve Yegge

Nested Class Summary
static class LockPickCommand.LockablePredicate
          A predicate that checks whether an object is lockable.
static class LockPickCommand.LockedPredicate
          A predicate that checks whether an object is locked.
 
Field Summary
static int PICK_LOCK_DELAY
          This is how long it takes to attempt to pick a lock.
 
Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Adds commands.
 CommandEvent createEvent(CommandEvent initial)
          Creates a pick-lock event.
 void damagePick(Commandable agent, GameObject lockpick)
          Does damage to the lock pick, possibly destroying it.
 GameObject determineTarget(java.lang.String arg, TargetedEvent event)
          Parses the args and gets the appropriate object to operate on.
 boolean execute(CommandEvent e)
          Executes the pick-lock event.
protected  void fail(Commandable agent, TargetedEvent event)
          Agent fails to pick the lock.
static LockPickCommand getImpl()
           
 GameObject getNoArgTarget(TargetedEvent event)
          Find the nearest object with a pickable lock.
static int getPickChance(int skill, Lock lock)
          Returns the agent's chance of picking this lock.
 GameObject getSpecificTarget(int dir, TargetedEvent event)
          Looks in specified direction for a lock.
 boolean knowsCommand(java.lang.String command)
          Built-in commands always return true, so that *someone* handles it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PICK_LOCK_DELAY

public static final int PICK_LOCK_DELAY
This is how long it takes to attempt to pick a lock.

See Also:
Constant Field Values
Method Detail

getImpl

public static LockPickCommand getImpl()

addCommands

public void addCommands(java.util.Map commands,
                        CommandList list)
Adds commands.

Specified by:
addCommands in interface BuiltInCommand
Parameters:
commands - the map to add ourself to
list - the command list we're registering in, from which we can derive the command agent (i.e. player or monster) and other information.

knowsCommand

public boolean knowsCommand(java.lang.String command)
Built-in commands always return true, so that *someone* handles it.

Specified by:
knowsCommand in interface Command
Parameters:
command - the complete original text of the command.
Returns:
true if we want to handle the command.

createEvent

public CommandEvent createEvent(CommandEvent initial)
Creates a pick-lock event. Sets the target to the locked object, and sets a "lockpick" property on the event that's the lock pick to use.

Specified by:
createEvent in interface Command
Parameters:
initial - 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.
See Also:
Command.createEvent(wyvern.lib.CommandEvent)

getNoArgTarget

public GameObject getNoArgTarget(TargetedEvent event)
Find the nearest object with a pickable lock.

Parameters:
event - the targeted event
Returns:
a suitable target object, or null if none found

determineTarget

public GameObject determineTarget(java.lang.String arg,
                                  TargetedEvent event)
Parses the args and gets the appropriate object to operate on.

Parameters:
arg - the argument string
event - the OpenEvent or LockEvent
Returns:
the target object, or null if none found

getSpecificTarget

public GameObject getSpecificTarget(int dir,
                                    TargetedEvent event)
Looks in specified direction for a lock.

Parameters:
dir - a valid Direction constant
event - the event for this command
Returns:
a lock in that direction, or null if not found

execute

public boolean execute(CommandEvent e)
Executes the pick-lock event.

Specified by:
execute in interface Command
Parameters:
e - the CommandEvent to execute
Returns:
true if the event completed successfully, else false.
See Also:
Command.execute(wyvern.lib.CommandEvent)

getPickChance

public static int getPickChance(int skill,
                                Lock lock)
Returns the agent's chance of picking this lock.

Parameters:
skill - the agent's pick-locks skill level, including any bonus from the lock pick itself.
lock - the Lock to pick
Returns:
the chance of success

fail

protected void fail(Commandable agent,
                    TargetedEvent event)
Agent fails to pick the lock. Might break the lockpick.

Parameters:
agent - the person picking the lock
event - the event

damagePick

public void damagePick(Commandable agent,
                       GameObject lockpick)
Does damage to the lock pick, possibly destroying it.