Refactor: removed dead code and standarized to camelCase

This commit is contained in:
2026-06-12 18:37:18 +02:00
parent 5a0d201341
commit bc9e4480c0
49 changed files with 187 additions and 352 deletions
+14 -17
View File
@@ -11,8 +11,11 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.12.1</junit.version> <junit.version>5.14.4</junit.version>
<javafx.version>23</javafx.version> <javafx.version>26</javafx.version>
<gson.version>2.14.0</gson.version>
<controlsfx.version>11.2.3</controlsfx.version>
<jline.version>3.30.13</jline.version>
</properties> </properties>
<dependencies> <dependencies>
@@ -34,7 +37,7 @@
<dependency> <dependency>
<groupId>org.controlsfx</groupId> <groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId> <artifactId>controlsfx</artifactId>
<version>11.2.1</version> <version>${controlsfx.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
@@ -48,36 +51,30 @@
<version>${junit.version}</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.10.1</version> <version>${gson.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jline</groupId> <groupId>org.jline</groupId>
<artifactId>jline-terminal</artifactId> <artifactId>jline-terminal</artifactId>
<version>3.26.3</version> <version>${jline.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jline</groupId> <groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId> <artifactId>jline-reader</artifactId>
<version>3.26.3</version> <version>${jline.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jline</groupId> <groupId>org.jline</groupId>
<artifactId>jline-builtins</artifactId> <artifactId>jline-builtins</artifactId>
<version>3.26.3</version> <version>${jline.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jline</groupId> <groupId>org.jline</groupId>
<artifactId>jline-terminal-jansi</artifactId> <artifactId>jline-terminal-jansi</artifactId>
<version>3.26.3</version> <version>${jline.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -86,7 +83,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version> <version>3.15.0</version>
<configuration> <configuration>
<release>25</release> <release>25</release>
<compilerArgs> <compilerArgs>
@@ -97,7 +94,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version> <version>3.5.6</version>
<configuration> <configuration>
<argLine>--enable-preview</argLine> <argLine>--enable-preview</argLine>
</configuration> </configuration>
@@ -129,7 +126,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version> <version>3.6.2</version>
<executions> <executions>
<!-- SERVER --> <!-- SERVER -->
@@ -169,7 +169,9 @@ public class ClientLauncherTUI {
RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, myIP); RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, myIP);
ErrorType err = client.connect(username, nPlayers); ErrorType err = client.connect(username, nPlayers);
if (err != null) { 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; return false;
} }
System.out.println("Connected via RMI."); 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); TCPClient client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
ErrorType err = client.connect(username, nPlayers); ErrorType err = client.connect(username, nPlayers);
if (err != null) { 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; return false;
} }
System.out.println("Connected via TCP."); System.out.println("Connected via TCP.");
@@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.IClient;
import it.polimi.ingsw.gc14.View.IView; import it.polimi.ingsw.gc14.View.IView;
import java.util.Objects;
/** /**
* Controller responsible for coordinating the client-side components, * Controller responsible for coordinating the client-side components,
@@ -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();
}
}
@@ -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!");
}
}
@@ -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.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import java.util.HashMap;
/** /**
* At the end of the game, the player gains 6 Prestige Points * 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 { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); throw new IllegalArgumentException();
HashMap<CharacterType,Integer> map = new HashMap<CharacterType,Integer>();
int numSet=player.getNType(CharacterType.INVENTOR); int numSet=player.getNType(CharacterType.INVENTOR);
for(CharacterType type : CharacterType.values()) for(CharacterType type : CharacterType.values())
{ {
@@ -26,14 +26,14 @@ public class Building11 extends BuildingCard {
*/ */
public CharacterType getIcon() {return icon;} public CharacterType getIcon() {return icon;}
private int PrestigeMul; private int prestigeMul;
/** /**
* Returns the prestige multiplier associated with this building card effect. * Returns the prestige multiplier associated with this building card effect.
* *
* @return 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, * Creates a Building11 card with the specified era, price, prestige value,
@@ -50,7 +50,7 @@ public class Building11 extends BuildingCard {
effectType = EffectType.FINAL; effectType = EffectType.FINAL;
effectId = 11; effectId = 11;
this.icon = icon; this.icon = icon;
this.PrestigeMul = prestigeMul; this.prestigeMul = prestigeMul;
} }
/** /**
@@ -69,7 +69,7 @@ public class Building11 extends BuildingCard {
effectType = EffectType.FINAL; effectType = EffectType.FINAL;
effectId = 11; effectId = 11;
this.icon = icon; this.icon = icon;
this.PrestigeMul = prestigeMul; this.prestigeMul = prestigeMul;
} }
/** /**
@@ -79,7 +79,7 @@ public class Building11 extends BuildingCard {
*/ */
@Override @Override
public BuildingCard clone() { 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 { public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this)) if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException(); 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 @Override
public String toString() { 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 @Override
public String toStringPlayer() { 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 + ")";
} }
} }
@@ -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. * @return {@code true} if this card is an event card, {@code false} otherwise.
*/ */
public boolean IsEventCard() { public boolean isEventCard() {
return isEventCard; return isEventCard;
} }
@@ -76,17 +76,6 @@ public abstract class Character extends TribeCard implements Cloneable {
this.type = type; 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 * 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. * toString to provide a more detailed version.
@@ -53,16 +53,6 @@ public class Artist extends Character {
super(idIMG,Era, CharacterType.ARTIST,nMin); 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. * Creates and returns a copy of this Artist card.
* *
@@ -53,16 +53,6 @@ public class Gatherer extends Character {
super(idIMG,Era, CharacterType.GATHERER,nMin); 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. * 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. * @param player the player who receives the card.
*/ */
@Override
public void insert(Player player) { public void insert(Player player) {
player.getGatherers().add(this); player.getGatherers().add(this);
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player)); player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
@@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.lang.reflect.Array;
/** /**
* Abstract base class for all event cards. * Abstract base class for all event cards.
@@ -21,31 +21,31 @@ 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 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. * Creates a CavePaintings event card with the specified era and effect parameters.
* *
* @param Era the era of the 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 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 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 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); super(Era, EventType.CAVE_PAINTINGS);
this.NLower = NLower; this.nLower = nLower;
this.NPrestigeRem = NPrestigeRem; this.nPrestigeRem = nPrestigeRem;
this.NPrestigeMul = NPrestigeMul; this.nPrestigeMul = nPrestigeMul;
} }
/** /**
@@ -53,15 +53,15 @@ public class CavePaintings extends EventCard {
* *
* @param idIMG the image identifier of the CavePaintings event card. * @param idIMG the image identifier of the CavePaintings event card.
* @param Era the era of the 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 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 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 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); super(idIMG,Era, EventType.CAVE_PAINTINGS);
this.NLower = NLower; this.nLower = nLower;
this.NPrestigeRem = NPrestigeRem; this.nPrestigeRem = nPrestigeRem;
this.NPrestigeMul = NPrestigeMul; 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 * For each player, the number of Artist cards is computed together with the number
* of owned building cards having effect id equal to 9. * 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. * 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. * 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. * 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. * @param playerList the list of players affected by the event.
*/ */
@@ -87,11 +87,11 @@ public class CavePaintings extends EventCard {
} }
} }
player.addFood(NBuildings * NArtists); player.addFood(NBuildings * NArtists);
if (NArtists < NLower){ if (NArtists < nLower){
player.removePrestige(NPrestigeRem); player.removePrestige(nPrestigeRem);
} }
else{ else{
player.addPrestige(NPrestigeMul * NArtists); player.addPrestige(nPrestigeMul * NArtists);
} }
} }
} }
@@ -104,20 +104,20 @@ public class CavePaintings extends EventCard {
@Override @Override
public EventCard clone() 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 * 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. * toString to print a more detailed version.
* <p>NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code NLower} is needed), * <p>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. * however it's a parameter on the cards' design.
* </p> * </p>
* <p>Includes: * <p>Includes:
* <li>{@link #NLower} * <li>{@link #nLower}
* <li>{@code NUpper} * <li>{@code NUpper}
* <li>{@link #NPrestigeRem} * <li>{@link #nPrestigeRem}
* <li>{@link #NPrestigeMul} * <li>{@link #nPrestigeMul}
* </p> * </p>
* @return {@code String} - a string representation of this {@code TribeCard}. * @return {@code String} - a string representation of this {@code TribeCard}.
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
@@ -126,6 +126,6 @@ public class CavePaintings extends EventCard {
*/ */
@Override @Override
public String toStringBoard() { public String toStringBoard() {
return super.toStringBoard()+" 0-"+(NLower-1)+":"+NPrestigeRem+" "+NLower+"+:"+NPrestigeMul; return super.toStringBoard()+" 0-"+(nLower-1)+":"+nPrestigeRem+" "+nLower+"+:"+nPrestigeMul;
} }
} }
@@ -21,26 +21,26 @@ 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 int prestigeDebt;
/** /**
* Returns the prestige penalty multiplier associated with this Sustenance event. * Returns the prestige penalty multiplier associated with this Sustenance event.
* *
* @return the prestige penalty multiplier associated with this Sustenance event. * @return the prestige penalty multiplier associated with this Sustenance event.
*/ */
public int getPrestigeDebt() { public int getprestigeDebt() {
return PrestigeDebt; return prestigeDebt;
} }
/** /**
* Creates a Sustenance event card with the specified era and prestige debt value. * Creates a Sustenance event card with the specified era and prestige debt value.
* *
* @param Era the era of the 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(int Era, int PrestigeDebt) { public Sustenance(int Era, int prestigeDebt) {
super(Era, EventType.SUSTENANCE); 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 idIMG the image identifier of the Sustenance event card.
* @param Era the era of the 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); 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. * 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 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 * 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}.
* <b>This event is intended to be executed last among event effects.</b> * <b>This event is intended to be executed last among event effects.</b>
* *
* @param playerList the list of players affected by the event. * @param playerList the list of players affected by the event.
@@ -94,7 +94,7 @@ public class Sustenance extends EventCard {
else{ else{
FoodDebt -= player.getFoodValue(); FoodDebt -= player.getFoodValue();
player.removeFood(player.getFoodValue()); // player.getFoodValue() == 0 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 @Override
public EventCard clone() { 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 * 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. * toString to print a more detailed version.
* <p>Includes: * <p>Includes:
* <li>{@link #PrestigeDebt} * <li>{@link #prestigeDebt}
* </p> * </p>
* @return {@code String} - a string representation of this {@code TribeCard}. * @return {@code String} - a string representation of this {@code TribeCard}.
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
@@ -122,6 +122,6 @@ public class Sustenance extends EventCard {
*/ */
@Override @Override
public String toStringBoard() { public String toStringBoard() {
return super.toStringBoard()+" -1\uD83C\uDF56/-"+PrestigeDebt+"\uD83C\uDFC5"; return super.toStringBoard()+" -1\uD83C\uDF56/-"+prestigeDebt+"\uD83C\uDFC5";
} }
} }
@@ -21,6 +21,8 @@ import java.util.*;
*/ */
public class DecksCreator { public class DecksCreator {
private DecksCreator() {}
/** /**
* Loads the tribe card deck for the specified era from the corresponding JSON resource file. * 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) { private static TribeCard createCard(TribeCardDefinition def) {
int era = def.era; int era = def.era;
String id = def.id;
int[] p = def.params.stream().mapToInt(d -> ((Double) d).intValue()).toArray(); int[] p = def.params.stream().mapToInt(d -> ((Double) d).intValue()).toArray();
if(def.isEvent) if(def.isEvent)
{ {
@@ -321,12 +321,12 @@ public class Game implements Serializable {
/** /**
* Returns the player with the specified username, if present. * 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. * @return the player with the specified username, or {@code null} if no such player exists.
* @throws IndexOutOfBoundsException if an index access error occurs. * @throws IndexOutOfBoundsException if an index access error occurs.
*/ */
public Player getPlayerByUsername(String Username) throws IndexOutOfBoundsException { public Player getPlayerByUsername(String username) throws IndexOutOfBoundsException {
return playersList.stream().filter(x->x.getUserName().equals(Username)).findFirst().orElse(null); 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) if(currentState.getNUpper() <1 && currentState.getGameStage()==GameStages.RES_ACTIONS)
return false; return false;
TribeCard tribeCard = board.upperListTribe.get(cardIndex); TribeCard tribeCard = board.upperListTribe.get(cardIndex);
if(tribeCard.IsEventCard()) if(tribeCard.isEventCard())
return false; return false;
Character tempCard = (Character) tribeCard; Character tempCard = (Character) tribeCard;
@@ -578,7 +578,7 @@ public class Game implements Serializable {
if(currentState.getNLower() <1) if(currentState.getNLower() <1)
return false; return false;
TribeCard tribeCard = board.lowerListTribe.get(cardIndex); TribeCard tribeCard = board.lowerListTribe.get(cardIndex);
if(tribeCard.IsEventCard()) if(tribeCard.isEventCard())
return false; return false;
Character tempCard = (Character) tribeCard; Character tempCard = (Character) tribeCard;
@@ -868,7 +868,7 @@ public class Game implements Serializable {
*/ */
private boolean hasDrawableUp() 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() 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}. * 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() { private void nextRound() {
EventResolution(); EventResolution();
if(currentState.getRound()==10)
{
currentState.GameStageUpdate(GameStages.ENDING);
endGame();
return;
}
if(currentState.getEra()!= board.nextRound()) { if(currentState.getEra()!= board.nextRound()) {
currentState.EraUpdate(); currentState.EraUpdate();
} }
@@ -936,7 +929,7 @@ public class Game implements Serializable {
*/ */
private void endGame() { private void endGame() {
Queue<EventCard> events; Queue<EventCard> 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));
ArrayList<EventCard>sustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new)); ArrayList<EventCard>sustenance=events.stream().filter(x->x.getType().equals(EventType.SUSTENANCE)).collect(Collectors.toCollection(ArrayList::new));
events.removeAll(sustenance); events.removeAll(sustenance);
events.forEach(event->event.activateEvent(playersList)); events.forEach(event->event.activateEvent(playersList));
@@ -97,7 +97,7 @@ public class Board implements Serializable {
for(int i=0;i<nTotem+1;i++) for(int i=0;i<nTotem+1;i++)
{ {
TribeCard tempCard = tribeDeck.remove(); TribeCard tempCard = tribeDeck.remove();
if(tempCard.IsEventCard()) if(tempCard.isEventCard())
{ {
upperListTribe.add(tempCard); upperListTribe.add(tempCard);
i--; i--;
@@ -186,7 +186,7 @@ public class Board implements Serializable {
/** @return the queue of events cards from the lower list that need to be activated */ /** @return the queue of events cards from the lower list that need to be activated */
public Queue<EventCard> getPendingEvents(){ public Queue<EventCard> 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); lowerListBuilding.addAll(upperListBuilding);
upperListBuilding.clear(); upperListBuilding.clear();
ArrayList<BuildingCard> buildingCards= new ArrayList<>(DecksCreator.loadBuildingDeckByEra(era));
Collections.shuffle(buildingCards);
if(era==2) if(era==2)
{ {
upperListBuilding.addAll(buildingCardsAllEras.get(1)); upperListBuilding.addAll(buildingCardsAllEras.get(1));
@@ -77,7 +77,7 @@ public class CurrentState implements Serializable {
/** /**
* The number of upper cards currently available. * The number of upper cards currently available.
*/ */
private int NUpper; private int nUpper;
/** /**
* Returns the number of upper cards currently available. * 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. * @return the number of upper cards currently available.
*/ */
public int getNUpper(){ public int getNUpper(){
return NUpper; return nUpper;
} }
/** /**
* The number of lower cards currently available. * The number of lower cards currently available.
*/ */
private int NLower; private int nLower;
/** /**
* Returns the number of lower cards currently available. * 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. * @return the number of lower cards currently available.
*/ */
public int getNLower(){ public int getNLower(){
return NLower; return nLower;
} }
/** /**
@@ -138,14 +138,14 @@ public class CurrentState implements Serializable {
* Decrements the number of upper cards by 1. * Decrements the number of upper cards by 1.
*/ */
public void UpperDrawn(){ public void UpperDrawn(){
NUpper--; nUpper--;
} }
/** /**
* Decrements the number of lower cards by 1. * Decrements the number of lower cards by 1.
*/ */
public void LowerDrawn(){ public void LowerDrawn(){
NLower--; nLower--;
} }
/** /**
@@ -170,8 +170,8 @@ public class CurrentState implements Serializable {
this.slot = null; this.slot = null;
this.Era = 1; this.Era = 1;
this.round = 1; this.round = 1;
this.NUpper = 0; this.nUpper = 0;
this.NLower = 0; this.nLower = 0;
this.GameStage = GameStages.WAITING; this.GameStage = GameStages.WAITING;
} }
// endregion constructors // endregion constructors
@@ -190,12 +190,12 @@ public class CurrentState implements Serializable {
this.player = player; this.player = player;
this.slot = slot; this.slot = slot;
if(slot == null){ if(slot == null){
this.NUpper = 0; this.nUpper = 0;
this.NLower = 0; this.nLower = 0;
} }
else{ else{
this.NUpper = slot.getNUpper(); this.nUpper = slot.getNUpper();
this.NLower = slot.getNLower(); this.nLower = slot.getNLower();
} }
} }
@@ -1,11 +1,5 @@
package it.polimi.ingsw.gc14.Model; 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. */ /** Standalone entry point used for local model testing. */
public class Main { public class Main {
@@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player; 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.AsciiTable;
import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
@@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player; 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.AsciiTable;
import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
@@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player; 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.AsciiTable;
import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
@@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.Model.Orders;
import it.polimi.ingsw.gc14.Model.OrderLogicCard; import it.polimi.ingsw.gc14.Model.OrderLogicCard;
import it.polimi.ingsw.gc14.Model.Player; 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.AsciiTable;
import it.polimi.ingsw.gc14.View.TUI.BorderStyle; import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
@@ -26,14 +26,14 @@ public class Slot implements Serializable {
/** /**
* The number of upper cards associated with this slot. * 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. * Returns the number of upper cards associated with this slot.
* *
* @return the number of upper cards associated with this slot. * @return the number of upper cards associated with this slot.
*/ */
public int getNUpper(){ 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. * 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. * 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. * @return the number of lower cards associated with this slot.
*/ */
public int getNLower(){ public int getNLower(){
return NLower; return nLower;
} }
/** /**
* The amount of Food associated with this slot. * The amount of Food associated with this slot.
*/ */
private int Food; private int food;
/** /**
* Returns the amount of Food associated with this slot. * 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. * @return the amount of Food associated with this slot.
*/ */
public int getFood(){ public int getFood(){
return Food; return food;
} }
// End getters // End getters
@@ -100,41 +100,41 @@ public class Slot implements Serializable {
switch(slotId) switch(slotId)
{ {
case 'A': case 'A':
this.Food = 3; this.food = 3;
this.NLower = 0; this.nLower = 0;
this.NUpper = 0; this.nUpper = 0;
this.nMinPlayer=5; this.nMinPlayer=5;
break; break;
case 'B': case 'B':
this.Food = 0; this.food = 0;
this.NLower = 1; this.nLower = 1;
this.NUpper = 0; this.nUpper = 0;
break; break;
case 'C': case 'C':
this.Food = 0; this.food = 0;
this.NLower = 0; this.nLower = 0;
this.NUpper = 1; this.nUpper = 1;
break; break;
case 'D': case 'D':
this.Food = 0; this.food = 0;
this.NLower = 2; this.nLower = 2;
this.NUpper = 0; this.nUpper = 0;
this.nMinPlayer = 3; this.nMinPlayer = 3;
break; break;
case 'E': case 'E':
this.Food = 0; this.food = 0;
this.NLower = 1; this.nLower = 1;
this.NUpper = 1; this.nUpper = 1;
break; break;
case 'F': case 'F':
this.Food = 0; this.food = 0;
this.NLower = 0; this.nLower = 0;
this.NUpper = 2; this.nUpper = 2;
break; break;
case 'G': case 'G':
this.Food = 0; this.food = 0;
this.NLower = 1; this.nLower = 1;
this.NUpper = 2; this.nUpper = 2;
this.nMinPlayer = 4; this.nMinPlayer = 4;
break; break;
default: default:
@@ -5,6 +5,8 @@ import java.util.Enumeration;
/** Utility class for resolving the local network interface to use when connecting to a server. */ /** Utility class for resolving the local network interface to use when connecting to a server. */
public class InterfaceResolver { public class InterfaceResolver {
private InterfaceResolver() {}
/** /**
* Returns the local IPv4 address that can reach the given server IP. * Returns the local IPv4 address that can reach the given server IP.
* *
@@ -5,14 +5,11 @@ import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.View.IView;
import java.io.Serializable;
/** /**
* NetworkEvent to add a player. * 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 */ /** Number of proposed players to add to the match */
private int proposedNPlayer; private int proposedNPlayer;
/** /**
@@ -11,9 +11,7 @@ import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Slot; import it.polimi.ingsw.gc14.Model.Slot;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -21,7 +19,7 @@ import java.util.Map;
/** /**
* NetworkEvent to draw a tribe card from the lower card list. * NetworkEvent to draw a tribe card from the lower card list.
*/ */
public class ApplyNextRound extends NetworkEvent implements Serializable{ public class ApplyNextRound extends NetworkEvent{
List<Player> players; List<Player> players;
ArrayList<TribeCard> upperListTribeCards; ArrayList<TribeCard> upperListTribeCards;
@@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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. * 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 */ /** Index of the card to draw */
private int pos; private int pos;
@@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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. * 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 */ /** Index of the card to draw */
private int pos; private int pos;
@@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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. * 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 */ /** Index of the card to draw */
private int pos; private int pos;
@@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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. * 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 */ /** Index of the card to draw */
private int pos; private int pos;
@@ -9,9 +9,7 @@ import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Slot; import it.polimi.ingsw.gc14.Model.Slot;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -19,7 +17,7 @@ import java.util.Map;
/** /**
* NetworkEvent to draw a tribe card from the lower card list. * NetworkEvent to draw a tribe card from the lower card list.
*/ */
public class EndedGame extends NetworkEvent implements Serializable{ public class EndedGame extends NetworkEvent{
ArrayList<Player> players; ArrayList<Player> players;
@@ -5,14 +5,12 @@ import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.MiniModel; import it.polimi.ingsw.gc14.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.EventType; import it.polimi.ingsw.gc14.Network.EventType;
import it.polimi.ingsw.gc14.Network.NetworkEvent; 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. * 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 */ /** Index of the card to draw */
private int pos; private int pos;
@@ -1,7 +1,6 @@
package it.polimi.ingsw.gc14.Network.RMI.Client; package it.polimi.ingsw.gc14.Network.RMI.Client;
import it.polimi.ingsw.gc14.Controller.ClientController; 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.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;
@@ -1,8 +1,6 @@
package it.polimi.ingsw.gc14.Network.RMI.Common; package it.polimi.ingsw.gc14.Network.RMI.Common;
import it.polimi.ingsw.gc14.Model.*; 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 it.polimi.ingsw.gc14.Network.NetworkEvent;
import java.io.Serializable; import java.io.Serializable;
@@ -2,13 +2,11 @@ package it.polimi.ingsw.gc14.Network.TCP.Client;
import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.ErrorType; 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.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.IClient; import it.polimi.ingsw.gc14.Network.IClient;
import it.polimi.ingsw.gc14.Network.NetworkEvent; import it.polimi.ingsw.gc14.Network.NetworkEvent;
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.NetworkEvents.*;
import javafx.application.Platform;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
@@ -1,9 +1,7 @@
package it.polimi.ingsw.gc14.View; package it.polimi.ingsw.gc14.View;
import it.polimi.ingsw.gc14.ErrorType; 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.Model.MiniModel;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
/** View interface implemented by both the TUI and GUI. */ /** View interface implemented by both the TUI and GUI. */
public interface IView { public interface IView {
@@ -12,24 +12,24 @@ public enum BorderStyle {
/** /**
* Unicode box-drawing border style. * Unicode box-drawing border style.
*/ */
UNICODE("","","","","","","","","","","","","","",""), UNICODE("","","","","","","","","","","","","",""),
/** /**
* Plain ASCII border style. * Plain ASCII border style.
*/ */
ASCII ("+","+","+","+","-","|","+","+","+","+","+","+","+","-","+"), ASCII ("+","+","+","+","-","|","+","+","+","+","+","+","+","+"),
/** /**
* Rounded Unicode border style. * 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, BorderStyle(String tl,String tr,String bl,String br,
String h, String v, String ml,String mr, String h, String v, String ml,String mr,
String mt,String mb,String x, 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.tl = tl; this.tr = tr;
this.bl = bl; this.br = br; this.bl = bl; this.br = br;
this.h = h; this.v = v; this.h = h; this.v = v;
@@ -37,7 +37,7 @@ public enum BorderStyle {
this.mt = mt; this.mb = mb; this.mt = mt; this.mb = mb;
this.x = x; this.x = x;
this.sl = sl; this.sr = sr; 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; } public String sr() { return sr; }
/**
* @return the separator horizontal line character.
*/
public String sh() { return sh; }
/** /**
* @return the separator center junction character. * @return the separator center junction character.
*/ */
@@ -2,7 +2,6 @@ package it.polimi.ingsw.gc14.View.TUI;
import it.polimi.ingsw.gc14.ErrorType; import it.polimi.ingsw.gc14.ErrorType;
import it.polimi.ingsw.gc14.Model.*; import it.polimi.ingsw.gc14.Model.*;
import it.polimi.ingsw.gc14.Model.GamePackage.GameStages; import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.View.IView; import it.polimi.ingsw.gc14.View.IView;
import org.jline.reader.LineReader; import org.jline.reader.LineReader;
@@ -128,7 +127,7 @@ public class TUI implements IView {
* hands arranged in a responsive grid. * hands arranged in a responsive grid.
*/ */
private String buildBoardContent() { private String buildBoardContent() {
List<String> left = List.of(BoardStamp().split("\n")); List<String> left = List.of(boardStamp().split("\n"));
List<String> right = List.of(buildAllHandsContent().split("\n")); List<String> right = List.of(buildAllHandsContent().split("\n"));
return AsciiTable.sideBySide(left, right, 3); return AsciiTable.sideBySide(left, right, 3);
} }
@@ -259,33 +258,13 @@ public class TUI implements IView {
// Board / players stamp helpers // 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<Player> 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, * Returns the board state as a multi-line string: turn order, upper cards,
* offer track, lower cards. * offer track, lower cards.
* *
* @return multi-line board string. * @return multi-line board string.
*/ */
public String BoardStamp() { public String boardStamp() {
var offerTrack = new AsciiTable(BorderStyle.ROUNDED, model.slotPlayerMap.size()); var offerTrack = new AsciiTable(BorderStyle.ROUNDED, model.slotPlayerMap.size());
List<String> slotNames = new ArrayList<>(); List<String> slotNames = new ArrayList<>();
List<String> slotPlayers = new ArrayList<>(); List<String> slotPlayers = new ArrayList<>();
@@ -296,33 +275,33 @@ public class TUI implements IView {
slotPlayers.add(entry.getValue() != null ? entry.getValue().getUserName() : " "); slotPlayers.add(entry.getValue() != null ? entry.getValue().getUserName() : " ");
} }
var UpperCards = new AsciiTable(BorderStyle.ROUNDED, 2); var upperCards = new AsciiTable(BorderStyle.ROUNDED, 2);
var LowerCards = new AsciiTable(BorderStyle.ROUNDED, 2); var lowerCards = new AsciiTable(BorderStyle.ROUNDED, 2);
UpperCards.addHeader("Char/Events", "Building"); upperCards.addHeader("Char/Events", "Building");
LowerCards.addHeader("Char/Events", "Building"); lowerCards.addHeader("Char/Events", "Building");
int maxU = Math.max(model.upperListTribeCards.size(), model.upperListBuildingCards.size()); int maxU = Math.max(model.upperListTribeCards.size(), model.upperListBuildingCards.size());
for (int i = 0; i < maxU; i++) { for (int i = 0; i < maxU; i++) {
String t = i < model.upperListTribeCards.size() ? i + model.upperListTribeCards.get(i).toStringBoard() : ""; String t = i < model.upperListTribeCards.size() ? i + model.upperListTribeCards.get(i).toStringBoard() : "";
String b = i < model.upperListBuildingCards.size() ? i + model.upperListBuildingCards.get(i).toString() : ""; 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()); int maxL = Math.max(model.lowerListTribeCards.size(), model.lowerListBuildingCards.size());
for (int i = 0; i < maxL; i++) { for (int i = 0; i < maxL; i++) {
String t = i < model.lowerListTribeCards.size() ? i + model.lowerListTribeCards.get(i).toStringBoard() : ""; String t = i < model.lowerListTribeCards.size() ? i + model.lowerListTribeCards.get(i).toStringBoard() : "";
String b = i < model.lowerListBuildingCards.size() ? i + model.lowerListBuildingCards.get(i).toString() : ""; 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(slotPlayers);
offerTrack.addRow(slotNames); offerTrack.addRow(slotNames);
String upperSection = UpperCards.build(); String upperSection = upperCards.build();
String middleSection = model.orderLogicCard.toString() + offerTrack.build(); String middleSection = model.orderLogicCard.toString() + offerTrack.build();
String lowerSection = LowerCards.build(); String lowerSection = lowerCards.build();
return model.currentState + "\n" return model.currentState + "\n"
+ upperSection + "\n" + upperSection + "\n"
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
fx:controller="it.polimi.ingsw.gc14.HelloController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding>
<Label fx:id="welcomeText"/>
<Button text="Hello!" onAction="#onHelloButtonClick"/>
</VBox>
@@ -71,7 +71,7 @@ class GameControllerTest {
private int firstNonEventIndex(List<TribeCard> cards) { private int firstNonEventIndex(List<TribeCard> cards) {
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
if (!cards.get(i).IsEventCard()) { if (!cards.get(i).isEventCard()) {
return i; return i;
} }
} }
@@ -82,7 +82,7 @@ class GameControllerTest {
private int firstEventIndexOrMinusOne(List<TribeCard> cards) { private int firstEventIndexOrMinusOne(List<TribeCard> cards) {
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
if (cards.get(i).IsEventCard()) { if (cards.get(i).isEventCard()) {
return i; return i;
} }
} }
@@ -92,7 +92,7 @@ class GameControllerTest {
private int firstNonEventIndexOrMinusOne(List<TribeCard> cards) { private int firstNonEventIndexOrMinusOne(List<TribeCard> cards) {
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
if (!cards.get(i).IsEventCard()) { if (!cards.get(i).isEventCard()) {
return i; return i;
} }
} }
@@ -148,7 +148,7 @@ class GameControllerTest {
} }
if (game.getCurrentState().getNUpper() == 0 if (game.getCurrentState().getNUpper() == 0
|| game.getUpperListTribeCards().stream().allMatch(TribeCard::IsEventCard)) { || game.getUpperListTribeCards().stream().allMatch(TribeCard::isEventCard)) {
assertTrue(controller.skipTurn(username)); assertTrue(controller.skipTurn(username));
return; return;
} }
@@ -171,7 +171,7 @@ class GameControllerTest {
} }
if (game.getCurrentState().getNLower() == 0 if (game.getCurrentState().getNLower() == 0
|| game.getLowerListTribeCards().stream().allMatch(TribeCard::IsEventCard)) { || game.getLowerListTribeCards().stream().allMatch(TribeCard::isEventCard)) {
assertTrue(controller.skipTurn(username)); assertTrue(controller.skipTurn(username));
return; return;
} }
@@ -56,7 +56,7 @@ class ArtistTest {
assertEquals(1, a.getEra()); assertEquals(1, a.getEra());
assertEquals(CharacterType.ARTIST, a.getType()); assertEquals(CharacterType.ARTIST, a.getType());
assertEquals(0, a.getNMin()); assertEquals(0, a.getNMin());
assertFalse(a.IsEventCard()); assertFalse(a.isEventCard());
} }
@Test @Test
@@ -66,7 +66,7 @@ class ArtistTest {
assertEquals(1, a.getEra()); assertEquals(1, a.getEra());
assertEquals(CharacterType.ARTIST, a.getType()); assertEquals(CharacterType.ARTIST, a.getType());
assertEquals(3, a.getNMin()); assertEquals(3, a.getNMin());
assertFalse(a.IsEventCard()); assertFalse(a.isEventCard());
} }
@Test @Test
@@ -77,7 +77,7 @@ class ArtistTest {
assertEquals(1, a.getEra()); assertEquals(1, a.getEra());
assertEquals(CharacterType.ARTIST, a.getType()); assertEquals(CharacterType.ARTIST, a.getType());
assertEquals(0, a.getNMin()); assertEquals(0, a.getNMin());
assertFalse(a.IsEventCard()); assertFalse(a.isEventCard());
} }
@Test @Test
@@ -88,6 +88,6 @@ class ArtistTest {
assertEquals(1, a.getEra()); assertEquals(1, a.getEra());
assertEquals(CharacterType.ARTIST, a.getType()); assertEquals(CharacterType.ARTIST, a.getType());
assertEquals(3, a.getNMin()); assertEquals(3, a.getNMin());
assertFalse(a.IsEventCard()); assertFalse(a.isEventCard());
} }
} }
@@ -77,7 +77,7 @@ class BuilderTest {
assertEquals(2, b.getReductionValue()); assertEquals(2, b.getReductionValue());
assertEquals(3, b.getPrestigeValue()); assertEquals(3, b.getPrestigeValue());
assertEquals(0, b.getNMin()); assertEquals(0, b.getNMin());
assertFalse(b.IsEventCard()); assertFalse(b.isEventCard());
} }
@Test @Test
@@ -89,7 +89,7 @@ class BuilderTest {
assertEquals(2, b.getReductionValue()); assertEquals(2, b.getReductionValue());
assertEquals(3, b.getPrestigeValue()); assertEquals(3, b.getPrestigeValue());
assertEquals(4, b.getNMin()); assertEquals(4, b.getNMin());
assertFalse(b.IsEventCard()); assertFalse(b.isEventCard());
assertThrows(IllegalArgumentException.class, () -> assertThrows(IllegalArgumentException.class, () ->
new Builder(1, -1, 3, 4) new Builder(1, -1, 3, 4)
@@ -124,7 +124,7 @@ class BuilderTest {
assertEquals(2, b.getReductionValue()); assertEquals(2, b.getReductionValue());
assertEquals(3, b.getPrestigeValue()); assertEquals(3, b.getPrestigeValue());
assertEquals(0, b.getNMin()); assertEquals(0, b.getNMin());
assertFalse(b.IsEventCard()); assertFalse(b.isEventCard());
} }
@Test @Test
@@ -137,7 +137,7 @@ class BuilderTest {
assertEquals(2, b.getReductionValue()); assertEquals(2, b.getReductionValue());
assertEquals(3, b.getPrestigeValue()); assertEquals(3, b.getPrestigeValue());
assertEquals(4, b.getNMin()); assertEquals(4, b.getNMin());
assertFalse(b.IsEventCard()); assertFalse(b.isEventCard());
} }
@Test @Test
@@ -57,7 +57,7 @@ class GathererTest {
assertEquals(1, g.getEra()); assertEquals(1, g.getEra());
assertEquals(CharacterType.GATHERER, g.getType()); assertEquals(CharacterType.GATHERER, g.getType());
assertEquals(0, g.getNMin()); assertEquals(0, g.getNMin());
assertFalse(g.IsEventCard()); assertFalse(g.isEventCard());
} }
@Test @Test
@@ -67,7 +67,7 @@ class GathererTest {
assertEquals(1, g.getEra()); assertEquals(1, g.getEra());
assertEquals(CharacterType.GATHERER, g.getType()); assertEquals(CharacterType.GATHERER, g.getType());
assertEquals(3, g.getNMin()); assertEquals(3, g.getNMin());
assertFalse(g.IsEventCard()); assertFalse(g.isEventCard());
} }
@Test @Test
@@ -78,7 +78,7 @@ class GathererTest {
assertEquals(1, g.getEra()); assertEquals(1, g.getEra());
assertEquals(CharacterType.GATHERER, g.getType()); assertEquals(CharacterType.GATHERER, g.getType());
assertEquals(0, g.getNMin()); assertEquals(0, g.getNMin());
assertFalse(g.IsEventCard()); assertFalse(g.isEventCard());
} }
@Test @Test
@@ -89,6 +89,6 @@ class GathererTest {
assertEquals(1, g.getEra()); assertEquals(1, g.getEra());
assertEquals(CharacterType.GATHERER, g.getType()); assertEquals(CharacterType.GATHERER, g.getType());
assertEquals(3, g.getNMin()); assertEquals(3, g.getNMin());
assertFalse(g.IsEventCard()); assertFalse(g.isEventCard());
} }
} }
@@ -114,7 +114,7 @@ class HunterTest {
assertEquals(CharacterType.HUNTER, h.getType()); assertEquals(CharacterType.HUNTER, h.getType());
assertTrue(h.getIcon()); assertTrue(h.getIcon());
assertEquals(0, h.getNMin()); assertEquals(0, h.getNMin());
assertFalse(h.IsEventCard()); assertFalse(h.isEventCard());
} }
@Test @Test
@@ -125,7 +125,7 @@ class HunterTest {
assertEquals(CharacterType.HUNTER, h.getType()); assertEquals(CharacterType.HUNTER, h.getType());
assertFalse(h.getIcon()); assertFalse(h.getIcon());
assertEquals(3, h.getNMin()); assertEquals(3, h.getNMin());
assertFalse(h.IsEventCard()); assertFalse(h.isEventCard());
} }
@Test @Test
@@ -137,7 +137,7 @@ class HunterTest {
assertEquals(CharacterType.HUNTER, h.getType()); assertEquals(CharacterType.HUNTER, h.getType());
assertTrue(h.getIcon()); assertTrue(h.getIcon());
assertEquals(0, h.getNMin()); assertEquals(0, h.getNMin());
assertFalse(h.IsEventCard()); assertFalse(h.isEventCard());
} }
@Test @Test
@@ -149,6 +149,6 @@ class HunterTest {
assertEquals(CharacterType.HUNTER, h.getType()); assertEquals(CharacterType.HUNTER, h.getType());
assertFalse(h.getIcon()); assertFalse(h.getIcon());
assertEquals(3, h.getNMin()); assertEquals(3, h.getNMin());
assertFalse(h.IsEventCard()); assertFalse(h.isEventCard());
} }
} }
@@ -76,7 +76,7 @@ class InventorTest {
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.Icon());
assertEquals(0, i.getNMin()); assertEquals(0, i.getNMin());
assertFalse(i.IsEventCard()); assertFalse(i.isEventCard());
} }
@Test @Test
@@ -87,7 +87,7 @@ class InventorTest {
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.Icon());
assertEquals(3, i.getNMin()); assertEquals(3, i.getNMin());
assertFalse(i.IsEventCard()); assertFalse(i.isEventCard());
} }
@Test @Test
@@ -99,7 +99,7 @@ class InventorTest {
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.Icon());
assertEquals(0, i.getNMin()); assertEquals(0, i.getNMin());
assertFalse(i.IsEventCard()); assertFalse(i.isEventCard());
} }
@Test @Test
@@ -111,7 +111,7 @@ class InventorTest {
assertEquals(CharacterType.INVENTOR, i.getType()); assertEquals(CharacterType.INVENTOR, i.getType());
assertEquals(5, i.Icon()); assertEquals(5, i.Icon());
assertEquals(3, i.getNMin()); assertEquals(3, i.getNMin());
assertFalse(i.IsEventCard()); assertFalse(i.isEventCard());
} }
@Test @Test
@@ -76,7 +76,7 @@ class ShamanTest {
assertEquals(CharacterType.SHAMAN, s.getType()); assertEquals(CharacterType.SHAMAN, s.getType());
assertEquals(4, s.getIcon()); assertEquals(4, s.getIcon());
assertEquals(0, s.getNMin()); assertEquals(0, s.getNMin());
assertFalse(s.IsEventCard()); assertFalse(s.isEventCard());
} }
@Test @Test
@@ -87,7 +87,7 @@ class ShamanTest {
assertEquals(CharacterType.SHAMAN, s.getType()); assertEquals(CharacterType.SHAMAN, s.getType());
assertEquals(4, s.getIcon()); assertEquals(4, s.getIcon());
assertEquals(3, s.getNMin()); assertEquals(3, s.getNMin());
assertFalse(s.IsEventCard()); assertFalse(s.isEventCard());
} }
@Test @Test
@@ -99,7 +99,7 @@ class ShamanTest {
assertEquals(CharacterType.SHAMAN, s.getType()); assertEquals(CharacterType.SHAMAN, s.getType());
assertEquals(4, s.getIcon()); assertEquals(4, s.getIcon());
assertEquals(0, s.getNMin()); assertEquals(0, s.getNMin());
assertFalse(s.IsEventCard()); assertFalse(s.isEventCard());
} }
@Test @Test
@@ -111,6 +111,6 @@ class ShamanTest {
assertEquals(CharacterType.SHAMAN, s.getType()); assertEquals(CharacterType.SHAMAN, s.getType());
assertEquals(4, s.getIcon()); assertEquals(4, s.getIcon());
assertEquals(3, s.getNMin()); assertEquals(3, s.getNMin());
assertFalse(s.IsEventCard()); assertFalse(s.isEventCard());
} }
} }
@@ -103,7 +103,7 @@ class BoardTest {
assertEquals(96 - (numPlayer+4) - (numPlayer+1), bd.getTribeDeckSize()); // Verifica che dal mazzo TribeDeck venga pescato il numero corretto di carte assertEquals(96 - (numPlayer+4) - (numPlayer+1), bd.getTribeDeckSize()); // Verifica che dal mazzo TribeDeck venga pescato il numero corretto di carte
assertEquals(numPlayer+1, bd.lowerListTribe.size()); // Verifica che la dimensione della lista inferiore sia corretta assertEquals(numPlayer+1, bd.lowerListTribe.size()); // Verifica che la dimensione della lista inferiore sia corretta
assertTrue(bd.lowerListTribe.stream().noneMatch(card -> card.IsEventCard())); // Verifica che non ci siano EventCard dentro alla lista inferiore assertTrue(bd.lowerListTribe.stream().noneMatch(card -> card.isEventCard())); // Verifica che non ci siano EventCard dentro alla lista inferiore
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la dimensione della lista superiore sia corretta assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la dimensione della lista superiore sia corretta
@@ -117,7 +117,7 @@ class BoardTest {
Queue<EventCard> eventQueue = new LinkedList<>(); Queue<EventCard> eventQueue = new LinkedList<>();
for (TribeCard card : bd.lowerListTribe) { for (TribeCard card : bd.lowerListTribe) {
if (card.IsEventCard()) { if (card.isEventCard()) {
eventQueue.add((EventCard) card); eventQueue.add((EventCard) card);
} }
} }
@@ -69,7 +69,7 @@ class GameTest {
private int firstNonEventIndex(List<TribeCard> cards) { private int firstNonEventIndex(List<TribeCard> cards) {
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
if (!cards.get(i).IsEventCard()) { if (!cards.get(i).isEventCard()) {
return i; return i;
} }
} }
@@ -80,7 +80,7 @@ class GameTest {
private int firstNonEventIndexOrMinusOne(List<TribeCard> cards) { private int firstNonEventIndexOrMinusOne(List<TribeCard> cards) {
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
if (!cards.get(i).IsEventCard()) { if (!cards.get(i).isEventCard()) {
return i; return i;
} }
} }
@@ -117,7 +117,7 @@ class GameTest {
return; return;
} }
if(game.getCurrentState().getNUpper() == 0 || game.getUpperListTribeCards().stream().allMatch(TribeCard::IsEventCard)) if(game.getCurrentState().getNUpper() == 0 || game.getUpperListTribeCards().stream().allMatch(TribeCard::isEventCard))
{ {
assertTrue(game.skipTurn(current)); assertTrue(game.skipTurn(current));
return; return;
@@ -138,7 +138,7 @@ class GameTest {
return; return;
} }
if(game.getCurrentState().getNLower() == 0 || game.getLowerListTribeCards().stream().allMatch(TribeCard::IsEventCard)) if(game.getCurrentState().getNLower() == 0 || game.getLowerListTribeCards().stream().allMatch(TribeCard::isEventCard))
{ {
assertTrue(game.skipTurn(current)); assertTrue(game.skipTurn(current));
return; return;
@@ -675,7 +675,7 @@ class GameTest {
private int firstEventIndexOrMinusOne(List<TribeCard> cards) { private int firstEventIndexOrMinusOne(List<TribeCard> cards) {
for (int i = 0; i < cards.size(); i++) { for (int i = 0; i < cards.size(); i++) {
if (cards.get(i).IsEventCard()) { if (cards.get(i).isEventCard()) {
return i; return i;
} }
} }