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 void
connect()
void
void
abstract void
connectToGame
(String gameId) abstract void
createAndConnectToGame
(String gameId, int numberPlayers) abstract void
createGame
(String gameId, int players) abstract void
abstract void
getGames()
Retrieves the list of available games and displays them in the viewabstract void
Gets the objective cards the client should choose fromvoid
abstract void
Gets the starter card the player has to placeabstract void
Sends a heart beat to the serverisLosing()
abstract void
Leaves the game the player has joined, if anyabstract void
Leaves lobbyabstract void
lobbyChooseObjectiveCard
(Boolean first) abstract void
lobbyJoinGame
(CardSideType cardSide) Sets the chosen starter card side and make player join gameabstract void
lobbySetNickname
(String nickname) abstract void
lobbySetToken
(TokenColor color) void
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)abstract void
nextTurn
(DrawingCardSource drawingSource, DrawingDeckType deckType) draws a card from the game board and continues to the next turnabstract void
placeCard
(Integer playerHandCardNumber, CardSideType side, Position position) Places a card in the gridabstract void
sendChatMessage
(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()
-