From 514e22d61f98fa1e9694adca192b2380d5eb5599 Mon Sep 17 00:00:00 2001 From: rubenpirreram Date: Sat, 16 May 2026 20:03:18 +0200 Subject: [PATCH] Fixed: next player setup logic --- .../java/it/polimi/ingsw/gc14/Model/Game.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) 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 2c4ac8d..8aac3d6 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -391,10 +391,6 @@ public class Game implements Serializable { { return false; } - if(slotPlayerEntry.getKey().getSlotId()=='A') - { - player.addFood(3); - } slotMap.put(slotPlayerEntry.getKey(),player); nextPlayerSetup(); return true; @@ -437,7 +433,7 @@ public class Game implements Serializable { tempCard.insert(player); board.removeUpperTribeCard(tempCard); currentState.UpperDrawn(); - if((currentState.getNLower() ==0 ||( getLowerListTribeCards().size()==0 && getLowerListBuilding().size()==0)) && ((currentState.getNUpper() ==0)||( getUpperListTribeCards().size()==0 && getUpperListBuilding().size()==0))) + if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) nextPlayerSetup(); return true; } @@ -508,7 +504,7 @@ public class Game implements Serializable { tempCard.insert(player); board.removeLowerTribeCard(tempCard); currentState.LowerDrawn(); - if((currentState.getNLower() ==0 ||( getLowerListTribeCards().size()==0 && getLowerListBuilding().size()==0)) && ((currentState.getNUpper() ==0)||( getUpperListTribeCards().size()==0 && getUpperListBuilding().size()==0))) + if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) nextPlayerSetup(); return true; @@ -547,7 +543,7 @@ public class Game implements Serializable { } else return false; - if((currentState.getNLower() ==0 ||( getLowerListTribeCards().size()==0 && getLowerListBuilding().size()==0)) && ((currentState.getNUpper() ==0)||( getUpperListTribeCards().size()==0 && getUpperListBuilding().size()==0))) + if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) nextPlayerSetup(); return true; @@ -587,7 +583,7 @@ public class Game implements Serializable { } else return false; - if((currentState.getNLower() ==0 ||( getLowerListTribeCards().size()==0 && getLowerListBuilding().size()==0)) && ((currentState.getNUpper() ==0)||( getUpperListTribeCards().size()==0 && getUpperListBuilding().size()==0))) + if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().isEmpty()))) nextPlayerSetup(); return true; @@ -728,15 +724,20 @@ public class Game implements Serializable { currentState.GameStageUpdate(GameStages.RES_ACTIONS); boolean anyAssigned = false; - for (Slot s : slotMap.keySet()) { - if (slotMap.get(s) != null) { - currentState.PlayerUpdate(slotMap.get(s), s); - + for (Map.Entry entry : slotMap.entrySet()) { + if (entry.getValue() != null) { + if(entry.getKey().getSlotId()=='A') + { + entry.getValue().addFood(3); + orderLogicCard.push(entry.getValue()); + entry.setValue(null); + continue; + } + currentState.PlayerUpdate(entry.getValue(), entry.getKey()); boolean hasDrawableLower = currentState.getNLower() > 0 && (hasDrawableDown() || !getLowerListBuilding().isEmpty()); boolean hasDrawableUpper = currentState.getNUpper() > 0 && (hasDrawableUp() || !getUpperListBuilding().isEmpty()); - if (!hasDrawableLower && !hasDrawableUpper) { // This player has nothing drawable, skip them immediately orderLogicCard.push(currentState.getCurrentPlayer()); @@ -757,25 +758,27 @@ public class Game implements Serializable { } if (GameStages.RES_ACTIONS == currentState.getGameStage()) { - orderLogicCard.push(currentState.getCurrentPlayer()); + if(!disconnetedPlayers.containsKey(currentState.getCurrentPlayer())|| !disconnetedPlayers.get(currentState.getCurrentPlayer())) + orderLogicCard.push(currentState.getCurrentPlayer()); slotMap.put(currentState.getSlot(), null); - for (Slot s : slotMap.keySet()) { - if (slotMap.get(s) != null) { - currentState.PlayerUpdate(slotMap.get(s), s); - if(disconnetedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnetedPlayers.get(currentState.getCurrentPlayer())) + for (Map.Entry entry : slotMap.entrySet()) { + if (entry.getValue() != null) { + + if(disconnetedPlayers.containsKey(entry.getValue())&&disconnetedPlayers.get(currentState.getCurrentPlayer())) { - slotMap.put(currentState.getSlot(), null); + entry.setValue(null); continue; } + currentState.PlayerUpdate(entry.getValue(), entry.getKey()); boolean hasDrawableLower = currentState.getNLower() > 0 && (hasDrawableDown() || !getLowerListBuilding().isEmpty()); boolean hasDrawableUpper = currentState.getNUpper() > 0 && (hasDrawableUp() || !getUpperListBuilding().isEmpty()); if (!hasDrawableLower && !hasDrawableUpper) { // This player also has nothing, skip and continue the loop - orderLogicCard.push(currentState.getCurrentPlayer()); - slotMap.put(currentState.getSlot(), null); + orderLogicCard.push(entry.getValue()); + entry.setValue(null); } else { // Found a player with something to do, stop here return;