Package aiinterface
Class CommandCenter
java.lang.Object
aiinterface.CommandCenter
The class that converts actions received from AI to keys and manages the keys
after conversion.
-
Field Summary
Modifier and TypeFieldDescriptionprivate FrameData
The frame data storing the information from the game status.private boolean
The character's side flag.
true
if the character is P1, orfalse
if P2.private LinkedList<Key>
The list storing the converted keys. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
actionToCommand
(String str) Converts the action name to a command and creates a key corresponding to the command.void
commandCall
(String str) Converts the action name entered by AI into Key and stores it in the list of keys waiting to be executed.
If there are unexecuted keys in the list, this method does nothing.private void
createKeys
(String str) Creates a key corresponding to a command name.boolean
Returns whether there are unexecuted keys in the list of keys waiting to be executed.Returns the first element from the list of keys waiting to be executed.Returns the list of keys waiting to be executed.boolean
Returns the character's side flag.private String[]
reverseKey
(String[] commands) Reverses the command horizontally according to the direction the character is facing.void
setFrameData
(FrameData frameData, boolean playerNumber) Sets the current frame data and the boolean variable representing P1 and P2.void
Deletes all the keys from the list of keys waiting to be executed.
-
Field Details
-
skillKey
The list storing the converted keys. -
frameData
The frame data storing the information from the game status. -
playerNumber
private boolean playerNumberThe character's side flag.
true
if the character is P1, orfalse
if P2.
-
-
Constructor Details
-
CommandCenter
public CommandCenter()Class constructor.
-
-
Method Details
-
commandCall
Converts the action name entered by AI into Key and stores it in the list of keys waiting to be executed.
If there are unexecuted keys in the list, this method does nothing.- Parameters:
str
- an action name
-
actionToCommand
Converts the action name to a command and creates a key corresponding to the command.- Parameters:
str
- an action name
-
createKeys
Creates a key corresponding to a command name.- Parameters:
str
- a command name
-
setFrameData
Sets the current frame data and the boolean variable representing P1 and P2.- Parameters:
frameData
- the current frame dataplayerNumber
- The character's side flag.
true
if the character is P1, orfalse
if P2.
-
getSkillFlag
public boolean getSkillFlag()Returns whether there are unexecuted keys in the list of keys waiting to be executed.- Returns:
true
if there are keys not yet executed in the list,false
otherwise.
-
getSkillKey
Returns the first element from the list of keys waiting to be executed.
The returned element is deleted from the CommandCenter.- Returns:
- the next key to be executed
-
getSkillKeys
Returns the list of keys waiting to be executed.- Returns:
- the list of keys waiting to be executed
-
skillCancel
public void skillCancel()Deletes all the keys from the list of keys waiting to be executed. -
isPlayerNumber
public boolean isPlayerNumber()Returns the character's side flag.- Returns:
true
if the character is P1, orfalse
if P2.
-
reverseKey
Reverses the command horizontally according to the direction the character is facing.- Parameters:
commands
- an array containing the command converted from an action name- Returns:
- an array that contains the command after processing
-