Class CommandLineInterface
java.lang.Object
it.polimi.ingsw.eriantys.client.UserInterface
it.polimi.ingsw.eriantys.client.cli.CommandLineInterface
- All Implemented Interfaces:
ClientMessageHandler,Runnable
This class represents the command line user interface (CLI).
It handles user inputs and messages received from the server.
-
Field Summary
Fields inherited from class it.polimi.ingsw.eriantys.client.UserInterface
characterCardInfo, client -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleMessage(Accepted message) Handles aAcceptedmessage.voidhandleMessage(AcceptedJoinLobby message) Handles aAcceptedJoinLobbymessage.voidhandleMessage(AcceptedLeaveLobby message) Handles aAcceptedLeaveLobbymessage.voidhandleMessage(AcceptedUsername message) Handles aAcceptedUsernamemessage.voidhandleMessage(AssistantCardUpdate message) Handles aAssistantCardUpdatemessage.voidhandleMessage(AvailableLobbies message) Handles aAvailableLobbiesmessage.voidhandleMessage(BoardUpdate message) Handles aBoardUpdatemessage.voidhandleMessage(DisconnectionUpdate message) Handles aDisconnectionUpdatemessage.voidhandleMessage(GameOverUpdate message) Handles aGameOverUpdatemessage.voidhandleMessage(HelpResponse message) Handles aHelpResponsemessage.voidhandleMessage(InitialBoardStatus message) Handles aInitialBoardStatusmessage.voidhandleMessage(LobbyUpdate message) Handles aLobbyUpdatemessage.voidhandleMessage(UserSelectionUpdate message) Handles aUserSelectionUpdatemessage.voidquit()Notifies the user that they have been disconnected from the game due to an error.voidrun()Starts the loop reading user inputs and handling commands.voidShows an error message to the user.voidShows an information message to the user.voidPrints the current status of the player's schoolboard.voidshowSchoolBoard(String player) Prints the current status of a player's schoolboard.Methods inherited from class it.polimi.ingsw.eriantys.client.UserInterface
handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, init, setClient
-
Constructor Details
-
CommandLineInterface
Constructs aCommandLineInterfaceobject.- Throws:
IOException- if theScannerto read user inputs couldn't be created
-
-
Method Details
-
showInfo
Description copied from class:UserInterfaceShows an information message to the user.- Specified by:
showInfoin classUserInterface- Parameters:
details- the message to show
-
showError
Description copied from class:UserInterfaceShows an error message to the user.- Specified by:
showErrorin classUserInterface- 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
Prints the current status of a player's schoolboard.- Parameters:
player- the player whose schoolboard should be printed
-
handleMessage
Handles aAcceptedmessage. Prints a message letting the player know that the action has been accepted.- Parameters:
message- the received message
-
handleMessage
Handles aAcceptedUsernamemessage. 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
Handles aAcceptedJoinLobbymessage. 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
Handles aAcceptedLeaveLobbymessage. Removes reconnection settings. Prints a message letting the player know the lobby was left correctly.- Parameters:
message- the received message
-
handleMessage
Handles aHelpResponsemessage. Prints the correct help message received from the server.- Parameters:
message- the received message
-
handleMessage
Handles aAvailableLobbiesmessage. Prints the list of available lobbies.- Parameters:
message- the received message
-
handleMessage
Handles aLobbyUpdatemessage. Prints the list of players in the joined lobby- Parameters:
message- the received message
-
handleMessage
Handles aAssistantCardUpdatemessage. 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:
handleMessagein interfaceClientMessageHandler- Overrides:
handleMessagein classUserInterface- Parameters:
message- the received message
-
handleMessage
Handles aBoardUpdatemessage. Saves the board status. If the player is the next one to play, prints a message.- Specified by:
handleMessagein interfaceClientMessageHandler- Overrides:
handleMessagein classUserInterface- Parameters:
message- the received message
-
handleMessage
Handles aUserSelectionUpdatemessage. 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:
handleMessagein interfaceClientMessageHandler- Overrides:
handleMessagein classUserInterface- Parameters:
message- the received message
-
handleMessage
Handles aGameOverUpdatemessage. Removes reconnection settings. Prints the winner. Stops the application.- Parameters:
message- the received message
-
handleMessage
Handles aInitialBoardStatusmessage. Saves the initial board status. Prints a message letting the player know that the game has started.- Parameters:
message- the received message
-
handleMessage
Handles aDisconnectionUpdatemessage. Prints a message with disconnection details.- Parameters:
message- the received message
-
quit
public void quit()Description copied from class:UserInterfaceNotifies the user that they have been disconnected from the game due to an error.- Specified by:
quitin classUserInterface
-