diff --git a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherGUI.java b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherGUI.java index e94be59..dfec71d 100644 --- a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherGUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherGUI.java @@ -17,6 +17,7 @@ public class ClientLauncherGUI extends Application { GUI view = new GUI(stage); ClientController controller = new ClientController(view); + view.setController(controller); loginView.getBtnAccedi().setOnAction(e -> { String nome = loginView.getNome(); @@ -28,11 +29,12 @@ public class ClientLauncherGUI extends Application { loginView.setErrore("Compila tutti i campi."); return; } + view.setUsername(nome); // Connessione in un thread separato — non bloccare il JavaFX thread! new Thread(() -> { if (networkType == 0) { - RMIClient client = new RMIClient(controller, ip, 1099); + RMIClient client = new RMIClient(controller, ip, 1099, loginView.getInterfaccia()); if (client.connect(nome, numPlayer)) { controller.setClient(client); // Da qui in poi il server chiamerà onGameInit → render() diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java index 4dc0a38..58c293e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java @@ -23,6 +23,20 @@ public class Building0 extends BuildingCard { */ private int numSet; + /** + * Constructor of the building + * @param era The game era of the building. + * @param price The price (in food) of the building. + * @param prestigeValue The number of Prestige Points gained from this building at the end of the game. + */ + public Building0(String idImage,int era,int price,int prestigeValue) { + super(idImage,era,price,prestigeValue); + effectType=EffectType.CARD_SET; + effectId=0; + purchased = false; + numSet = 0; + } + /** * Constructor of the building * @param era The game era of the building. @@ -77,7 +91,7 @@ public class Building0 extends BuildingCard { */ @Override public BuildingCard clone() { - return new Building0(getEra(),getPrice(),getPrestigeValue()); + return new Building0(getIdIMG(),getEra(),getPrice(),getPrestigeValue()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java index e63df7c..70de501 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building1.java @@ -33,6 +33,19 @@ public class Building1 extends BuildingCard { effectId = 1; this.icon = icon; } + /** + * Constructor of the building. + * @param era The game era of the building. + * @param price The price (in food) of the building. + * @param prestigeValue The number of Prestige Points gained from this building at the end of the game. + * @param icon The character type used by the building effect. + */ + public Building1(String idIMG,int era, int price,int prestigeValue, CharacterType icon) { + super(idIMG,era,price,prestigeValue); + effectType = EffectType.ON_EVENT; + effectId = 1; + this.icon = icon; + } /** * Method to clone the building: it creates an exact copy. @@ -40,7 +53,7 @@ public class Building1 extends BuildingCard { */ @Override public BuildingCard clone() { - return new Building1(getEra(),getPrice(),getPrestigeValue(),getIcon()); + return new Building1(getIdIMG(),getEra(),getPrice(),getPrestigeValue(),getIcon()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java index 883de4c..58b8668 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java @@ -27,6 +27,19 @@ public class Building10 extends BuildingCard { effectId=10; } + /** + * Creates a Building10 card with the specified era, price, and prestige value. + * + * @param era the era of the building card. + * @param price the price of the building card. + * @param prestigeValue the prestige value of the building card. + */ + public Building10(String idIMG,int era, int price,int prestigeValue) { + super(idIMG,era,price,prestigeValue); + effectType= EffectType.FINAL; + effectId=10; + } + /** * Creates and returns a copy of this Building10 card. * @@ -34,7 +47,7 @@ public class Building10 extends BuildingCard { */ @Override public BuildingCard clone() { - return new Building10(getEra(),getPrice(),getPrestigeValue()); + return new Building10(getIdIMG(),getEra(),getPrice(),getPrestigeValue()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java index 9f2df2b..de25796 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building11.java @@ -50,6 +50,23 @@ public class Building11 extends BuildingCard { this.icon = icon; this.PrestigeMul = prestigeMul; } + /** + * Creates a Building11 card with the specified era, price, prestige value, + * character type icon, and prestige multiplier. + * + * @param era the era of the building card. + * @param price the price of the building card. + * @param prestigeValue the prestige value of the building card. + * @param icon the CharacterType associated with the building card effect. + * @param prestigeMul the prestige multiplier of the building card effect. + */ + public Building11(String idIMG,int era, int price,int prestigeValue, CharacterType icon, int prestigeMul) { + super(idIMG,era,price,prestigeValue); + effectType = EffectType.FINAL; + effectId = 11; + this.icon = icon; + this.PrestigeMul = prestigeMul; + } /** * Creates and returns a copy of this Building11 card. @@ -58,7 +75,7 @@ public class Building11 extends BuildingCard { */ @Override public BuildingCard clone() { - return new Building11(getEra(),getPrice(),getPrestigeValue(), getIcon(), getPrestigeMul()); + return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getPrestigeMul()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java index 049925f..378b89c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java @@ -23,6 +23,18 @@ public class Building13 extends BuildingCard{ effectType= EffectType.FINAL; effectId=13; } + /** + * Creates a Building13 card with the specified era, price, and prestige value. + * + * @param era the era of the building card. + * @param price the price of the building card. + * @param prestigeValue the prestige value of the building card. + */ + public Building13(String idIMG,int era, int price,int prestigeValue) { + super(idIMG,era,price,prestigeValue); + effectType= EffectType.FINAL; + effectId=13; + } /** * Creates and returns a copy of this Building13 card. @@ -31,7 +43,7 @@ public class Building13 extends BuildingCard{ */ @Override public BuildingCard clone() { - return new Building13(getEra(),getPrice(),getPrestigeValue()); + return new Building13(getIdIMG(),getEra(),getPrice(),getPrestigeValue()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java index 60e4d2f..7c3b0b1 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java @@ -35,6 +35,18 @@ public class Building4 extends BuildingCard { effectId=4; } + /** + * Constructor of the building + * @param era The game era of the building. + * @param price The price (in food) of the building. + * @param prestigeValue The number of Prestige Points gained from this building at the end of the game. + */ + public Building4(String idIMG,int era, int price,int prestigeValue) { + super(idIMG,era,price,prestigeValue); + effectType= EffectType.INVENTOR_PAIR; + effectId=4; + } + /** * Initializes the building by counting the number of pairs of inventors at the moment of purchase. * The building can only be initialized once. @@ -84,7 +96,7 @@ public class Building4 extends BuildingCard { */ @Override public BuildingCard clone() { - return new Building4(getEra(),getPrice(),getPrestigeValue()); + return new Building4(getIdIMG(),getEra(),getPrice(),getPrestigeValue()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java index 0c4db48..62e6393 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building8.java @@ -23,13 +23,25 @@ public class Building8 extends BuildingCard { effectId=8; } + /** + * Constructor of the building + * @param era The game era of the building. + * @param price The price (in food) of the building. + * @param prestigeValue The number of Prestige Points gained from this building at the end of the game. + */ + public Building8(String idIMG,int era, int price,int prestigeValue) { + super(idIMG,era,price,prestigeValue); + effectType= EffectType.FINAL; + effectId=8; + } + /** * Method to clone the building: it creates an exact copy. * @return The new copy of the building. */ @Override public BuildingCard clone() { - return new Building8(getEra(),getPrice(),getPrestigeValue()); + return new Building8(getIdIMG(),getEra(),getPrice(),getPrestigeValue()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java index 9770187..295e5e2 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/BuildingCard.java @@ -101,6 +101,30 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf bought = false; } + /** + * Creates a building card with the specified era, price, and prestige value. + * + * @param era the era of the building card. + * @param price the price of the building card. + * @param prestigeValue the prestige value of the building card. + * @throws IllegalArgumentException if {@code price <= 0} or {@code prestigeValue < 0} + */ + protected BuildingCard(String idIMG,int era,int price,int prestigeValue) throws IllegalArgumentException{ + super(idIMG,era); + if (price > 0) { + this.price = price; + } else { + throw new IllegalArgumentException(); + } + if (prestigeValue >= 0) { + this.prestigeValue = prestigeValue; + } else { + throw new IllegalArgumentException(); + } + + bought = false; + } + /** * Creates a building card with the specified effect identifier, era, price, @@ -145,6 +169,49 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf this(era,price,prestigeValue); } + /** + * Creates a building card with the specified effect identifier, era, price, + * and prestige value. + * The effect type is determined from the given effect identifier. + * + * @param effectId the identifier of the effect associated with the building card. + * @param era the era of the building card. + * @param price the price of the building card. + * @param prestigeValue the prestige value of the building card. + * @throws IllegalArgumentException if the effect identifier is not valid, + * if {@code price <= 0}, or if {@code prestigeValue < 0} + */ + public BuildingCard(String idIMG,int effectId ,int era,int price,int prestigeValue) throws IllegalArgumentException{ + this.effectId = effectId; + switch (effectId){ + case 2: + this.effectType=EffectType.ON_EVENT; + break; + case 3: + this.effectType=EffectType.ON_END_TURN; + break; + case 5: + this.effectType=EffectType.ON_EVENT; + break; + case 6: + this.effectType=EffectType.ON_EVENT; + break; + case 7: + this.effectType=EffectType.ON_EVENT; + break; + case 9: + this.effectType=EffectType.ON_EVENT; + break; + case 12: + this.effectType=EffectType.ON_ROUND_END; + break; + default: + throw new IllegalArgumentException(); + + } + this(idIMG,era,price,prestigeValue); + } + /** * Creates and returns a copy of this building card. * @@ -153,7 +220,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf @Override public BuildingCard clone() { - return new BuildingCard(effectId,getEra(),getPrice(),getPrestigeValue()); + return new BuildingCard(getIdIMG(),effectId,getEra(),getPrice(),getPrestigeValue()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java index 88cfeea..0950f46 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCard.java @@ -50,6 +50,16 @@ public abstract class TribeCard extends PlayableCard implements Serializable { public TribeCard(int Era,boolean isEventCard) { this(Era,isEventCard,0); } + /** + * Creates a tribe card with the specified era and event-card flag. + * The minimum number of players is set to 0. + * + * @param Era the era of the tribe card. + * @param isEventCard whether the card is an event card. + */ + public TribeCard(String idIMG,int Era,boolean isEventCard) { + this(idIMG,Era,isEventCard,0); + } /** * Creates a tribe card with the specified era, event-card flag, @@ -65,6 +75,20 @@ public abstract class TribeCard extends PlayableCard implements Serializable { this.isEventCard=isEventCard; } + /** + * Creates a tribe card with the specified era, event-card flag, + * and minimum number of players. + * + * @param Era the era of the tribe card. + * @param isEventCard whether the card is an event card. + * @param nMin the minimum number of players required for the card. + */ + public TribeCard(String idIMG, int Era,boolean isEventCard,int nMin) { + super(idIMG,Era); + this.nMin=nMin; + this.isEventCard=isEventCard; + } + /** * Creates and returns a copy of this tribe card. * diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java index b7e5ef0..0b2eafc 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Character.java @@ -34,6 +34,17 @@ public abstract class Character extends TribeCard implements Cloneable { super(Era,false ); this.type = type; } + /** + * Creates a character card with the specified era and character type. + * + * @param Era the era of the character card. + * @param type the type of the character card. + */ + public Character(String idIMG,int Era, CharacterType type){ + super(idIMG,Era,false ); + this.type = type; + } + /** * Creates a character card with the specified era, character type, @@ -47,6 +58,18 @@ public abstract class Character extends TribeCard implements Cloneable { super(Era,false ,nMin); this.type = type; } + /** + * Creates a character card with the specified era, character type, + * and minimum number of players. + * + * @param Era the era of the character card. + * @param type the type of the character card. + * @param nMin the minimum number of players required for the card. + */ + public Character(String idIMG,int Era, CharacterType type,int nMin){ + super(idIMG,Era,false ,nMin); + this.type = type; + } /** * Returns the string representation of this character card. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java index 4dceff7..0a4faba 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Artist.java @@ -31,6 +31,25 @@ public class Artist extends Character { super(Era, CharacterType.ARTIST,nMin); } + /** + * Creates an Artist character card with the specified era. + * + * @param Era the era of the Artist card + */ + public Artist(String idIMG,int Era) { + super(idIMG,Era, CharacterType.ARTIST); + } + + /** + * Creates an Artist character card with the specified Era and minimum number of players required to play it. + * + * @param Era the era of the Artist card + * @param nMin the minimum number of players required for the card + */ + public Artist(String idIMG,int Era,int nMin) { + super(idIMG,Era, CharacterType.ARTIST,nMin); + } + /** * Returns the string representation of this Artist card. * @@ -48,7 +67,7 @@ public class Artist extends Character { */ @Override public Character clone() { - return new Artist(getEra(), getNMin()); + return new Artist(getIdIMG(),getEra(), getNMin()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java index 9089088..6025793 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java @@ -85,6 +85,51 @@ public class Builder extends Character { this.prestigeValue = prestigeValue; } + /** + * Creates a Builder character card with the specified era, reduction value, + * and prestige value. + * + * @param Era the era of the Builder card. + * @param reductionValue the reduction value of the Builder card. + * @param prestigeValue the prestige value of the Builder card. + * @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}. + */ + public Builder(String idIMG,int Era, int reductionValue, int prestigeValue) throws IllegalArgumentException { + super(idIMG,Era,CharacterType.BUILDER); + if(reductionValue < 0) { + throw new IllegalArgumentException(); + } + this.reductionValue = reductionValue; + + if(prestigeValue < 0) { + throw new IllegalArgumentException(); + } + this.prestigeValue = prestigeValue; + } + + /** + * Creates a Builder character card with the specified era, reduction value, + * prestige value, and minimum number of players. + * + * @param Era the era of the Builder card. + * @param reductionValue the reduction value of the Builder card. + * @param prestigeValue the prestige value of the Builder card. + * @param nMin the minimum number of players required for the card. + * @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}. + */ + public Builder(String idIMG,int Era, int reductionValue, int prestigeValue,int nMin) throws IllegalArgumentException { + super(idIMG,Era,CharacterType.BUILDER,nMin); + if(reductionValue < 0) { + throw new IllegalArgumentException(); + } + this.reductionValue = reductionValue; + + if(prestigeValue < 0) { + throw new IllegalArgumentException(); + } + this.prestigeValue = prestigeValue; + } + /** * Returns the string representation of this Builder card. * @@ -121,7 +166,7 @@ public class Builder extends Character { */ @Override public Character clone() { - return new Builder(getEra(),getReductionValue(), getPrestigeValue(), getNMin()); + return new Builder(getIdIMG(),getEra(),getReductionValue(), getPrestigeValue(), getNMin()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java index d0e8187..ea20e56 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Gatherer.java @@ -31,6 +31,25 @@ public class Gatherer extends Character { super(Era, CharacterType.GATHERER,nMin); } + /** + * Creates a Gatherer character card with the specified era. + * + * @param Era Gatherers era. + */ + public Gatherer(String idIMG,int Era) { + super(idIMG,Era, CharacterType.GATHERER); + } + + /** + * Creates a Gatherer character card with the specified era and minimum number of players. + * + * @param Era the era of the Gatherer card. + * @param nMin the minimum number of players required for the card. + */ + public Gatherer(String idIMG,int Era, int nMin) { + super(idIMG,Era, CharacterType.GATHERER,nMin); + } + /** * Returns the string representation of this Gatherer card. * @@ -48,7 +67,7 @@ public class Gatherer extends Character { */ @Override public Character clone() { - return new Gatherer(getEra(), getNMin()); + return new Gatherer(getIdIMG(),getEra(), getNMin()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java index b60d40a..263b99c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Hunter.java @@ -51,6 +51,29 @@ public class Hunter extends Character { super(Era, CharacterType.HUNTER,nMin); this.icon = icon; } + /** + * Creates a Hunter character card with the specified era and icon value. + * + * @param Era the era of the Hunter card. + * @param icon the icon value of the Hunter card. + */ + public Hunter(String idIMG,int Era, boolean icon) { + super(idIMG,Era, CharacterType.HUNTER); + this.icon = icon; + } + + /** + * Creates a Hunter character card with the specified era, icon value, + * and minimum number of players. + * + * @param Era the era of the Hunter card. + * @param icon the icon value of the Hunter card. + * @param nMin the minimum number of players required for the card. + */ + public Hunter(String idIMG,int Era, boolean icon, int nMin) { + super(idIMG,Era, CharacterType.HUNTER,nMin); + this.icon = icon; + } /** * Returns the string representation of this Hunter card. @@ -93,7 +116,7 @@ public class Hunter extends Character { */ @Override public Character clone() { - return new Hunter(getEra(), getIcon(), getNMin()); + return new Hunter(getIdIMG(),getEra(), getIcon(), getNMin()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Inventor.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Inventor.java index 5d21c71..047fa61 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Inventor.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Inventor.java @@ -54,6 +54,35 @@ public class Inventor extends Character { this.icon = icon; } + /** + * Creates an Inventor character card with the specified era and icon value. + * + * @param Era the era of the Inventor card. + * @param icon the icon value of the Inventor card. + * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}. + */ + public Inventor(String idIMG,int Era,int icon) throws IllegalArgumentException { + super(idIMG,Era, CharacterType.INVENTOR); + if(icon<0 || icon>9) + throw new IllegalArgumentException(); + this.icon = icon; + } + + /** + * Creates an Inventor character card with the specified era, icon value, + * and minimum number of players. + * + * @param Era the era of the Inventor card. + * @param icon the icon value of the Inventor card. + * @param nMin the minimum number of players required for the card. + * @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}. + */ + public Inventor(String idIMG,int Era,int icon,int nMin) throws IllegalArgumentException { + super(idIMG,Era, CharacterType.INVENTOR,nMin); + if(icon<0 || icon>9) + throw new IllegalArgumentException(); + this.icon = icon; + } /** * Returns the string representation of this Inventor card. * @@ -87,7 +116,7 @@ public class Inventor extends Character { */ @Override public Character clone() { - return new Inventor(getEra(),icon, getNMin()); + return new Inventor(getIdIMG(),getEra(),icon, getNMin()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java index 7352819..810d669 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Shaman.java @@ -52,6 +52,29 @@ public class Shaman extends Character { super(Era, CharacterType.SHAMAN,nMin); this.icon = icon; } + /** + * Creates a Shaman character card with the specified era and icon value. + * + * @param Era the era of the Shaman card. + * @param icon the icon value of the Shaman card. + */ + public Shaman(String idIMG,int Era, int icon) { + super(idIMG,Era, CharacterType.SHAMAN); + this.icon = icon; + } + + /** + * Creates a Shaman character card with the specified era, icon value, + * and minimum number of players. + * + * @param Era the era of the Shaman card. + * @param icon the icon value of the Shaman card. + * @param nMin the minimum number of players required for the card. + */ + public Shaman(String idIMG,int Era, int icon, int nMin) { + super(idIMG,Era, CharacterType.SHAMAN,nMin); + this.icon = icon; + } /** * Returns the string representation of this Shaman card. @@ -86,7 +109,7 @@ public class Shaman extends Character { */ @Override public Character clone() { - return new Shaman(getEra(), getIcon(), getNMin()); + return new Shaman(getIdIMG(),getEra(), getIcon(), getNMin()); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java index e8cd013..34b033d 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/EventCard.java @@ -41,6 +41,16 @@ public abstract class EventCard extends TribeCard { super(Era,true); this.type = type; } + /** + * Creates an event card with the specified era and event type. + * + * @param Era the era of the event card. + * @param type the type of the event card. + */ + public EventCard(String idIMG,int Era, EventType type) { + super(idIMG,Era,true); + this.type = type; + } // End Constructors // Function diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java index 6971681..f0f7716 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintings.java @@ -47,6 +47,20 @@ public class CavePaintings extends EventCard { this.NPrestigeRem = NPrestigeRem; this.NPrestigeMul = NPrestigeMul; } + /** + * Creates a CavePaintings event card with the specified era and effect parameters. + * + * @param Era the era of the event card. + * @param NLower the minimum number of Artist cards required to avoid the prestige penalty. + * @param NPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code NLower}. + * @param NPrestigeMul the Prestige multiplier applied if the player has at least {@code NLower} Artist cards. + */ + public CavePaintings(String idIMG,int Era, int NLower, int NPrestigeRem, int NPrestigeMul) { + super(idIMG,Era, EventType.CAVE_PAINTINGS); + this.NLower = NLower; + this.NPrestigeRem = NPrestigeRem; + this.NPrestigeMul = NPrestigeMul; + } /** * Activates the CavePaintings event for the specified list of players. @@ -88,7 +102,7 @@ public class CavePaintings extends EventCard { @Override public EventCard clone() { - return new CavePaintings(getEra(), NLower, NPrestigeRem, NPrestigeMul) ; + return new CavePaintings(getIdIMG(),getEra(), NLower, NPrestigeRem, NPrestigeMul) ; } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java index 80870d2..af57191 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java @@ -30,6 +30,17 @@ public class Hunt extends EventCard { this.foodMultiplier = 1; this.prestigeMultiplier = prestigeMultiplier; } + /** + * Creates a new Hunt event card. + * + * @param Era the era of the card + * @param prestigeMultiplier prestige points multiplicator used during the event + */ + public Hunt(String idIMG,int Era, int prestigeMultiplier) { + super(idIMG,Era, EventType.HUNT); + this.foodMultiplier = 1; + this.prestigeMultiplier = prestigeMultiplier; + } /** * Activates the event card "Hunt". @@ -68,7 +79,7 @@ public class Hunt extends EventCard { */ @Override public EventCard clone() { - return new Hunt(getEra(), prestigeMultiplier); + return new Hunt(getIdIMG(),getEra(), prestigeMultiplier); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java index 1a65f10..fcbb7e5 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java @@ -33,6 +33,19 @@ public class ShamanicRitual extends EventCard { this.prestigeToAdd = prestigeToAdd; this.prestigeToRemove = prestigeToRemove; + } + /** + * Creates a new ShamanicRitual event card. + * + * @param Era the era of the card + * @param prestigeToAdd prestige points awarded to the player with the most icons + * @param prestigeToRemove prestige points removed from the player with the fewest icons + */ + public ShamanicRitual(String idIMG,int Era, int prestigeToAdd, int prestigeToRemove) { + super(idIMG,Era, EventType.SHAMANIC_RITUAL); + this.prestigeToAdd = prestigeToAdd; + this.prestigeToRemove = prestigeToRemove; + } /** @@ -94,7 +107,7 @@ public class ShamanicRitual extends EventCard { */ @Override public EventCard clone() { - return new ShamanicRitual(getEra(), prestigeToAdd, prestigeToRemove); + return new ShamanicRitual(getIdIMG(),getEra(), prestigeToAdd, prestigeToRemove); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java index ac53288..1e20492 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java @@ -39,6 +39,16 @@ public class Sustenance extends EventCard { super(Era, EventType.SUSTENANCE); this.PrestigeDebt = PrestigeDebt; } + /** + * Creates a Sustenance event card with the specified era and prestige debt value. + * + * @param Era the era of the event card. + * @param PrestigeDebt the prestige penalty multiplier for unpaid Food units. + */ + public Sustenance(String idIMG,int Era, int PrestigeDebt) { + super(idIMG,Era, EventType.SUSTENANCE); + this.PrestigeDebt = PrestigeDebt; + } /** * Activates the Sustenance event for the specified list of players. @@ -92,7 +102,7 @@ public class Sustenance extends EventCard { */ @Override public EventCard clone() { - return new Sustenance(getEra(), PrestigeDebt); + return new Sustenance(getIdIMG(),getEra(), PrestigeDebt); } /** diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java b/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java index 971b545..93006f1 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/DecksCreator.java @@ -133,45 +133,45 @@ public class DecksCreator { */ private static TribeCard createCard(TribeCardDefinition def) { int era = def.era; - + String id = def.id; int[] p = def.params.stream().mapToInt(d -> ((Double) d).intValue()).toArray(); if(def.isEvent) { return switch (def.type) { - case "Sustenance" -> new Sustenance(era,p[0]); - case "Hunt" -> new Hunt(era,p[0]); - case "CavePaintings" -> new CavePaintings(era,p[0],p[1],p[2]); - case "ShamanicRitual" -> new ShamanicRitual(era,p[0],p[1]); + case "Sustenance" -> new Sustenance(def.id,era,p[0]); + case "Hunt" -> new Hunt(def.id,era,p[0]); + case "CavePaintings" -> new CavePaintings(def.id,era,p[0],p[1],p[2]); + case "ShamanicRitual" -> new ShamanicRitual(def.id,era,p[0],p[1]); default -> throw new IllegalArgumentException("Tipo sconosciuto: " + def.type); }; } return switch (def.type) { case "Hunter" -> p.length == 0 - ? new Hunter(era, def.armed) - : new Hunter(era, def.armed, p[0]); + ? new Hunter(def.id,era, def.armed) + : new Hunter(def.id,era, def.armed, p[0]); case "Builder" -> switch (p.length) { - case 2 -> new Builder(era, p[0], p[1]); - case 3 -> new Builder(era, p[0], p[1], p[2]); + case 2 -> new Builder(def.id,era, p[0], p[1]); + case 3 -> new Builder(def.id,era, p[0], p[1], p[2]); default -> throw new IllegalArgumentException("Builder: parametri non validi"); }; case "Gatherer" -> switch (p.length) { - case 0 -> new Gatherer(era); - case 1 -> new Gatherer(era, p[0]); + case 0 -> new Gatherer(def.id,era); + case 1 -> new Gatherer(def.id,era, p[0]); default -> throw new IllegalArgumentException("Gatherer: parametri non validi"); }; case "Artist" -> switch (p.length) { - case 0 -> new Artist(era); - case 1 -> new Artist(era, p[0]); + case 0 -> new Artist(def.id,era); + case 1 -> new Artist(def.id,era, p[0]); default -> throw new IllegalArgumentException("Artist: parametri non validi"); }; case "Inventor" -> switch (p.length) { - case 1 -> new Inventor(era, p[0]); - case 2 -> new Inventor(era, p[0], p[1]); + case 1 -> new Inventor(def.id,era, p[0]); + case 2 -> new Inventor(def.id,era, p[0], p[1]); default -> throw new IllegalArgumentException("Inventor: parametri non validi"); }; case "Shaman" -> switch (p.length) { - case 1 -> new Shaman(era, p[0]); - case 2 -> new Shaman(era, p[0], p[1]); + case 1 -> new Shaman(def.id,era, p[0]); + case 2 -> new Shaman(def.id,era, p[0], p[1]); default -> throw new IllegalArgumentException("Shaman: parametri non validi"); }; default -> throw new IllegalArgumentException("Tipo sconosciuto: " + def.type); @@ -188,14 +188,14 @@ public class DecksCreator { */ private static BuildingCard createCard(BuildingCardDefinition def) { return switch (def.effectId) { - case 0 -> new Building0(def.era, def.price, def.prestigeValue); - case 1 -> new Building1(def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase())); - case 4 -> new Building4(def.era, def.price, def.prestigeValue); - case 8 -> new Building8(def.era, def.price, def.prestigeValue); - case 10 -> new Building10(def.era, def.price, def.prestigeValue); - case 11 -> new Building11(def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()), ((Double) def.params.get(1)).intValue()); - case 13 -> new Building13(def.era, def.price, def.prestigeValue); - default -> new BuildingCard(def.effectId, def.era, def.price, def.prestigeValue); + case 0 -> new Building0(def.id,def.era, def.price, def.prestigeValue); + case 1 -> new Building1(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase())); + case 4 -> new Building4(def.id,def.era, def.price, def.prestigeValue); + case 8 -> new Building8(def.id,def.era, def.price, def.prestigeValue); + case 10 -> new Building10(def.id,def.era, def.price, def.prestigeValue); + case 11 -> new Building11(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()), ((Double) def.params.get(1)).intValue()); + case 13 -> new Building13(def.id,def.era, def.price, def.prestigeValue); + default -> new BuildingCard(def.id,def.effectId, def.era, def.price, def.prestigeValue); }; } @@ -206,6 +206,7 @@ public class DecksCreator { * and a list of additional parameters. */ private static class TribeCardDefinition { + String id; String type; int era; boolean armed; @@ -218,6 +219,7 @@ public class DecksCreator { * Contains the effect ID, era, price, prestige value, and a list of additional parameters. */ private static class BuildingCardDefinition { + String id; int effectId; int era; int price; diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java index 500a4a5..2277dac 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -63,6 +63,7 @@ public class Game implements Serializable { * The mapping between slots and the players assigned to them. */ private HashMap slotMap; + public HashMap getSlotMap() {return slotMap;}; /** * The configured number of players for this game. diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java index 473062e..ac2c9e5 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/Board.java @@ -176,8 +176,8 @@ public class Board implements Serializable { tribeDeck_temp.addAll(era1); tribeDeck_temp.addAll(era2); tribeDeck_temp.addAll(era3); - tribeDeck_temp.add(new Sustenance(3,3)); - tribeDeck_temp.add(new ShamanicRitual(3,15,7)); + tribeDeck_temp.add(new Sustenance("95",3,3)); + tribeDeck_temp.add(new ShamanicRitual("96",3,15,7)); return tribeDeck_temp; } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java index f2446bd..b9d40df 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java @@ -8,6 +8,11 @@ import java.io.Serializable; */ public abstract class PlayableCard implements Serializable { + private String idIMG; + public String getIdIMG() { + return idIMG; + } + /** * The era associated with this playable card. */ @@ -29,6 +34,22 @@ public abstract class PlayableCard implements Serializable { * @throws IllegalArgumentException if {@code Era <= 0} or {@code Era >= 4}. */ public PlayableCard (int Era) throws IllegalArgumentException{ + idIMG="-1"; + if (Era>0 && Era<4) { + this.Era = Era; + } else { + throw new IllegalArgumentException(); + } + } + + /** + * Creates a playable card with the specified era. + * + * @param Era the era of the playable card. + * @throws IllegalArgumentException if {@code Era <= 0} or {@code Era >= 4}. + */ + public PlayableCard (String idIMG,int Era) throws IllegalArgumentException{ + this.idIMG = idIMG; if (Era>0 && Era<4) { this.Era = Era; } else { diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java index 9a49330..7c32b35 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/GUI.java @@ -12,6 +12,7 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI private final Stage stage; private final MainView mainView = new MainView(); private Game model; + private ClientController controller; private String username; public GUI(Stage stage) { @@ -21,7 +22,12 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI @Override public void setModel(Game model) { this.model = model; - mainView.setModel(model); + mainView.setModel(model, controller, username); + + Platform.runLater(() -> { + stage.setScene(mainView.getScene()); + }); + } /** @@ -32,7 +38,6 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI public void render() { Platform.runLater(() -> { mainView.render(); - stage.setScene(mainView.getScene()); }); } @@ -50,6 +55,8 @@ public class GUI implements IView { // stessa interfaccia che implementa TUI this.username=username; } + public void setController(ClientController controller) { this.controller = controller;} + // Getter per il launcher public Stage getStage() { return stage; } } \ No newline at end of file diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java index 8e6cba6..64cc6de 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginFXMLController.java @@ -1,8 +1,16 @@ package it.polimi.ingsw.gc14.View.GUI; +import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.control.*; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + public class LoginFXMLController { @FXML private TextField campoNome; @@ -12,14 +20,38 @@ public class LoginFXMLController { @FXML private RadioButton btnTCP; @FXML private Button btnAccedi; @FXML private Label labelErrore; + @FXML private ComboBox comboInterfaccia; @FXML public void initialize() { - // I RadioButton vanno collegati a un ToggleGroup a mano - // perché FXML non lo fa automaticamente ToggleGroup group = new ToggleGroup(); btnRMI.setToggleGroup(group); btnTCP.setToggleGroup(group); + + // Carica le interfacce in background + new Thread(() -> { + try { + List ips = new ArrayList<>(); + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface ni = interfaces.nextElement(); + if (!ni.isUp() || ni.isLoopback() || ni.isVirtual()) continue; + Enumeration addresses = ni.getInetAddresses(); + while (addresses.hasMoreElements()) { + InetAddress addr = addresses.nextElement(); + if (addr instanceof Inet4Address) { + ips.add(ni.getDisplayName() + " -> " + addr.getHostAddress()); + } + } + } + Platform.runLater(() -> { + comboInterfaccia.getItems().addAll(ips); + if (!ips.isEmpty()) comboInterfaccia.getSelectionModel().selectFirst(); + }); + } catch (Exception e) { + Platform.runLater(() -> setErrore("Errore nel rilevare le interfacce.")); + } + }).start(); } // --- Getter esposti a LoginView --- @@ -40,5 +72,11 @@ public class LoginFXMLController { public String getIP() { return campoIP.getText().trim(); } + public String getInterfaccia() { + String selected = comboInterfaccia.getValue(); + if (selected == null) return ""; + return selected.contains("->") ? selected.split("->")[1].trim() : selected; + } + public void setErrore(String messaggio) { labelErrore.setText(messaggio); } } \ No newline at end of file diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginView.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginView.java index 51eaf1b..75e8e9b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginView.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/LoginView.java @@ -31,5 +31,6 @@ public class LoginView { public int getNumPlayers() { return fxmlController.getNumPlayers(); } public int getNetworkType() { return fxmlController.getNetworkType(); } public String getIP() { return fxmlController.getIP(); } + public String getInterfaccia() {return fxmlController.getInterfaccia();} public void setErrore(String messaggio) { fxmlController.setErrore(messaggio); } } \ No newline at end of file diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java index 496245b..705ebf9 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainFXMLController.java @@ -1,13 +1,20 @@ package it.polimi.ingsw.gc14.View.GUI; +import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Game; +import it.polimi.ingsw.gc14.Model.Player; +import it.polimi.ingsw.gc14.Model.Slot; import javafx.fxml.FXML; +import javafx.geometry.Pos; +import javafx.scene.control.Button; import javafx.scene.image.*; import javafx.scene.layout.*; import javafx.scene.shape.*; +import java.util.ArrayList; import java.util.List; +import java.util.Map; public class MainFXMLController { @@ -17,27 +24,84 @@ public class MainFXMLController { @FXML private HBox myHand; @FXML private VBox playersHand; + @FXML private Button reload; + private Game model; + private ClientController controller; + private String username; public void setModel(Game model) { this.model = model; } + public void setController(ClientController controller) {this.controller = controller;} + public void setUsername(String username) {this.username = username;} public void render() { - Image placeholder = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-001.png")); + + // Upper list + upperList.setSpacing(6); + upperList.setAlignment(Pos.CENTER); + upperList.getChildren().clear(); + + int i = 0; for (TribeCard card : model.getUpperListTribeCards()) { - ImageView view = new ImageView(placeholder); - view.setFitHeight(250); + final int index = i; + + Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); + ImageView view = new ImageView(tribeImg); + view.fitHeightProperty().bind(upperList.heightProperty().subtract(10)); view.setPreserveRatio(true); + + view.setOnMouseClicked(e -> controller.drawUpperTribeCard(username, index)); + upperList.getChildren().add(view); + i++; } - for (TribeCard card : model.getLowerListTribeCards()) { - ImageView view = new ImageView(placeholder); - view.setFitHeight(250); + + // Board + board.setSpacing(6); + board.setAlignment(Pos.CENTER); + board.getChildren().clear(); + + i = 0; + for (Map.Entry entry : model.getSlotMap().entrySet()) { + Slot slot = entry.getKey(); + final int index = i; + + Image slotImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-"+slot.getSlotId()+".png")); + ImageView view = new ImageView(slotImg); + + view.fitHeightProperty().bind(board.heightProperty().subtract(10)); view.setPreserveRatio(true); + + view.setOnMouseClicked(e -> controller.slotChoice(username, index)); + + board.getChildren().add(view); + i++; + } + + + + // Lower list + lowerList.setSpacing(6); + lowerList.setAlignment(Pos.CENTER); + lowerList.getChildren().clear(); + + i = 0; + for (TribeCard card : model.getLowerListTribeCards()) { + final int index = i; + + Image tribeImg = new Image(getClass().getResourceAsStream("/GUIImages/Fronts/card-" + card.getIdIMG() + ".png")); + ImageView view = new ImageView(tribeImg); + view.fitHeightProperty().bind(lowerList.heightProperty().subtract(10)); + view.setPreserveRatio(true); + + view.setOnMouseClicked(e -> controller.drawLowerTribeCard(username, index)); + lowerList.getChildren().add(view); + i++; } } } diff --git a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainView.java b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainView.java index 7df0470..50f8d08 100644 --- a/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainView.java +++ b/src/main/java/it/polimi/ingsw/gc14/View/GUI/MainView.java @@ -1,5 +1,6 @@ package it.polimi.ingsw.gc14.View.GUI; +import it.polimi.ingsw.gc14.Controller.ClientController; import it.polimi.ingsw.gc14.Model.Game; import javafx.fxml.FXMLLoader; import javafx.geometry.Insets; @@ -15,6 +16,8 @@ public class MainView { private final Scene scene; private final MainFXMLController fxmlController; private Game model; + private ClientController controller; + private String username; public MainView() { try { @@ -29,11 +32,17 @@ public class MainView { } public Scene getScene() { return scene; } - public void setModel(Game model) { + public void setModel(Game model, ClientController controller, String username) { this.model = model; fxmlController.setModel(model); + this.controller = controller; + fxmlController.setController(controller); + this.username = username; + fxmlController.setUsername(username); + } public void render() { fxmlController.render(); } + } \ No newline at end of file diff --git a/src/main/resources/Cards/buildingCards.json b/src/main/resources/Cards/buildingCards.json index 085ed72..ae48b3d 100644 --- a/src/main/resources/Cards/buildingCards.json +++ b/src/main/resources/Cards/buildingCards.json @@ -1,26 +1,25 @@ [ - {"effectId": "0","era": 1,"price":4,"prestigeValue": 3,"params": []}, - {"effectId": "1","era": 1,"price":4,"prestigeValue": 4,"params": ["Gatherer"]}, - {"effectId": "1","era": 1,"price":5,"prestigeValue": 3,"params": ["Artist"]}, - {"effectId": "2","era": 1,"price":5,"prestigeValue": 2,"params": []}, - {"effectId": "3","era": 1,"price":3,"prestigeValue": 3,"params": []}, - {"effectId": "4","era": 1,"price":3,"prestigeValue": 4,"params": []}, + {"id":"097","effectId": "0","era": 1,"price":4,"prestigeValue": 3,"params": []}, + {"id":"098","effectId": "1","era": 1,"price":4,"prestigeValue": 4,"params": ["Gatherer"]}, + {"id":"099","effectId": "1","era": 1,"price":5,"prestigeValue": 3,"params": ["Artist"]}, + {"id":"100","effectId": "2","era": 1,"price":5,"prestigeValue": 2,"params": []}, + {"id":"101","effectId": "3","era": 1,"price":3,"prestigeValue": 3,"params": []}, + {"id":"102","effectId": "4","era": 1,"price":3,"prestigeValue": 4,"params": []}, - {"effectId": "6","era": 2,"price":4,"prestigeValue": 0,"params": []}, - {"effectId": "5","era": 2,"price":6,"prestigeValue": 4,"params": []}, - {"effectId": "1","era": 2,"price":7,"prestigeValue": 4,"params": ["Inventor"]}, - {"effectId": "7","era": 2,"price":7,"prestigeValue": 2,"params": []}, - {"effectId": "8","era": 2,"price":6,"prestigeValue": 4,"params": []}, - {"effectId": "9","era": 2,"price":5,"prestigeValue": 6,"params": []}, - {"effectId": "10","era": 2,"price":5,"prestigeValue": 6,"params": []}, - - {"effectId": "11","era": 3,"price":8,"prestigeValue": 8,"params": ["Hunter",3]}, - {"effectId": "11","era": 3,"price":7,"prestigeValue": 6,"params": ["Gatherer",4]}, - {"effectId": "11","era": 3,"price":7,"prestigeValue": 4,"params": ["Shaman",4]}, - {"effectId": "11","era": 3,"price":6,"prestigeValue": 3,"params": ["Builder",4]}, - {"effectId": "11","era": 3,"price":7,"prestigeValue": 4,"params": ["Artist",4]}, - {"effectId": "11","era": 3,"price":6,"prestigeValue": 6,"params": ["Inventor",2]}, - {"effectId": "12","era": 3,"price":9,"prestigeValue": 3,"params": []}, - {"effectId": "13","era": 3,"price":10,"prestigeValue": 0,"params": []} + {"id":"103","effectId": "6","era": 2,"price":4,"prestigeValue": 0,"params": []}, + {"id":"104","effectId": "5","era": 2,"price":6,"prestigeValue": 4,"params": []}, + {"id":"105","effectId": "1","era": 2,"price":7,"prestigeValue": 4,"params": ["Inventor"]}, + {"id":"106","effectId": "7","era": 2,"price":7,"prestigeValue": 2,"params": []}, + {"id":"107","effectId": "8","era": 2,"price":6,"prestigeValue": 4,"params": []}, + {"id":"108","effectId": "9","era": 2,"price":5,"prestigeValue": 6,"params": []}, + {"id":"109","effectId": "10","era": 2,"price":5,"prestigeValue": 6,"params": []}, + {"id":"110","effectId": "11","era": 3,"price":8,"prestigeValue": 8,"params": ["Hunter",3]}, + {"id":"111","effectId": "11","era": 3,"price":7,"prestigeValue": 6,"params": ["Gatherer",4]}, + {"id":"112","effectId": "11","era": 3,"price":7,"prestigeValue": 4,"params": ["Shaman",4]}, + {"id":"113","effectId": "11","era": 3,"price":6,"prestigeValue": 3,"params": ["Builder",4]}, + {"id":"114","effectId": "11","era": 3,"price":7,"prestigeValue": 4,"params": ["Artist",4]}, + {"id":"115","effectId": "11","era": 3,"price":6,"prestigeValue": 6,"params": ["Inventor",2]}, + {"id":"116","effectId": "12","era": 3,"price":9,"prestigeValue": 3,"params": []}, + {"id":"117","effectId": "13","era": 3,"price":10,"prestigeValue": 0,"params": []} ] \ No newline at end of file diff --git a/src/main/resources/Cards/tribe_era1.json b/src/main/resources/Cards/tribe_era1.json index e8ad026..7f61b1d 100644 --- a/src/main/resources/Cards/tribe_era1.json +++ b/src/main/resources/Cards/tribe_era1.json @@ -1,5 +1,6 @@ [ { + "id": "001", "isEvent": false, "type": "Hunter", "era": 1, @@ -7,6 +8,7 @@ "params": [] }, { + "id": "002", "isEvent": false, "type": "Hunter", "era": 1, @@ -14,6 +16,7 @@ "params": [] }, { + "id": "003", "isEvent": false, "type": "Hunter", "era": 1, @@ -21,6 +24,7 @@ "params": [] }, { + "id": "004", "isEvent": false, "type": "Hunter", "era": 1, @@ -30,6 +34,7 @@ ] }, { + "id": "005", "isEvent": false, "type": "Hunter", "era": 1, @@ -39,6 +44,7 @@ ] }, { + "id": "006", "isEvent": false, "type": "Builder", "era": 1, @@ -49,6 +55,7 @@ ] }, { + "id": "007", "isEvent": false, "type": "Builder", "era": 1, @@ -59,6 +66,7 @@ ] }, { + "id": "008", "isEvent": false, "type": "Builder", "era": 1, @@ -70,6 +78,7 @@ ] }, { + "id": "009", "isEvent": false, "type": "Builder", "era": 1, @@ -80,6 +89,7 @@ ] }, { + "id": "010", "isEvent": false, "type": "Gatherer", "era": 1, @@ -87,6 +97,7 @@ "params": [] }, { + "id": "011", "isEvent": false, "type": "Gatherer", "era": 1, @@ -94,6 +105,7 @@ "params": [] }, { + "id": "012", "isEvent": false, "type": "Gatherer", "era": 1, @@ -103,6 +115,7 @@ ] }, { + "id": "013", "isEvent": false, "type": "Gatherer", "era": 1, @@ -112,6 +125,7 @@ ] }, { + "id": "014", "isEvent": false, "type": "Artist", "era": 1, @@ -119,6 +133,7 @@ "params": [] }, { + "id": "015", "isEvent": false, "type": "Artist", "era": 1, @@ -126,6 +141,7 @@ "params": [] }, { + "id": "016", "isEvent": false, "type": "Artist", "era": 1, @@ -133,6 +149,7 @@ "params": [] }, { + "id": "017", "isEvent": false, "type": "Artist", "era": 1, @@ -142,6 +159,7 @@ ] }, { + "id": "018", "isEvent": false, "type": "Artist", "era": 1, @@ -151,6 +169,7 @@ ] }, { + "id": "019", "isEvent": false, "type": "Inventor", "era": 1, @@ -160,6 +179,7 @@ ] }, { + "id": "020", "isEvent": false, "type": "Inventor", "era": 1, @@ -169,6 +189,7 @@ ] }, { + "id": "021", "isEvent": false, "type": "Inventor", "era": 1, @@ -178,6 +199,7 @@ ] }, { + "id": "022", "isEvent": false, "type": "Inventor", "era": 1, @@ -187,6 +209,7 @@ ] }, { + "id": "023", "isEvent": false, "type": "Inventor", "era": 1, @@ -197,6 +220,7 @@ ] }, { + "id": "024", "isEvent": false, "type": "Inventor", "era": 1, @@ -207,6 +231,7 @@ ] }, { + "id": "025", "isEvent": false, "type": "Inventor", "era": 1, @@ -217,6 +242,7 @@ ] }, { + "id": "026", "isEvent": false, "type": "Shaman", "era": 1, @@ -227,6 +253,7 @@ ] }, { + "id": "027", "isEvent": false, "type": "Shaman", "era": 1, @@ -236,6 +263,7 @@ ] }, { + "id": "028", "isEvent": false, "type": "Shaman", "era": 1, @@ -245,6 +273,7 @@ ] }, { + "id": "029", "isEvent": false, "type": "Shaman", "era": 1, @@ -255,6 +284,7 @@ ] }, { + "id": "085", "isEvent": true, "type": "Hunt", "era": 1, @@ -264,6 +294,7 @@ ] }, { + "id": "086", "isEvent": true, "type": "Sustenance", "era": 1, @@ -273,6 +304,7 @@ ] }, { + "id": "087", "isEvent": true, "type": "ShamanicRitual", "era": 1, @@ -283,6 +315,7 @@ ] }, { + "id": "088", "isEvent": true, "type": "CavePaintings", "era": 1, @@ -293,5 +326,4 @@ 1 ] } - ] \ No newline at end of file diff --git a/src/main/resources/Cards/tribe_era2.json b/src/main/resources/Cards/tribe_era2.json index 0650796..b6a7b57 100644 --- a/src/main/resources/Cards/tribe_era2.json +++ b/src/main/resources/Cards/tribe_era2.json @@ -1,5 +1,6 @@ [ { + "id": "030", "isEvent": false, "type": "Hunter", "era": 2, @@ -7,6 +8,7 @@ "params": [] }, { + "id": "031", "isEvent": false, "type": "Hunter", "era": 2, @@ -14,6 +16,7 @@ "params": [] }, { + "id": "032", "isEvent": false, "type": "Hunter", "era": 2, @@ -23,6 +26,7 @@ ] }, { + "id": "033", "isEvent": false, "type": "Hunter", "era": 2, @@ -30,13 +34,17 @@ "params": [] }, { + "id": "034", "isEvent": false, "type": "Hunter", "era": 2, "armed": true, - "params": [4] + "params": [ + 4 + ] }, { + "id": "035", "isEvent": false, "type": "Hunter", "era": 2, @@ -46,6 +54,7 @@ ] }, { + "id": "036", "isEvent": false, "type": "Builder", "era": 2, @@ -56,6 +65,7 @@ ] }, { + "id": "037", "isEvent": false, "type": "Builder", "era": 2, @@ -66,6 +76,7 @@ ] }, { + "id": "038", "isEvent": false, "type": "Builder", "era": 2, @@ -77,6 +88,7 @@ ] }, { + "id": "039", "isEvent": false, "type": "Builder", "era": 2, @@ -87,6 +99,7 @@ ] }, { + "id": "040", "isEvent": false, "type": "Gatherer", "era": 2, @@ -94,6 +107,7 @@ "params": [] }, { + "id": "041", "isEvent": false, "type": "Gatherer", "era": 2, @@ -103,6 +117,7 @@ ] }, { + "id": "042", "isEvent": false, "type": "Gatherer", "era": 2, @@ -112,6 +127,7 @@ ] }, { + "id": "043", "isEvent": false, "type": "Gatherer", "era": 2, @@ -121,6 +137,7 @@ ] }, { + "id": "044", "isEvent": false, "type": "Artist", "era": 2, @@ -130,6 +147,7 @@ ] }, { + "id": "045", "isEvent": false, "type": "Artist", "era": 2, @@ -137,6 +155,7 @@ "params": [] }, { + "id": "046", "isEvent": false, "type": "Artist", "era": 2, @@ -144,6 +163,7 @@ "params": [] }, { + "id": "047", "isEvent": false, "type": "Artist", "era": 2, @@ -151,6 +171,7 @@ "params": [] }, { + "id": "048", "isEvent": false, "type": "Inventor", "era": 2, @@ -160,6 +181,7 @@ ] }, { + "id": "049", "isEvent": false, "type": "Inventor", "era": 2, @@ -170,6 +192,7 @@ ] }, { + "id": "050", "isEvent": false, "type": "Inventor", "era": 2, @@ -179,6 +202,7 @@ ] }, { + "id": "051", "isEvent": false, "type": "Inventor", "era": 2, @@ -188,6 +212,7 @@ ] }, { + "id": "052", "isEvent": false, "type": "Inventor", "era": 2, @@ -197,6 +222,7 @@ ] }, { + "id": "053", "isEvent": false, "type": "Inventor", "era": 2, @@ -206,6 +232,7 @@ ] }, { + "id": "054", "isEvent": false, "type": "Shaman", "era": 2, @@ -215,6 +242,7 @@ ] }, { + "id": "055", "isEvent": false, "type": "Shaman", "era": 2, @@ -224,6 +252,7 @@ ] }, { + "id": "056", "isEvent": false, "type": "Shaman", "era": 2, @@ -234,6 +263,7 @@ ] }, { + "id": "057", "isEvent": false, "type": "Shaman", "era": 2, @@ -244,6 +274,7 @@ ] }, { + "id": "089", "isEvent": true, "type": "Hunt", "era": 2, @@ -253,6 +284,7 @@ ] }, { + "id": "090", "isEvent": true, "type": "Sustenance", "era": 2, @@ -262,6 +294,7 @@ ] }, { + "id": "091", "isEvent": true, "type": "ShamanicRitual", "era": 2, @@ -272,6 +305,7 @@ ] }, { + "id": "092", "isEvent": true, "type": "CavePaintings", "era": 2, diff --git a/src/main/resources/Cards/tribe_era3.json b/src/main/resources/Cards/tribe_era3.json index d1d2a02..f3a4006 100644 --- a/src/main/resources/Cards/tribe_era3.json +++ b/src/main/resources/Cards/tribe_era3.json @@ -1,5 +1,6 @@ [ { + "id": "058", "isEvent": false, "type": "Hunter", "era": 3, @@ -9,6 +10,7 @@ ] }, { + "id": "059", "isEvent": false, "type": "Hunter", "era": 3, @@ -16,6 +18,7 @@ "params": [] }, { + "id": "060", "isEvent": false, "type": "Hunter", "era": 3, @@ -23,6 +26,7 @@ "params": [] }, { + "id": "061", "isEvent": false, "type": "Hunter", "era": 3, @@ -30,6 +34,7 @@ "params": [] }, { + "id": "062", "isEvent": false, "type": "Builder", "era": 3, @@ -40,6 +45,7 @@ ] }, { + "id": "063", "isEvent": false, "type": "Builder", "era": 3, @@ -50,6 +56,7 @@ ] }, { + "id": "064", "isEvent": false, "type": "Builder", "era": 3, @@ -61,6 +68,7 @@ ] }, { + "id": "065", "isEvent": false, "type": "Builder", "era": 3, @@ -71,6 +79,7 @@ ] }, { + "id": "066", "isEvent": false, "type": "Gatherer", "era": 3, @@ -80,6 +89,7 @@ ] }, { + "id": "067", "isEvent": false, "type": "Gatherer", "era": 3, @@ -89,6 +99,7 @@ ] }, { + "id": "068", "isEvent": false, "type": "Gatherer", "era": 3, @@ -96,6 +107,7 @@ "params": [] }, { + "id": "069", "isEvent": false, "type": "Artist", "era": 3, @@ -105,6 +117,7 @@ ] }, { + "id": "070", "isEvent": false, "type": "Artist", "era": 3, @@ -112,6 +125,7 @@ "params": [] }, { + "id": "071", "isEvent": false, "type": "Artist", "era": 3, @@ -119,6 +133,7 @@ "params": [] }, { + "id": "072", "isEvent": false, "type": "Artist", "era": 3, @@ -126,6 +141,7 @@ "params": [] }, { + "id": "073", "isEvent": false, "type": "Inventor", "era": 3, @@ -136,6 +152,7 @@ ] }, { + "id": "074", "isEvent": false, "type": "Inventor", "era": 3, @@ -146,6 +163,7 @@ ] }, { + "id": "075", "isEvent": false, "type": "Inventor", "era": 3, @@ -156,6 +174,7 @@ ] }, { + "id": "076", "isEvent": false, "type": "Inventor", "era": 3, @@ -165,6 +184,7 @@ ] }, { + "id": "077", "isEvent": false, "type": "Inventor", "era": 3, @@ -174,6 +194,7 @@ ] }, { + "id": "078", "isEvent": false, "type": "Inventor", "era": 3, @@ -183,6 +204,7 @@ ] }, { + "id": "079", "isEvent": false, "type": "Inventor", "era": 3, @@ -192,6 +214,7 @@ ] }, { + "id": "080", "isEvent": false, "type": "Shaman", "era": 3, @@ -202,6 +225,7 @@ ] }, { + "id": "081", "isEvent": false, "type": "Shaman", "era": 3, @@ -211,6 +235,7 @@ ] }, { + "id": "082", "isEvent": false, "type": "Shaman", "era": 3, @@ -220,6 +245,7 @@ ] }, { + "id": "083", "isEvent": false, "type": "Shaman", "era": 3, @@ -229,6 +255,7 @@ ] }, { + "id": "084", "isEvent": false, "type": "Shaman", "era": 3, @@ -239,6 +266,7 @@ ] }, { + "id": "093", "isEvent": true, "type": "Hunt", "era": 3, @@ -248,6 +276,7 @@ ] }, { + "id": "094", "isEvent": true, "type": "CavePaintings", "era": 3, diff --git a/src/main/resources/GUIScene/login.fxml b/src/main/resources/GUIScene/login.fxml index 9e55c8f..c9219e4 100644 --- a/src/main/resources/GUIScene/login.fxml +++ b/src/main/resources/GUIScene/login.fxml @@ -22,6 +22,9 @@