Class TotemChoice

java.lang.Object
it.polimi.ingsw.gc14.Network.NetworkEvent
it.polimi.ingsw.gc14.Network.NetworkEvents.TotemChoice
All Implemented Interfaces:
Serializable

public class TotemChoice extends NetworkEvent implements Serializable
Network event used to handle a player's totem choice.
See Also:
  • Field Details

    • totem

      private final String totem
      Name of the totem selected by the player.
    • availableTotems

      private List<Totems> availableTotems
      List of totems still available after the choice has been processed.
  • Constructor Details

    • TotemChoice

      public TotemChoice(String username, String totem)
      Constructs a totem choice event for the specified player.
      Parameters:
      username - the username of the player making the choice.
      totem - the name of the selected totem.
  • Method Details

    • enrichWithGameState

      public void enrichWithGameState(Game game, ArrayList<String> disconnectedUsernames)
      Description copied from class: NetworkEvent
      Populates 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 call super first.
      Overrides:
      enrichWithGameState in class NetworkEvent
      Parameters:
      game - the current game model.
      disconnectedUsernames - usernames of currently disconnected players.
    • apply

      public boolean apply(GameController gameController)
      Applies the totem choice event to the server-side game controller.
      Specified by:
      apply in class NetworkEvent
      Parameters:
      gameController - the game controller on which to apply the event.
      Returns:
      true if the totem choice is handled successfully, false otherwise.
    • apply

      public void apply(MiniModel miniModel)
      Applies the totem choice update to the client-side mini model.

      If the event does not represent an error, the player data, turn order, current game state, slot assignments, and available totems are updated.

      Specified by:
      apply in class NetworkEvent
      Parameters:
      miniModel - the mini model on which to apply the event.