Added: Totem CHoice first implementation
This commit is contained in:
@@ -41,6 +41,9 @@ public class Game implements Serializable {
|
|||||||
return playersList;
|
return playersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
private Queue<Player> totemChoiceQueue = new LinkedList<>();
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
public Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
public Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
||||||
//TODO
|
//TODO
|
||||||
@@ -75,6 +78,8 @@ public class Game implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Totem
|
||||||
|
|
||||||
public void ClearDisconnected()
|
public void ClearDisconnected()
|
||||||
{
|
{
|
||||||
disconnetedPlayers.clear();
|
disconnetedPlayers.clear();
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ public class MiniModel implements Serializable {
|
|||||||
public OrderLogicCard orderLogicCard;
|
public OrderLogicCard orderLogicCard;
|
||||||
public CurrentState currentState;
|
public CurrentState currentState;
|
||||||
public Map<String,Player> players;
|
public Map<String,Player> players;
|
||||||
public MiniModel(Board board, Map<Slot,Player> slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List<Player> players) {
|
public List<Object>availableTotems;
|
||||||
|
public MiniModel(Board board) {
|
||||||
|
this.board = board;
|
||||||
|
}
|
||||||
|
public MiniModel(Board board, Map<Slot,Player> slotPlayerMap, OrderLogicCard orderLogicCard, CurrentState currentState, List<Player> players, List<Object>availableTotems) {
|
||||||
this.board = board;
|
this.board = board;
|
||||||
this.slotPlayerMap = slotPlayerMap;
|
this.slotPlayerMap = slotPlayerMap;
|
||||||
this.orderLogicCard = orderLogicCard;
|
this.orderLogicCard = orderLogicCard;
|
||||||
@@ -27,6 +31,9 @@ public class MiniModel implements Serializable {
|
|||||||
public void setBoard(Board board) {
|
public void setBoard(Board board) {
|
||||||
this.board = board;
|
this.board = board;
|
||||||
}
|
}
|
||||||
|
public void setAvailableTotems(List<Object>availableTotems) {
|
||||||
|
this.availableTotems = availableTotems;
|
||||||
|
}
|
||||||
public void setSlotPlayerMap(Map<Slot,Player> slotPlayerMap) {
|
public void setSlotPlayerMap(Map<Slot,Player> slotPlayerMap) {
|
||||||
this.slotPlayerMap = slotPlayerMap;
|
this.slotPlayerMap = slotPlayerMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package it.polimi.ingsw.gc14.Network;
|
|||||||
*/
|
*/
|
||||||
public enum EventType {
|
public enum EventType {
|
||||||
ADD_PLAYER,
|
ADD_PLAYER,
|
||||||
|
TOTEM_CHOICE,
|
||||||
SLOT_CHOICE,
|
SLOT_CHOICE,
|
||||||
DRAW_UPPER_TRIBE,
|
DRAW_UPPER_TRIBE,
|
||||||
DRAW_LOWER_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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user