Fix: public access now are private with setter/getter

This commit is contained in:
2026-06-09 21:06:51 +02:00
parent 3318801913
commit cbf6cb3c5b
43 changed files with 351 additions and 336 deletions
@@ -24,7 +24,7 @@ public class Player implements Serializable {
* Identifier for the {@code Player} when displaying the game through the GUI.
* @see Totems
*/
public Totems totem;
private Totems totem;
// region Getters
/**
@@ -42,6 +42,10 @@ public class Player implements Serializable {
return UserName;
}
public Totems getTotem() {
return totem;
}
/**
* Counts the total {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character Character Cards}
* the player currently possesses.
@@ -69,40 +73,21 @@ public class Player implements Serializable {
case GATHERER -> gatherers.size();
};
}
/**
* The List containing all {@link BuildingCard Building Cards} the player currently possesses.
*/
public ArrayList <BuildingCard> buildingCards;
private ArrayList<BuildingCard> buildingCards;
private ArrayList<Artist> artists;
private ArrayList<Builder> builders;
private ArrayList<Inventor> inventors;
private ArrayList<Gatherer> gatherers;
private ArrayList<Shaman> shamans;
private ArrayList<Hunter> hunters;
/**
* The List containing all {@link Artist Artist Character Cards} the player currently possesses.
*/
public ArrayList <Artist> artists;
/**
* The List containing all {@link Builder Builder Character Cards} the player currently possesses.
*/
public ArrayList <Builder> builders;
/**
* The List containing all {@link Inventor Inventor Character Cards} the player currently possesses.
*/
public ArrayList <Inventor> inventors;
/**
* The List containing all {@link Gatherer Gatherer Character Cards} the player currently possesses.
*/
public ArrayList <Gatherer> gatherers;
/**
* The List containing all {@link Shaman Shaman Character Cards} the player currently possesses.
*/
public ArrayList <Shaman> shamans;
/**
* The List containing all {@link Hunter Hunter Character Cards} the player currently possesses.
*/
public ArrayList <Hunter> hunters;
public ArrayList<BuildingCard> getBuildingCards() { return buildingCards; }
public ArrayList<Artist> getArtists() { return artists; }
public ArrayList<Builder> getBuilders() { return builders; }
public ArrayList<Inventor> getInventors() { return inventors; }
public ArrayList<Gatherer> getGatherers() { return gatherers; }
public ArrayList<Shaman> getShamans() { return shamans; }
public ArrayList<Hunter> getHunters() { return hunters; }
/**
* The current amount of {@code Food} the Player possesses.
@@ -147,6 +132,10 @@ public class Player implements Serializable {
this.FoodValue += Value;
}
public void setTotem(Totems totem) {
this.totem = totem;
}
/**
* Removes {@code Value} amount of {@code Food} from the Player.
* Note: {@link #FoodValue} cannot be negative, so the method returns
@@ -231,6 +220,19 @@ public class Player implements Serializable {
// endregion constructors
// region Functions
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Player)) return false;
return UserName.equals(((Player) obj).UserName);
}
@Override
public int hashCode() {
return UserName.hashCode();
}
/**
* Prints the {@code Player}'s attributes for the {@code Board}'s representation.
* Uses the {@code UNICODE} border style.