Initial problem solving (identified by Intellij)

This commit is contained in:
2026-06-14 21:01:43 +02:00
parent e27a2e1b0c
commit bac4a6b7f5
69 changed files with 175 additions and 368 deletions
@@ -121,7 +121,7 @@ public class ClientLauncherTUI {
if (!doLogin(controller)) continue; if (!doLogin(controller)) continue;
while (controller.getClient() != null) { while (controller.getClient() != null) {
String prompt = buildPrompt(controller); String prompt = buildPrompt();
String line; String line;
try { try {
line = gameReader.readLine(prompt); line = gameReader.readLine(prompt);
@@ -247,10 +247,9 @@ public class ClientLauncherTUI {
/** /**
* Returns the command-line prompt string showing the current username. * Returns the command-line prompt string showing the current username.
* *
* @param controller the client controller (reserved for future use).
* @return the prompt string. * @return the prompt string.
*/ */
private String buildPrompt(ClientController controller) { private String buildPrompt() {
return currentUsername.isEmpty() ? "> " : currentUsername + "> "; return currentUsername.isEmpty() ? "> " : currentUsername + "> ";
} }
@@ -270,7 +269,7 @@ public class ClientLauncherTUI {
if (pos >= 0) controller.totemChoice(pos); if (pos >= 0) controller.totemChoice(pos);
} }
case "skip" -> controller.skipTurn(); 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 "help" -> gameReader.printAbove("Commands: slot, draw, totem, skip, clear, help, details, rematch, quit");
case "details" -> { case "details" -> {
if (parts.length > 1 && parts[1].equalsIgnoreCase("buildings")) 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. * 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(); view.renderBoard();
} }
/** /**
@@ -18,7 +18,7 @@ public class ClientController {
private MiniModel miniModel; private MiniModel miniModel;
/** View of the client. */ /** View of the client. */
private IView view; private final IView view;
/** Network client, either TCP or RMI. */ /** Network client, either TCP or RMI. */
private IClient client; private IClient client;
@@ -2,8 +2,6 @@ package it.polimi.ingsw.gc14;
/** Enumeration of error types that can be returned by server-side operations. */ /** Enumeration of error types that can be returned by server-side operations. */
public enum ErrorType { 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. */ /** The chosen username is already taken by another connected player. */
USERNAME_ALREADY_USED("Username is already in use"), USERNAME_ALREADY_USED("Username is already in use"),
/** The user is already connected to the server. */ /** The user is already connected to the server. */
@@ -101,13 +101,6 @@ public class LimitedMap<K, V> implements Map<K, V> {
*/ */
public void setLimit(int num) { this.limit = num; } 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. * Sets a new action to execute when the map size reaches or exceeds the limit.
* *
@@ -1,7 +1,5 @@
package it.polimi.ingsw.gc14.Model.Cards.Building; package it.polimi.ingsw.gc14.Model.Cards.Building;
import it.polimi.ingsw.gc14.Model.Player;
/** /**
* Defines the effect behavior of a building card. * Defines the effect behavior of a building card.
* *
@@ -10,10 +8,4 @@ import it.polimi.ingsw.gc14.Model.Player;
*/ */
public interface BuildingEffect { public interface BuildingEffect {
/**
* Applies the building effect to the specified player.
*
* @param player the player affected by the building effect.
*/
void applyEffect(Player player);
} }
@@ -127,7 +127,6 @@ public class Building0 extends BuildingCard {
* @param player the player who owns the building. * @param player the player who owns the building.
* @throws IllegalArgumentException if the specified player does not own this card. * @throws IllegalArgumentException if the specified player does not own this card.
*/ */
@Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -13,7 +13,7 @@ public class Building1 extends BuildingCard {
/** /**
* Character type involved in the building effect. * Character type involved in the building effect.
*/ */
private CharacterType icon ; private final CharacterType icon ;
/** /**
* Returns the character type associated with this building effect. * Returns the character type associated with this building effect.
@@ -64,7 +64,6 @@ public class Building10 extends BuildingCard {
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
* @throws IllegalArgumentException if the player does not own this building card. * @throws IllegalArgumentException if the player does not own this building card.
*/ */
@Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -17,7 +17,7 @@ public class Building11 extends BuildingCard {
/** /**
* The character type involved in this building effect. * The character type involved in this building effect.
*/ */
private CharacterType characterType; private final CharacterType characterType;
/** /**
* Returns the CharacterType associated with this building card effect. * 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. * 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. * 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. * @param player the player to whom the effect is applied.
* @throws IllegalArgumentException if the player does not own this building card. * @throws IllegalArgumentException if the player does not own this building card.
*/ */
@Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -57,7 +57,6 @@ public class Building13 extends BuildingCard{
* @param player the player to whom the effect is applied. * @param player the player to whom the effect is applied.
* @throws IllegalArgumentException if the player does not own this building card. * @throws IllegalArgumentException if the player does not own this building card.
*/ */
@Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -130,7 +130,6 @@ public class Building4 extends BuildingCard {
* @param player The player who owns the building. * @param player The player who owns the building.
* @throws IllegalArgumentException Thrown if the specified player does not own this card. * @throws IllegalArgumentException Thrown if the specified player does not own this card.
*/ */
@Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -55,7 +55,6 @@ public class Building8 extends BuildingCard {
* @param player The player who owns the building. * @param player The player who owns the building.
* @throws IllegalArgumentException Thrown if the specified player does not own this building. * @throws IllegalArgumentException Thrown if the specified player does not own this building.
*/ */
@Override
public void applyEffect(Player player) throws IllegalArgumentException { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -168,12 +168,8 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
private static EffectType effectTypeFromId(int effectId) { private static EffectType effectTypeFromId(int effectId) {
switch (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 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; case 12: return EffectType.ON_ROUND_END;
default: throw new IllegalArgumentException(); 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. * @param player the player to whom the effect may be applied.
*/ */
@Override
public void applyEffect(Player player) {} public void applyEffect(Player player) {}
@Override @Override
@@ -1,6 +1,5 @@
package it.polimi.ingsw.gc14.Model.Cards; package it.polimi.ingsw.gc14.Model.Cards;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.PlayableCard; import it.polimi.ingsw.gc14.Model.PlayableCard;
import java.io.Serializable; 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. * 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. * Returns whether this tribe card is an event card.
@@ -14,7 +14,7 @@ public abstract class Character extends TribeCard implements Cloneable {
/** /**
* The specific type of this character card. * The specific type of this character card.
*/ */
private CharacterType type; private final CharacterType type;
/** /**
* Returns the type of this character card. * Returns the type of this character card.
@@ -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 * {@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). * (with or without an icon).
*/ */
private boolean icon; private final boolean icon;
/** /**
* Returns whether this Hunter card has the icon. * Returns whether this Hunter card has the icon.
@@ -18,7 +18,7 @@ public class Shaman extends Character {
* having the minority, on the other hand, results in * having the minority, on the other hand, results in
* losing Prestige Points. * losing Prestige Points.
*/ */
private int icon; private final int icon;
/** /**
* Returns the icon value of this Shaman card. * Returns the icon value of this Shaman card.
@@ -15,7 +15,7 @@ public abstract class EventCard extends TribeCard {
/** /**
* The specific type of this event card. * The specific type of this event card.
*/ */
private EventType type; private final EventType type;
/** /**
* Returns the type of this event card. * Returns the type of this event card.
@@ -1,10 +1,7 @@
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events; package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; 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.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.EventType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
import it.polimi.ingsw.gc14.Model.Player; 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. * The minimum number of Artist cards required to avoid the prestige penalty.
* Also, the bottom number on the card. * 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}. * 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. * 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. * Creates a CavePaintings event card with the specified era and effect parameters.
@@ -17,7 +17,7 @@ public class Hunt extends EventCard {
private static final int BASE_FOOD_PER_HUNTER = 1; private static final int BASE_FOOD_PER_HUNTER = 1;
/** Prestige Points multiplier used during the event. */ /** Prestige Points multiplier used during the event. */
private int prestigeMultiplier; private final int prestigeMultiplier;
int getPrestigeMultiplier() { return prestigeMultiplier; } int getPrestigeMultiplier() { return prestigeMultiplier; }
@@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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. * 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; private static final int BUILDING5_BONUS_ICONS = 3;
/** Prestige points awarded to the player with the most shaman icons. */ /** 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. * 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; } int getPrestigeToAdd() { return prestigeToAdd; }
/** Prestige points removed from the player with the fewest shaman icons. */ /** 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. * 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 maxIcon = playerMap.values().stream().mapToInt(Integer::intValue).max().orElse(0);
int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0); int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0);
List<Player> maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).collect(Collectors.toList()); List<Player> maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).toList();
List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).collect(Collectors.toList()); List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).toList();
for (Player player : maxIconsPlayer) { for (Player player : maxIconsPlayer) {
@@ -111,7 +110,7 @@ public class ShamanicRitual extends EventCard {
} }
for (Player player : minIconsPlayer) { 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); player.removePrestige(prestigeToRemove);
} }
} }
@@ -21,7 +21,7 @@ public class Sustenance extends EventCard {
/** /**
* The prestige penalty multiplier applied for each unpaid Food unit. * 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. * Returns the prestige penalty multiplier associated with this Sustenance event.
@@ -66,7 +66,7 @@ public class Game implements Serializable {
/** /**
* Queue containing the players who still have to choose their totem. * Queue containing the players who still have to choose their totem.
*/ */
private Queue<Player> totemChoiceQueue = new LinkedList<>(); private final Queue<Player> totemChoiceQueue = new LinkedList<>();
/** /**
* Assigns the selected totem to the specified player during the totem choice phase. * 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. * Map tracking the players who are currently disconnected.
* Key: player; value: {@code true} if currently disconnected, {@code false} if reconnected. * Key: player; value: {@code true} if currently disconnected, {@code false} if reconnected.
*/ */
private Map<Player,Boolean> disconnectedPlayers = new HashMap<>(); private final Map<Player,Boolean> disconnectedPlayers = new HashMap<>();
/** /**
* Returns an unmodifiable view of the disconnected-players map. * Returns an unmodifiable view of the disconnected-players map.
@@ -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. * 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. * Each slot (tile) has special action as drawing from the upper/lower row or taking food.
*/ */
private List<Slot> slotList; private final List<Slot> slotList;
/** tribeDeck is the deck from where you draw tribe cards as characters and events. */ /** tribeDeck is the deck from where you draw tribe cards as characters and events. */
private Queue<TribeCard> tribeDeck; private final Queue<TribeCard> tribeDeck;
/** /**
* The upper row of tribe cards. It contains a total of * The upper row of tribe cards. It contains a total of
* {@code nTotem + 4} tribe cards, which may include both character and event cards. * {@code nTotem + 4} tribe cards, which may include both character and event cards.
*/ */
private List<TribeCard> upperListTribe; private final List<TribeCard> upperListTribe;
/** /**
* The lower row of the tribe card. During the first round, there will be (num. of players + 1) character cards. * 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. * 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. * When an Event card gets in the lower row, the event effect will be activated at the end of the round.
*/ */
private List<TribeCard> lowerListTribe; private final List<TribeCard> lowerListTribe;
/** Contains all the building cards of the upper list. When a new era starts, all its building cards are placed here. */ /** Contains all the building cards of the upper list. When a new era starts, all its building cards are placed here. */
private List<BuildingCard> upperListBuilding; private final List<BuildingCard> 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. */ /** 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<BuildingCard> lowerListBuilding; private final List<BuildingCard> lowerListBuilding;
/** /**
* Returns the upper row of tribe cards. * 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. */ /** All building card lists grouped by era; index 0 = era 1, index 1 = era 2, etc. */
private final ArrayList<List<BuildingCard>> buildingCardsAllEras; private final ArrayList<List<BuildingCard>> buildingCardsAllEras;
/** Number of players */ /** Number of players */
private int nTotem; private final int nTotem;
/** Current era of the game */ /** Current era of the game */
private int era; private int era;
@@ -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.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard; 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.Model.GamePackage.CurrentState;
import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvent;
import java.io.Serializable; 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. * Sets the final standing of the players.
* *
@@ -1,13 +1,9 @@
package it.polimi.ingsw.gc14.Model; 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.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.io.Serializable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* Abstract base class for all order logic cards. * 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. * The queue of {@link Player Players} associated with this order logic card.
*/ */
private Queue<Player> players; private final Queue<Player> players;
/** /**
* The list of {@link OrderPlayer} entries tracking turn order and played status. * 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 so subclasses can read it for display purposes (e.g., {@link #toString()}).
*/ */
protected List<OrderPlayer> playerList; protected final List<OrderPlayer> playerList;
/** /**
* Returns an unmodifiable view of the player order list. * Returns an unmodifiable view of the player order list.
@@ -6,7 +6,6 @@ import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
import java.util.*; import java.util.*;
import java.util.stream.IntStream;
/** /**
* Represents the order logic card used in a two-player game. * Represents the order logic card used in a two-player game.
@@ -51,12 +50,10 @@ public class Order2 extends OrderLogicCard {
buildingEffect(player); buildingEffect(player);
return; return;
} }
if(index==1){ if (!player.removeFood(1)) {
if(!player.removeFood(1)){
player.removePrestige(2); player.removePrestige(2);
} }
} }
}
/** /**
* Creates the TURN ORDER box of the TUI. * Creates the TURN ORDER box of the TUI.
@@ -11,7 +11,7 @@ public abstract class PlayableCard implements Serializable {
/** /**
* The image identifier of the playable card. * The image identifier of the playable card.
*/ */
private String idIMG; private final String idIMG;
/** /**
* Returns the image identifier of this playable card. * Returns the image identifier of this playable card.
@@ -12,7 +12,7 @@ public class Slot implements Serializable {
/** /**
* The identifier of this slot. * The identifier of this slot.
*/ */
private char slotId; private final char slotId;
/** /**
* Returns the identifier of this slot. * Returns the identifier of this slot.
@@ -171,7 +171,7 @@ public class Slot implements Serializable {
StringBuilder s = new StringBuilder(" "); StringBuilder s = new StringBuilder(" ");
for(int i=0;i<this.getNUpper();i++) s.append(""); for(int i=0;i<this.getNUpper();i++) s.append("");
for(int i=0;i<this.getNLower();i++) s.append(""); for(int i=0;i<this.getNLower();i++) s.append("");
if(getFood()!=0) s.append("+"+getFood()+" \uD83C\uDF56"); if(getFood()!=0) s.append("+").append(getFood()).append(" \uD83C\uDF56");
s.append(" "); s.append(" ");
return s.toString(); return s.toString();
} }
@@ -38,7 +38,7 @@ public abstract class NetworkEvent implements Serializable {
/** /**
* Username of the player requesting the event. * Username of the player requesting the event.
*/ */
protected String username; protected final String username;
/** /**
* Returns the username of the player requesting the event. * Returns the username of the player requesting the event.
@@ -52,7 +52,7 @@ public abstract class NetworkEvent implements Serializable {
/** /**
* Type of the network event. * Type of the network event.
*/ */
protected EventType eventType; protected final EventType eventType;
/** /**
* Map associating each occupied slot with the corresponding player. * Map associating each occupied slot with the corresponding player.
@@ -15,7 +15,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
*/ */
public class AddPlayer extends NetworkEvent { public class AddPlayer extends NetworkEvent {
/** Number of players proposed by this player; used only when creating a new game. */ /** Number of players proposed by this player; used only when creating a new game. */
private int proposedNPlayer; private final int proposedNPlayer;
/** /**
* @return the number of proposed players to add to the match * @return the number of proposed players to add to the match
@@ -26,10 +26,10 @@ import java.util.Map;
*/ */
public class ApplyNextRound extends NetworkEvent { public class ApplyNextRound extends NetworkEvent {
private ArrayList<TribeCard> upperListTribeCards; private final ArrayList<TribeCard> upperListTribeCards;
private ArrayList<TribeCard> lowerListTribeCards; private final ArrayList<TribeCard> lowerListTribeCards;
private ArrayList<BuildingCard> upperListBuildingCards; private final ArrayList<BuildingCard> upperListBuildingCards;
private ArrayList<BuildingCard> lowerListBuildingCards; private final ArrayList<BuildingCard> lowerListBuildingCards;
/** /**
@@ -12,7 +12,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
*/ */
public class DrawLowerBuildingCard extends NetworkEvent{ public class DrawLowerBuildingCard extends NetworkEvent{
/** Index of the card to draw */ /** Index of the card to draw */
private int pos; private final int pos;
/** /**
* Class constructor. * Class constructor.
@@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
public class DrawLowerTribeCard extends NetworkEvent{ public class DrawLowerTribeCard extends NetworkEvent{
/** Index of the card to draw */ /** Index of the card to draw */
private int pos; private final int pos;
/** /**
* Class constructor. * Class constructor.
@@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
public class DrawUpperBuildingCard extends NetworkEvent{ public class DrawUpperBuildingCard extends NetworkEvent{
/** Index of the card to draw */ /** Index of the card to draw */
private int pos; private final int pos;
/** /**
* Class constructor. * Class constructor.
@@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
public class DrawUpperTribeCard extends NetworkEvent{ public class DrawUpperTribeCard extends NetworkEvent{
/** Index of the card to draw */ /** Index of the card to draw */
private int pos; private final int pos;
/** /**
* Class constructor. * Class constructor.
@@ -13,7 +13,7 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
public class SlotChoice extends NetworkEvent { public class SlotChoice extends NetworkEvent {
/** Index of the selected slot. */ /** Index of the selected slot. */
private int pos; private final int pos;
/** /**
* Class constructor. * Class constructor.
@@ -20,22 +20,13 @@ public class TotemChoice extends NetworkEvent implements Serializable {
/** /**
* Name of the totem selected by the player. * 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. * List of totems still available after the choice has been processed.
*/ */
private List<Totems> availableTotems; private List<Totems> availableTotems;
/**
* Sets the list of currently available totems.
*
* @param availableTotems the totems still available for selection.
*/
public void setAvailableTotems(List<Totems> availableTotems) {
this.availableTotems = availableTotems;
}
/** /**
* Constructs a totem choice event for the specified player. * Constructs a totem choice event for the specified player.
* *
@@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback; import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
import javafx.application.Platform;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject; import java.rmi.server.UnicastRemoteObject;
@@ -8,7 +8,6 @@ import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.IClient;
import it.polimi.ingsw.gc14.Network.NetworkConfig; import it.polimi.ingsw.gc14.Network.NetworkConfig;
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer; import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer;
/** /**
@@ -19,8 +18,8 @@ public class RMIClient implements IClient {
private final String host; private final String host;
private final int port; private final int port;
private IGameServer stub; private IGameServer stub;
private ClientController controller; private final ClientController controller;
private String myIp; private final String myIp;
private String username; private String username;
private volatile boolean running = false; private volatile boolean running = false;
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
import java.io.Serializable; import java.io.Serializable;
import java.rmi.*; import java.rmi.*;
import java.util.Map;
/** /**
* Callback interface used by the server to notify an RMI client about * Callback interface used by the server to notify an RMI client about
@@ -21,7 +21,6 @@ import java.util.Map;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.rmi.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -36,7 +35,6 @@ import java.util.stream.Collectors;
public class RMIServer extends UnicastRemoteObject implements IGameServer { public class RMIServer extends UnicastRemoteObject implements IGameServer {
private final String host; private final String host;
private final GameController controller; private final GameController controller;
private Registry registry;
private final int nPort; private final int nPort;
/** username → callback */ /** username → callback */
@@ -304,7 +302,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
public boolean start() { public boolean start() {
try { try {
System.setProperty("java.rmi.server.hostname", host); System.setProperty("java.rmi.server.hostname", host);
registry = LocateRegistry.createRegistry(nPort); Registry registry = LocateRegistry.createRegistry(nPort);
registry.rebind("RMIGameServer", this); registry.rebind("RMIGameServer", this);
System.out.println("RMI Server started on port: " + nPort); System.out.println("RMI Server started on port: " + nPort);
return true; return true;
@@ -314,29 +312,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
} }
} }
/**
* Stops the RMI server and removes its binding from the registry.
*
* <p>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. * Creates and starts an {@link RMIHeartbeat} for the specified player.
@@ -31,16 +31,16 @@ public class TCPClient implements IClient {
private ObjectOutputStream socketSend; private ObjectOutputStream socketSend;
/** Client game's controller */ /** Client game's controller */
private ClientController controller; private final ClientController controller;
/** IP address of the server to connect to */ /** IP address of the server to connect to */
private String hostname; private final String hostname;
private boolean running; private boolean running;
/** TCP port */ /** TCP port */
private int mainPort; private final int mainPort;
private int heartbeatPort; private final int heartbeatPort;
private Socket heartbeatSocket; private Socket heartbeatSocket;
private OutputStream heartbeatOut; private OutputStream heartbeatOut;
private InputStream heartbeatIn; private InputStream heartbeatIn;
@@ -134,7 +134,7 @@ public class TCPClient implements IClient {
heartbeatSocket.setSoTimeout((int) NetworkConfig.SILENCE_THRESHOLD_MS); heartbeatSocket.setSoTimeout((int) NetworkConfig.SILENCE_THRESHOLD_MS);
while (running) { while (running) {
int b = heartbeatIn.read(); int b = heartbeatIn.read();
if (b == -1 || b != PONG) { if (b != PONG) {
disconnect(); disconnect();
controller.getView().showError(ErrorType.SERVER_CRASHED, ErrorType.SERVER_CRASHED.toString()); controller.getView().showError(ErrorType.SERVER_CRASHED, ErrorType.SERVER_CRASHED.toString());
break; break;
@@ -1,7 +1,6 @@
package it.polimi.ingsw.gc14.Network.TCP.Server; package it.polimi.ingsw.gc14.Network.TCP.Server;
import it.polimi.ingsw.gc14.LimitedMap; 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.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer; import it.polimi.ingsw.gc14.Network.NetworkEvents.DisconnectedPlayer;
@@ -34,25 +33,25 @@ public class ClientHandler implements Runnable {
return username; return username;
} }
/** The TCP socket */ /** The TCP socket */
private Socket clientSocket; private final Socket clientSocket;
/** Input stream used to receive objects from the client */ /** 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 */ /** Output stream used to send objects to the client */
private ObjectOutputStream out; private final ObjectOutputStream out;
/** /**
* Shared list of all client handlers. * Shared list of all client handlers.
* This handler removes itself from the list when disconnected. * This handler removes itself from the list when disconnected.
*/ */
private List<ClientHandler> clientHandlers; private final List<ClientHandler> clientHandlers;
/** Maps each connected player's username to their connection state (true = connected). */ /** Maps each connected player's username to their connection state (true = connected). */
private LimitedMap<String, Boolean> limitedMap; private final LimitedMap<String, Boolean> limitedMap;
/** Queue containing the events to be applied to the game model */ /** Queue containing the events to be applied to the game model */
private BlockingQueue<NetworkEvent> actionQueue; private final BlockingQueue<NetworkEvent> actionQueue;
/** /**
@@ -35,12 +35,12 @@ public class TCPServer {
/** /**
* Main TCP port used for standard client-server communication. * Main TCP port used for standard client-server communication.
*/ */
private int port; private final int port;
/** /**
* TCP port dedicated to heartbeat communication. * TCP port dedicated to heartbeat communication.
*/ */
private int heartbeatPort; private final int heartbeatPort;
/** /**
* Main server socket used to accept client connections. * Main server socket used to accept client connections.
@@ -60,17 +60,17 @@ public class TCPServer {
/** /**
* Queue containing network events received from clients. * Queue containing network events received from clients.
*/ */
private BlockingQueue<NetworkEvent> actionQueue; private final BlockingQueue<NetworkEvent> actionQueue;
/** /**
* Map storing the online/offline status of connected players. * Map storing the online/offline status of connected players.
*/ */
private LimitedMap<String, Boolean> playerList; private final LimitedMap<String, Boolean> playerList;
/** /**
* List of active TCP client handlers. * List of active TCP client handlers.
*/ */
private CopyOnWriteArrayList<ClientHandler> clientHandlers; private final CopyOnWriteArrayList<ClientHandler> clientHandlers;
/** /**
@@ -21,8 +21,7 @@ import java.util.Random;
* <li><b>dust</b> (type 2) large, translucent brown drifting circles.</li> * <li><b>dust</b> (type 2) large, translucent brown drifting circles.</li>
* </ul> * </ul>
* *
* <p>Call {@link #start()} after adding {@link #getPane()} to the scene graph, * <p>Call {@link #start()} after adding {@link #getPane()} to the scene graph
* and {@link #stop()} when the scene is hidden.
*/ */
public class FireParticleSystem { public class FireParticleSystem {
@@ -43,8 +42,6 @@ public class FireParticleSystem {
private final List<Particle> particles = new ArrayList<>(); private final List<Particle> particles = new ArrayList<>();
/** Shared random source for particle initialisation and physics noise. */ /** Shared random source for particle initialisation and physics noise. */
private final Random rnd = new Random(); 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. */ /** Timestamp (ns) of the last particle spawn batch. */
private long lastSpawn = 0; private long lastSpawn = 0;
/** Timestamp (ns) of the last rendered frame. */ /** Timestamp (ns) of the last rendered frame. */
@@ -74,7 +71,7 @@ public class FireParticleSystem {
/** Starts the animation timer. */ /** Starts the animation timer. */
public void start() { public void start() {
timer = new AnimationTimer() { AnimationTimer timer = new AnimationTimer() {
@Override @Override
public void handle(long now) { public void handle(long now) {
if (now - lastFrame < FRAME_INTERVAL_NS) return; if (now - lastFrame < FRAME_INTERVAL_NS) return;
@@ -85,11 +82,6 @@ public class FireParticleSystem {
timer.start(); 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, * 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. * 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. */ /** Remaining life fraction (1.0 = full, 0.0 = dead); only decrements for sparks. */
double life; double life;
/** Visual radius of the particle's core circle. */ /** Visual radius of the particle's core circle. */
double size; final double size;
/** Current phase of the sinusoidal wobble. */ /** Current phase of the sinusoidal wobble. */
double wobblePhase; double wobblePhase;
/** Angular speed of the wobble oscillation. */ /** Angular speed of the wobble oscillation. */
double wobbleSpeed; final double wobbleSpeed;
/** Amplitude factor of the wobble displacement. */ /** Amplitude factor of the wobble displacement. */
double wobbleAmp; final double wobbleAmp;
/** Particle type: 0 = ember, 1 = spark, 2 = dust. */ /** Particle type: 0 = ember, 1 = spark, 2 = dust. */
final int type; final int type;
/** Shared random source used during physics updates. */ /** Shared random source used during physics updates. */
@@ -105,7 +105,7 @@ public class GUI extends Application implements IView {
controllerLogin.updateLoginButton(true); controllerLogin.updateLoginButton(true);
controllerLogin.showError(""); controllerLogin.showError("");
fadeToScene(loginScene); fadeToScene(loginScene);
}, loginScene); });
@@ -6,7 +6,6 @@ import javafx.animation.ScaleTransition;
import it.polimi.ingsw.gc14.Model.PlayableCard; import it.polimi.ingsw.gc14.Model.PlayableCard;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
import javafx.stage.Popup; import javafx.stage.Popup;
import javafx.geometry.Insets; import javafx.geometry.Insets;
@@ -24,7 +23,6 @@ import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop; import javafx.scene.paint.Stop;
import javafx.scene.paint.CycleMethod; import javafx.scene.paint.CycleMethod;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.Window; import javafx.stage.Window;
import javafx.util.Duration; import javafx.util.Duration;
@@ -49,8 +47,6 @@ public class LeaderboardFXMLController {
private VBox popupContent; private VBox popupContent;
/** Shared image cache to avoid reloading resources multiple times. */ /** Shared image cache to avoid reloading resources multiple times. */
private static final Map<String, Image> imageCache = new HashMap<>(); private static final Map<String, Image> 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). */ /** Action run when the player returns to the login screen (disconnect + scene switch). */
private Runnable action; private Runnable action;
@@ -66,11 +62,9 @@ public class LeaderboardFXMLController {
* *
* @param controller the client controller. * @param controller the client controller.
* @param action the action to run when the player returns to the login screen. * @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.controller = controller;
this.loginScene = loginScene;
this.action = action; this.action = action;
} }
@@ -20,9 +20,6 @@ import javafx.scene.paint.Color;
import javafx.stage.Screen; import javafx.stage.Screen;
import javafx.util.Duration; import javafx.util.Duration;
import java.net.*;
import java.util.Enumeration;
/** /**
* FXML controller for the login scene. * FXML controller for the login scene.
* *
@@ -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.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer; import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import javafx.animation.ScaleTransition; import javafx.animation.ScaleTransition;
import javafx.animation.TranslateTransition; import javafx.animation.TranslateTransition;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Bounds;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.Cursor; import javafx.scene.Cursor;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
@@ -33,7 +26,6 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.*; import javafx.scene.shape.*;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.stage.Popup; import javafx.stage.Popup;
import javafx.stage.Screen;
import javafx.stage.Window; import javafx.stage.Window;
import javafx.util.Duration; import javafx.util.Duration;
@@ -46,14 +38,10 @@ import java.util.*;
* the player's hand, and action buttons (skip, details). * the player's hand, and action buttons (skip, details).
*/ */
public class MainFXMLController { public class MainFXMLController {
/** Left column grid used for the board slots layout. */
@FXML private GridPane leftGrid;
/** Scrollable container holding all player side-panel cards. */ /** Scrollable container holding all player side-panel cards. */
@FXML private ScrollPane playerSide; @FXML private ScrollPane playerSide;
/** Root HBox containing all main scene elements. */ /** Root HBox containing all main scene elements. */
@FXML private HBox mainHBox; @FXML private HBox mainHBox;
/** Background image view for the main scene. */
@FXML private ImageView backgroundImage;
/** HBox holding the board slot and order cards. */ /** HBox holding the board slot and order cards. */
@FXML private HBox board; @FXML private HBox board;
/** HBox holding the upper tribe card row (and upper building stack). */ /** 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. */ /** Adds the era-specific deck back image to the board. */
private void renderDeck() { private void renderDeck() {
String path = switch (controller.getMiniModel().currentState.getEra()) { String path = switch (controller.getMiniModel().currentState.getEra()) {
case 1 -> "/GUIImages/Backs/back-001.png";
case 2 -> "/GUIImages/Backs/back-030.png"; case 2 -> "/GUIImages/Backs/back-030.png";
case 3 -> "/GUIImages/Backs/back-058.png"; case 3 -> "/GUIImages/Backs/back-058.png";
default -> "/GUIImages/Backs/back-001.png"; default -> "/GUIImages/Backs/back-001.png";
@@ -103,11 +103,6 @@ public class TUI implements IView {
display(buildBoardContent()); 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, * 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. * so only one {@code printAbove} is issued and the prompt is redrawn correctly.
+2 -2
View File
@@ -10,7 +10,7 @@
stylesheets="@styles.css"> stylesheets="@styles.css">
<ImageView fx:id="backgroundImage" fitWidth="1920" fitHeight="1080" preserveRatio="false"/> <ImageView fx:id="backgroundImage" fitWidth="1920" fitHeight="1080"/>
<!-- Corner decorations --> <!-- Corner decorations -->
<Region prefWidth="52" prefHeight="52" <Region prefWidth="52" prefHeight="52"
@@ -35,7 +35,7 @@
</Region> </Region>
<!-- Central panel --> <!-- Central panel -->
<VBox fx:id="formPanel" alignment="CENTER" spacing="0" maxWidth="420" maxHeight="600" <VBox fx:id="formPanel" alignment="CENTER" maxWidth="420" maxHeight="600"
StackPane.alignment="CENTER" StackPane.alignment="CENTER"
style="-fx-background-color: rgba(9,6,3,0.72); style="-fx-background-color: rgba(9,6,3,0.72);
-fx-border-color: rgba(200,120,20,0.40); -fx-border-color: rgba(200,120,20,0.40);
+9 -15
View File
@@ -13,7 +13,6 @@
fx:controller="it.polimi.ingsw.gc14.View.GUI.MainFXMLController" fx:controller="it.polimi.ingsw.gc14.View.GUI.MainFXMLController"
stylesheets="@styles.css"> stylesheets="@styles.css">
<children>
<!-- VBox sinistra: si espande per riempire tutto lo spazio disponibile --> <!-- VBox sinistra: si espande per riempire tutto lo spazio disponibile -->
<VBox alignment="CENTER" <VBox alignment="CENTER"
fillWidth="false" fillWidth="false"
@@ -21,33 +20,31 @@
maxWidth="Infinity" maxWidth="Infinity"
HBox.hgrow="ALWAYS"> HBox.hgrow="ALWAYS">
<HBox.margin> <HBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5"/>
</HBox.margin> </HBox.margin>
<children>
<HBox fx:id="upperList" styleClass="card-list" VBox.vgrow="ALWAYS"> <HBox fx:id="upperList" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin> <VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5"/>
</VBox.margin> </VBox.margin>
</HBox> </HBox>
<HBox fx:id="board" styleClass="card-list" VBox.vgrow="NEVER"> <HBox fx:id="board" styleClass="card-list" VBox.vgrow="NEVER">
<VBox.margin> <VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5"/>
</VBox.margin> </VBox.margin>
</HBox> </HBox>
<HBox fx:id="lowerList" styleClass="card-list" VBox.vgrow="ALWAYS"> <HBox fx:id="lowerList" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin> <VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5"/>
</VBox.margin> </VBox.margin>
</HBox> </HBox>
<HBox fx:id="myHand" styleClass="card-list" VBox.vgrow="ALWAYS"> <HBox fx:id="myHand" styleClass="card-list" VBox.vgrow="ALWAYS">
<VBox.margin> <VBox.margin>
<Insets top="5" right="5" bottom="5" left="5" /> <Insets top="5" right="5" bottom="5" left="5"/>
</VBox.margin> </VBox.margin>
</HBox> </HBox>
</children>
</VBox> </VBox>
<!-- VBox destra: dimensione fissa, non si espande --> <!-- VBox destra: dimensione fissa, non si espande -->
<VBox fx:id="sidePanel" <VBox fx:id="sidePanel"
@@ -57,21 +54,20 @@
HBox.hgrow="NEVER" HBox.hgrow="NEVER"
styleClass="side-panel"> styleClass="side-panel">
<HBox.margin> <HBox.margin>
<Insets bottom="10" left="10" right="10" top="10" /> <Insets bottom="10" left="10" right="10" top="10"/>
</HBox.margin> </HBox.margin>
<children>
<HBox fx:id="info" prefHeight="80.0" prefWidth="483.0" styleClass="frame" alignment="CENTER"> <HBox fx:id="info" prefHeight="80.0" prefWidth="483.0" styleClass="frame" alignment="CENTER">
<Label fx:id="infoText" styleClass="label-medium" text="VALORE" /> <Label fx:id="infoText" styleClass="label-medium" text="VALORE"/>
</HBox> </HBox>
<ScrollPane fx:id="playerSide" fitToWidth="true" <ScrollPane fx:id="playerSide" fitToWidth="true"
style="-fx-background: transparent; -fx-background-color: transparent;" hbarPolicy="NEVER" style="-fx-background: transparent; -fx-background-color: transparent;" hbarPolicy="NEVER"
vbarPolicy="AS_NEEDED" VBox.vgrow="ALWAYS"> VBox.vgrow="ALWAYS">
<VBox.margin> <VBox.margin>
<Insets top="5"/> <Insets top="5"/>
</VBox.margin> </VBox.margin>
</ScrollPane> </ScrollPane>
<Pane HBox.hgrow="ALWAYS"/> <Pane HBox.hgrow="ALWAYS"/>
<HBox alignment="CENTER" fx:id="buttonRow" > <HBox alignment="CENTER" fx:id="buttonRow">
<HBox spacing="10"> <HBox spacing="10">
<Button fx:id="skipBtn" styleClass="action-button" text="Skip Turn"/> <Button fx:id="skipBtn" styleClass="action-button" text="Skip Turn"/>
<Button fx:id="detailsBtn" styleClass="action-button" text="Ending Details"/> <Button fx:id="detailsBtn" styleClass="action-button" text="Ending Details"/>
@@ -83,8 +79,6 @@
</HBox> </HBox>
</children>
</VBox> </VBox>
</children>
</HBox> </HBox>
@@ -16,7 +16,6 @@
<ScrollPane fitToWidth="true" <ScrollPane fitToWidth="true"
hbarPolicy="NEVER" hbarPolicy="NEVER"
vbarPolicy="AS_NEEDED"
style="-fx-background: transparent; -fx-background-color: transparent;" style="-fx-background: transparent; -fx-background-color: transparent;"
VBox.vgrow="ALWAYS"> VBox.vgrow="ALWAYS">
<VBox fx:id="rankingList" alignment="CENTER" spacing="16"> <VBox fx:id="rankingList" alignment="CENTER" spacing="16">
+6 -7
View File
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.image.Image?> <?import javafx.scene.layout.*?>
<StackPane xmlns="http://javafx.com/javafx/26" <StackPane xmlns="http://javafx.com/javafx/26"
xmlns:fx="http://javafx.com/fxml/1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="it.polimi.ingsw.gc14.View.GUI.TotemFXMLController" fx:controller="it.polimi.ingsw.gc14.View.GUI.TotemFXMLController"
style="-fx-background-color: #09060300;"> style="-fx-background-color: #09060300;">
<ImageView fx:id="backgroundImage" fitWidth="1920" fitHeight="1080" preserveRatio="false"> <ImageView fx:id="backgroundImage" fitWidth="1920" fitHeight="1080">
</ImageView> </ImageView>
<Region fx:id="cornerTL" prefWidth="52" prefHeight="52" <Region fx:id="cornerTL" prefWidth="52" prefHeight="52"
@@ -34,7 +33,7 @@
<StackPane.margin><Insets bottom="18" right="18"/></StackPane.margin> <StackPane.margin><Insets bottom="18" right="18"/></StackPane.margin>
</Region> </Region>
<VBox alignment="CENTER" spacing="0" StackPane.alignment="CENTER"> <VBox alignment="CENTER" StackPane.alignment="CENTER">
<padding><Insets top="40" bottom="40" left="40" right="40"/></padding> <padding><Insets top="40" bottom="40" left="40" right="40"/></padding>
<!-- Banner turno --> <!-- Banner turno -->
@@ -64,7 +64,7 @@ class Building1Test {
BuildingCard bClone = b0.clone(); BuildingCard bClone = b0.clone();
assertTrue(bClone instanceof Building1); assertInstanceOf(Building1.class, bClone);
Building1 clonedBuilding = (Building1) bClone; Building1 clonedBuilding = (Building1) bClone;
@@ -1,7 +1,6 @@
package it.polimi.ingsw.gc14.Model.Cards; package it.polimi.ingsw.gc14.Model.Cards;
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType; import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building13;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@@ -9,22 +9,12 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
class CavePaintingsTest { class CavePaintingsTest {
@Test
@DisplayName("Testing constructor")
void testConstructor() {
// Gli attributi di CavePainting era e EventType vengono testati in EventCardTest.
// Gli attributi NLower, NPrestigeRem e NPrestigeMul non possono essere testati singolarmente in quanto non hanno metodi getter
// Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect.
// Come conseguenza finale, non può essere testato il costruttore di CavePainting
}
@Test @Test
@DisplayName("No edge case test") @DisplayName("No edge case test")
void activateEvent() { void activateEvent() {
@@ -46,7 +36,7 @@ class CavePaintingsTest {
@DisplayName("Multiple activations test") @DisplayName("Multiple activations test")
void activateEvent1() { void activateEvent1() {
Player p1 = new Player("Marco"); Player p1 = new Player("Marco");
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1)); ArrayList<Player> players = new ArrayList<>(List.of(p1));
CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); CavePaintings cp1 = new CavePaintings(1, 1, 3, 2);
CavePaintings cp2 = new CavePaintings(1, 1, 3, 4); CavePaintings cp2 = new CavePaintings(1, 1, 3, 4);
CavePaintings cp3 = new CavePaintings(1, 1, 10, 2); CavePaintings cp3 = new CavePaintings(1, 1, 10, 2);
@@ -71,7 +61,7 @@ class CavePaintingsTest {
@DisplayName("Building 9 test") @DisplayName("Building 9 test")
void activateEvent2() { void activateEvent2() {
Player p1 = new Player("Marco"); Player p1 = new Player("Marco");
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1)); ArrayList<Player> players = new ArrayList<>(List.of(p1));
CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); CavePaintings cp1 = new CavePaintings(1, 1, 3, 2);
BuildingCard bc1 = new BuildingCard(9,1,5,5); BuildingCard bc1 = new BuildingCard(9,1,5,5);
p1.addFood(5); p1.addFood(5);
@@ -98,7 +88,7 @@ class CavePaintingsTest {
@DisplayName("Not Building 9 test") @DisplayName("Not Building 9 test")
void activateEvent3() { void activateEvent3() {
Player p1 = new Player("Marco"); Player p1 = new Player("Marco");
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1)); ArrayList<Player> players = new ArrayList<>(List.of(p1));
CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); CavePaintings cp1 = new CavePaintings(1, 1, 3, 2);
BuildingCard bc1 = new BuildingCard(9,1,5,5); BuildingCard bc1 = new BuildingCard(9,1,5,5);
p1.addFood(5); p1.addFood(5);
@@ -1,10 +1,7 @@
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events; package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building0;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@@ -16,16 +13,6 @@ import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
class HuntTest { class HuntTest {
@Test
@DisplayName("Testing constructor")
void testConstructor() {
// Gli attributi di Hunt era e EventType vengono testati in EventCardTest.
// Gli attributi foodMultiplier e prestigeMultiplier non possono essere testati singolarmente in quanto non hanno metodi getter
// Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect.
// Come conseguenza finale, non può essere testato il costruttore di Hunt
}
@Test @Test
@DisplayName("No edge case test") @DisplayName("No edge case test")
@@ -139,7 +126,6 @@ class HuntTest {
Hunt h1 = new Hunt(era, prestigeMultiplier); Hunt h1 = new Hunt(era, prestigeMultiplier);
Hunt h2 = (Hunt) h1.clone(); Hunt h2 = (Hunt) h1.clone();
assertEquals(1, 1); // foodMultiplier is now a constant BASE_FOOD_PER_HUNTER=1
assertEquals(3, h2.getPrestigeMultiplier()); assertEquals(3, h2.getPrestigeMultiplier());
assertEquals(1, h2.getEra()); assertEquals(1, h2.getEra());
assertEquals(EventType.HUNT, h2.getType()); assertEquals(EventType.HUNT, h2.getType());
@@ -1,15 +1,10 @@
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events; package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Shaman; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Shaman;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -18,21 +13,8 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ShamanicRitualTest { class ShamanicRitualTest {
@Test
@DisplayName("Testing constructor")
void testConstructor() {
// Gli attributi di ShamanicRitual era e EventType vengono testati in EventCardTest.
// Gli attributi prestigeToAdd e prestigeToRemove non possono essere testati singolarmente in quanto non hanno metodi getter
// Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect.
// Come conseguenza finale, non può essere testato il costruttore di ShamanicRitual
}
@Test @Test
@DisplayName("No edge case test") @DisplayName("No edge case test")
void applyEvent() { void applyEvent() {
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
class SustenanceTest { class SustenanceTest {
@@ -3,14 +3,10 @@ package it.polimi.ingsw.gc14.Model.GamePackage;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
import it.polimi.ingsw.gc14.Model.DecksCreator;
import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Slot;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -188,7 +184,7 @@ class BoardTest {
void nextRound() { void nextRound() {
int numPlayer = 3; int numPlayer = 3;
Board bd = new Board(numPlayer); Board bd = new Board(numPlayer);
assertTrue(!bd.getLowerListTribe().isEmpty()); assertFalse(bd.getLowerListTribe().isEmpty());
List<TribeCard> upperListBefore = new ArrayList<>(bd.getUpperListTribe()); List<TribeCard> upperListBefore = new ArrayList<>(bd.getUpperListTribe());
bd.nextRound(); bd.nextRound();
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -32,7 +31,7 @@ class Order2Test {
Order2 order = new Order2(players); Order2 order = new Order2(players);
Player firstToAct = order.pull(); Player firstToAct = order.pull();
Player secondToAct = order.pull(); order.pull();
int initialFood = firstToAct.getFoodValue(); int initialFood = firstToAct.getFoodValue();
order.push(firstToAct); order.push(firstToAct);
@@ -193,7 +192,7 @@ class Order2Test {
assertTrue(order.toString().contains("+1🍖")); assertTrue(order.toString().contains("+1🍖"));
assertTrue(order.toString().contains("-1🍖/-2🏅")); assertTrue(order.toString().contains("-1🍖/-2🏅"));
Player extraPlayer = new Player("px"); new Player("px");
//TODO testare IndexOutOfBoundsException //TODO testare IndexOutOfBoundsException
// assertThrows(IndexOutOfBoundsException.class, () -> { // assertThrows(IndexOutOfBoundsException.class, () -> {
// Order2 ox = new Order2(new ArrayList<>(Arrays.asList(p1, p2)));; // Order2 ox = new Order2(new ArrayList<>(Arrays.asList(p1, p2)));;
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -3,17 +3,10 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -344,7 +337,7 @@ class Order5Test {
assertNotEquals(thirdOut, fifthOut); assertNotEquals(thirdOut, fifthOut);
assertNotEquals(fourthOut, fifthOut); assertNotEquals(fourthOut, fifthOut);
assertEquals(null, order.pull()); assertNull(order.pull());
} }
@Test @Test
@@ -355,11 +348,11 @@ class Order5Test {
Player p4 = new Player("p4"); Player p4 = new Player("p4");
Player p5 = new Player("p5"); Player p5 = new Player("p5");
Order5 order = new Order5(new ArrayList<>(Arrays.asList(p1,p2,p3,p4,p5))); Order5 order = new Order5(new ArrayList<>(Arrays.asList(p1,p2,p3,p4,p5)));
Player firstOut = order.pull(); order.pull();
Player secondOut = order.pull(); order.pull();
Player thirdOut = order.pull(); order.pull();
Player fourthOut = order.pull(); order.pull();
Player fifthOut = order.pull(); order.pull();
assertNull(order.getFirst()); assertNull(order.getFirst());
order.push(p1); order.push(p1);
@@ -1,7 +1,6 @@
package it.polimi.ingsw.gc14.Model; package it.polimi.ingsw.gc14.Model;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -125,9 +125,9 @@ class PlayerTest {
@Test @Test
void removeFood() { void removeFood() {
Player p = new Player("test"); Player p = new Player("test");
assertEquals(true, p.removeFood(0)); assertTrue(p.removeFood(0));
assertEquals(false, p.removeFood(1)); assertFalse(p.removeFood(1));
assertEquals(true, p.removeFood(-1)); assertTrue(p.removeFood(-1));
} }
@Test @Test
@@ -183,7 +183,7 @@ class PlayerTest {
@DisplayName("Exception Test Max Length") @DisplayName("Exception Test Max Length")
void test_max() { void test_max() {
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
Player p = new Player("abcdabcdabcdabcdabcdabcdabcdabcdZ"); new Player("abcdabcdabcdabcdabcdabcdabcdabcdZ");
}); });
} }
@@ -191,7 +191,7 @@ class PlayerTest {
@DisplayName("Exception Test Min Length") @DisplayName("Exception Test Min Length")
void test_min() { void test_min() {
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
Player p = new Player(""); new Player("");
}); });
} }
@@ -9,29 +9,29 @@ class SlotTest {
@Test @Test
void SlotWrongArgument() { void SlotWrongArgument() {
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('A'); new Slot('A');
}); });
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('B'); new Slot('B');
}); });
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('C'); new Slot('C');
}); });
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('D'); new Slot('D');
}); });
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('E'); new Slot('E');
}); });
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('F'); new Slot('F');
}); });
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
Slot sl1 = new Slot('G'); new Slot('G');
}); });
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
Slot sl1 = new Slot('H'); new Slot('H');
}); });
} }