Class CommandLineInterface

java.lang.Object
it.polimi.ingsw.eriantys.client.UserInterface
it.polimi.ingsw.eriantys.client.cli.CommandLineInterface
All Implemented Interfaces:
ClientMessageHandler, Runnable

public class CommandLineInterface extends UserInterface
This class represents the command line user interface (CLI). It handles user inputs and messages received from the server.
  • Constructor Details

  • Method Details

    • showInfo

      public void showInfo(String details)
      Description copied from class: UserInterface
      Shows an information message to the user.
      Specified by:
      showInfo in class UserInterface
      Parameters:
      details - the message to show
    • showError

      public void showError(String details)
      Description copied from class: UserInterface
      Shows an error message to the user.
      Specified by:
      showError in class UserInterface
      Parameters:
      details - the message to show
    • run

      public void run()
      Starts the loop reading user inputs and handling commands. Notifies the client that the user interface is ready.
    • showSchoolBoard

      public void showSchoolBoard()
      Prints the current status of the player's schoolboard.
    • showSchoolBoard

      public void showSchoolBoard(String player)
      Prints the current status of a player's schoolboard.
      Parameters:
      player - the player whose schoolboard should be printed
    • handleMessage

      public void handleMessage(Accepted message)
      Handles a Accepted message. Prints a message letting the player know that the action has been accepted.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(AcceptedUsername message)
      Handles a AcceptedUsername message. Saves the selected username and checks if a reconnection is available. Prints a message letting the player know the username was accepted and how to reconnect.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(AcceptedJoinLobby message)
      Handles a AcceptedJoinLobby message. Saves the game id and the reconnection settings. Prints a message letting the player know the lobby was joined correctly.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(AcceptedLeaveLobby message)
      Handles a AcceptedLeaveLobby message. Removes reconnection settings. Prints a message letting the player know the lobby was left correctly.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(HelpResponse message)
      Handles a HelpResponse message. Prints the correct help message received from the server.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(AvailableLobbies message)
      Handles a AvailableLobbies message. Prints the list of available lobbies.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(LobbyUpdate message)
      Handles a LobbyUpdate message. Prints the list of players in the joined lobby
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(AssistantCardUpdate message)
      Handles a AssistantCardUpdate message. Prints the assistant cards played by the other players and then, if the player is the next one to play, prints the available assistant cards.
      Specified by:
      handleMessage in interface ClientMessageHandler
      Overrides:
      handleMessage in class UserInterface
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(BoardUpdate message)
      Handles a BoardUpdate message. Saves the board status. If the player is the next one to play, prints a message.
      Specified by:
      handleMessage in interface ClientMessageHandler
      Overrides:
      handleMessage in class UserInterface
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(UserSelectionUpdate message)
      Handles a UserSelectionUpdate message. Prints the tower colors and wizards selected by other players and, if the player is the next to choose, prints the remaining tower colors and wizards.
      Specified by:
      handleMessage in interface ClientMessageHandler
      Overrides:
      handleMessage in class UserInterface
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(GameOverUpdate message)
      Handles a GameOverUpdate message. Removes reconnection settings. Prints the winner. Stops the application.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(InitialBoardStatus message)
      Handles a InitialBoardStatus message. Saves the initial board status. Prints a message letting the player know that the game has started.
      Parameters:
      message - the received message
    • handleMessage

      public void handleMessage(DisconnectionUpdate message)
      Handles a DisconnectionUpdate message. Prints a message with disconnection details.
      Parameters:
      message - the received message
    • quit

      public void quit()
      Description copied from class: UserInterface
      Notifies the user that they have been disconnected from the game due to an error.
      Specified by:
      quit in class UserInterface