Coverage Summary for Class: ApplyNextRound (it.polimi.ingsw.gc14.Network.NetworkEvents)
| Class |
Class, %
|
Method, %
|
Line, %
|
| ApplyNextRound |
0%
(0/1)
|
0%
(0/3)
|
0%
(0/18)
|
package it.polimi.ingsw.gc14.Network.NetworkEvents;
import it.polimi.ingsw.gc14.Controller.GameController;
import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Slot;
import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Network event that transitions all clients to the next round.
*
* <p>Carries refreshed card lists for all four board rows in addition
* to the standard game state (slot map, turn order, current state,
* player list). Only applied client-side; {@link #apply(GameController)}
* always returns {@code false}.
*/
public class ApplyNextRound extends NetworkEvent {
/** Tribe cards shown in the upper row of the board for the new round. */
private final ArrayList<TribeCard> upperListTribeCards;
/** Tribe cards shown in the lower row of the board for the new round. */
private final ArrayList<TribeCard> lowerListTribeCards;
/** Building cards shown in the upper row of the board for the new round. */
private final ArrayList<BuildingCard> upperListBuildingCards;
/** Building cards shown in the lower row of the board for the new round. */
private final ArrayList<BuildingCard> lowerListBuildingCards;
/**
* Constructs an event that updates the game state for the next round.
*
* @param slotPlayerMap the map associating each slot with the player occupying it.
* @param orderLogicCard the order logic card that determines the player order.
* @param currentState the current state of the game.
* @param players the list of players in the game.
* @param upperListTribeCards the upper row of tribe cards for the new round.
* @param lowerListTribeCards the lower row of tribe cards for the new round.
* @param upperListBuildingCards the upper row of building cards for the new round.
* @param lowerListBuildingCards the lower row of building cards for the new round.
*/
public ApplyNextRound(Map<Slot, Player> slotPlayerMap,
OrderLogicCard orderLogicCard,
CurrentState currentState,
List<Player> players,
ArrayList<TribeCard> upperListTribeCards,
ArrayList<TribeCard> lowerListTribeCards,
ArrayList<BuildingCard> upperListBuildingCards,
ArrayList<BuildingCard> lowerListBuildingCards) {
super("SERVER", EventType.NEXT_ROUND, false, ErrorType.WRONG_ACTION);
setData(slotPlayerMap, orderLogicCard, currentState, players);
this.upperListBuildingCards = upperListBuildingCards;
this.lowerListBuildingCards = lowerListBuildingCards;
this.upperListTribeCards = upperListTribeCards;
this.lowerListTribeCards = lowerListTribeCards;
}
/**
* Not applicable server-side.
*
* @param gameController the game controller (unused).
* @return {@code false} always.
*/
@Override
public boolean apply(GameController gameController) {
return false;
}
/**
* Applies this event to the client-side mini model, updating all board lists,
* slot map, turn order, and game state for the new round.
*
* @param miniModel the client-side model to update.
*/
@Override
public void apply(MiniModel miniModel) {
synchronized (miniModel) {
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setPlayers(playerList);
miniModel.setUpperListTribeCards(upperListTribeCards);
miniModel.setLowerListTribeCards(lowerListTribeCards);
miniModel.setUpperListBuildingCards(upperListBuildingCards);
miniModel.setLowerListBuildingCards(lowerListBuildingCards);
miniModel.setLastEvent(this);
}
}
}