From bc9e4480c05c2f16a376165f0287c67c12f5c818 Mon Sep 17 00:00:00 2001 From: aleandro Date: Fri, 12 Jun 2026 18:37:18 +0200 Subject: [PATCH] Refactor: removed dead code and standarized to camelCase --- pom.xml | 31 +++++----- .../polimi/ingsw/gc14/ClientLauncherTUI.java | 8 ++- .../gc14/Controller/ClientController.java | 1 - .../polimi/ingsw/gc14/HelloApplication.java | 29 --------- .../it/polimi/ingsw/gc14/HelloController.java | 20 ------- .../Cards/Building/Effects/Building10.java | 3 - .../Cards/Building/Effects/Building11.java | 16 ++--- .../ingsw/gc14/Model/Cards/TribeCard.java | 2 +- .../Model/Cards/TribeCards/Character.java | 11 ---- .../Cards/TribeCards/Characters/Artist.java | 10 ---- .../Cards/TribeCards/Characters/Gatherer.java | 11 +--- .../Model/Cards/TribeCards/EventCard.java | 1 - .../TribeCards/Events/CavePaintings.java | 60 +++++++++---------- .../Cards/TribeCards/Events/Sustenance.java | 28 ++++----- .../polimi/ingsw/gc14/Model/DecksCreator.java | 3 +- .../java/it/polimi/ingsw/gc14/Model/Game.java | 23 +++---- .../ingsw/gc14/Model/GamePackage/Board.java | 6 +- .../gc14/Model/GamePackage/CurrentState.java | 24 ++++---- .../java/it/polimi/ingsw/gc14/Model/Main.java | 6 -- .../ingsw/gc14/Model/Orders/Order2.java | 1 - .../ingsw/gc14/Model/Orders/Order3.java | 1 - .../ingsw/gc14/Model/Orders/Order4.java | 1 - .../ingsw/gc14/Model/Orders/Order5.java | 1 - .../java/it/polimi/ingsw/gc14/Model/Slot.java | 54 ++++++++--------- .../ingsw/gc14/Network/InterfaceResolver.java | 2 + .../gc14/Network/NetworkEvents/AddPlayer.java | 5 +- .../Network/NetworkEvents/ApplyNextRound.java | 4 +- .../NetworkEvents/DrawLowerBuildingCard.java | 4 +- .../NetworkEvents/DrawLowerTribeCard.java | 4 +- .../NetworkEvents/DrawUpperBuildingCard.java | 4 +- .../NetworkEvents/DrawUpperTribeCard.java | 4 +- .../gc14/Network/NetworkEvents/EndedGame.java | 4 +- .../Network/NetworkEvents/SlotChoice.java | 4 +- .../RMI/Client/ClientCallbackImpl.java | 1 - .../Network/RMI/Common/IClientCallback.java | 2 - .../gc14/Network/TCP/Client/TCPClient.java | 2 - .../java/it/polimi/ingsw/gc14/View/IView.java | 2 - .../ingsw/gc14/View/TUI/BorderStyle.java | 17 ++---- .../it/polimi/ingsw/gc14/View/TUI/TUI.java | 41 ++++--------- .../it/polimi/ingsw/gc14/hello-view.fxml | 16 ----- .../gc14/Controller/GameControllerTest.java | 10 ++-- .../TribeCards/Characters/ArtistTest.java | 8 +-- .../TribeCards/Characters/BuilderTest.java | 8 +-- .../TribeCards/Characters/GathererTest.java | 8 +-- .../TribeCards/Characters/HunterTest.java | 8 +-- .../TribeCards/Characters/InventorTest.java | 8 +-- .../TribeCards/Characters/ShamanTest.java | 8 +-- .../gc14/Model/GamePackage/BoardTest.java | 4 +- .../it/polimi/ingsw/gc14/Model/GameTest.java | 10 ++-- 49 files changed, 187 insertions(+), 352 deletions(-) delete mode 100644 src/main/java/it/polimi/ingsw/gc14/HelloApplication.java delete mode 100644 src/main/java/it/polimi/ingsw/gc14/HelloController.java delete mode 100644 src/main/resources/it/polimi/ingsw/gc14/hello-view.fxml diff --git a/pom.xml b/pom.xml index e808268..7553b93 100644 --- a/pom.xml +++ b/pom.xml @@ -11,8 +11,11 @@ UTF-8 - 5.12.1 - 23 + 5.14.4 + 26 + 2.14.0 + 11.2.3 + 3.30.13 @@ -34,7 +37,7 @@ org.controlsfx controlsfx - 11.2.1 + ${controlsfx.version} org.junit.jupiter @@ -48,36 +51,30 @@ ${junit.version} test - - junit - junit - 3.8.1 - test - com.google.code.gson gson - 2.10.1 + ${gson.version} org.jline jline-terminal - 3.26.3 + ${jline.version} org.jline jline-reader - 3.26.3 + ${jline.version} org.jline jline-builtins - 3.26.3 + ${jline.version} org.jline jline-terminal-jansi - 3.26.3 + ${jline.version} @@ -86,7 +83,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.13.0 + 3.15.0 25 @@ -97,7 +94,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.5.6 --enable-preview @@ -129,7 +126,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.5.2 + 3.6.2 diff --git a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java index 37d76f9..7fa23ac 100644 --- a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java @@ -169,7 +169,9 @@ public class ClientLauncherTUI { RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, myIP); ErrorType err = client.connect(username, nPlayers); if (err != null) { - view.showError(err, err.toString()); + terminal.writer().print("\033[H\033[2J"); + terminal.writer().flush(); + System.out.println("Errore: " + err); return false; } System.out.println("Connected via RMI."); @@ -179,7 +181,9 @@ public class ClientLauncherTUI { TCPClient client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT); ErrorType err = client.connect(username, nPlayers); if (err != null) { - view.showError(err, err.toString()); + terminal.writer().print("\033[H\033[2J"); + terminal.writer().flush(); + System.out.println("Errore: " + err); return false; } System.out.println("Connected via TCP."); 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 d978271..3570f1d 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java +++ b/src/main/java/it/polimi/ingsw/gc14/Controller/ClientController.java @@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.View.IView; -import java.util.Objects; /** * Controller responsible for coordinating the client-side components, diff --git a/src/main/java/it/polimi/ingsw/gc14/HelloApplication.java b/src/main/java/it/polimi/ingsw/gc14/HelloApplication.java deleted file mode 100644 index 4823506..0000000 --- a/src/main/java/it/polimi/ingsw/gc14/HelloApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -package it.polimi.ingsw.gc14; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Scene; -import javafx.stage.Stage; - -import java.io.IOException; - -/** - * JavaFX application entry point used to start the graphical interface. - */ -public class HelloApplication extends Application { - - /** - * Starts the JavaFX application and loads the initial FXML view. - * - * @param stage the primary stage of the application. - * @throws IOException if the FXML file cannot be loaded. - */ - @Override - public void start(Stage stage) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 320, 240); - stage.setTitle("Hello!"); - stage.setScene(scene); - stage.show(); - } -} diff --git a/src/main/java/it/polimi/ingsw/gc14/HelloController.java b/src/main/java/it/polimi/ingsw/gc14/HelloController.java deleted file mode 100644 index 43f007a..0000000 --- a/src/main/java/it/polimi/ingsw/gc14/HelloController.java +++ /dev/null @@ -1,20 +0,0 @@ -package it.polimi.ingsw.gc14; - -import javafx.fxml.FXML; -import javafx.scene.control.Label; - -/** - * Controller for the initial JavaFX view. - */ -public class HelloController { - @FXML - private Label welcomeText; - - /** - * Handles the click on the hello button. - */ - @FXML - protected void onHelloButtonClick() { - welcomeText.setText("Welcome to JavaFX Application!"); - } -} 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 4c71355..d785d13 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 @@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType; import it.polimi.ingsw.gc14.Model.Player; -import java.util.HashMap; /** * At the end of the game, the player gains 6 Prestige Points @@ -69,8 +68,6 @@ public class Building10 extends BuildingCard { public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); - HashMap map = new HashMap(); - int numSet=player.getNType(CharacterType.INVENTOR); for(CharacterType type : CharacterType.values()) { 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 e95e051..555a75f 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 @@ -26,14 +26,14 @@ public class Building11 extends BuildingCard { */ public CharacterType getIcon() {return icon;} - private int PrestigeMul; + private int prestigeMul; /** * Returns the prestige multiplier associated with this building card effect. * * @return the prestige multiplier associated with this building card effect. */ - public int getPrestigeMul() {return PrestigeMul;} + public int getprestigeMul() {return prestigeMul;} /** * Creates a Building11 card with the specified era, price, prestige value, @@ -50,7 +50,7 @@ public class Building11 extends BuildingCard { effectType = EffectType.FINAL; effectId = 11; this.icon = icon; - this.PrestigeMul = prestigeMul; + this.prestigeMul = prestigeMul; } /** @@ -69,7 +69,7 @@ public class Building11 extends BuildingCard { effectType = EffectType.FINAL; effectId = 11; this.icon = icon; - this.PrestigeMul = prestigeMul; + this.prestigeMul = prestigeMul; } /** @@ -79,7 +79,7 @@ public class Building11 extends BuildingCard { */ @Override public BuildingCard clone() { - return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getPrestigeMul()); + return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getprestigeMul()); } /** @@ -94,7 +94,7 @@ public class Building11 extends BuildingCard { public void applyEffect(Player player) throws IllegalArgumentException { if(!player.getBuildingCards().contains(this)) throw new IllegalArgumentException(); - player.addPrestige(player.getNType(getIcon()) * this.getPrestigeMul()); + player.addPrestige(player.getNType(getIcon()) * this.getprestigeMul()); } /** @@ -105,11 +105,11 @@ public class Building11 extends BuildingCard { */ @Override public String toString() { - return super.toString() + "+" + this.icon.toString().substring(0, 3) + "×" + this.PrestigeMul; + return super.toString() + "+" + this.icon.toString().substring(0, 3) + "×" + this.prestigeMul; } @Override public String toStringPlayer() { - return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.icon.toString().substring(0, 3) + "×" + this.PrestigeMul + ")"; + return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.icon.toString().substring(0, 3) + "×" + this.prestigeMul + ")"; } } \ No newline at end of file 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 f7ec819..5944f14 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 @@ -22,7 +22,7 @@ public abstract class TribeCard extends PlayableCard implements Serializable { * * @return {@code true} if this card is an event card, {@code false} otherwise. */ - public boolean IsEventCard() { + public boolean isEventCard() { return isEventCard; } 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 28877b3..459be4e 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 @@ -76,17 +76,6 @@ public abstract class Character extends TribeCard implements Cloneable { this.type = type; } - /** - * Returns the string representation of this character card. - * - * @return the string representation of this character card. - */ - @Override - public String toString() { - return super.toString(); - } - - /** * Returns a string representation of this {@code Character}. This specific variation is used in the {@code Game}'s * toString to provide a more detailed version. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java index 7390e72..faa5c0e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java @@ -53,16 +53,6 @@ public class Artist extends Character { super(idIMG,Era, CharacterType.ARTIST,nMin); } - /** - * Returns the string representation of this Artist card. - * - * @return the string representation of this Artist card. - */ - @Override - public String toString() { - return super.toString(); - } - /** * Creates and returns a copy of this Artist card. * diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java index d892eca..589f8db 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java @@ -53,16 +53,6 @@ public class Gatherer extends Character { super(idIMG,Era, CharacterType.GATHERER,nMin); } - /** - * Returns the string representation of this Gatherer card. - * - * @return the string representation of this Gatherer card. - */ - @Override - public String toString() { - return super.toString(); - } - /** * Creates and returns a copy of this Gatherer card. * @@ -79,6 +69,7 @@ public class Gatherer extends Character { * * @param player the player who receives the card. */ + @Override public void insert(Player player) { player.getGatherers().add(this); player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player)); 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 4b2e87d..0af6977 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 @@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Player; import java.util.ArrayList; -import java.lang.reflect.Array; /** * Abstract base class for all event cards. 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 38803b1..f1fe488 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 @@ -21,31 +21,31 @@ 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 int nLower; /** - * The amount of Prestige removed if the player has fewer Artist cards than {@code NLower}. + * The amount of Prestige removed if the player has fewer Artist cards than {@code nLower}. */ - private int NPrestigeRem; // NPrestigeLower + private int nPrestigeRem; // NPrestigeLower /** - * The Prestige multiplier applied if the player has at least {@code NLower} Artist cards. + * The Prestige multiplier applied if the player has at least {@code nLower} Artist cards. */ - private int NPrestigeMul; // NPrestigeUpper + private int nPrestigeMul; // NPrestigeUpper /** * Creates a CavePaintings event card with the specified era and effect parameters. * * @param Era the era of the event card. - * @param NLower the minimum number of Artist cards required to avoid the prestige penalty. - * @param NPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code NLower}. - * @param NPrestigeMul the Prestige multiplier applied if the player has at least {@code NLower} Artist cards. + * @param nLower the minimum number of Artist cards required to avoid the prestige penalty. + * @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}. + * @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards. */ - public CavePaintings(int Era, int NLower, int NPrestigeRem, int NPrestigeMul) { + public CavePaintings(int Era, int nLower, int nPrestigeRem, int nPrestigeMul) { super(Era, EventType.CAVE_PAINTINGS); - this.NLower = NLower; - this.NPrestigeRem = NPrestigeRem; - this.NPrestigeMul = NPrestigeMul; + this.nLower = nLower; + this.nPrestigeRem = nPrestigeRem; + this.nPrestigeMul = nPrestigeMul; } /** @@ -53,15 +53,15 @@ public class CavePaintings extends EventCard { * * @param idIMG the image identifier of the CavePaintings event card. * @param Era the era of the event card. - * @param NLower the minimum number of Artist cards required to avoid the prestige penalty. - * @param NPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code NLower}. - * @param NPrestigeMul the Prestige multiplier applied if the player has at least {@code NLower} Artist cards. + * @param nLower the minimum number of Artist cards required to avoid the prestige penalty. + * @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}. + * @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards. */ - public CavePaintings(String idIMG,int Era, int NLower, int NPrestigeRem, int NPrestigeMul) { + public CavePaintings(String idIMG,int Era, int nLower, int nPrestigeRem, int nPrestigeMul) { super(idIMG,Era, EventType.CAVE_PAINTINGS); - this.NLower = NLower; - this.NPrestigeRem = NPrestigeRem; - this.NPrestigeMul = NPrestigeMul; + this.nLower = nLower; + this.nPrestigeRem = nPrestigeRem; + this.nPrestigeMul = nPrestigeMul; } /** @@ -69,8 +69,8 @@ public class CavePaintings extends EventCard { * For each player, the number of Artist cards is computed together with the number * of owned building cards having effect id equal to 9. * The player gains Food equal to the number of such buildings multiplied by the number of Artist cards. - * If the player has fewer Artist cards than {@code NLower}, the player loses {@code NPrestigeRem} Prestige. - * Otherwise, the player gains Prestige equal to {@code NPrestigeMul} multiplied by the number of Artist cards. + * If the player has fewer Artist cards than {@code nLower}, the player loses {@code nPrestigeRem} Prestige. + * Otherwise, the player gains Prestige equal to {@code nPrestigeMul} multiplied by the number of Artist cards. * * @param playerList the list of players affected by the event. */ @@ -87,11 +87,11 @@ public class CavePaintings extends EventCard { } } player.addFood(NBuildings * NArtists); - if (NArtists < NLower){ - player.removePrestige(NPrestigeRem); + if (NArtists < nLower){ + player.removePrestige(nPrestigeRem); } else{ - player.addPrestige(NPrestigeMul * NArtists); + player.addPrestige(nPrestigeMul * NArtists); } } } @@ -104,20 +104,20 @@ public class CavePaintings extends EventCard { @Override public EventCard clone() { - return new CavePaintings(getIdIMG(),getEra(), NLower, NPrestigeRem, NPrestigeMul) ; + return new CavePaintings(getIdIMG(),getEra(), nLower, nPrestigeRem, nPrestigeMul) ; } /** * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s * toString to print a more detailed version. - *

NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code NLower} is needed), + *

NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code nLower} is needed), * however it's a parameter on the cards' design. *

*

Includes: - *

  • {@link #NLower} + *
  • {@link #nLower} *
  • {@code NUpper} - *
  • {@link #NPrestigeRem} - *
  • {@link #NPrestigeMul} + *
  • {@link #nPrestigeRem} + *
  • {@link #nPrestigeMul} *

    * @return {@code String} - a string representation of this {@code TribeCard}. * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard @@ -126,6 +126,6 @@ public class CavePaintings extends EventCard { */ @Override public String toStringBoard() { - return super.toStringBoard()+" 0-"+(NLower-1)+":"+NPrestigeRem+" "+NLower+"+:"+NPrestigeMul; + return super.toStringBoard()+" 0-"+(nLower-1)+":"+nPrestigeRem+" "+nLower+"+:"+nPrestigeMul; } } 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 cc3f1bc..26207fd 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,26 +21,26 @@ public class Sustenance extends EventCard { /** * The prestige penalty multiplier applied for each unpaid Food unit. */ - private int PrestigeDebt; + private int prestigeDebt; /** * Returns the prestige penalty multiplier associated with this Sustenance event. * * @return the prestige penalty multiplier associated with this Sustenance event. */ - public int getPrestigeDebt() { - return PrestigeDebt; + public int getprestigeDebt() { + return prestigeDebt; } /** * Creates a Sustenance event card with the specified era and prestige debt value. * * @param Era the era of the event card. - * @param PrestigeDebt the prestige penalty multiplier for unpaid Food units. + * @param prestigeDebt the prestige penalty multiplier for unpaid Food units. */ - public Sustenance(int Era, int PrestigeDebt) { + public Sustenance(int Era, int prestigeDebt) { super(Era, EventType.SUSTENANCE); - this.PrestigeDebt = PrestigeDebt; + this.prestigeDebt = prestigeDebt; } /** @@ -48,11 +48,11 @@ public class Sustenance extends EventCard { * * @param idIMG the image identifier of the Sustenance event card. * @param Era the era of the event card. - * @param PrestigeDebt the prestige penalty multiplier for unpaid Food units. + * @param prestigeDebt the prestige penalty multiplier for unpaid Food units. */ - public Sustenance(String idIMG,int Era, int PrestigeDebt) { + public Sustenance(String idIMG,int Era, int prestigeDebt) { super(idIMG,Era, EventType.SUSTENANCE); - this.PrestigeDebt = PrestigeDebt; + this.prestigeDebt = prestigeDebt; } /** @@ -62,7 +62,7 @@ public class Sustenance extends EventCard { * granted by owned building cards with effect id equal to 1. * If the resulting Food debt is positive, the player must pay it with available Food. * If the player does not have enough Food, all remaining Food is removed and the player - * loses Prestige equal to the unpaid Food debt multiplied by {@code PrestigeDebt}. + * loses Prestige equal to the unpaid Food debt multiplied by {@code prestigeDebt}. * This event is intended to be executed last among event effects. * * @param playerList the list of players affected by the event. @@ -94,7 +94,7 @@ public class Sustenance extends EventCard { else{ FoodDebt -= player.getFoodValue(); player.removeFood(player.getFoodValue()); // player.getFoodValue() == 0 - player.removePrestige(FoodDebt * PrestigeDebt); + player.removePrestige(FoodDebt * prestigeDebt); } } } @@ -106,14 +106,14 @@ public class Sustenance extends EventCard { */ @Override public EventCard clone() { - return new Sustenance(getIdIMG(),getEra(), PrestigeDebt); + return new Sustenance(getIdIMG(),getEra(), prestigeDebt); } /** * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s * toString to print a more detailed version. *

    Includes: - *

  • {@link #PrestigeDebt} + *
  • {@link #prestigeDebt} *

    * @return {@code String} - a string representation of this {@code TribeCard}. * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard @@ -122,6 +122,6 @@ public class Sustenance extends EventCard { */ @Override public String toStringBoard() { - return super.toStringBoard()+" -1\uD83C\uDF56/-"+PrestigeDebt+"\uD83C\uDFC5"; + return super.toStringBoard()+" -1\uD83C\uDF56/-"+prestigeDebt+"\uD83C\uDFC5"; } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java b/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java index ffe490e..4f5b10b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java @@ -21,6 +21,8 @@ import java.util.*; */ public class DecksCreator { + private DecksCreator() {} + /** * Loads the tribe card deck for the specified era from the corresponding JSON resource file. * @@ -133,7 +135,6 @@ public class DecksCreator { */ private static TribeCard createCard(TribeCardDefinition def) { int era = def.era; - String id = def.id; int[] p = def.params.stream().mapToInt(d -> ((Double) d).intValue()).toArray(); if(def.isEvent) { 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 ac48c59..c9a197c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -321,12 +321,12 @@ public class Game implements Serializable { /** * Returns the player with the specified username, if present. * - * @param Username the username of the player to search for. + * @param username the username of the player to search for. * @return the player with the specified username, or {@code null} if no such player exists. * @throws IndexOutOfBoundsException if an index access error occurs. */ - public Player getPlayerByUsername(String Username) throws IndexOutOfBoundsException { - return playersList.stream().filter(x->x.getUserName().equals(Username)).findFirst().orElse(null); + public Player getPlayerByUsername(String username) throws IndexOutOfBoundsException { + return playersList.stream().filter(x->x.getUserName().equals(username)).findFirst().orElse(null); } /** @@ -493,7 +493,7 @@ public class Game implements Serializable { if(currentState.getNUpper() <1 && currentState.getGameStage()==GameStages.RES_ACTIONS) return false; TribeCard tribeCard = board.upperListTribe.get(cardIndex); - if(tribeCard.IsEventCard()) + if(tribeCard.isEventCard()) return false; Character tempCard = (Character) tribeCard; @@ -578,7 +578,7 @@ public class Game implements Serializable { if(currentState.getNLower() <1) return false; TribeCard tribeCard = board.lowerListTribe.get(cardIndex); - if(tribeCard.IsEventCard()) + if(tribeCard.isEventCard()) return false; Character tempCard = (Character) tribeCard; @@ -868,7 +868,7 @@ public class Game implements Serializable { */ private boolean hasDrawableUp() { - return getUpperListTribeCards().stream().anyMatch(x -> !x.IsEventCard()); + return getUpperListTribeCards().stream().anyMatch(x -> !x.isEventCard()); } /** @@ -879,7 +879,7 @@ public class Game implements Serializable { */ private boolean hasDrawableDown() { - return getLowerListTribeCards().stream().anyMatch(x -> !x.IsEventCard()); + return getLowerListTribeCards().stream().anyMatch(x -> !x.isEventCard()); } /** * Resolves all pending event cards if the current game stage is {@code RESOLVING_EVENT}. @@ -915,13 +915,6 @@ public class Game implements Serializable { private void nextRound() { EventResolution(); - if(currentState.getRound()==10) - { - currentState.GameStageUpdate(GameStages.ENDING); - endGame(); - return; - } - if(currentState.getEra()!= board.nextRound()) { currentState.EraUpdate(); } @@ -936,7 +929,7 @@ public class Game implements Serializable { */ private void endGame() { Queue events; - events=Stream.concat(board.lowerListTribe.stream().filter(TribeCard::IsEventCard),board.upperListTribe.stream().filter(TribeCard::IsEventCard)).map(x->((EventCard)x)).collect(Collectors.toCollection(LinkedList::new)); + events=Stream.concat(board.lowerListTribe.stream().filter(TribeCard::isEventCard),board.upperListTribe.stream().filter(TribeCard::isEventCard)).map(x->((EventCard)x)).collect(Collectors.toCollection(LinkedList::new)); ArrayListsustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new)); events.removeAll(sustenance); events.forEach(event->event.activateEvent(playersList)); 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 9dfe9e8..2b2bc3e 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 @@ -97,7 +97,7 @@ public class Board implements Serializable { for(int i=0;i getPendingEvents(){ - return lowerListTribe.stream().filter(TribeCard::IsEventCard).map(x->(EventCard)x).collect(Collectors.toCollection(LinkedList::new)); + return lowerListTribe.stream().filter(TribeCard::isEventCard).map(x->(EventCard)x).collect(Collectors.toCollection(LinkedList::new)); } /** @@ -267,8 +267,6 @@ public class Board implements Serializable { lowerListBuilding.addAll(upperListBuilding); upperListBuilding.clear(); - ArrayList buildingCards= new ArrayList<>(DecksCreator.loadBuildingDeckByEra(era)); - Collections.shuffle(buildingCards); if(era==2) { upperListBuilding.addAll(buildingCardsAllEras.get(1)); diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java index 81b68a8..4b9b2a3 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java @@ -77,7 +77,7 @@ public class CurrentState implements Serializable { /** * The number of upper cards currently available. */ - private int NUpper; + private int nUpper; /** * Returns the number of upper cards currently available. @@ -85,13 +85,13 @@ public class CurrentState implements Serializable { * @return the number of upper cards currently available. */ public int getNUpper(){ - return NUpper; + return nUpper; } /** * The number of lower cards currently available. */ - private int NLower; + private int nLower; /** * Returns the number of lower cards currently available. @@ -99,7 +99,7 @@ public class CurrentState implements Serializable { * @return the number of lower cards currently available. */ public int getNLower(){ - return NLower; + return nLower; } /** @@ -138,14 +138,14 @@ public class CurrentState implements Serializable { * Decrements the number of upper cards by 1. */ public void UpperDrawn(){ - NUpper--; + nUpper--; } /** * Decrements the number of lower cards by 1. */ public void LowerDrawn(){ - NLower--; + nLower--; } /** @@ -170,8 +170,8 @@ public class CurrentState implements Serializable { this.slot = null; this.Era = 1; this.round = 1; - this.NUpper = 0; - this.NLower = 0; + this.nUpper = 0; + this.nLower = 0; this.GameStage = GameStages.WAITING; } // endregion constructors @@ -190,12 +190,12 @@ public class CurrentState implements Serializable { this.player = player; this.slot = slot; if(slot == null){ - this.NUpper = 0; - this.NLower = 0; + this.nUpper = 0; + this.nLower = 0; } else{ - this.NUpper = slot.getNUpper(); - this.NLower = slot.getNLower(); + this.nUpper = slot.getNUpper(); + this.nLower = slot.getNLower(); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Main.java b/src/main/java/it/polimi/ingsw/gc14/Model/Main.java index 1fc238e..3ab2d61 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Main.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Main.java @@ -1,11 +1,5 @@ package it.polimi.ingsw.gc14.Model; -//import it.polimi.ingsw.gc14.Controller.GameController; -import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; -import it.polimi.ingsw.gc14.Model.Cards.TribeCard; -import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor; - -import java.util.*; /** Standalone entry point used for local model testing. */ public class Main { 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 01c06ba..dc9eadc 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 @@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders; import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.Player; -import it.polimi.ingsw.gc14.Model.Totems; import it.polimi.ingsw.gc14.View.TUI.AsciiTable; import it.polimi.ingsw.gc14.View.TUI.BorderStyle; diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java index 8dbd399..362b3f6 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order3.java @@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders; import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.Player; -import it.polimi.ingsw.gc14.Model.Totems; import it.polimi.ingsw.gc14.View.TUI.AsciiTable; import it.polimi.ingsw.gc14.View.TUI.BorderStyle; diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java index c7f03db..b377e5b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order4.java @@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders; import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.Player; -import it.polimi.ingsw.gc14.Model.Totems; import it.polimi.ingsw.gc14.View.TUI.AsciiTable; import it.polimi.ingsw.gc14.View.TUI.BorderStyle; diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java index 947587c..433ab0d 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Orders/Order5.java @@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders; import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.Player; -import it.polimi.ingsw.gc14.Model.Totems; import it.polimi.ingsw.gc14.View.TUI.AsciiTable; import it.polimi.ingsw.gc14.View.TUI.BorderStyle; 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 155c7f6..4f38c85 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java @@ -26,14 +26,14 @@ public class Slot implements Serializable { /** * The number of upper cards associated with this slot. */ - private int NUpper; + private int nUpper; /** * Returns the number of upper cards associated with this slot. * * @return the number of upper cards associated with this slot. */ public int getNUpper(){ - return NUpper; + return nUpper; } /** @@ -54,7 +54,7 @@ public class Slot implements Serializable { /** * The number of lower cards associated with this slot. */ - private int NLower; + private int nLower; /** * Returns the number of lower cards associated with this slot. @@ -62,13 +62,13 @@ public class Slot implements Serializable { * @return the number of lower cards associated with this slot. */ public int getNLower(){ - return NLower; + return nLower; } /** * The amount of Food associated with this slot. */ - private int Food; + private int food; /** * Returns the amount of Food associated with this slot. @@ -76,7 +76,7 @@ public class Slot implements Serializable { * @return the amount of Food associated with this slot. */ public int getFood(){ - return Food; + return food; } // End getters @@ -100,41 +100,41 @@ public class Slot implements Serializable { switch(slotId) { case 'A': - this.Food = 3; - this.NLower = 0; - this.NUpper = 0; + this.food = 3; + this.nLower = 0; + this.nUpper = 0; this.nMinPlayer=5; break; case 'B': - this.Food = 0; - this.NLower = 1; - this.NUpper = 0; + this.food = 0; + this.nLower = 1; + this.nUpper = 0; break; case 'C': - this.Food = 0; - this.NLower = 0; - this.NUpper = 1; + this.food = 0; + this.nLower = 0; + this.nUpper = 1; break; case 'D': - this.Food = 0; - this.NLower = 2; - this.NUpper = 0; + this.food = 0; + this.nLower = 2; + this.nUpper = 0; this.nMinPlayer = 3; break; case 'E': - this.Food = 0; - this.NLower = 1; - this.NUpper = 1; + this.food = 0; + this.nLower = 1; + this.nUpper = 1; break; case 'F': - this.Food = 0; - this.NLower = 0; - this.NUpper = 2; + this.food = 0; + this.nLower = 0; + this.nUpper = 2; break; case 'G': - this.Food = 0; - this.NLower = 1; - this.NUpper = 2; + this.food = 0; + this.nLower = 1; + this.nUpper = 2; this.nMinPlayer = 4; break; default: diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/InterfaceResolver.java b/src/main/java/it/polimi/ingsw/gc14/Network/InterfaceResolver.java index 32e1b58..da7e099 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/InterfaceResolver.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/InterfaceResolver.java @@ -5,6 +5,8 @@ import java.util.Enumeration; /** Utility class for resolving the local network interface to use when connecting to a server. */ public class InterfaceResolver { + private InterfaceResolver() {} + /** * Returns the local IPv4 address that can reach the given server IP. * diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java index bd76602..0dd4d0b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java @@ -5,14 +5,11 @@ import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; - -import java.io.Serializable; /** * NetworkEvent to add a player. */ -public class AddPlayer extends NetworkEvent implements Serializable { +public class AddPlayer extends NetworkEvent { /** Number of proposed players to add to the match */ private int proposedNPlayer; /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/ApplyNextRound.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/ApplyNextRound.java index 702f134..8ce76ad 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/ApplyNextRound.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/ApplyNextRound.java @@ -11,9 +11,7 @@ import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Slot; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -21,7 +19,7 @@ import java.util.Map; /** * NetworkEvent to draw a tribe card from the lower card list. */ -public class ApplyNextRound extends NetworkEvent implements Serializable{ +public class ApplyNextRound extends NetworkEvent{ List players; ArrayList upperListTribeCards; 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 458189a..938fa8a 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 @@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; /** * NetworkEvent to draw a building card from the lower card list. */ -public class DrawLowerBuildingCard extends NetworkEvent implements Serializable{ +public class DrawLowerBuildingCard extends NetworkEvent{ /** Index of the card to draw */ private int pos; 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 a651265..c6f175c 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 @@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; /** * NetworkEvent to draw a tribe card from the lower card list. */ -public class DrawLowerTribeCard extends NetworkEvent implements Serializable{ +public class DrawLowerTribeCard extends NetworkEvent{ /** Index of the card to draw */ private int pos; 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 1cfd378..41de04f 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 @@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; /** * NetworkEvent to draw a building card from the upper card list. */ -public class DrawUpperBuildingCard extends NetworkEvent implements Serializable{ +public class DrawUpperBuildingCard extends NetworkEvent{ /** Index of the card to draw */ private int pos; 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 a7b82a3..e16e3c5 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 @@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; /** * NetworkEvent to draw a tribe card from the upper card list. */ -public class DrawUpperTribeCard extends NetworkEvent implements Serializable{ +public class DrawUpperTribeCard extends NetworkEvent{ /** Index of the card to draw */ private int pos; diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/EndedGame.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/EndedGame.java index a68d416..791ab8f 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/EndedGame.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/EndedGame.java @@ -9,9 +9,7 @@ import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Slot; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -19,7 +17,7 @@ import java.util.Map; /** * NetworkEvent to draw a tribe card from the lower card list. */ -public class EndedGame extends NetworkEvent implements Serializable{ +public class EndedGame extends NetworkEvent{ ArrayList players; 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 6a5d714..a1c5b51 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 @@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.NetworkEvent; -import it.polimi.ingsw.gc14.View.IView; -import java.io.Serializable; /** * NetworkEvent to select a slot where to place the player totem. */ -public class SlotChoice extends NetworkEvent implements Serializable { +public class SlotChoice extends NetworkEvent { /** Index of the card to draw */ private int pos; 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 7cdb902..12bc513 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 @@ -1,7 +1,6 @@ package it.polimi.ingsw.gc14.Network.RMI.Client; import it.polimi.ingsw.gc14.Controller.ClientController; -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.RMI.Common.IClientCallback; 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 e09a065..6c77591 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 @@ -1,8 +1,6 @@ package it.polimi.ingsw.gc14.Network.RMI.Common; import it.polimi.ingsw.gc14.Model.*; -import it.polimi.ingsw.gc14.Model.GamePackage.Board; -import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState; import it.polimi.ingsw.gc14.Network.NetworkEvent; import java.io.Serializable; 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 f35e572..afe9d50 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 @@ -2,13 +2,11 @@ package it.polimi.ingsw.gc14.Network.TCP.Client; import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.ErrorType; -import it.polimi.ingsw.gc14.Model.Game; import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkConfig; import it.polimi.ingsw.gc14.Network.NetworkEvents.*; -import javafx.application.Platform; import java.io.*; import java.net.*; diff --git a/src/main/java/it/polimi/ingsw/gc14/View/IView.java b/src/main/java/it/polimi/ingsw/gc14/View/IView.java index 9bce3e8..6667024 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/IView.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/IView.java @@ -1,9 +1,7 @@ package it.polimi.ingsw.gc14.View; import it.polimi.ingsw.gc14.ErrorType; -import it.polimi.ingsw.gc14.Model.Game; import it.polimi.ingsw.gc14.Model.MiniModel; -import it.polimi.ingsw.gc14.Network.NetworkEvent; /** View interface implemented by both the TUI and GUI. */ public interface IView { diff --git a/src/main/java/it/polimi/ingsw/gc14/View/TUI/BorderStyle.java b/src/main/java/it/polimi/ingsw/gc14/View/TUI/BorderStyle.java index b629784..3f29a22 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/TUI/BorderStyle.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/TUI/BorderStyle.java @@ -12,24 +12,24 @@ public enum BorderStyle { /** * Unicode box-drawing border style. */ - UNICODE("╔","╗","╚","╝","═","║","╠","╣","╦","╩","╬","├","┤","─","┼"), + UNICODE("╔","╗","╚","╝","═","║","╠","╣","╦","╩","╬","├","┤","┼"), /** * Plain ASCII border style. */ - ASCII ("+","+","+","+","-","|","+","+","+","+","+","+","+","-","+"), + ASCII ("+","+","+","+","-","|","+","+","+","+","+","+","+","+"), /** * Rounded Unicode border style. */ - ROUNDED("╭","╮","╰","╯","─","│","├","┤","┬","┴","┼","├","┤","─","┼"); + ROUNDED("╭","╮","╰","╯","─","│","├","┤","┬","┴","┼","├","┤","┼"); - private final String tl,tr,bl,br,h,v,ml,mr,mt,mb,x,sl,sr,sh,sx; + private final String tl,tr,bl,br,h,v,ml,mr,mt,mb,x,sl,sr,sx; BorderStyle(String tl,String tr,String bl,String br, String h, String v, String ml,String mr, String mt,String mb,String x, - String sl,String sr,String sh,String sx) { + String sl,String sr,String sx) { this.tl = tl; this.tr = tr; this.bl = bl; this.br = br; this.h = h; this.v = v; @@ -37,7 +37,7 @@ public enum BorderStyle { this.mt = mt; this.mb = mb; this.x = x; this.sl = sl; this.sr = sr; - this.sh = sh; this.sx = sx; + this.sx = sx; } /** @@ -105,11 +105,6 @@ public enum BorderStyle { */ public String sr() { return sr; } - /** - * @return the separator horizontal line character. - */ - public String sh() { return sh; } - /** * @return the separator center junction character. */ 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 5fcc20a..bed2132 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 @@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.View.TUI; import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.Model.*; import it.polimi.ingsw.gc14.Model.GamePackage.GameStages; -import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.View.IView; import org.jline.reader.LineReader; @@ -128,7 +127,7 @@ public class TUI implements IView { * hands arranged in a responsive grid. */ private String buildBoardContent() { - List left = List.of(BoardStamp().split("\n")); + List left = List.of(boardStamp().split("\n")); List right = List.of(buildAllHandsContent().split("\n")); return AsciiTable.sideBySide(left, right, 3); } @@ -259,33 +258,13 @@ public class TUI implements IView { // ── Board / players stamp helpers ───────────────────────────────────────── - /** - * Returns all players rendered side-by-side in pairs. - * - * @return multi-line string with all player panels. - */ - public String PlayersStamp() { - StringBuilder sb = new StringBuilder(); - ArrayList list = new ArrayList<>(model.players.values()); - for (int i = 0; i < list.size() / 2; i++) { - sb.append(AsciiTable.sideBySide( - List.of(list.get(i * 2).toString().split("\n")), - List.of(list.get(i * 2 + 1).toString().split("\n")), 2)); - } - sb.append("\n"); - if (list.size() % 2 != 0) { - sb.append(list.get(list.size() - 1)).append("\n"); - } - return sb.toString(); - } - /** * Returns the board state as a multi-line string: turn order, upper cards, * offer track, lower cards. * * @return multi-line board string. */ - public String BoardStamp() { + public String boardStamp() { var offerTrack = new AsciiTable(BorderStyle.ROUNDED, model.slotPlayerMap.size()); List slotNames = new ArrayList<>(); List slotPlayers = new ArrayList<>(); @@ -296,33 +275,33 @@ public class TUI implements IView { slotPlayers.add(entry.getValue() != null ? entry.getValue().getUserName() : " "); } - var UpperCards = new AsciiTable(BorderStyle.ROUNDED, 2); - var LowerCards = new AsciiTable(BorderStyle.ROUNDED, 2); - UpperCards.addHeader("Char/Events", "Building"); - LowerCards.addHeader("Char/Events", "Building"); + var upperCards = new AsciiTable(BorderStyle.ROUNDED, 2); + var lowerCards = new AsciiTable(BorderStyle.ROUNDED, 2); + upperCards.addHeader("Char/Events", "Building"); + lowerCards.addHeader("Char/Events", "Building"); int maxU = Math.max(model.upperListTribeCards.size(), model.upperListBuildingCards.size()); for (int i = 0; i < maxU; i++) { String t = i < model.upperListTribeCards.size() ? i + model.upperListTribeCards.get(i).toStringBoard() : ""; String b = i < model.upperListBuildingCards.size() ? i + model.upperListBuildingCards.get(i).toString() : ""; - UpperCards.addRow(t, b); + upperCards.addRow(t, b); } int maxL = Math.max(model.lowerListTribeCards.size(), model.lowerListBuildingCards.size()); for (int i = 0; i < maxL; i++) { String t = i < model.lowerListTribeCards.size() ? i + model.lowerListTribeCards.get(i).toStringBoard() : ""; String b = i < model.lowerListBuildingCards.size() ? i + model.lowerListBuildingCards.get(i).toString() : ""; - LowerCards.addRow(t, b); + lowerCards.addRow(t, b); } offerTrack.addRow(slotPlayers); offerTrack.addRow(slotNames); - String upperSection = UpperCards.build(); + String upperSection = upperCards.build(); String middleSection = model.orderLogicCard.toString() + offerTrack.build(); - String lowerSection = LowerCards.build(); + String lowerSection = lowerCards.build(); return model.currentState + "\n" + upperSection + "\n" diff --git a/src/main/resources/it/polimi/ingsw/gc14/hello-view.fxml b/src/main/resources/it/polimi/ingsw/gc14/hello-view.fxml deleted file mode 100644 index f11c121..0000000 --- a/src/main/resources/it/polimi/ingsw/gc14/hello-view.fxml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - -