From bac4a6b7f5aa555e2205d44fe5e283799c86def3 Mon Sep 17 00:00:00 2001 From: aleandro Date: Sun, 14 Jun 2026 21:01:43 +0200 Subject: [PATCH] Initial problem solving (identified by Intellij) --- .../polimi/ingsw/gc14/ClientLauncherTUI.java | 10 +- .../gc14/Controller/ClientController.java | 2 +- .../java/it/polimi/ingsw/gc14/ErrorType.java | 2 - .../java/it/polimi/ingsw/gc14/LimitedMap.java | 7 - .../Model/Cards/Building/BuildingEffect.java | 8 -- .../Cards/Building/Effects/Building0.java | 1 - .../Cards/Building/Effects/Building1.java | 2 +- .../Cards/Building/Effects/Building10.java | 1 - .../Cards/Building/Effects/Building11.java | 5 +- .../Cards/Building/Effects/Building13.java | 1 - .../Cards/Building/Effects/Building4.java | 1 - .../Cards/Building/Effects/Building8.java | 1 - .../ingsw/gc14/Model/Cards/BuildingCard.java | 7 +- .../ingsw/gc14/Model/Cards/TribeCard.java | 3 +- .../Model/Cards/TribeCards/Character.java | 2 +- .../Cards/TribeCards/Characters/Hunter.java | 2 +- .../Cards/TribeCards/Characters/Shaman.java | 2 +- .../Model/Cards/TribeCards/EventCard.java | 2 +- .../TribeCards/Events/CavePaintings.java | 9 +- .../Model/Cards/TribeCards/Events/Hunt.java | 2 +- .../TribeCards/Events/ShamanicRitual.java | 11 +- .../Cards/TribeCards/Events/Sustenance.java | 2 +- .../java/it/polimi/ingsw/gc14/Model/Game.java | 4 +- .../ingsw/gc14/Model/GamePackage/Board.java | 14 +- .../it/polimi/ingsw/gc14/Model/MiniModel.java | 11 -- .../ingsw/gc14/Model/OrderLogicCard.java | 8 +- .../ingsw/gc14/Model/Orders/Order2.java | 7 +- .../polimi/ingsw/gc14/Model/PlayableCard.java | 2 +- .../java/it/polimi/ingsw/gc14/Model/Slot.java | 4 +- .../ingsw/gc14/Network/NetworkEvent.java | 4 +- .../gc14/Network/NetworkEvents/AddPlayer.java | 2 +- .../Network/NetworkEvents/ApplyNextRound.java | 8 +- .../NetworkEvents/DrawLowerBuildingCard.java | 2 +- .../NetworkEvents/DrawLowerTribeCard.java | 2 +- .../NetworkEvents/DrawUpperBuildingCard.java | 2 +- .../NetworkEvents/DrawUpperTribeCard.java | 2 +- .../Network/NetworkEvents/SlotChoice.java | 2 +- .../Network/NetworkEvents/TotemChoice.java | 11 +- .../RMI/Client/ClientCallbackImpl.java | 1 - .../gc14/Network/RMI/Client/RMIClient.java | 5 +- .../Network/RMI/Common/IClientCallback.java | 1 - .../gc14/Network/RMI/Server/RMIServer.java | 27 +--- .../gc14/Network/TCP/Client/TCPClient.java | 10 +- .../Network/TCP/Server/ClientHandler.java | 13 +- .../gc14/Network/TCP/Server/TCPServer.java | 10 +- .../gc14/View/GUI/FireParticleSystem.java | 18 +-- .../it/polimi/ingsw/gc14/View/GUI/GUI.java | 2 +- .../View/GUI/LeaderboardFXMLController.java | 8 +- .../gc14/View/GUI/LoginFXMLController.java | 3 - .../gc14/View/GUI/MainFXMLController.java | 13 -- .../it/polimi/ingsw/gc14/View/TUI/TUI.java | 5 - src/main/resources/GUIScene/login.fxml | 4 +- src/main/resources/GUIScene/main.fxml | 128 +++++++++--------- src/main/resources/GUIScene/standing.fxml | 1 - src/main/resources/GUIScene/totem.fxml | 13 +- .../Cards/Building/Effects/Building1Test.java | 2 +- .../gc14/Model/Cards/BuildingCardTest.java | 1 - .../TribeCards/Events/CavePaintingsTest.java | 18 +-- .../Cards/TribeCards/Events/HuntTest.java | 14 -- .../TribeCards/Events/ShamanicRitualTest.java | 18 --- .../TribeCards/Events/SustenanceTest.java | 1 - .../gc14/Model/GamePackage/BoardTest.java | 6 +- .../ingsw/gc14/Model/Orders/Order2Test.java | 5 +- .../ingsw/gc14/Model/Orders/Order3Test.java | 1 - .../ingsw/gc14/Model/Orders/Order4Test.java | 1 - .../ingsw/gc14/Model/Orders/Order5Test.java | 19 +-- .../ingsw/gc14/Model/PlayableCardTest.java | 1 - .../polimi/ingsw/gc14/Model/PlayerTest.java | 10 +- .../it/polimi/ingsw/gc14/Model/SlotTest.java | 16 +-- 69 files changed, 175 insertions(+), 368 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java index 6e4276d..9aacd2a 100644 --- a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java @@ -121,7 +121,7 @@ public class ClientLauncherTUI { if (!doLogin(controller)) continue; while (controller.getClient() != null) { - String prompt = buildPrompt(controller); + String prompt = buildPrompt(); String line; try { line = gameReader.readLine(prompt); @@ -247,10 +247,9 @@ public class ClientLauncherTUI { /** * Returns the command-line prompt string showing the current username. * - * @param controller the client controller (reserved for future use). * @return the prompt string. */ - private String buildPrompt(ClientController controller) { + private String buildPrompt() { return currentUsername.isEmpty() ? "> " : currentUsername + "> "; } @@ -270,7 +269,7 @@ public class ClientLauncherTUI { if (pos >= 0) controller.totemChoice(pos); } case "skip" -> controller.skipTurn(); - case "clear" -> handleRender(parts); + case "clear" -> handleRender(); case "help" -> gameReader.printAbove("Commands: slot, draw, totem, skip, clear, help, details, rematch, quit"); case "details" -> { if (parts.length > 1 && parts[1].equalsIgnoreCase("buildings")) @@ -325,9 +324,8 @@ public class ClientLauncherTUI { /** * Handles the {@code clear} command by triggering a full board re-render. * - * @param parts the tokenised command (only the command token is used). */ - private void handleRender(String[] parts) { + private void handleRender() { view.renderBoard(); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java index 0bacdb9..b5faf01 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java +++ b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java @@ -18,7 +18,7 @@ public class ClientController { private MiniModel miniModel; /** View of the client. */ - private IView view; + private final IView view; /** Network client, either TCP or RMI. */ private IClient client; diff --git a/src/main/java/it/polimi/ingsw/gc14/ErrorType.java b/src/main/java/it/polimi/ingsw/gc14/ErrorType.java index 0f50536..8f92add 100644 --- a/src/main/java/it/polimi/ingsw/gc14/ErrorType.java +++ b/src/main/java/it/polimi/ingsw/gc14/ErrorType.java @@ -2,8 +2,6 @@ package it.polimi.ingsw.gc14; /** Enumeration of error types that can be returned by server-side operations. */ public enum ErrorType { - /** The requested user does not exist. */ - USER_NOT_FOUND("User not found"), /** The chosen username is already taken by another connected player. */ USERNAME_ALREADY_USED("Username is already in use"), /** The user is already connected to the server. */ diff --git a/src/main/java/it/polimi/ingsw/gc14/LimitedMap.java b/src/main/java/it/polimi/ingsw/gc14/LimitedMap.java index 3673b0c..cbf69a4 100644 --- a/src/main/java/it/polimi/ingsw/gc14/LimitedMap.java +++ b/src/main/java/it/polimi/ingsw/gc14/LimitedMap.java @@ -101,13 +101,6 @@ public class LimitedMap implements Map { */ public void setLimit(int num) { this.limit = num; } - /** - * Returns the current size limit of this map. - * - * @return the current limit. - */ - public int getLimit() { return limit; } - /** * Sets a new action to execute when the map size reaches or exceeds the limit. * diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/BuildingEffect.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/BuildingEffect.java index bcbe693..a0f6b5c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/BuildingEffect.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/BuildingEffect.java @@ -1,7 +1,5 @@ package it.polimi.ingsw.gc14.Model.Cards.Building; -import it.polimi.ingsw.gc14.Model.Player; - /** * Defines the effect behavior of a building card. * @@ -10,10 +8,4 @@ import it.polimi.ingsw.gc14.Model.Player; */ public interface BuildingEffect { - /** - * Applies the building effect to the specified player. - * - * @param player the player affected by the building effect. - */ - void applyEffect(Player player); } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java index 44ae2c5..6868525 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java @@ -127,7 +127,6 @@ public class Building0 extends BuildingCard { * @param player the player who owns the building. * @throws IllegalArgumentException if the specified player does not own this card. */ - @Override public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java index 4ccc527..084348b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java @@ -13,7 +13,7 @@ public class Building1 extends BuildingCard { /** * Character type involved in the building effect. */ - private CharacterType icon ; + private final CharacterType icon ; /** * Returns the character type associated with this building effect. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java index d785d13..b776c18 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java @@ -64,7 +64,6 @@ public class Building10 extends BuildingCard { * @param player the player to whom the effect is applied. * @throws IllegalArgumentException if the player does not own this building card. */ - @Override public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java index bc9c861..a32c9dd 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java @@ -17,7 +17,7 @@ public class Building11 extends BuildingCard { /** * The character type involved in this building effect. */ - private CharacterType characterType; + private final CharacterType characterType; /** * Returns the CharacterType associated with this building card effect. @@ -29,7 +29,7 @@ public class Building11 extends BuildingCard { /** * The prestige multiplier applied per matching character card at end of game. */ - private int prestigeMul; + private final int prestigeMul; /** * Returns the prestige multiplier associated with this building card effect. @@ -93,7 +93,6 @@ public class Building11 extends BuildingCard { * @param player the player to whom the effect is applied. * @throws IllegalArgumentException if the player does not own this building card. */ - @Override public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java index 4a5f977..23a884c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java @@ -57,7 +57,6 @@ public class Building13 extends BuildingCard{ * @param player the player to whom the effect is applied. * @throws IllegalArgumentException if the player does not own this building card. */ - @Override public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java index f2f8d53..22485dc 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java @@ -130,7 +130,6 @@ public class Building4 extends BuildingCard { * @param player The player who owns the building. * @throws IllegalArgumentException Thrown if the specified player does not own this card. */ - @Override public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java index a698624..a26f01b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java @@ -55,7 +55,6 @@ public class Building8 extends BuildingCard { * @param player The player who owns the building. * @throws IllegalArgumentException Thrown if the specified player does not own this building. */ - @Override public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java index 8926eaa..98b444c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java @@ -168,12 +168,8 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf private static EffectType effectTypeFromId(int effectId) { switch (effectId) { - case 2: return EffectType.ON_EVENT; + case 2, 9, 7, 6, 5: return EffectType.ON_EVENT; case 3: return EffectType.ON_END_TURN; - case 5: return EffectType.ON_EVENT; - case 6: return EffectType.ON_EVENT; - case 7: return EffectType.ON_EVENT; - case 9: return EffectType.ON_EVENT; case 12: return EffectType.ON_ROUND_END; default: throw new IllegalArgumentException(); } @@ -225,7 +221,6 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf * * @param player the player to whom the effect may be applied. */ - @Override public void applyEffect(Player player) {} @Override diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java index 5944f14..2c611fd 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java @@ -1,6 +1,5 @@ package it.polimi.ingsw.gc14.Model.Cards; -import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character; import it.polimi.ingsw.gc14.Model.PlayableCard; import java.io.Serializable; @@ -15,7 +14,7 @@ public abstract class TribeCard extends PlayableCard implements Serializable { /** * Indicates whether this tribe card is an event card. */ - private boolean isEventCard; + private final boolean isEventCard; /** * Returns whether this tribe card is an event card. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java index 9ce0cb2..86e1226 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java @@ -14,7 +14,7 @@ public abstract class Character extends TribeCard implements Cloneable { /** * The specific type of this character card. */ - private CharacterType type; + private final CharacterType type; /** * Returns the type of this character card. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java index b42dd5d..5fd415e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java @@ -17,7 +17,7 @@ public class Hunter extends Character { * {@code Hunter} with an {@code Hunter Icon} is added to the tribe, 1 {@code Food token} is awarded for each Hunter in the tribe * (with or without an icon). */ - private boolean icon; + private final boolean icon; /** * Returns whether this Hunter card has the icon. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java index 86489eb..84005be 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java @@ -18,7 +18,7 @@ public class Shaman extends Character { * having the minority, on the other hand, results in * losing Prestige Points. */ - private int icon; + private final int icon; /** * Returns the icon value of this Shaman card. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java index 9e99ecc..04c4673 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java @@ -15,7 +15,7 @@ public abstract class EventCard extends TribeCard { /** * The specific type of this event card. */ - private EventType type; + private final EventType type; /** * Returns the type of this event card. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java index 845b68f..0661c29 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java @@ -1,10 +1,7 @@ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; -import it.polimi.ingsw.gc14.Model.Cards.TribeCard; -import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType; -import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard; import it.polimi.ingsw.gc14.Model.Player; @@ -21,17 +18,17 @@ public class CavePaintings extends EventCard { * The minimum number of Artist cards required to avoid the prestige penalty. * Also, the bottom number on the card. */ - private int nLower; + private final int nLower; /** * The amount of Prestige removed if the player has fewer Artist cards than {@code nLower}. */ - private int nPrestigeRem; // NPrestigeLower + private final int nPrestigeRem; // NPrestigeLower /** * The Prestige multiplier applied if the player has at least {@code nLower} Artist cards. */ - private int nPrestigeMul; // NPrestigeUpper + private final int nPrestigeMul; // NPrestigeUpper /** * Creates a CavePaintings event card with the specified era and effect parameters. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java index 4bdf028..063e183 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java @@ -17,7 +17,7 @@ public class Hunt extends EventCard { private static final int BASE_FOOD_PER_HUNTER = 1; /** Prestige Points multiplier used during the event. */ - private int prestigeMultiplier; + private final int prestigeMultiplier; int getPrestigeMultiplier() { return prestigeMultiplier; } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java index 7a857c3..14a3795 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * When activated, rewards the player with the most shaman icons and penalizes the one with the fewest. @@ -19,7 +18,7 @@ public class ShamanicRitual extends EventCard { private static final int BUILDING5_BONUS_ICONS = 3; /** Prestige points awarded to the player with the most shaman icons. */ - private int prestigeToAdd; + private final int prestigeToAdd; /** * Returns the prestige points awarded to the player with the most shaman icons. @@ -29,7 +28,7 @@ public class ShamanicRitual extends EventCard { int getPrestigeToAdd() { return prestigeToAdd; } /** Prestige points removed from the player with the fewest shaman icons. */ - private int prestigeToRemove; + private final int prestigeToRemove; /** * Returns the prestige points removed from the player with the fewest shaman icons. @@ -98,8 +97,8 @@ public class ShamanicRitual extends EventCard { int maxIcon = playerMap.values().stream().mapToInt(Integer::intValue).max().orElse(0); int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0); - List maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).collect(Collectors.toList()); - List minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).collect(Collectors.toList()); + List maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).toList(); + List minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).toList(); for (Player player : maxIconsPlayer) { @@ -111,7 +110,7 @@ public class ShamanicRitual extends EventCard { } for (Player player : minIconsPlayer) { - if (!(player.getBuildingCards().stream().anyMatch(b -> b.getEffectId() == 2))) { + if (player.getBuildingCards().stream().noneMatch(b -> b.getEffectId() == 2)) { player.removePrestige(prestigeToRemove); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java index c5856da..0a18294 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java @@ -21,7 +21,7 @@ public class Sustenance extends EventCard { /** * The prestige penalty multiplier applied for each unpaid Food unit. */ - private int prestigeDebt; + private final int prestigeDebt; /** * Returns the prestige penalty multiplier associated with this Sustenance event. 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 597f5d4..50c426b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -66,7 +66,7 @@ public class Game implements Serializable { /** * Queue containing the players who still have to choose their totem. */ - private Queue totemChoiceQueue = new LinkedList<>(); + private final Queue totemChoiceQueue = new LinkedList<>(); /** * Assigns the selected totem to the specified player during the totem choice phase. @@ -122,7 +122,7 @@ public class Game implements Serializable { * Map tracking the players who are currently disconnected. * Key: player; value: {@code true} if currently disconnected, {@code false} if reconnected. */ - private Map disconnectedPlayers = new HashMap<>(); + private final Map disconnectedPlayers = new HashMap<>(); /** * Returns an unmodifiable view of the disconnected-players map. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java index 59e9f81..5cc8b26 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java @@ -20,29 +20,29 @@ public class Board implements Serializable { * slotList contains the ordered list of slots (tiles). The slots changes based on the number of players. * Each slot (tile) has special action as drawing from the upper/lower row or taking food. */ - private List slotList; + private final List slotList; /** tribeDeck is the deck from where you draw tribe cards as characters and events. */ - private Queue tribeDeck; + private final Queue tribeDeck; /** * The upper row of tribe cards. It contains a total of * {@code nTotem + 4} tribe cards, which may include both character and event cards. */ - private List upperListTribe; + private final List upperListTribe; /** * The lower row of the tribe card. During the first round, there will be (num. of players + 1) character cards. * During the following rounds, lower row will be emptied and populated with upper row's cards. * When an Event card gets in the lower row, the event effect will be activated at the end of the round. */ - private List lowerListTribe; + private final List lowerListTribe; /** Contains all the building cards of the upper list. When a new era starts, all its building cards are placed here. */ - private List upperListBuilding; + private final List upperListBuilding; /** Contains all the building cards of the lower list. When a new era starts, the old era's buildings are moved from the upper to the lower list. */ - private List lowerListBuilding; + private final List lowerListBuilding; /** * Returns the upper row of tribe cards. @@ -75,7 +75,7 @@ public class Board implements Serializable { /** All building card lists grouped by era; index 0 = era 1, index 1 = era 2, etc. */ private final ArrayList> buildingCardsAllEras; /** Number of players */ - private int nTotem; + private final int nTotem; /** Current era of the game */ private int era; diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java b/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java index 12f4219..10347c7 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java @@ -2,9 +2,7 @@ package it.polimi.ingsw.gc14.Model; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard; -import it.polimi.ingsw.gc14.Model.GamePackage.Board; import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState; -import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; import java.io.Serializable; @@ -177,15 +175,6 @@ public class MiniModel implements Serializable { } } - /** - * Adds or updates a single player in the mini model. - * - * @param player the player to store. - */ - public void setPlayer(Player player) { - players.put(player.getUserName(), player); - } - /** * Sets the final standing of the players. * diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java index 225fc2b..921e77a 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java @@ -1,13 +1,9 @@ package it.polimi.ingsw.gc14.Model; -import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer; -import it.polimi.ingsw.gc14.View.TUI.AsciiTable; -import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import java.io.Serializable; import java.util.*; -import java.util.stream.Collectors; /** * Abstract base class for all order logic cards. @@ -20,13 +16,13 @@ public abstract class OrderLogicCard implements Serializable { /** * The queue of {@link Player Players} associated with this order logic card. */ - private Queue players; + private final Queue players; /** * The list of {@link OrderPlayer} entries tracking turn order and played status. * Protected so subclasses can read it for display purposes (e.g., {@link #toString()}). */ - protected List playerList; + protected final List playerList; /** * Returns an unmodifiable view of the player order list. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java index 88e4111..4900f35 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order2.java @@ -6,7 +6,6 @@ import it.polimi.ingsw.gc14.View.TUI.AsciiTable; import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import java.util.*; -import java.util.stream.IntStream; /** * Represents the order logic card used in a two-player game. @@ -51,10 +50,8 @@ public class Order2 extends OrderLogicCard { buildingEffect(player); return; } - if(index==1){ - if(!player.removeFood(1)){ - player.removePrestige(2); - } + if (!player.removeFood(1)) { + player.removePrestige(2); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java index c3ea8ff..238f144 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java @@ -11,7 +11,7 @@ public abstract class PlayableCard implements Serializable { /** * The image identifier of the playable card. */ - private String idIMG; + private final String idIMG; /** * Returns the image identifier of this playable card. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java b/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java index bd2c903..f3d26c9 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java @@ -12,7 +12,7 @@ public class Slot implements Serializable { /** * The identifier of this slot. */ - private char slotId; + private final char slotId; /** * Returns the identifier of this slot. @@ -171,7 +171,7 @@ public class Slot implements Serializable { StringBuilder s = new StringBuilder(" "); for(int i=0;i upperListTribeCards; - private ArrayList lowerListTribeCards; - private ArrayList upperListBuildingCards; - private ArrayList lowerListBuildingCards; + private final ArrayList upperListTribeCards; + private final ArrayList lowerListTribeCards; + private final ArrayList upperListBuildingCards; + private final ArrayList lowerListBuildingCards; /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java index e0f819c..6a31cba 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java @@ -12,7 +12,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent; */ public class DrawLowerBuildingCard extends NetworkEvent{ /** Index of the card to draw */ - private int pos; + private final int pos; /** * Class constructor. diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java index d1d1813..cfd36e3 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java @@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent; public class DrawLowerTribeCard extends NetworkEvent{ /** Index of the card to draw */ - private int pos; + private final int pos; /** * Class constructor. diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java index e366280..8905424 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java @@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent; public class DrawUpperBuildingCard extends NetworkEvent{ /** Index of the card to draw */ - private int pos; + private final int pos; /** * Class constructor. diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java index 6f4d3b1..df05c24 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java @@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent; public class DrawUpperTribeCard extends NetworkEvent{ /** Index of the card to draw */ - private int pos; + private final int pos; /** * Class constructor. diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java index 61aa5d3..0eb7b6b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java @@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent; public class SlotChoice extends NetworkEvent { /** Index of the selected slot. */ - private int pos; + private final int pos; /** * Class constructor. diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java index bdbf962..fb87143 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/TotemChoice.java @@ -20,22 +20,13 @@ public class TotemChoice extends NetworkEvent implements Serializable { /** * Name of the totem selected by the player. */ - private String totem; + private final String totem; /** * List of totems still available after the choice has been processed. */ private List availableTotems; - /** - * Sets the list of currently available totems. - * - * @param availableTotems the totems still available for selection. - */ - public void setAvailableTotems(List availableTotems) { - this.availableTotems = availableTotems; - } - /** * Constructs a totem choice event for the specified player. * diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/ClientCallbackImpl.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/ClientCallbackImpl.java index 2d3305d..1f0ebd4 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/ClientCallbackImpl.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/ClientCallbackImpl.java @@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback; -import javafx.application.Platform; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java index 3eb575b..0081c92 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java @@ -8,7 +8,6 @@ import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.NetworkConfig; -import it.polimi.ingsw.gc14.Network.NetworkEvents.*; import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer; /** @@ -19,8 +18,8 @@ public class RMIClient implements IClient { private final String host; private final int port; private IGameServer stub; - private ClientController controller; - private String myIp; + private final ClientController controller; + private final String myIp; private String username; private volatile boolean running = false; diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Common/IClientCallback.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Common/IClientCallback.java index 6c77591..0be3f69 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Common/IClientCallback.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Common/IClientCallback.java @@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent; import java.io.Serializable; import java.rmi.*; -import java.util.Map; /** * Callback interface used by the server to notify an RMI client about diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java index 472b62c..5c440ad 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; -import java.rmi.*; import java.util.stream.Collectors; @@ -36,7 +35,6 @@ import java.util.stream.Collectors; public class RMIServer extends UnicastRemoteObject implements IGameServer { private final String host; private final GameController controller; - private Registry registry; private final int nPort; /** username → callback */ @@ -304,7 +302,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer { public boolean start() { try { System.setProperty("java.rmi.server.hostname", host); - registry = LocateRegistry.createRegistry(nPort); + Registry registry = LocateRegistry.createRegistry(nPort); registry.rebind("RMIGameServer", this); System.out.println("RMI Server started on port: " + nPort); return true; @@ -314,29 +312,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer { } } - /** - * Stops the RMI server and removes its binding from the registry. - * - *

The remote server object is unexported, the registry entry associated - * with {@code RMIGameServer} is removed, and the server shutdown is logged. - * - * @return {@code true} if the server is stopped successfully, - * {@code false} otherwise. - */ - public boolean stop() { - try { - registry.unbind("RMIGameServer"); - UnicastRemoteObject.unexportObject(this, true); - watchdogs.values().forEach(RMIHeartbeat::disconnect); - watchdogs.clear(); - System.out.println("RMI Server stopped"); - return true; - } catch (RemoteException | NotBoundException e) { - e.printStackTrace(); - return false; - } - } - /** * Creates and starts an {@link RMIHeartbeat} for the specified player. diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java index d11a582..c6868b6 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java @@ -31,16 +31,16 @@ public class TCPClient implements IClient { private ObjectOutputStream socketSend; /** Client game's controller */ - private ClientController controller; + private final ClientController controller; /** IP address of the server to connect to */ - private String hostname; + private final String hostname; private boolean running; /** TCP port */ - private int mainPort; + private final int mainPort; - private int heartbeatPort; + private final int heartbeatPort; private Socket heartbeatSocket; private OutputStream heartbeatOut; private InputStream heartbeatIn; @@ -134,7 +134,7 @@ public class TCPClient implements IClient { heartbeatSocket.setSoTimeout((int) NetworkConfig.SILENCE_THRESHOLD_MS); while (running) { int b = heartbeatIn.read(); - if (b == -1 || b != PONG) { + if (b != PONG) { disconnect(); controller.getView().showError(ErrorType.SERVER_CRASHED, ErrorType.SERVER_CRASHED.toString()); break; diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java index a10f832..f74cb8f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java @@ -1,7 +1,6 @@ package it.polimi.ingsw.gc14.Network.TCP.Server; import it.polimi.ingsw.gc14.LimitedMap; -import it.polimi.ingsw.gc14.Model.Game; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer; @@ -34,25 +33,25 @@ public class ClientHandler implements Runnable { return username; } /** The TCP socket */ - private Socket clientSocket; + private final Socket clientSocket; /** Input stream used to receive objects from the client */ - private ObjectInputStream in; + private final ObjectInputStream in; /** Output stream used to send objects to the client */ - private ObjectOutputStream out; + private final ObjectOutputStream out; /** * Shared list of all client handlers. * This handler removes itself from the list when disconnected. */ - private List clientHandlers; + private final List clientHandlers; /** Maps each connected player's username to their connection state (true = connected). */ - private LimitedMap limitedMap; + private final LimitedMap limitedMap; /** Queue containing the events to be applied to the game model */ - private BlockingQueue actionQueue; + private final BlockingQueue actionQueue; /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/TCPServer.java b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/TCPServer.java index ecb9fea..811f7a4 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/TCPServer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/TCPServer.java @@ -35,12 +35,12 @@ public class TCPServer { /** * Main TCP port used for standard client-server communication. */ - private int port; + private final int port; /** * TCP port dedicated to heartbeat communication. */ - private int heartbeatPort; + private final int heartbeatPort; /** * Main server socket used to accept client connections. @@ -60,17 +60,17 @@ public class TCPServer { /** * Queue containing network events received from clients. */ - private BlockingQueue actionQueue; + private final BlockingQueue actionQueue; /** * Map storing the online/offline status of connected players. */ - private LimitedMap playerList; + private final LimitedMap playerList; /** * List of active TCP client handlers. */ - private CopyOnWriteArrayList clientHandlers; + private final CopyOnWriteArrayList clientHandlers; /** diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/FireParticleSystem.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/FireParticleSystem.java index f279f6a..2ef001f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/FireParticleSystem.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/FireParticleSystem.java @@ -21,8 +21,7 @@ import java.util.Random; *

  • dust (type 2) — large, translucent brown drifting circles.
  • * * - *

    Call {@link #start()} after adding {@link #getPane()} to the scene graph, - * and {@link #stop()} when the scene is hidden. + *

    Call {@link #start()} after adding {@link #getPane()} to the scene graph */ public class FireParticleSystem { @@ -43,8 +42,6 @@ public class FireParticleSystem { private final List particles = new ArrayList<>(); /** Shared random source for particle initialisation and physics noise. */ private final Random rnd = new Random(); - /** The JavaFX animation timer driving the particle loop. */ - private AnimationTimer timer; /** Timestamp (ns) of the last particle spawn batch. */ private long lastSpawn = 0; /** Timestamp (ns) of the last rendered frame. */ @@ -74,7 +71,7 @@ public class FireParticleSystem { /** Starts the animation timer. */ public void start() { - timer = new AnimationTimer() { + AnimationTimer timer = new AnimationTimer() { @Override public void handle(long now) { if (now - lastFrame < FRAME_INTERVAL_NS) return; @@ -85,11 +82,6 @@ public class FireParticleSystem { timer.start(); } - /** Stops the animation timer. */ - public void stop() { - if (timer != null) timer.stop(); - } - /** * Advances the simulation by one frame: pre-warms on first call, spawns new particles, * steps existing ones, removes dead ones, and updates their visual state. @@ -177,13 +169,13 @@ public class FireParticleSystem { /** Remaining life fraction (1.0 = full, 0.0 = dead); only decrements for sparks. */ double life; /** Visual radius of the particle's core circle. */ - double size; + final double size; /** Current phase of the sinusoidal wobble. */ double wobblePhase; /** Angular speed of the wobble oscillation. */ - double wobbleSpeed; + final double wobbleSpeed; /** Amplitude factor of the wobble displacement. */ - double wobbleAmp; + final double wobbleAmp; /** Particle type: 0 = ember, 1 = spark, 2 = dust. */ final int type; /** Shared random source used during physics updates. */ diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java index d2d64d3..0c6f2ce 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java @@ -105,7 +105,7 @@ public class GUI extends Application implements IView { controllerLogin.updateLoginButton(true); controllerLogin.showError(""); fadeToScene(loginScene); - }, loginScene); + }); diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LeaderboardFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LeaderboardFXMLController.java index e5dd476..18298f3 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LeaderboardFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LeaderboardFXMLController.java @@ -6,7 +6,6 @@ import javafx.animation.ScaleTransition; import it.polimi.ingsw.gc14.Model.PlayableCard; import javafx.event.Event; import javafx.fxml.FXML; -import javafx.scene.Scene; import javafx.scene.control.ScrollPane; import javafx.stage.Popup; import javafx.geometry.Insets; @@ -24,7 +23,6 @@ import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.scene.paint.CycleMethod; import javafx.scene.text.Font; -import javafx.stage.Stage; import javafx.stage.Window; import javafx.util.Duration; @@ -49,8 +47,6 @@ public class LeaderboardFXMLController { private VBox popupContent; /** Shared image cache to avoid reloading resources multiple times. */ private static final Map imageCache = new HashMap<>(); - /** The login scene shown when the player starts a new game. */ - private Scene loginScene; /** Action run when the player returns to the login screen (disconnect + scene switch). */ private Runnable action; @@ -66,11 +62,9 @@ public class LeaderboardFXMLController { * * @param controller the client controller. * @param action the action to run when the player returns to the login screen. - * @param loginScene the login scene to show on exit. */ - public void setController(ClientController controller, Runnable action, Scene loginScene) { + public void setController(ClientController controller, Runnable action) { this.controller = controller; - this.loginScene = loginScene; this.action = action; } diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java index e006cbf..e08af98 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java @@ -20,9 +20,6 @@ import javafx.scene.paint.Color; import javafx.stage.Screen; import javafx.util.Duration; -import java.net.*; -import java.util.Enumeration; - /** * FXML controller for the login scene. * diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java index d3779dc..94940e8 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java @@ -6,21 +6,14 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer; import it.polimi.ingsw.gc14.Network.EventType; -import it.polimi.ingsw.gc14.Network.NetworkEvent; import javafx.animation.ScaleTransition; import javafx.animation.TranslateTransition; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.event.Event; import javafx.fxml.FXML; -import javafx.geometry.Bounds; import javafx.geometry.Insets; import javafx.geometry.Pos; -import javafx.geometry.Rectangle2D; import javafx.scene.Cursor; import javafx.scene.Node; -import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; @@ -33,7 +26,6 @@ import javafx.scene.paint.Color; import javafx.scene.shape.*; import javafx.scene.text.Font; import javafx.stage.Popup; -import javafx.stage.Screen; import javafx.stage.Window; import javafx.util.Duration; @@ -46,14 +38,10 @@ import java.util.*; * the player's hand, and action buttons (skip, details). */ public class MainFXMLController { - /** Left column grid used for the board slots layout. */ - @FXML private GridPane leftGrid; /** Scrollable container holding all player side-panel cards. */ @FXML private ScrollPane playerSide; /** Root HBox containing all main scene elements. */ @FXML private HBox mainHBox; - /** Background image view for the main scene. */ - @FXML private ImageView backgroundImage; /** HBox holding the board slot and order cards. */ @FXML private HBox board; /** HBox holding the upper tribe card row (and upper building stack). */ @@ -594,7 +582,6 @@ public class MainFXMLController { /** Adds the era-specific deck back image to the board. */ private void renderDeck() { String path = switch (controller.getMiniModel().currentState.getEra()) { - case 1 -> "/GUIImages/Backs/back-001.png"; case 2 -> "/GUIImages/Backs/back-030.png"; case 3 -> "/GUIImages/Backs/back-058.png"; default -> "/GUIImages/Backs/back-001.png"; diff --git a/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java b/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java index 8afe44a..3458157 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/TUI/TUI.java @@ -103,11 +103,6 @@ public class TUI implements IView { display(buildBoardContent()); } - /** Renders the totem-choice panel. */ - public void renderTotems() { - display(buildTotemsContent()); - } - /** * Shows an error message combined with the current board in one display call, * so only one {@code printAbove} is issued and the prompt is redrawn correctly. diff --git a/src/main/resources/GUIScene/login.fxml b/src/main/resources/GUIScene/login.fxml index 0af42d9..76ce665 100644 --- a/src/main/resources/GUIScene/login.fxml +++ b/src/main/resources/GUIScene/login.fxml @@ -10,7 +10,7 @@ stylesheets="@styles.css"> - + - - - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - -