Package aiinterface

Class CommandCenter

java.lang.Object
aiinterface.CommandCenter

public class CommandCenter extends Object
The class that converts actions received from AI to keys and manages the keys after conversion.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private FrameData
    The frame data storing the information from the game status.
    private boolean
    The character's side flag.
    true if the character is P1, or false if P2.
    private LinkedList<Key>
    The list storing the converted keys.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Class constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    Converts the action name to a command and creates a key corresponding to the command.
    void
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • skillKey

      private LinkedList<Key> skillKey
      The list storing the converted keys.
    • frameData

      private FrameData frameData
      The frame data storing the information from the game status.
    • playerNumber

      private boolean playerNumber
      The character's side flag.
      true if the character is P1, or false if P2.
  • Constructor Details

    • CommandCenter

      public CommandCenter()
      Class constructor.
  • Method Details

    • commandCall

      public 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.
      Parameters:
      str - an action name
    • actionToCommand

      private void actionToCommand(String str)
      Converts the action name to a command and creates a key corresponding to the command.
      Parameters:
      str - an action name
    • createKeys

      private void createKeys(String str)
      Creates a key corresponding to a command name.
      Parameters:
      str - a command name
    • setFrameData

      public void setFrameData(FrameData frameData, boolean playerNumber)
      Sets the current frame data and the boolean variable representing P1 and P2.
      Parameters:
      frameData - the current frame data
      playerNumber - The character's side flag.
      true if the character is P1, or false 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

      public Key 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

      public Deque<Key> 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, or false if P2.
    • reverseKey

      private String[] reverseKey(String[] commands)
      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