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 TypeMethodDescriptionvoidconnect()voidconnectToGame(String gameId) voidcreateAndConnectToGame(String gameId, int players) voidcreateGame(String gameId, int players) voidvoidgetGames()Retrieves the list of available games and displays them in the viewvoidGets the objective cards the client should choose fromvoidGets the starter card the player has to placevoidhandleMessage(Message message) voidhandleMessage(AvailableGameLobbiesMessage message) voidhandleMessage(ObjectiveCardsMessage message) voidhandleMessage(StarterCardSidesMessage message) voidhandleMessage(InvalidActionMessage message) voidhandleMessage(NotAClientMessageMessage ignored) voidhandleMessage(UnknownMessageTypeMessage ignored) voidhandleMessage(ChatMessageMessage message) voidhandleMessage(CardPlacedMessage message) voidhandleMessage(GameHaltedMessage gameHaltedMessage) voidhandleMessage(GameOverMessage ignored) voidhandleMessage(NextTurnUpdateMessage message) voidhandleMessage(PlayerJoinedGameMessage message) voidhandleMessage(PlayerScoresUpdateMessage message) voidhandleMessage(RemainingRoundsMessage message) voidhandleMessage(WinningPlayerMessage message) voidhandleMessage(GameCreatedMessage message) voidhandleMessage(GameDeletedMessage message) voidhandleMessage(GameStartedMessage message) voidhandleMessage(LobbyInfoMessage message) voidvoidhandleMessage(PlayerJoinedLobbyMessage message) voidhandleMessage(PlayerLeftLobbyMessage message) voidhandleMessage(PlayerSetNicknameMessage message) voidhandleMessage(PlayerSetTokenColorMessage message) voidvoidhandleMessage(UserContextMessage message) voidSends a heart beat to the servervoidLeaves the game the player has joined, if anyvoidLeaves lobbyvoidlobbyChooseObjectiveCard(Boolean first) voidlobbyJoinGame(CardSideType cardSide) Sets the chosen starter card side and make player join gamevoidlobbySetNickname(String nickname) voidlobbySetToken(TokenColor color) voidnextTurn()Goes to next turn ( called only when the game is in the last round, since you cannot draw a card in that case)voidnextTurn(DrawingCardSource drawingSource, DrawingDeckType deckType) draws a card from the game board and continues to the next turnvoidplaceCard(Integer playerHandCardNumber, CardSideType side, Position position) Places a card in the gridvoidsendChatMessage(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:
connectin classClientConnectionHandler
-
disconnect
public void disconnect()- Specified by:
disconnectin classClientConnectionHandler
-
getGames
public void getGames()Description copied from class:ClientConnectionHandlerRetrieves the list of available games and displays them in the view- Specified by:
getGamesin classClientConnectionHandler
-
createGame
- Specified by:
createGamein classClientConnectionHandler- Parameters:
gameId- the id of the game to createplayers- the number of players in the game
-
connectToGame
- Specified by:
connectToGamein classClientConnectionHandler- Parameters:
gameId- the id of the game to connect to
-
leaveGameLobby
public void leaveGameLobby()Description copied from class:ClientConnectionHandlerLeaves the game the player has joined, if any- Specified by:
leaveGameLobbyin classClientConnectionHandler
-
createAndConnectToGame
- Specified by:
createAndConnectToGamein classClientConnectionHandler- Parameters:
gameId- the id of the game create and connect to
-
lobbySetToken
- Specified by:
lobbySetTokenin classClientConnectionHandler- Parameters:
color- the color of the chosen token color
-
lobbySetNickname
- Specified by:
lobbySetNicknamein classClientConnectionHandler- Parameters:
nickname- the nickname of the lobby player
-
getObjectiveCards
public void getObjectiveCards()Description copied from class:ClientConnectionHandlerGets the objective cards the client should choose from- Specified by:
getObjectiveCardsin classClientConnectionHandler
-
lobbyChooseObjectiveCard
- Specified by:
lobbyChooseObjectiveCardin classClientConnectionHandler- Parameters:
first- true if the player selects the first card in the pair otherwise false
-
getStarterCard
public void getStarterCard()Description copied from class:ClientConnectionHandlerGets the starter card the player has to place- Specified by:
getStarterCardin classClientConnectionHandler
-
lobbyJoinGame
Description copied from class:ClientConnectionHandlerSets the chosen starter card side and make player join game- Specified by:
lobbyJoinGamein classClientConnectionHandler- Parameters:
cardSide- the starter card side chosen by the player
-
placeCard
Description copied from class:ClientConnectionHandlerPlaces a card in the grid- Specified by:
placeCardin 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:ClientConnectionHandlerLeaves lobby- Specified by:
leaveLobbyin classClientConnectionHandler
-
nextTurn
Description copied from class:ClientConnectionHandlerdraws a card from the game board and continues to the next turn- Specified by:
nextTurnin 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:ClientConnectionHandlerGoes to next turn ( called only when the game is in the last round, since you cannot draw a card in that case)- Specified by:
nextTurnin classClientConnectionHandler
-
heartBeat
Description copied from class:ClientConnectionHandlerSends a heart beat to the server- Specified by:
heartBeatin classClientConnectionHandler
-
sendChatMessage
- Specified by:
sendChatMessagein 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
-