Add: idIMG constructor

This commit is contained in:
rubenpirreram
2026-05-06 16:09:20 +02:00
parent 5d31e6346d
commit 67b0e0ff7b
18 changed files with 396 additions and 0 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.
@@ -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.
@@ -22,6 +22,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.
*
@@ -45,6 +45,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.
@@ -17,6 +17,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.
@@ -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.
@@ -23,6 +23,18 @@ 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.
@@ -93,6 +93,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,
@@ -137,6 +161,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.
*
@@ -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.
@@ -25,6 +25,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.
*
@@ -78,6 +78,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.
*
@@ -24,6 +24,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.
*
@@ -45,6 +45,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.
@@ -48,6 +48,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.
*
@@ -47,6 +47,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.
@@ -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
@@ -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 {