Added: Totem CHoice first implementation

This commit is contained in:
rubenpirreram
2026-05-13 16:06:20 +02:00
parent 690a010248
commit fe18ad35ca
4 changed files with 71 additions and 1 deletions
@@ -6,6 +6,7 @@ package it.polimi.ingsw.gc14.Network;
*/
public enum EventType {
ADD_PLAYER,
TOTEM_CHOICE,
SLOT_CHOICE,
DRAW_UPPER_TRIBE,
DRAW_LOWER_TRIBE,
@@ -0,0 +1,57 @@
package it.polimi.ingsw.gc14.Network.NetworkEvents;
import it.polimi.ingsw.gc14.Controller.GameController;
import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.View.IView;
import java.io.Serializable;
import java.util.List;
/**
* NetworkEvent to select a slot where to place the player totem.
*/
public class TotemChoice extends NetworkEvent implements Serializable {
/** Index of the card to draw */
private int pos;
private List<Object>availableTotems;
public void setAvailableTotems(List<Object> availableTotems) {
this.availableTotems = availableTotems;
}
/**
* 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 TotemChoice(String username, int pos) {
super(username, EventType.TOTEM_CHOICE, false);
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.slotChoice(username, pos);
}
//TODO
@Override
public boolean apply(MiniModel miniModel){
if(isError)
return false;
miniModel.setPlayer(player);
miniModel.setOrderLogicCard(orderLogicCard);
miniModel.setCurrentState(currentState);
miniModel.setSlotPlayerMap(slotPlayerMap);
miniModel.setAvailableTotems(availableTotems);
return true;
}
}