Refactor: removed dead code and standarized to camelCase

This commit is contained in:
2026-06-12 18:37:18 +02:00
parent 5a0d201341
commit bc9e4480c0
49 changed files with 187 additions and 352 deletions
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.HashMap;
/**
* At the end of the game, the player gains 6 Prestige Points
@@ -69,8 +68,6 @@ public class Building10 extends BuildingCard {
public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException();
HashMap<CharacterType,Integer> map = new HashMap<CharacterType,Integer>();
int numSet=player.getNType(CharacterType.INVENTOR);
for(CharacterType type : CharacterType.values())
{
@@ -26,14 +26,14 @@ public class Building11 extends BuildingCard {
*/
public CharacterType getIcon() {return icon;}
private int PrestigeMul;
private int prestigeMul;
/**
* Returns the prestige multiplier associated with this building card effect.
*
* @return the prestige multiplier associated with this building card effect.
*/
public int getPrestigeMul() {return PrestigeMul;}
public int getprestigeMul() {return prestigeMul;}
/**
* Creates a Building11 card with the specified era, price, prestige value,
@@ -50,7 +50,7 @@ public class Building11 extends BuildingCard {
effectType = EffectType.FINAL;
effectId = 11;
this.icon = icon;
this.PrestigeMul = prestigeMul;
this.prestigeMul = prestigeMul;
}
/**
@@ -69,7 +69,7 @@ public class Building11 extends BuildingCard {
effectType = EffectType.FINAL;
effectId = 11;
this.icon = icon;
this.PrestigeMul = prestigeMul;
this.prestigeMul = prestigeMul;
}
/**
@@ -79,7 +79,7 @@ public class Building11 extends BuildingCard {
*/
@Override
public BuildingCard clone() {
return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getPrestigeMul());
return new Building11(getIdIMG(),getEra(),getPrice(),getPrestigeValue(), getIcon(), getprestigeMul());
}
/**
@@ -94,7 +94,7 @@ public class Building11 extends BuildingCard {
public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException();
player.addPrestige(player.getNType(getIcon()) * this.getPrestigeMul());
player.addPrestige(player.getNType(getIcon()) * this.getprestigeMul());
}
/**
@@ -105,11 +105,11 @@ public class Building11 extends BuildingCard {
*/
@Override
public String toString() {
return super.toString() + "+" + this.icon.toString().substring(0, 3) + "×" + this.PrestigeMul;
return super.toString() + "+" + this.icon.toString().substring(0, 3) + "×" + this.prestigeMul;
}
@Override
public String toStringPlayer() {
return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.icon.toString().substring(0, 3) + "×" + this.PrestigeMul + ")";
return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.icon.toString().substring(0, 3) + "×" + this.prestigeMul + ")";
}
}
@@ -22,7 +22,7 @@ public abstract class TribeCard extends PlayableCard implements Serializable {
*
* @return {@code true} if this card is an event card, {@code false} otherwise.
*/
public boolean IsEventCard() {
public boolean isEventCard() {
return isEventCard;
}
@@ -76,17 +76,6 @@ public abstract class Character extends TribeCard implements Cloneable {
this.type = type;
}
/**
* Returns the string representation of this character card.
*
* @return the string representation of this character card.
*/
@Override
public String toString() {
return super.toString();
}
/**
* Returns a string representation of this {@code Character}. This specific variation is used in the {@code Game}'s
* toString to provide a more detailed version.
@@ -53,16 +53,6 @@ public class Artist extends Character {
super(idIMG,Era, CharacterType.ARTIST,nMin);
}
/**
* Returns the string representation of this Artist card.
*
* @return the string representation of this Artist card.
*/
@Override
public String toString() {
return super.toString();
}
/**
* Creates and returns a copy of this Artist card.
*
@@ -53,16 +53,6 @@ public class Gatherer extends Character {
super(idIMG,Era, CharacterType.GATHERER,nMin);
}
/**
* Returns the string representation of this Gatherer card.
*
* @return the string representation of this Gatherer card.
*/
@Override
public String toString() {
return super.toString();
}
/**
* Creates and returns a copy of this Gatherer card.
*
@@ -79,6 +69,7 @@ public class Gatherer extends Character {
*
* @param player the player who receives the card.
*/
@Override
public void insert(Player player) {
player.getGatherers().add(this);
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
@@ -4,7 +4,6 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList;
import java.lang.reflect.Array;
/**
* Abstract base class for all event cards.
@@ -21,31 +21,31 @@ public class CavePaintings extends EventCard {
* The minimum number of Artist cards required to avoid the prestige penalty.
* Also, the bottom number on the card.
*/
private int NLower;
private int nLower;
/**
* The amount of Prestige removed if the player has fewer Artist cards than {@code NLower}.
* The amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
*/
private int NPrestigeRem; // NPrestigeLower
private int nPrestigeRem; // NPrestigeLower
/**
* The Prestige multiplier applied if the player has at least {@code NLower} Artist cards.
* The Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
*/
private int NPrestigeMul; // NPrestigeUpper
private int nPrestigeMul; // NPrestigeUpper
/**
* Creates a CavePaintings event card with the specified era and effect parameters.
*
* @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.
* @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(int Era, int NLower, int NPrestigeRem, int NPrestigeMul) {
public CavePaintings(int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
super(Era, EventType.CAVE_PAINTINGS);
this.NLower = NLower;
this.NPrestigeRem = NPrestigeRem;
this.NPrestigeMul = NPrestigeMul;
this.nLower = nLower;
this.nPrestigeRem = nPrestigeRem;
this.nPrestigeMul = nPrestigeMul;
}
/**
@@ -53,15 +53,15 @@ public class CavePaintings extends EventCard {
*
* @param idIMG the image identifier of the CavePaintings event card.
* @param Era the era of the event card.
* @param NLower the minimum number of Artist cards required to avoid the prestige penalty.
* @param NPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code NLower}.
* @param NPrestigeMul the Prestige multiplier applied if the player has at least {@code NLower} Artist cards.
* @param 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) {
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;
this.nLower = nLower;
this.nPrestigeRem = nPrestigeRem;
this.nPrestigeMul = nPrestigeMul;
}
/**
@@ -69,8 +69,8 @@ public class CavePaintings extends EventCard {
* For each player, the number of Artist cards is computed together with the number
* of owned building cards having effect id equal to 9.
* The player gains Food equal to the number of such buildings multiplied by the number of Artist cards.
* If the player has fewer Artist cards than {@code NLower}, the player loses {@code NPrestigeRem} Prestige.
* Otherwise, the player gains Prestige equal to {@code NPrestigeMul} multiplied by the number of Artist cards.
* If the player has fewer Artist cards than {@code nLower}, the player loses {@code nPrestigeRem} Prestige.
* Otherwise, the player gains Prestige equal to {@code nPrestigeMul} multiplied by the number of Artist cards.
*
* @param playerList the list of players affected by the event.
*/
@@ -87,11 +87,11 @@ public class CavePaintings extends EventCard {
}
}
player.addFood(NBuildings * NArtists);
if (NArtists < NLower){
player.removePrestige(NPrestigeRem);
if (NArtists < nLower){
player.removePrestige(nPrestigeRem);
}
else{
player.addPrestige(NPrestigeMul * NArtists);
player.addPrestige(nPrestigeMul * NArtists);
}
}
}
@@ -104,20 +104,20 @@ public class CavePaintings extends EventCard {
@Override
public EventCard clone()
{
return new CavePaintings(getIdIMG(),getEra(), NLower, NPrestigeRem, NPrestigeMul) ;
return new CavePaintings(getIdIMG(),getEra(), nLower, nPrestigeRem, nPrestigeMul) ;
}
/**
* Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
* toString to print a more detailed version.
* <p>NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code NLower} is needed),
* <p>NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code nLower} is needed),
* however it's a parameter on the cards' design.
* </p>
* <p>Includes:
* <li>{@link #NLower}
* <li>{@link #nLower}
* <li>{@code NUpper}
* <li>{@link #NPrestigeRem}
* <li>{@link #NPrestigeMul}
* <li>{@link #nPrestigeRem}
* <li>{@link #nPrestigeMul}
* </p>
* @return {@code String} - a string representation of this {@code TribeCard}.
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
@@ -126,6 +126,6 @@ public class CavePaintings extends EventCard {
*/
@Override
public String toStringBoard() {
return super.toStringBoard()+" 0-"+(NLower-1)+":"+NPrestigeRem+" "+NLower+"+:"+NPrestigeMul;
return super.toStringBoard()+" 0-"+(nLower-1)+":"+nPrestigeRem+" "+nLower+"+:"+nPrestigeMul;
}
}
@@ -21,26 +21,26 @@ public class Sustenance extends EventCard {
/**
* The prestige penalty multiplier applied for each unpaid Food unit.
*/
private int PrestigeDebt;
private int prestigeDebt;
/**
* Returns the prestige penalty multiplier associated with this Sustenance event.
*
* @return the prestige penalty multiplier associated with this Sustenance event.
*/
public int getPrestigeDebt() {
return PrestigeDebt;
public int getprestigeDebt() {
return 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.
* @param prestigeDebt the prestige penalty multiplier for unpaid Food units.
*/
public Sustenance(int Era, int PrestigeDebt) {
public Sustenance(int Era, int prestigeDebt) {
super(Era, EventType.SUSTENANCE);
this.PrestigeDebt = PrestigeDebt;
this.prestigeDebt = prestigeDebt;
}
/**
@@ -48,11 +48,11 @@ public class Sustenance extends EventCard {
*
* @param idIMG the image identifier of the Sustenance event card.
* @param Era the era of the event card.
* @param PrestigeDebt the prestige penalty multiplier for unpaid Food units.
* @param prestigeDebt the prestige penalty multiplier for unpaid Food units.
*/
public Sustenance(String idIMG,int Era, int PrestigeDebt) {
public Sustenance(String idIMG,int Era, int prestigeDebt) {
super(idIMG,Era, EventType.SUSTENANCE);
this.PrestigeDebt = PrestigeDebt;
this.prestigeDebt = prestigeDebt;
}
/**
@@ -62,7 +62,7 @@ public class Sustenance extends EventCard {
* granted by owned building cards with effect id equal to 1.
* If the resulting Food debt is positive, the player must pay it with available Food.
* If the player does not have enough Food, all remaining Food is removed and the player
* loses Prestige equal to the unpaid Food debt multiplied by {@code PrestigeDebt}.
* loses Prestige equal to the unpaid Food debt multiplied by {@code prestigeDebt}.
* <b>This event is intended to be executed last among event effects.</b>
*
* @param playerList the list of players affected by the event.
@@ -94,7 +94,7 @@ public class Sustenance extends EventCard {
else{
FoodDebt -= player.getFoodValue();
player.removeFood(player.getFoodValue()); // player.getFoodValue() == 0
player.removePrestige(FoodDebt * PrestigeDebt);
player.removePrestige(FoodDebt * prestigeDebt);
}
}
}
@@ -106,14 +106,14 @@ public class Sustenance extends EventCard {
*/
@Override
public EventCard clone() {
return new Sustenance(getIdIMG(),getEra(), PrestigeDebt);
return new Sustenance(getIdIMG(),getEra(), prestigeDebt);
}
/**
* Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
* toString to print a more detailed version.
* <p>Includes:
* <li>{@link #PrestigeDebt}
* <li>{@link #prestigeDebt}
* </p>
* @return {@code String} - a string representation of this {@code TribeCard}.
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
@@ -122,6 +122,6 @@ public class Sustenance extends EventCard {
*/
@Override
public String toStringBoard() {
return super.toStringBoard()+" -1\uD83C\uDF56/-"+PrestigeDebt+"\uD83C\uDFC5";
return super.toStringBoard()+" -1\uD83C\uDF56/-"+prestigeDebt+"\uD83C\uDFC5";
}
}