Added:(Game) Totem CHoice first implementation
This commit is contained in:
@@ -40,10 +40,35 @@ public class Game implements Serializable {
|
|||||||
public List<Player> getPlayers() {
|
public List<Player> getPlayers() {
|
||||||
return playersList;
|
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
|
//TODO
|
||||||
private Queue<Player> totemChoiceQueue = new LinkedList<>();
|
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
|
//TODO
|
||||||
public Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
public Map<Player,Boolean> disconnetedPlayers = new HashMap<>();
|
||||||
//TODO
|
//TODO
|
||||||
@@ -79,7 +104,7 @@ public class Game implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Totem
|
//Totem
|
||||||
|
//TODO
|
||||||
public void ClearDisconnected()
|
public void ClearDisconnected()
|
||||||
{
|
{
|
||||||
disconnetedPlayers.clear();
|
disconnetedPlayers.clear();
|
||||||
@@ -258,6 +283,7 @@ public class Game implements Serializable {
|
|||||||
if(getPlayerByUsername(player.getUserName())!=null)
|
if(getPlayerByUsername(player.getUserName())!=null)
|
||||||
return false;
|
return false;
|
||||||
playersList.add(player);
|
playersList.add(player);
|
||||||
|
totemChoiceQueue.add(player);
|
||||||
if(playersList.size()>=nPlayers)
|
if(playersList.size()>=nPlayers)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@@ -296,8 +322,8 @@ public class Game implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
currentState.PlayerUpdate(totemChoiceQueue.poll(),null);
|
||||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
currentState.GameStageUpdate(GameStages.TOTEM_CHOICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//region Controller Methods
|
//region Controller Methods
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ package it.polimi.ingsw.gc14.Model.GamePackage;
|
|||||||
* Represents the possible stages of a game.
|
* Represents the possible stages of a game.
|
||||||
*/
|
*/
|
||||||
public enum GameStages {
|
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