final refactor 2 (problems noticed by intellij)

This commit is contained in:
2026-06-19 15:46:40 +02:00
parent 36814e3166
commit 79ebe6b93e
17 changed files with 28 additions and 40 deletions
@@ -13,7 +13,7 @@ public class ClientLauncherGUI {
*
* @param args command-line arguments passed to the JavaFX runtime.
*/
public static void main(String[] args) {
static void main(String[] args) {
System.setProperty("glass.gtk.uiScale", "1.0");
System.setProperty("glass.win.uiScale", "1.0");
Application.launch(GUIApp.class, args);
@@ -88,7 +88,7 @@ public class ClientLauncherTUI {
* @param args command-line arguments (unused).
* @throws InterruptedException if the thread is interrupted during startup.
*/
public static void main(String[] args) throws InterruptedException {
static void main(String[] args) throws InterruptedException {
new ClientLauncherTUI().start();
}
@@ -19,7 +19,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
/**
* The price of this building card.
*/
private int price;
private final int price;
/**
* Returns the price of this building card.
@@ -48,7 +48,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
/**
* The prestige value of this building card.
*/
private int prestigeValue;
private final int prestigeValue;
/**
* Returns the prestige value of this building card.
@@ -28,7 +28,7 @@ public abstract class TribeCard extends PlayableCard implements Serializable {
/**
* The minimum number of players required for this tribe card.
*/
private int nMin;
private final int nMin;
/**
* Returns the minimum number of players required for this tribe card.
@@ -15,12 +15,12 @@ public class Builder extends Character {
/**
* The reduction value provided by this Builder card.
*/
private int reductionValue;
private final int reductionValue;
/**
* The prestige value provided by this Builder card.
*/
private int prestigeValue;
private final int prestigeValue;
/**
* Returns the reduction value of this Builder card.
@@ -13,7 +13,7 @@ public class Inventor extends Character {
/**
* The {@code Icons}'s ID. There are a total of 10 different Icons.
*/
private int icon;
private final int icon;
/**
* Returns the icon value of this Inventor card.
@@ -160,7 +160,6 @@ public class Game implements Serializable {
if(currentState.getCurrentPlayer().equals(player)) {
if (currentState.getGameStage() != GameStages.TOTEM_CHOICE) {
nextPlayerSetup();
return true;
}
else {
if (totemChoiceQueue.isEmpty()) {
@@ -169,8 +168,8 @@ public class Game implements Serializable {
totemChoiceQueue.add(player);
}
currentState.playerUpdate(totemChoiceQueue.poll(), null);
return true;
}
return true;
}
return true;
@@ -59,7 +59,7 @@ public abstract class OrderLogicCard implements Serializable {
*/
public void push(Player player) {
effect(player, players.size());
if (players.size() == 0) {
if (players.isEmpty()) {
playerList.clear();
}
playerList.add(new OrderPlayer(player, false));
@@ -25,7 +25,7 @@ public abstract class PlayableCard implements Serializable {
/**
* The era associated with this playable card.
*/
private int era;
private final int era;
/**
* Returns the era of this playable card.
@@ -80,13 +80,13 @@ public class Player implements Serializable {
case GATHERER -> gatherers.size();
};
}
private ArrayList<BuildingCard> buildingCards;
private ArrayList<Artist> artists;
private ArrayList<Builder> builders;
private ArrayList<Inventor> inventors;
private ArrayList<Gatherer> gatherers;
private ArrayList<Shaman> shamans;
private ArrayList<Hunter> hunters;
private final ArrayList<BuildingCard> buildingCards;
private final ArrayList<Artist> artists;
private final ArrayList<Builder> builders;
private final ArrayList<Inventor> inventors;
private final ArrayList<Gatherer> gatherers;
private final ArrayList<Shaman> shamans;
private final ArrayList<Hunter> hunters;
/** @return this player's building cards. */
public ArrayList<BuildingCard> getBuildingCards() { return buildingCards; }
@@ -266,7 +266,7 @@ public class Player implements Serializable {
var table = new AsciiTable(ROUNDED, 1);
String totemStr = (this.totem != null) ? " (" + this.totem.toString() + ")" : "";
String totemStr = (this.totem != null) ? " (" + this.totem + ")" : "";
table.addHeader(this.getUserName() + totemStr + " | \uD83C\uDF56:" + this.getFoodValue() + " | \uD83C\uDFC5:" + this.getPrestigeValue());
table.addSeparator();
@@ -26,7 +26,7 @@ public class Slot implements Serializable {
/**
* The number of upper cards associated with this slot.
*/
private int nUpper;
private final int nUpper;
/**
* Returns the number of upper cards associated with this slot.
*
@@ -54,7 +54,7 @@ public class Slot implements Serializable {
/**
* The number of lower cards associated with this slot.
*/
private int nLower;
private final int nLower;
/**
* Returns the number of lower cards associated with this slot.
@@ -68,7 +68,7 @@ public class Slot implements Serializable {
/**
* The amount of Food associated with this slot.
*/
private int food;
private final int food;
/**
* Returns the amount of Food associated with this slot.
@@ -67,7 +67,7 @@ public enum EventType {
ENDED_GAME("Ended Game");
private final String description;
private EventType(String description) {
EventType(String description) {
this.description = description;
}
@Override
@@ -64,7 +64,7 @@ public class ServerLauncher {
* @param args command-line arguments (unused).
* @throws RemoteException if the RMI server cannot be created.
*/
public static void main(String[] args) throws RemoteException {
static void main(String[] args) throws RemoteException {
LimitedMap<String, Boolean> playerList = new LimitedMap<>(5, () -> {});
BlockingQueue<NetworkEvent> actionQueue = new LinkedBlockingQueue<>();
GameController gameController = new GameController();
@@ -411,7 +411,7 @@ public class MainFXMLController {
// ==== GROUPS ====
/** Builds the full side panel from scratch, creating a player card for each connected player. */
private void buildSidePanel() {
infoText.setText("Round: "+Integer.toString(controller.getMiniModel().currentState.getRound()) + "" + controller.getMiniModel().currentState.getGameStage().toString());
infoText.setText("Round: "+ controller.getMiniModel().currentState.getRound() + "" + controller.getMiniModel().currentState.getGameStage().toString());
VBox playerList = new VBox();
playerList.setFillWidth(true);
for (Player p : controller.getMiniModel().players.values()) {
@@ -424,7 +424,7 @@ public class MainFXMLController {
/** Updates food/prestige labels, current-player highlight, card-icon opacity, and plays error shake if needed. */
private void updateSidePanel() {
infoText.setText("Round: "+Integer.toString(controller.getMiniModel().currentState.getRound()) + "" + controller.getMiniModel().currentState.getGameStage().toString());
infoText.setText("Round: "+ controller.getMiniModel().currentState.getRound() + "" + controller.getMiniModel().currentState.getGameStage().toString());
if (controller.getMiniModel().currentState.getCurrentPlayer() == null) return;
String current = controller.getMiniModel().currentState.getCurrentPlayer().getUserName();
// ordine: building, artists, gatherers, inventors, builders, shamans, hunters
@@ -105,7 +105,6 @@ public class AsciiTable {
* @param maxWidth width in display columns of each cell (including padding).
* @return the rendered horizontal line string.
*/
@SuppressWarnings("GrazieInspection")
private String hline(String l, String m, String r, int maxWidth) {
var sb = new StringBuilder(l);
for (int i = 0; i < cols; i++) {
@@ -191,15 +191,5 @@ class Order2Test {
assertFalse(order.toString().contains(usr2));
assertTrue(order.toString().contains("+1🍖"));
assertTrue(order.toString().contains("-1🍖/-2🏅"));
new Player("px");
//TODO testare IndexOutOfBoundsException
// assertThrows(IndexOutOfBoundsException.class, () -> {
// Order2 ox = new Order2(new ArrayList<>(Arrays.asList(p1, p2)));;
// ox.pull();
// ox.pull();
// ox.pull();
// ox.push(extraPlayer);
// });
}
}
@@ -19,7 +19,7 @@ class PlayerTest {
Player p = new Player(usr);
assertEquals(usr, p.getUserName());
assertTrue(p.getUserName().length() <= 32);
assertTrue(p.getUserName().length() > 0);
assertTrue(!p.getUserName().isEmpty());
}
@Test
@@ -174,7 +174,7 @@ class PlayerTest {
assertTrue(p.getBuildingCards().isEmpty());
assertTrue(p.getUserName().length() <= 32);
assertTrue(p.getUserName().length() > 0);
assertTrue(!p.getUserName().isEmpty());
}
@Test