Module polimi.ingsw.am21.codex
Class TCPClientConnectionHandler
java.lang.Object
polimi.ingsw.am21.codex.connection.client.ClientConnectionHandler
polimi.ingsw.am21.codex.connection.client.TCP.TCPClientConnectionHandler
-
Constructor Summary
ConstructorsConstructorDescriptionTCPClientConnectionHandler
(String host, int port, View view, ClientGameEventHandler gameEventHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
void
connectToGame
(String gameId) void
createAndConnectToGame
(String gameId, int players) void
createGame
(String gameId, int players) void
void
getGames()
Retrieves the list of available games and displays them in the viewvoid
Gets the objective cards the client should choose fromvoid
Gets the starter card the player has to placevoid
handleMessage
(Message message) void
handleMessage
(AvailableGameLobbiesMessage message) void
handleMessage
(ObjectiveCardsMessage message) void
handleMessage
(StarterCardSidesMessage message) void
handleMessage
(InvalidActionMessage message) void
handleMessage
(NotAClientMessageMessage ignored) void
handleMessage
(UnknownMessageTypeMessage ignored) void
handleMessage
(ChatMessageMessage message) void
handleMessage
(CardPlacedMessage message) void
handleMessage
(GameHaltedMessage gameHaltedMessage) void
handleMessage
(GameOverMessage ignored) void
handleMessage
(NextTurnUpdateMessage message) void
handleMessage
(PlayerJoinedGameMessage message) void
handleMessage
(PlayerScoresUpdateMessage message) void
handleMessage
(RemainingRoundsMessage message) void
handleMessage
(WinningPlayerMessage message) void
handleMessage
(GameCreatedMessage message) void
handleMessage
(GameDeletedMessage message) void
handleMessage
(GameStartedMessage message) void
handleMessage
(LobbyInfoMessage message) void
void
handleMessage
(PlayerJoinedLobbyMessage message) void
handleMessage
(PlayerLeftLobbyMessage message) void
handleMessage
(PlayerSetNicknameMessage message) void
handleMessage
(PlayerSetTokenColorMessage message) void
void
handleMessage
(UserContextMessage message) void
Sends a heart beat to the servervoid
Leaves the game the player has joined, if anyvoid
Leaves lobbyvoid
lobbyChooseObjectiveCard
(Boolean first) void
lobbyJoinGame
(CardSideType cardSide) Sets the chosen starter card side and make player join gamevoid
lobbySetNickname
(String nickname) void
lobbySetToken
(TokenColor color) void
nextTurn()
Goes to next turn ( called only when the game is in the last round, since you cannot draw a card in that case)void
nextTurn
(DrawingCardSource drawingSource, DrawingDeckType deckType) draws a card from the game board and continues to the next turnvoid
placeCard
(Integer playerHandCardNumber, CardSideType side, Position position) Places a card in the gridvoid
sendChatMessage
(ChatMessage message) Methods inherited from class polimi.ingsw.am21.codex.connection.client.ClientConnectionHandler
connectionEstablished, connectionFailed, getConnectionType, getObjectivesIfNull, isConnected, isConnectedOrLosing, isLosing, messageNotSent
-
Constructor Details
-
TCPClientConnectionHandler
public TCPClientConnectionHandler(String host, int port, View view, ClientGameEventHandler gameEventHandler)
-
-
Method Details
-
connect
public void connect()- Specified by:
connect
in classClientConnectionHandler
-
disconnect
public void disconnect()- Specified by:
disconnect
in classClientConnectionHandler
-
getGames
public void getGames()Description copied from class:ClientConnectionHandler
Retrieves the list of available games and displays them in the view- Specified by:
getGames
in classClientConnectionHandler
-
createGame
- Specified by:
createGame
in classClientConnectionHandler
- Parameters:
gameId
- the id of the game to createplayers
- the number of players in the game
-
connectToGame
- Specified by:
connectToGame
in classClientConnectionHandler
- Parameters:
gameId
- the id of the game to connect to
-
leaveGameLobby
public void leaveGameLobby()Description copied from class:ClientConnectionHandler
Leaves the game the player has joined, if any- Specified by:
leaveGameLobby
in classClientConnectionHandler
-
createAndConnectToGame
- Specified by:
createAndConnectToGame
in classClientConnectionHandler
- Parameters:
gameId
- the id of the game create and connect to
-
lobbySetToken
- Specified by:
lobbySetToken
in classClientConnectionHandler
- Parameters:
color
- the color of the chosen token color
-
lobbySetNickname
- Specified by:
lobbySetNickname
in classClientConnectionHandler
- Parameters:
nickname
- the nickname of the lobby player
-
getObjectiveCards
public void getObjectiveCards()Description copied from class:ClientConnectionHandler
Gets the objective cards the client should choose from- Specified by:
getObjectiveCards
in classClientConnectionHandler
-
lobbyChooseObjectiveCard
- Specified by:
lobbyChooseObjectiveCard
in classClientConnectionHandler
- Parameters:
first
- true if the player selects the first card in the pair otherwise false
-
getStarterCard
public void getStarterCard()Description copied from class:ClientConnectionHandler
Gets the starter card the player has to place- Specified by:
getStarterCard
in classClientConnectionHandler
-
lobbyJoinGame
Description copied from class:ClientConnectionHandler
Sets the chosen starter card side and make player join game- Specified by:
lobbyJoinGame
in classClientConnectionHandler
- Parameters:
cardSide
- the starter card side chosen by the player
-
placeCard
Description copied from class:ClientConnectionHandler
Places a card in the grid- Specified by:
placeCard
in classClientConnectionHandler
- Parameters:
playerHandCardNumber
- the index of the card to place from the player handside
- which side the player wants to place itposition
- the target position
-
leaveLobby
public void leaveLobby()Description copied from class:ClientConnectionHandler
Leaves lobby- Specified by:
leaveLobby
in classClientConnectionHandler
-
nextTurn
Description copied from class:ClientConnectionHandler
draws a card from the game board and continues to the next turn- Specified by:
nextTurn
in classClientConnectionHandler
- Parameters:
drawingSource
- the source were we get the carddeckType
- the type of card that we draw
-
nextTurn
public void nextTurn()Description copied from class:ClientConnectionHandler
Goes to next turn ( called only when the game is in the last round, since you cannot draw a card in that case)- Specified by:
nextTurn
in classClientConnectionHandler
-
heartBeat
Description copied from class:ClientConnectionHandler
Sends a heart beat to the server- Specified by:
heartBeat
in classClientConnectionHandler
-
sendChatMessage
- Specified by:
sendChatMessage
in classClientConnectionHandler
-
getGameState
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-
handleMessage
-