Added:(Game) Totem CHoice first implementation
This commit is contained in:
@@ -40,10 +40,35 @@ public class Game implements Serializable {
|
||||
public List<Player> getPlayers() {
|
||||
return playersList;
|
||||
}
|
||||
|
||||
//TODO
|
||||
public List<Totems>getAvailableTotems() {
|
||||
List<Totems> totems=new ArrayList<>(List.of(Totems.values()));
|
||||
playersList.forEach(player -> {if(player.totem!=null)totems.remove(player.totem);});
|
||||
return totems;
|
||||
}
|
||||
//TODO
|
||||
private Queue<Player> totemChoiceQueue = new LinkedList<>();
|
||||
|
||||
//TODO
|
||||
private boolean TotemChoice(Player player,Totems totem) {
|
||||
if(!currentState.getGameStage().equals(GameStages.TOTEM_CHOICE))
|
||||
return false;
|
||||
if(!getCurrentState().getCurrentPlayer().equals(player))
|
||||
return false;
|
||||
if(!getAvailableTotems().contains(totem))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
player.totem=totem;
|
||||
Player nextPlayer= totemChoiceQueue.poll();
|
||||
if(nextPlayer==null)
|
||||
{
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO
|
||||
public Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
||||
//TODO
|
||||
@@ -79,7 +104,7 @@ public class Game implements Serializable {
|
||||
}
|
||||
|
||||
//Totem
|
||||
|
||||
//TODO
|
||||
public void ClearDisconnected()
|
||||
{
|
||||
disconnetedPlayers.clear();
|
||||
@@ -258,6 +283,7 @@ public class Game implements Serializable {
|
||||
if(getPlayerByUsername(player.getUserName())!=null)
|
||||
return false;
|
||||
playersList.add(player);
|
||||
totemChoiceQueue.add(player);
|
||||
if(playersList.size()>=nPlayers)
|
||||
{
|
||||
init();
|
||||
@@ -296,8 +322,8 @@ public class Game implements Serializable {
|
||||
}
|
||||
|
||||
}
|
||||
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||
currentState.PlayerUpdate(totemChoiceQueue.poll(),null);
|
||||
currentState.GameStageUpdate(GameStages.TOTEM_CHOICE);
|
||||
}
|
||||
|
||||
//region Controller Methods
|
||||
|
||||
@@ -4,5 +4,5 @@ package it.polimi.ingsw.gc14.Model.GamePackage;
|
||||
* Represents the possible stages of a game.
|
||||
*/
|
||||
public enum GameStages {
|
||||
WAITING, SLOT_CHOICE, RES_ACTIONS, OPT_CARD_E, RES_EVENT, ENDING, ENDED
|
||||
WAITING,TOTEM_CHOICE, SLOT_CHOICE, RES_ACTIONS, OPT_CARD_E, RES_EVENT, ENDING, ENDED
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user