Class MiniModel
java.lang.Object
it.polimi.ingsw.gc14.Model.MiniModel
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionList of totems still available for selection.Current state of the game.Usernames of players currently disconnected from the game.The most recent network event applied to this model.Lower row of building cards currently on the board.Lower row of tribe cards currently on the board.Card used to manage the player turn order.Map of players indexed by username.Map associating each occupied slot with the corresponding player.Final standing of the players at the end of the game.Upper row of building cards currently on the board.Upper row of tribe cards currently on the board. -
Constructor Summary
ConstructorsConstructorDescriptionMiniModel(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. -
Method Summary
Modifier and TypeMethodDescriptionintgetPositionByUsername(String username) Returns the position of the player with the specified username within the player collection.voidremoveLowerBuildingCard(int pos) Removes the card at the given position from the lower building card list.voidremoveLowerTribeCard(int pos) Removes the card at the given position from the lower tribe card list.voidremoveUpperBuildingCard(int pos) Removes the card at the given position from the upper building card list.voidremoveUpperTribeCard(int pos) Removes the card at the given position from the upper tribe card list.voidsetAvailableTotems(List<Totems> availableTotems) Sets the list of totems still available for selection.voidsetCurrentState(CurrentState currentState) Sets the current state of the game.voidsetDisconnectedPlayers(ArrayList<String> disconnectedPlayers) Sets the list of usernames of currently disconnected players.voidsetLastEvent(NetworkEvent lastEvent) Sets the last network event applied to the game state.voidReplaces the lower row of building cards on the board.voidsetLowerListTribeCards(ArrayList<TribeCard> cards) Replaces the lower row of tribe cards on the board.voidsetOrderLogicCard(OrderLogicCard orderLogicCard) Sets the card used to manage the player turn order.voidsetPlayers(List<Player> players) Replaces or updates the players stored in the mini model.voidsetSlotPlayerMap(Map<Slot, Player> slotPlayerMap) Sets the map associating occupied slots with players.voidsetStandingPlayers(List<Player> standingPlayers) Sets the final standing of the players.voidReplaces the upper row of building cards on the board.voidsetUpperListTribeCards(ArrayList<TribeCard> cards) Replaces the upper row of tribe cards on the board.
-
Field Details
-
upperListTribeCards
-
lowerListTribeCards
-
upperListBuildingCards
Upper row of building cards currently on the board. -
lowerListBuildingCards
Lower row of building cards currently on the board. -
disconnectedPlayers
-
lastEvent
The most recent network event applied to this model. -
slotPlayerMap
-
orderLogicCard
Card used to manage the player turn order. -
currentState
Current state of the game. -
players
-
availableTotems
-
standingPlayers
-
-
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
Sets the last network event applied to the game state.- Parameters:
lastEvent- the most recent event received from the server.
-
setAvailableTotems
-
setSlotPlayerMap
-
setOrderLogicCard
Sets the card used to manage the player turn order.- Parameters:
orderLogicCard- the order logic card to assign.
-
setCurrentState
Sets the current state of the game.- Parameters:
currentState- the current game state.
-
setPlayers
-
setStandingPlayers
-
setUpperListTribeCards
-
setLowerListTribeCards
-
setUpperListBuildingCards
Replaces the upper row of building cards on the board.- Parameters:
cards- the new upper building card list.
-
setLowerListBuildingCards
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
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
-1if no matching username is found.
-
setDisconnectedPlayers
-