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
FieldsModifier and TypeFieldDescriptionprivate FrameDataThe frame data storing the information from the game status.private booleanThe character's side flag.
trueif the character is P1, orfalseif P2.private LinkedList<Key>The list storing the converted keys. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidactionToCommand(String str) Converts the action name to a command and creates a key corresponding to the command.voidcommandCall(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 voidcreateKeys(String str) Creates a key corresponding to a command name.booleanReturns 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.booleanReturns the character's side flag.private String[]reverseKey(String[] commands) Reverses the command horizontally according to the direction the character is facing.voidsetFrameData(FrameData frameData, boolean playerNumber) Sets the current frame data and the boolean variable representing P1 and P2.voidDeletes 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.
trueif the character is P1, orfalseif 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.
trueif the character is P1, orfalseif P2.
-
getSkillFlag
public boolean getSkillFlag()Returns whether there are unexecuted keys in the list of keys waiting to be executed.- Returns:
trueif there are keys not yet executed in the list,falseotherwise.
-
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:
trueif the character is P1, orfalseif 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
-