Module polimi.ingsw.am21.codex
Class ClientConnectionHandler
java.lang.Object
polimi.ingsw.am21.codex.connection.client.ClientConnectionHandler
- Direct Known Subclasses:
RMIClientConnectionHandler,TCPClientConnectionHandler
-
Constructor Summary
ConstructorsConstructorDescriptionClientConnectionHandler(String host, Integer port, View view, ClientGameEventHandler gameEventHandler) ClientConnectionHandler(String host, Integer port, View view, ClientGameEventHandler gameEventHandler, UUID connectionID) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidconnect()voidvoidabstract voidconnectToGame(String gameId) abstract voidcreateAndConnectToGame(String gameId, int numberPlayers) abstract voidcreateGame(String gameId, int players) abstract voidabstract voidgetGames()Retrieves the list of available games and displays them in the viewabstract voidGets the objective cards the client should choose fromvoidabstract voidGets the starter card the player has to placeabstract voidSends a heart beat to the serverisLosing()abstract voidLeaves the game the player has joined, if anyabstract voidLeaves lobbyabstract voidlobbyChooseObjectiveCard(Boolean first) abstract voidlobbyJoinGame(CardSideType cardSide) Sets the chosen starter card side and make player join gameabstract voidlobbySetNickname(String nickname) abstract voidlobbySetToken(TokenColor color) voidabstract voidnextTurn()Goes to next turn ( called only when the game is in the last round, since you cannot draw a card in that case)abstract voidnextTurn(DrawingCardSource drawingSource, DrawingDeckType deckType) draws a card from the game board and continues to the next turnabstract voidplaceCard(Integer playerHandCardNumber, CardSideType side, Position position) Places a card in the gridabstract voidsendChatMessage(ChatMessage message)
-
Constructor Details
-
ClientConnectionHandler
public ClientConnectionHandler(String host, Integer port, View view, ClientGameEventHandler gameEventHandler) -
ClientConnectionHandler
public ClientConnectionHandler(String host, Integer port, View view, ClientGameEventHandler gameEventHandler, UUID connectionID)
-
-
Method Details
-
getConnectionType
-
getGames
public abstract void getGames()Retrieves the list of available games and displays them in the view -
createGame
- Parameters:
gameId- the id of the game to createplayers- the number of players in the game
-
connectToGame
- Parameters:
gameId- the id of the game to connect to
-
leaveGameLobby
public abstract void leaveGameLobby()Leaves the game the player has joined, if any -
createAndConnectToGame
- Parameters:
gameId- the id of the game create and connect to
-
lobbySetToken
- Parameters:
color- the color of the chosen token color
-
lobbySetNickname
- Parameters:
nickname- the nickname of the lobby player
-
getObjectiveCards
public abstract void getObjectiveCards()Gets the objective cards the client should choose from -
lobbyChooseObjectiveCard
- Parameters:
first- true if the player selects the first card in the pair otherwise false
-
getStarterCard
public abstract void getStarterCard()Gets the starter card the player has to place -
lobbyJoinGame
Sets the chosen starter card side and make player join game- Parameters:
cardSide- the starter card side chosen by the player
-
placeCard
Places a card in the grid- 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 abstract void leaveLobby()Leaves lobby -
nextTurn
draws a card from the game board and continues to the next turn- Parameters:
drawingSource- the source were we get the carddeckType- the type of card that we draw
-
nextTurn
public abstract 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) -
heartBeat
Sends a heart beat to the server- Throws:
PlayerNotFoundException
-
sendChatMessage
-
connect
public abstract void connect() -
disconnect
public abstract void disconnect() -
isConnected
-
isLosing
-
isConnectedOrLosing
-
messageNotSent
public void messageNotSent() -
connectionFailed
-
connectionEstablished
public void connectionEstablished() -
getObjectivesIfNull
public void getObjectivesIfNull()
-