Class DisconnectedPlayer
java.lang.Object
it.polimi.ingsw.gc14.Network.NetworkEvent
it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer
- All Implemented Interfaces:
Serializable
Network event used to notify all clients that a player has disconnected.
Also carries the updated list of available totems, since a disconnection during totem selection may free a totem for other players.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionUpdated list of totems available after the disconnection frees any previously chosen totem.Fields inherited from class NetworkEvent
currentState, disconnectedPlayers, errorType, eventType, isError, orderLogicCard, playerList, slotPlayerMap, username -
Constructor Summary
ConstructorsConstructorDescriptionDisconnectedPlayer(String username) Constructs a disconnection event for the specified player. -
Method Summary
Modifier and TypeMethodDescriptionbooleanapply(GameController gameController) Applies this disconnection event to the server-side game controller.voidApplies this disconnection event to the client-side mini model, updating player data, turn order, game state, and disconnected player list.voidenrichWithGameState(Game game, ArrayList<String> disconnectedUsernames) Populates this event with the current game state so clients can update their local model after receiving it.Methods inherited from class NetworkEvent
getErrorType, getEventType, getUsername, isError, setData, setErrorType, setIsError, toString
-
Field Details
-
availableTotems
-
-
Constructor Details
-
DisconnectedPlayer
Constructs a disconnection event for the specified player.- Parameters:
username- the username of the player who disconnected.
-
-
Method Details
-
enrichWithGameState
Description copied from class:NetworkEventPopulates this event with the current game state so clients can update their local model after receiving it. Subclasses that carry extra state (available totems, etc.) override this method and callsuperfirst.- Overrides:
enrichWithGameStatein classNetworkEvent- Parameters:
game- the current game model.disconnectedUsernames- usernames of currently disconnected players.
-
apply
Applies this disconnection event to the server-side game controller.- Specified by:
applyin classNetworkEvent- Parameters:
gameController- the game controller on which to apply the event.- Returns:
trueif the disconnection is handled successfully.
-
apply
Applies this disconnection event to the client-side mini model, updating player data, turn order, game state, and disconnected player list.- Specified by:
applyin classNetworkEvent- Parameters:
miniModel- the client-side model to update.
-