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
Modifier and TypeFieldDescriptionprotected final com.google.gson.JsonObject
JSON structured object containing information about character cards that should be available to the player.protected Client
Reference to the client object to which this user interface is associated. -
Constructor Summary
ConstructorDescriptionReads the JSON file and saves the information about character cards. -
Method Summary
Modifier and TypeMethodDescriptionvoid
handleMessage
(Message message) Handles a genericMessage
.void
handleMessage
(Ping message) Handles aPing
message.void
handleMessage
(AssistantCardUpdate message) Handles aAssistantCardUpdate
message.void
handleMessage
(BoardUpdate message) Handles aBoardUpdate
message.void
handleMessage
(CharacterCardUpdate message) Handles aCharacterCardUpdate
message.void
handleMessage
(LastRoundUpdate message) Handles aLastRoundUpdate
message.void
handleMessage
(ReconnectionUpdate message) Handles aReconnectionUpdate
message.void
handleMessage
(Refused message) Handles aRefused
message.void
handleMessage
(RefusedReconnect message) Handles aRefusedReconnect
message.void
handleMessage
(UserSelectionUpdate message) Handles aUserSelectionUpdate
message.void
init()
This method can be overridden if there are initialization steps that can only be processed after the UI has started.abstract void
quit()
Notifies the user that they have been disconnected from the game due to an error.void
Sets the reference to the client.abstract void
Shows an error message to the user.abstract void
Shows an information message to the user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
-Client
object 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:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Handles aRefusedReconnect
message. Shows an error with theRefusedReconnect
message and removes reconnection settings from the client.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Description copied from interface:ClientMessageHandler
Handles aUserSelectionUpdate
message.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Description copied from interface:ClientMessageHandler
Handles aAssistantCardUpdate
message.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Description copied from interface:ClientMessageHandler
Handles aBoardUpdate
message.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Handles aCharacterCardUpdate
message. Prints the name of the played card.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Description copied from interface:ClientMessageHandler
Handles aLastRoundUpdate
message.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
Handles aReconnectionUpdate
message. Prints a message with reconnection details.- Specified by:
handleMessage
in interfaceClientMessageHandler
- Parameters:
message
- the received message
-
handleMessage
- Specified by:
handleMessage
in 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.
-