|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.combat.WearCommand
This command handles donning & doffing armor and wearable magic items like rings & amulets.
Nested Class Summary | |
class |
WearCommand.UnwearEvent
Event class to encapsulate removing some armor. |
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. |
static void |
addDefense(Commandable agent,
Armor armor)
Adds the armor to the agent's @defense-list, for clients that need to know what armor the agent is wearing at the moment. |
static boolean |
canUsePart(BodyPart part,
java.lang.Class type,
Armor armor,
java.util.List parts,
WearEvent event)
Checks the slots for the passed BodyPart to see if any of them are slots we need for wearing the armor. |
boolean |
checkBlocked(Armor armor,
java.util.List parts,
Monster agent)
See if the passed armor cannot be removed because of a cursed piece of armor (or weapon) covering it. |
GameObject |
checkSlotBlocked(ItemSlot slot,
ItemSlot[] slots)
Checks if the passed slot is blocked on the same body part by a nonempty outer layer. |
CommandEvent |
createEvent(CommandEvent initial)
Creates a CommandEvent that encapsulates all the state necessary to perform the command. |
CommandEvent |
createRemoveEvent(CommandEvent initial)
Creates an event to encapsulate removing a piece of armor. |
CommandEvent |
createWearEvent(CommandEvent e)
|
static WearEvent |
createWearEvent(WearEvent event,
Armor armor,
int delay,
boolean quiet)
A function to create a wear event as if the user had typed "wear |
static boolean |
ensureCorrectSize(Monster monster,
Armor armor,
WearEvent event)
Makes sure they can actually wear the armor. |
boolean |
execute(CommandEvent event)
Executes the specified CommandEvent. |
void |
executeRemove(WearCommand.UnwearEvent event)
Performs the UnwearEvent |
boolean |
executeRemoveAll(WearCommand.UnwearEvent event)
Attempts to remove all the agent's worn armor. |
void |
executeWear(WearEvent event)
Wears the armor. |
static void |
findBodyParts(Monster agent,
Armor armor,
WearEvent event)
Searches the monster's parts-list for enough available body parts to wear the armor. |
static java.util.List |
findPartsUsed(Armor armor,
Monster agent)
If for some reason the armor lost track of its list of body-parts that were used to wear the armor, we need to sniff around the agent's body to see where the armor is worn. |
static WearCommand |
getImpl()
|
boolean |
knowsCommand(java.lang.String command)
Returns true if this Command wants to handle the command. |
static void |
removeDefense(Commandable agent,
Armor armor)
Removes the armor from the agent's @defense-list |
static void |
removeForce(Armor armor,
java.util.List parts,
Monster agent)
Forces the passed armor to be removed from the wearer. |
static void |
rewearInventory(Commandable agent)
Handles re-wearing armor and re-wielding weapons that were worn when the inventory was saved out. |
boolean |
tryRemove(Armor armor,
Monster agent,
WearCommand.UnwearEvent event)
Attempts to remove the passed piece of armor from the passed agent. |
static boolean |
wearArmor(Commandable agent,
java.util.List parts,
Armor armor)
Puts the armor on the agent. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static WearCommand getImpl()
public void addCommands(java.util.Map commands, CommandList list)
BuiltInCommand
addCommands
in interface BuiltInCommand
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.public boolean knowsCommand(java.lang.String command)
Command
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.
knowsCommand
in interface Command
command
- the entire command string, including arguments
public CommandEvent createEvent(CommandEvent initial)
Command
This method is called by the kernel. The kernel passes the event to the pre-hook, then calls Command.execute() (below) to execute the event, and finally calls the post-hook.
createEvent
in interface Command
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).
public CommandEvent createWearEvent(CommandEvent e)
public static WearEvent createWearEvent(WearEvent event, Armor armor, int delay, boolean quiet)
This method does various checks to see if the armor can be worn: whether it's the right size, whether there are enough body parts, whether it's already worn or not, etc.
This method is used by the Player object to re-wear armor
after a player logs in. It's better than just commanding
the Player to "wear
event
- a WearEvent with the original text and agent
already set up. Just call new WearEvent("wear whatever", agent)
and pass it to this method.armor
- the piece of armor to weardelay
- the delay to use for the event. Set a nonzero
delay if the player is putting the armor on; you can use zero
if you want it to go on instantaneously.quiet
- true not to print any messages to the player
if the event is successful.
public static void findBodyParts(Monster agent, Armor armor, WearEvent event)
agent
- the Monster trying to wear somethingarmor
- the armor to wearevent
- the eventpublic static boolean ensureCorrectSize(Monster monster, Armor armor, WearEvent event)
public static boolean canUsePart(BodyPart part, java.lang.Class type, Armor armor, java.util.List parts, WearEvent event)
Side effect: adds the part to the passed parts list if usable
part
- the BodyPart to examinetype
- the slot-type to look forparts
- the list of body-parts we've already chosenarmor
- the armor to wearevent
- the event
public CommandEvent createRemoveEvent(CommandEvent initial)
public boolean execute(CommandEvent event)
Command
execute
in interface Command
event
- the CommandEvent to execute
public void executeWear(WearEvent event)
event
- the event encapsulating the command parameterspublic static boolean wearArmor(Commandable agent, java.util.List parts, Armor armor)
agent
- the monsterparts
- a list of the agent's body parts (hashcodes)
public void executeRemove(WearCommand.UnwearEvent event)
event
- the command eventpublic static java.util.List findPartsUsed(Armor armor, Monster agent)
armor
- the armor to checkagent
- the agent to check
public boolean executeRemoveAll(WearCommand.UnwearEvent event)
event
- the event containing the command context
public boolean tryRemove(Armor armor, Monster agent, WearCommand.UnwearEvent event)
agent
- the monster/player wearing the armorarmor
- the armor to try to removeevent
- the command event, for messages
public static void removeForce(Armor armor, java.util.List parts, Monster agent)
armor
- the armor to removeparts
- the body parts the armor is being worn onagent
- the agent wearing the armorpublic boolean checkBlocked(Armor armor, java.util.List parts, Monster agent)
armor
- the armor to checkparts
- the body parts the armor is being worn on (hashcodes)agent
- the agent wearing the armor
public GameObject checkSlotBlocked(ItemSlot slot, ItemSlot[] slots)
slot
- the slot to checkslots
- the list of slots for the body part
public static void addDefense(Commandable agent, Armor armor)
agent
- the wearerarmor
- the thing being wornpublic static void removeDefense(Commandable agent, Armor armor)
agent
- the wearerarmor
- the thing being removedpublic static void rewearInventory(Commandable agent)
agent
- the player to set up
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |