wyvern.kernel.combat
Class WieldCommand

java.lang.Object
  extended bywyvern.kernel.combat.WieldCommand
All Implemented Interfaces:
BuiltInCommand, Command

public class WieldCommand
extends java.lang.Object
implements BuiltInCommand

The Wield command.

Version:
1.0, Jan 23, 1998
Author:
Steve Yegge

Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Adds commands.
static void checkUnwieldOtherWeapon(Commandable agent, CommandEvent event)
          Determines whether the agent needs to unwield something else in order to wield this weapon.
 CommandEvent createEvent(CommandEvent initial)
          Creates a wield- or unwield-event encapsulating the weapon & agent.
 CommandEvent createUnwieldEvent(CommandEvent initial)
          Creates an event for unwielding a weapon.
static CommandEvent createWieldEvent(CommandEvent initial)
          Creates a WieldEvent encapsulating the weapon & agent.
 boolean execute(CommandEvent ev)
          Executes the wield.
 boolean executeUnwield(Commandable agent, TargetedEvent event)
          Un-wields a weapon.
 boolean executeWield(Commandable agent, TargetedEvent event)
          Wields a weapon.
static void findBodyParts(Weapon weapon, Monster agent, TargetedEvent event)
          Finds the body part(s) that will wield the weapon and stuffs references to them into the event.
static void forceUnwield(Weapon weapon, Commandable agent)
          Removes the weapon from the agent's attacks.
static java.lang.String getHandString(Commandable agent)
          Returns "hand", "claw" or something appropriate for the monster.
static java.lang.String getHandString(Commandable agent, boolean plural)
          Returns the singular or plural gripping-appendage name for the monster.
static WieldCommand getImpl()
           
 boolean knowsCommand(java.lang.String command)
          Built-in commands always return true, so that *someone* handles the command.
static java.util.List searchParts(Commandable agent, java.lang.Class[] types)
          Searches for available parts to hold the specified types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImpl

public static WieldCommand getImpl()

addCommands

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

Specified by:
addCommands in interface BuiltInCommand
Parameters:
commands - the Map we're registering with
list - the CommandList the Command is being added to.

knowsCommand

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

Specified by:
knowsCommand in interface Command
Parameters:
command - the command to check
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent initial)
Creates a wield- or unwield-event encapsulating the weapon & agent.

Specified by:
createEvent in interface Command
Parameters:
initial - the event containing the original text
Returns:
a CommandEvent for wield or unwield

createWieldEvent

public static CommandEvent createWieldEvent(CommandEvent initial)
Creates a WieldEvent encapsulating the weapon & agent.

Parameters:
initial - the initial event
Returns:
a TargetedEvent containing the weapon to wield, possibly already vetoed (if the weapon wasn't found).

checkUnwieldOtherWeapon

public static void checkUnwieldOtherWeapon(Commandable agent,
                                           CommandEvent event)
Determines whether the agent needs to unwield something else in order to wield this weapon.


createUnwieldEvent

public CommandEvent createUnwieldEvent(CommandEvent initial)
Creates an event for unwielding a weapon.

Parameters:
initial - the initial event
Returns:
a TargetedEvent containing the weapon to unwield, possibly already vetoed (if the weapon wasn't found/wielded).

findBodyParts

public static void findBodyParts(Weapon weapon,
                                 Monster agent,
                                 TargetedEvent event)
Finds the body part(s) that will wield the weapon and stuffs references to them into the event.

Sets some properties on the event:

Parameters:
weapon - the weapon to wield
agent - the wielder
event - the event to stuff

searchParts

public static java.util.List searchParts(Commandable agent,
                                         java.lang.Class[] types)
Searches for available parts to hold the specified types.

Parameters:
agent - the agent whose body to search
types - the slot classes to search for
Returns:
a non-null, possibly empty list of parts to use

execute

public boolean execute(CommandEvent ev)
Executes the wield.

Specified by:
execute in interface Command
Parameters:
ev - the wield event
Returns:
true if it was successful

executeWield

public boolean executeWield(Commandable agent,
                            TargetedEvent event)
Wields a weapon.

Parameters:
agent - the agent to wield the weapon
event - the event containing the wield parameters

executeUnwield

public boolean executeUnwield(Commandable agent,
                              TargetedEvent event)
Un-wields a weapon.

Parameters:
agent - the agent to wield the weapon
event - the event containing the wield parameters

forceUnwield

public static void forceUnwield(Weapon weapon,
                                Commandable agent)
Removes the weapon from the agent's attacks.

Parameters:
weapon - the weapon to unwield
agent - the agent to make unwield the weapon

getHandString

public static java.lang.String getHandString(Commandable agent)
Returns "hand", "claw" or something appropriate for the monster.


getHandString

public static java.lang.String getHandString(Commandable agent,
                                             boolean plural)
Returns the singular or plural gripping-appendage name for the monster.

Parameters:
agent - the Monster to check
plural - true to retrieve the plural form of the name
Returns:
"hand", "claw" or whatever. Defaults to "hand" if the monster has no gripping appendages.