|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.combat.DamageCommand
Handles dealing out damage, the last phase of the combat sequence.
Method Summary | |
void |
addCommands(java.util.Map map,
CommandList list)
Tells the Command to add the commands that it wants to implement into the passed data structure. |
java.lang.String |
addHitLocation(java.lang.String msg,
DamageEvent e)
Appends the hit-location, if any, to the defender message. |
DamageEvent |
createDamageEvent(Commandable agent,
GameObject defender,
DamageType[] dtypes,
BodyPart hitLoc,
Attack attack)
Utility method for creating a damage event suitable for placement in the agent's queue. |
DamageEvent |
createDamageEvent(Commandable agent,
GameObject defender,
DamageType dtype,
BodyPart hitLoc,
Attack attack)
Utility method for creating a to-hit event suitable for placement in the agent's queue. |
CommandEvent |
createEvent(CommandEvent e)
Creates a CommandEvent that encapsulates all the state necessary to perform the command. |
void |
damageArmor(DamageEvent e)
Figures out how much damage to do to the armor, if any. |
void |
damageWeapon(DamageEvent e)
Figures out how much damage to to do the weapon, if any. |
boolean |
execute(CommandEvent event)
Executes the damage for a DamageEvent, which could have been from a spell, a monster attack, a trap, or just about anything else. |
static DamageCommand |
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 |
Method Detail |
public static DamageCommand getImpl()
public void addCommands(java.util.Map map, CommandList list)
BuiltInCommand
addCommands
in interface BuiltInCommand
map
- 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 e)
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
e
- 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 DamageEvent createDamageEvent(Commandable agent, GameObject defender, DamageType dtype, BodyPart hitLoc, Attack attack)
The attack results in a single message each to the attacker and defender; it's chosen based on whichever DamageType resulted in the most damage this round. The total of all damages is used for the magnitude of the message, so a flaming sword that does some cut damage ("hit") and some burn damage ("burn") might say "burned badly" on one round, and "hit hard" on another round, depending on which damage type was greater.
agent
- the attackerdefender
- the attackeedtype
- the damage type used by the attackhitLoc
- the hit location on the attacker, or null if
it was a whole-body or unspecified attack.attack
- the weapon or attack
public DamageEvent createDamageEvent(Commandable agent, GameObject defender, DamageType[] dtypes, BodyPart hitLoc, Attack attack)
agent
- the attackerdefender
- the attackeedtypes
- the damages that are done in the attack. For
instance, a flaming sword might do some cut and some fire damage.hitLoc
- the hit location on the attacker, null if
it was a whole-body or unspecified attack.
public boolean execute(CommandEvent event)
execute
in interface Command
event
- the CommandEvent to execute
public java.lang.String addHitLocation(java.lang.String msg, DamageEvent e)
public void damageWeapon(DamageEvent e)
public void damageArmor(DamageEvent e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |