Fixed: next player setup logic

This commit is contained in:
rubenpirreram
2026-05-16 20:03:18 +02:00
parent 34732b1bf6
commit 514e22d61f
@@ -391,10 +391,6 @@ public class Game implements Serializable {
{ {
return false; return false;
} }
if(slotPlayerEntry.getKey().getSlotId()=='A')
{
player.addFood(3);
}
slotMap.put(slotPlayerEntry.getKey(),player); slotMap.put(slotPlayerEntry.getKey(),player);
nextPlayerSetup(); nextPlayerSetup();
return true; return true;
@@ -437,7 +433,7 @@ public class Game implements Serializable {
tempCard.insert(player); tempCard.insert(player);
board.removeUpperTribeCard(tempCard); board.removeUpperTribeCard(tempCard);
currentState.UpperDrawn(); 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(); nextPlayerSetup();
return true; return true;
} }
@@ -508,7 +504,7 @@ public class Game implements Serializable {
tempCard.insert(player); tempCard.insert(player);
board.removeLowerTribeCard(tempCard); board.removeLowerTribeCard(tempCard);
currentState.LowerDrawn(); 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(); nextPlayerSetup();
return true; return true;
@@ -547,7 +543,7 @@ public class Game implements Serializable {
} }
else else
return false; 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(); nextPlayerSetup();
return true; return true;
@@ -587,7 +583,7 @@ public class Game implements Serializable {
} }
else else
return false; 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(); nextPlayerSetup();
return true; return true;
@@ -728,15 +724,20 @@ public class Game implements Serializable {
currentState.GameStageUpdate(GameStages.RES_ACTIONS); currentState.GameStageUpdate(GameStages.RES_ACTIONS);
boolean anyAssigned = false; boolean anyAssigned = false;
for (Slot s : slotMap.keySet()) { for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) {
if (slotMap.get(s) != null) { if (entry.getValue() != null) {
currentState.PlayerUpdate(slotMap.get(s), s); 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 boolean hasDrawableLower = currentState.getNLower() > 0
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty()); && (hasDrawableDown() || !getLowerListBuilding().isEmpty());
boolean hasDrawableUpper = currentState.getNUpper() > 0 boolean hasDrawableUpper = currentState.getNUpper() > 0
&& (hasDrawableUp() || !getUpperListBuilding().isEmpty()); && (hasDrawableUp() || !getUpperListBuilding().isEmpty());
if (!hasDrawableLower && !hasDrawableUpper) { if (!hasDrawableLower && !hasDrawableUpper) {
// This player has nothing drawable, skip them immediately // This player has nothing drawable, skip them immediately
orderLogicCard.push(currentState.getCurrentPlayer()); orderLogicCard.push(currentState.getCurrentPlayer());
@@ -757,25 +758,27 @@ public class Game implements Serializable {
} }
if (GameStages.RES_ACTIONS == currentState.getGameStage()) { 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); slotMap.put(currentState.getSlot(), null);
for (Slot s : slotMap.keySet()) { for (Map.Entry<Slot,Player> entry : slotMap.entrySet()) {
if (slotMap.get(s) != null) { if (entry.getValue() != null) {
currentState.PlayerUpdate(slotMap.get(s), s);
if(disconnetedPlayers.containsKey(currentState.getCurrentPlayer())&& disconnetedPlayers.get(currentState.getCurrentPlayer())) if(disconnetedPlayers.containsKey(entry.getValue())&&disconnetedPlayers.get(currentState.getCurrentPlayer()))
{ {
slotMap.put(currentState.getSlot(), null); entry.setValue(null);
continue; continue;
} }
currentState.PlayerUpdate(entry.getValue(), entry.getKey());
boolean hasDrawableLower = currentState.getNLower() > 0 boolean hasDrawableLower = currentState.getNLower() > 0
&& (hasDrawableDown() || !getLowerListBuilding().isEmpty()); && (hasDrawableDown() || !getLowerListBuilding().isEmpty());
boolean hasDrawableUpper = currentState.getNUpper() > 0 boolean hasDrawableUpper = currentState.getNUpper() > 0
&& (hasDrawableUp() || !getUpperListBuilding().isEmpty()); && (hasDrawableUp() || !getUpperListBuilding().isEmpty());
if (!hasDrawableLower && !hasDrawableUpper) { if (!hasDrawableLower && !hasDrawableUpper) {
// This player also has nothing, skip and continue the loop // This player also has nothing, skip and continue the loop
orderLogicCard.push(currentState.getCurrentPlayer()); orderLogicCard.push(entry.getValue());
slotMap.put(currentState.getSlot(), null); entry.setValue(null);
} else { } else {
// Found a player with something to do, stop here // Found a player with something to do, stop here
return; return;