Coverage Summary for Class: DrawLowerBuildingCard (it.polimi.ingsw.gc14.Network.NetworkEvents)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
| DrawLowerBuildingCard |
0%
(0/1)
|
0%
(0/3)
|
0%
(0/2)
|
0%
(0/13)
|
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.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
/**
* NetworkEvent to draw a building card from the lower card list.
*/
public class DrawLowerBuildingCard extends NetworkEvent{
/** Index of the card to draw */
private final int pos;
/**
* Class constructor.
* Initializes all the attributes.
* @param username the name of the player requesting the event
* @param pos the index of the card to draw
*/
public DrawLowerBuildingCard(String username, int pos){
super(username, EventType.DRAW_LOWER_BUILD, false, ErrorType.WRONG_ACTION);
this.pos = pos;
}
/**
* @param gameController the Game Controller on which to apply the event
* @return true if the player could draw the card, false otherwise
*/
@Override
public boolean apply(GameController gameController){
return gameController.drawLowerBuildingCard(username, pos);
}
/**
* Applies this event to the client-side mini model, removing the drawn card
* from the lower building list and updating players, turn order, game state, and slot map.
*
* @param miniModel the client-side model to update.
*/
@Override
public void apply(MiniModel miniModel){
synchronized (miniModel) {
if (isError)
return;
miniModel.removeLowerBuildingCard(pos);
miniModel.setPlayers(playerList);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setLastEvent(this);
}
}
}