Add: id JSON

This commit is contained in:
rubenpirreram
2026-05-06 16:27:17 +02:00
parent 67b0e0ff7b
commit 32572ca33a
9 changed files with 193 additions and 49 deletions
@@ -42,6 +42,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.
@@ -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(Era, EventType.HUNT);
this.foodMultiplier = 1;
this.prestigeMultiplier = prestigeMultiplier;
}
/**
* Activates the event card "Hunt".
@@ -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(Era, EventType.SHAMANIC_RITUAL);
this.prestigeToAdd = prestigeToAdd;
this.prestigeToRemove = prestigeToRemove;
}
/**
@@ -34,6 +34,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.
@@ -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;