Class MiniModel

java.lang.Object
it.polimi.ingsw.gc14.Model.MiniModel
All Implemented Interfaces:
Serializable

public class MiniModel extends Object implements Serializable
Lightweight representation of the game model shared with clients.

The mini model contains only the information required by the client-side view and controllers to render the current match state and process incoming network updates.

See Also:
  • Field Details

    • upperListTribeCards

      public ArrayList<TribeCard> upperListTribeCards
      Upper row of tribe cards currently on the board.
    • lowerListTribeCards

      public ArrayList<TribeCard> lowerListTribeCards
      Lower row of tribe cards currently on the board.
    • upperListBuildingCards

      public ArrayList<BuildingCard> upperListBuildingCards
      Upper row of building cards currently on the board.
    • lowerListBuildingCards

      public ArrayList<BuildingCard> lowerListBuildingCards
      Lower row of building cards currently on the board.
    • disconnectedPlayers

      public ArrayList<String> disconnectedPlayers
      Usernames of players currently disconnected from the game.
    • lastEvent

      public NetworkEvent lastEvent
      The most recent network event applied to this model.
    • slotPlayerMap

      public Map<Slot,Player> slotPlayerMap
      Map associating each occupied slot with the corresponding player.
    • orderLogicCard

      public OrderLogicCard orderLogicCard
      Card used to manage the player turn order.
    • currentState

      public CurrentState currentState
      Current state of the game.
    • players

      public final Map<String,Player> players
      Map of players indexed by username.
    • availableTotems

      public List<Totems> availableTotems
      List of totems still available for selection.
    • standingPlayers

      public List<Player> standingPlayers
      Final standing of the players at the end of the game.
  • Constructor Details

    • MiniModel

      public MiniModel(Map<Slot,Player> slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List<Player> players, List<Totems> availableTotems, ArrayList<TribeCard> upperListTribeCards, ArrayList<TribeCard> lowerListTribeCards, ArrayList<BuildingCard> upperListBuildingCards, ArrayList<BuildingCard> lowerListBuildingCards, ArrayList<String> disconnectedPlayers)
      Constructs a complete mini model from the current server-side game data.
      Parameters:
      slotPlayerMap - the map associating occupied slots with players.
      orderLogicCard - the card managing player turn order.
      currentState - the current state of the game.
      players - the list of players in the match.
      availableTotems - the list of totems still available for selection.
      upperListTribeCards - the upper row of tribe cards on the board.
      lowerListTribeCards - the lower row of tribe cards on the board.
      upperListBuildingCards - the upper row of building cards on the board.
      lowerListBuildingCards - the lower row of building cards on the board.
      disconnectedPlayers - the list of usernames of currently disconnected players.
  • Method Details

    • setLastEvent

      public void setLastEvent(NetworkEvent lastEvent)
      Sets the last network event applied to the game state.
      Parameters:
      lastEvent - the most recent event received from the server.
    • setAvailableTotems

      public void setAvailableTotems(List<Totems> availableTotems)
      Sets the list of totems still available for selection.
      Parameters:
      availableTotems - the available totems.
    • setSlotPlayerMap

      public void setSlotPlayerMap(Map<Slot,Player> slotPlayerMap)
      Sets the map associating occupied slots with players.
      Parameters:
      slotPlayerMap - the slot-player map to assign.
    • setOrderLogicCard

      public void setOrderLogicCard(OrderLogicCard orderLogicCard)
      Sets the card used to manage the player turn order.
      Parameters:
      orderLogicCard - the order logic card to assign.
    • setCurrentState

      public void setCurrentState(CurrentState currentState)
      Sets the current state of the game.
      Parameters:
      currentState - the current game state.
    • setPlayers

      public void setPlayers(List<Player> players)
      Replaces or updates the players stored in the mini model.

      Each player is indexed by username.

      Parameters:
      players - the list of players to store.
    • setStandingPlayers

      public void setStandingPlayers(List<Player> standingPlayers)
      Sets the final standing of the players.
      Parameters:
      standingPlayers - the final ordered list of players.
    • setUpperListTribeCards

      public void setUpperListTribeCards(ArrayList<TribeCard> cards)
      Replaces the upper row of tribe cards on the board.
      Parameters:
      cards - the new upper tribe card list.
    • setLowerListTribeCards

      public void setLowerListTribeCards(ArrayList<TribeCard> cards)
      Replaces the lower row of tribe cards on the board.
      Parameters:
      cards - the new lower tribe card list.
    • setUpperListBuildingCards

      public void setUpperListBuildingCards(ArrayList<BuildingCard> cards)
      Replaces the upper row of building cards on the board.
      Parameters:
      cards - the new upper building card list.
    • setLowerListBuildingCards

      public void setLowerListBuildingCards(ArrayList<BuildingCard> cards)
      Replaces the lower row of building cards on the board.
      Parameters:
      cards - the new lower building card list.
    • removeUpperTribeCard

      public void removeUpperTribeCard(int pos)
      Removes the card at the given position from the upper tribe card list.
      Parameters:
      pos - the zero-based index of the card to remove.
    • removeLowerTribeCard

      public void removeLowerTribeCard(int pos)
      Removes the card at the given position from the lower tribe card list.
      Parameters:
      pos - the zero-based index of the card to remove.
    • removeUpperBuildingCard

      public void removeUpperBuildingCard(int pos)
      Removes the card at the given position from the upper building card list.
      Parameters:
      pos - the zero-based index of the card to remove.
    • removeLowerBuildingCard

      public void removeLowerBuildingCard(int pos)
      Removes the card at the given position from the lower building card list.
      Parameters:
      pos - the zero-based index of the card to remove.
    • getPositionByUsername

      public int getPositionByUsername(String username)
      Returns the position of the player with the specified username within the player collection.
      Parameters:
      username - the username of the player to search for.
      Returns:
      the zero-based position of the player, or -1 if no matching username is found.
    • setDisconnectedPlayers

      public void setDisconnectedPlayers(ArrayList<String> disconnectedPlayers)
      Sets the list of usernames of currently disconnected players.
      Parameters:
      disconnectedPlayers - the list of disconnected player usernames.