Merge pull request #86 from rubenpirreram/GUI

First implementation GUI
This commit is contained in:
rubenpirreram
2026-05-06 17:37:56 +02:00
committed by GitHub
39 changed files with 763 additions and 86 deletions
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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.
*
@@ -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.
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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());
}
/**
@@ -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
@@ -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) ;
}
/**
@@ -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);
}
/**
@@ -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);
}
/**
@@ -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);
}
/**
@@ -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;
@@ -63,6 +63,7 @@ public class Game implements Serializable {
* The mapping between slots and the players assigned to them.
*/
private HashMap<Slot,Player> slotMap;
public HashMap<Slot,Player> getSlotMap() {return slotMap;};
/**
* The configured number of players for this game.
@@ -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;
}
@@ -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 {