|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.combat.AttackCommand
Controls the attacking sequence. Figures out the attacker and defender, and what attacks the attacker will be using. Enqueues a HitEvent for each attack. Also handles automatic followup attacks for implementing synchronous, timed combat.
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. |
boolean |
alreadyAttacking(Commandable agent,
Attackable target)
Checks if we're already attacking this target. |
void |
computeAttacks(CommandEvent event,
Commandable agent,
int num_attacks)
Figures out what things the agent will be attacking with. |
CommandEvent |
createAttackEvent(boolean player_originated,
java.lang.String originalText,
Commandable agent,
Attackable target)
Creates an AttackEvent and stuffs the event parameters. |
CommandEvent |
createEvent(CommandEvent initial)
Creates a CommandEvent that encapsulates all the state necessary to perform the command. |
boolean |
execute(CommandEvent event)
Executes the attack. |
static AttackCommand |
getImpl()
|
void |
handlePostAttack(CommandEvent event,
Commandable agent)
Handles automatically maybe-enqueuing another attack. |
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 AttackCommand 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 createAttackEvent(boolean player_originated, java.lang.String originalText, Commandable agent, Attackable target)
player_originated
- true if the player explicitly originated
this attack, e.g. by moving into the defender or typing
"kill originalText
- e.g. "kill agent
- the event agenttarget
- the target of the attackpublic boolean alreadyAttacking(Commandable agent, Attackable target)
agent
- the agenttarget
- the target we're attacking
public void computeAttacks(CommandEvent event, Commandable agent, int num_attacks)
event
- the attack eventagent
- the Commandable doing the attackingnum_attacks
- the actual number of attacks the agent getspublic boolean execute(CommandEvent event)
execute
in interface Command
event
- the CommandEvent to execute
public void handlePostAttack(CommandEvent event, Commandable agent)
event
- the eventagent
- the attacker
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |