diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java index d037ce2..6863c8a 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -41,6 +41,9 @@ public class Game implements Serializable { return playersList; } + //TODO + private Queue totemChoiceQueue = new LinkedList<>(); + //TODO public Map disconnetedPlayers = new HashMap<>(); //TODO @@ -75,6 +78,8 @@ public class Game implements Serializable { return true; } + //Totem + public void ClearDisconnected() { disconnetedPlayers.clear(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java b/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java index bd90ad9..154f057 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java @@ -16,7 +16,11 @@ public class MiniModel implements Serializable { public OrderLogicCard orderLogicCard; public CurrentState currentState; public Map players; - public MiniModel(Board board, Map slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List players) { + public ListavailableTotems; + public MiniModel(Board board) { + this.board = board; + } + public MiniModel(Board board, Map slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List players, ListavailableTotems) { this.board = board; this.slotPlayerMap = slotPlayerMap; this.orderLogicCard = orderLogicCard; @@ -27,6 +31,9 @@ public class MiniModel implements Serializable { public void setBoard(Board board) { this.board = board; } + public void setAvailableTotems(ListavailableTotems) { + this.availableTotems = availableTotems; + } public void setSlotPlayerMap(Map slotPlayerMap) { this.slotPlayerMap = slotPlayerMap; } diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/EventType.java b/src/main/java/it/polimi/ingsw/gc14/Network/EventType.java index 1bbc99d..2bf097f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/EventType.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/EventType.java @@ -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, diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java new file mode 100644 index 0000000..136600d --- /dev/null +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java @@ -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 ListavailableTotems; + public void setAvailableTotems(List 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; + + } + +}