Package it.polimi.ingsw.eriantys.client
Class UserInterface
java.lang.Object
it.polimi.ingsw.eriantys.client.UserInterface
- All Implemented Interfaces:
ClientMessageHandler,Runnable
- Direct Known Subclasses:
CommandLineInterface,GraphicalUserInterface
This abstract class represents the generic user interface, which is associated with a single
Client.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.google.gson.JsonObjectJSON structured object containing information about character cards that should be available to the player.protected ClientReference to the client object to which this user interface is associated. -
Constructor Summary
ConstructorsConstructorDescriptionReads the JSON file and saves the information about character cards. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleMessage(Message message) Handles a genericMessage.voidhandleMessage(Ping message) Handles aPingmessage.voidhandleMessage(AssistantCardUpdate message) Handles aAssistantCardUpdatemessage.voidhandleMessage(BoardUpdate message) Handles aBoardUpdatemessage.voidhandleMessage(CharacterCardUpdate message) Handles aCharacterCardUpdatemessage.voidhandleMessage(LastRoundUpdate message) Handles aLastRoundUpdatemessage.voidhandleMessage(ReconnectionUpdate message) Handles aReconnectionUpdatemessage.voidhandleMessage(Refused message) Handles aRefusedmessage.voidhandleMessage(RefusedReconnect message) Handles aRefusedReconnectmessage.voidhandleMessage(UserSelectionUpdate message) Handles aUserSelectionUpdatemessage.voidinit()This method can be overridden if there are initialization steps that can only be processed after the UI has started.abstract voidquit()Notifies the user that they have been disconnected from the game due to an error.voidSets the reference to the client.abstract voidShows an error message to the user.abstract voidShows an information message to the user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.polimi.ingsw.eriantys.client.ClientMessageHandler
handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage, handleMessage
-
Field Details
-
client
Reference to the client object to which this user interface is associated. -
characterCardInfo
protected final com.google.gson.JsonObject characterCardInfoJSON structured object containing information about character cards that should be available to the player.
-
-
Constructor Details
-
UserInterface
Reads the JSON file and saves the information about character cards.- Throws:
IOException- if the file can't be opened or read
-
-
Method Details
-
setClient
Sets the reference to the client.- Parameters:
client-Clientobject to which this user interface is associated
-
init
public void init()This method can be overridden if there are initialization steps that can only be processed after the UI has started. -
showInfo
Shows an information message to the user.- Parameters:
details- the message to show
-
showError
Shows an error message to the user.- Parameters:
details- the message to show
-
handleMessage
Handles a genericMessage. Shows an error because the message was not recognized.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Handles aRefusedReconnectmessage. Shows an error with theRefusedReconnectmessage and removes reconnection settings from the client.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Description copied from interface:ClientMessageHandlerHandles aUserSelectionUpdatemessage.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Description copied from interface:ClientMessageHandlerHandles aAssistantCardUpdatemessage.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Description copied from interface:ClientMessageHandlerHandles aBoardUpdatemessage.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Handles aCharacterCardUpdatemessage. Prints the name of the played card.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Description copied from interface:ClientMessageHandlerHandles aLastRoundUpdatemessage.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
Handles aReconnectionUpdatemessage. Prints a message with reconnection details.- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
handleMessage
- Specified by:
handleMessagein interfaceClientMessageHandler- Parameters:
message- the received message
-
quit
public abstract void quit()Notifies the user that they have been disconnected from the game due to an error.
-