From 39e06886a331f3758c6d656199852a575783d3e7 Mon Sep 17 00:00:00 2001 From: rubenpirreram Date: Fri, 1 May 2026 18:01:45 +0200 Subject: [PATCH] Fixed: No Drawable Logic --- .../java/it/polimi/ingsw/gc14/Model/Game.java | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 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 add7416..42b5261 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -318,6 +318,44 @@ public class Game implements Serializable { return true; } + public boolean SkipUpperDrawing(Player player) { + if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) + { + return false; + } + if(!player.equals(currentState.getCurrentPlayer())) + { + return false; + } + if(currentState.getNUpper() <1) + return false; + if(hasDrawableUp()) + return false; + currentState.UpperDrawn(); + if((currentState.getNLower() ==0 ||( !hasDrawableDown() && getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(getUpperListBuilding().isEmpty()))) + nextPlayerSetup(); + return true; + } + + public boolean SkipLowerDrawing(Player player) { + if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) + { + return false; + } + if(!player.equals(currentState.getCurrentPlayer())) + { + return false; + } + if(currentState.getNUpper() <1) + return false; + if(hasDrawableDown()) + return false; + currentState.LowerDrawn(); + if((currentState.getNLower() ==0 ||( getLowerListBuilding().isEmpty())) && ((currentState.getNUpper() ==0)||(!hasDrawableUp()&&getUpperListBuilding().isEmpty()))) + nextPlayerSetup(); + return true; + } + /** * Attempts to draw the lower tribe card at the specified index for the specified player. * The operation succeeds only if the index is valid, the game stage is {@code RESOLVING_ACTIONS}, @@ -569,7 +607,7 @@ public class Game implements Serializable { for (Slot s : slotMap.keySet()) { if (slotMap.get(s) != null) { currentState.PlayerUpdate(slotMap.get(s), s); - 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().size()==0)) && ((currentState.getNUpper() ==0)||(!hasDrawableUp() && getUpperListBuilding().size()==0)))) break; else { @@ -587,7 +625,7 @@ public class Game implements Serializable { for (Slot s : slotMap.keySet()) { if (slotMap.get(s) != null) { currentState.PlayerUpdate(slotMap.get(s), s); - 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().size()==0)) && ((currentState.getNUpper() ==0)||( !hasDrawableUp() && getUpperListBuilding().size()==0))) { orderLogicCard.push(currentState.getCurrentPlayer()); slotMap.put(currentState.getSlot(), null); @@ -661,7 +699,14 @@ public class Game implements Serializable { } } - + private boolean hasDrawableUp() + { + return getUpperListTribeCards().stream().filter(x-> !x.IsEventCard()).count()==0; + } + private boolean hasDrawableDown() + { + return getLowerListTribeCards().stream().filter(x-> !x.IsEventCard()).count()==0; + } /** * Resolves all pending event cards if the current game stage is {@code RESOLVING_EVENT}. * All pending events are activated on the player list.