Fix: minor bug

This commit is contained in:
2026-06-12 20:18:51 +02:00
parent 053f0048bc
commit 9a931bfc1b
21 changed files with 268 additions and 274 deletions
@@ -34,14 +34,14 @@ public class Player implements Serializable {
* exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
* when the {@link #Player(String) constructor} is called.
*/
private final String UserName;
private final String userName;
/**
* Getter for the private attribute {@link #UserName}.
* Getter for the private attribute {@link #userName}.
* @return {@code String} - The UserName
*/
public String getUserName() {
return UserName;
return userName;
}
/**
@@ -107,27 +107,27 @@ public class Player implements Serializable {
* The current amount of {@code Food} the Player possesses.
* Cannot be negative.
*/
private int FoodValue;
private int foodValue;
/**
* Getter for the private attribute {@link #FoodValue}.
* Getter for the private attribute {@link #foodValue}.
* @return {@code int} - The amount of Food the player possesses.
*/
public int getFoodValue() {
return FoodValue;
return foodValue;
}
/**
* The current amount of {@code Prestige} the Player possesses.
*/
private int PrestigeValue;
private int prestigeValue;
/**
* Getter for the private attribute {@link #PrestigeValue}.
* Getter for the private attribute {@link #prestigeValue}.
* @return {@code int} - The amount of Prestige the Player possesses.
*/
public int getPrestigeValue() {
return PrestigeValue;
return prestigeValue;
}
// endregion getters
@@ -136,14 +136,14 @@ public class Player implements Serializable {
/**
* Adds {@code Value} amount of {@code Food} to the Player.
* @param Value The amount of {@code Food} to be added.
* @param value The amount of {@code Food} to be added.
* Should be positive for expected results
* (otherwise the method will subtract the absolute
* value of {@code Value}).
* @see #FoodValue
* @see #foodValue
*/
public void addFood(int Value){
this.FoodValue += Value;
public void addFood(int value){
this.foodValue += value;
}
/**
@@ -157,50 +157,50 @@ public class Player implements Serializable {
/**
* Removes {@code Value} amount of {@code Food} from the Player.
* Note: {@link #FoodValue} cannot be negative, so the method returns
* Note: {@link #foodValue} cannot be negative, so the method returns
* {@code false} if {@code Value} is greater than the amount of {@code Food}
* the Player possesses, and {@code true} otherwise.
*
* @param Value The amount of {@code Food} to be removed.
* @param value The amount of {@code Food} to be removed.
* Should be positive for expected results
* (otherwise the method will add the absolute
* value of {@code Value}).
* @return {@code Boolean} - {@code true} if the Food is successfully removed,
* {@code false} otherwise.
* @see #FoodValue
* @see #foodValue
*/
public Boolean removeFood(int Value){
if(Value > this.FoodValue){
public Boolean removeFood(int value){
if(value > this.foodValue){
return false;
}
this.FoodValue -= Value;
this.foodValue -= value;
return true;
}
/**
* Adds {@code Value} amount of {@code Prestige} to the Player.
* @param Value The amount of {@code Prestige} to be added.
* @param value The amount of {@code Prestige} to be added.
* Should be positive for expected results
* (otherwise the method will subtract the absolute
* value of {@code Value}).
* @see #PrestigeValue
* @see #prestigeValue
*/
public void addPrestige(int Value){
public void addPrestige(int value){
this.PrestigeValue += Value;
this.prestigeValue += value;
}
/**
* Removes {@code Value} amount of {@code Prestige} to the Player.
* @param Value The amount of {@code Prestige} to be removed.
* @param value The amount of {@code Prestige} to be removed.
* Should be positive for expected results
* (otherwise the method will add the absolute
* value of {@code Value}).
* @see #PrestigeValue
* @see #prestigeValue
*/
public void removePrestige(int Value){
public void removePrestige(int value){
this.PrestigeValue -= Value;
this.prestigeValue -= value;
}
// endregion setters
@@ -208,21 +208,21 @@ public class Player implements Serializable {
// region Constructors
/**
* Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #UserName}.
* Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #userName}.
*
* @param UserName Unique String identifier for a Player.
* @param userName Unique String identifier for a Player.
* @throws IllegalArgumentException when {@code UserName} is empty or exceeds {@link #MAX_VALUE},
* with message:
* <pre>{@code UserName is empty or exceeds maximum permitted length.}</pre>
*
* @see #UserName
* @see #userName
* @see #MAX_VALUE
*/
public Player(String UserName) throws IllegalArgumentException {
if(UserName.isEmpty() || UserName.length() > MAX_VALUE) {
public Player(String userName) throws IllegalArgumentException {
if(userName.isEmpty() || userName.length() > MAX_VALUE) {
throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length.");
}
this.UserName = UserName;
this.userName = userName;
this.inventors = new ArrayList <>();
this.builders = new ArrayList <>();
@@ -232,8 +232,8 @@ public class Player implements Serializable {
this.artists = new ArrayList<>();
this.buildingCards = new ArrayList<>();
this.FoodValue = 0;
this.PrestigeValue = 0;
this.foodValue = 0;
this.prestigeValue = 0;
this.totem = null;
}
// endregion constructors
@@ -244,20 +244,20 @@ public class Player implements Serializable {
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Player)) return false;
return UserName.equals(((Player) obj).UserName);
return userName.equals(((Player) obj).userName);
}
@Override
public int hashCode() {
return UserName.hashCode();
return userName.hashCode();
}
/**
* Prints the {@code Player}'s attributes for the {@code Board}'s representation.
* Uses the {@code UNICODE} border style.
* <p><b>Includes:</b>
* <li>{@link #FoodValue Food}
* <li>{@link #PrestigeValue Prestige}
* <li>{@link #foodValue Food}
* <li>{@link #prestigeValue Prestige}
* <li>{@link #artists Artists}
* <li>{@link #builders Builders}
* <li>{@link #gatherers Gatherers}
@@ -271,7 +271,7 @@ public class Player implements Serializable {
*/
@Override
public String toString() {
int Last = -1;
int last = -1;
var table = new AsciiTable(ROUNDED, 1);
@@ -280,55 +280,55 @@ public class Player implements Serializable {
table.addSeparator();
if(!this.hunters.isEmpty()){
Last = 6;
last = 6;
}
else if(!this.inventors.isEmpty()){
Last = 5;
last = 5;
}
else if(!this.shamans.isEmpty()){
Last = 4;
last = 4;
}
else if(!this.gatherers.isEmpty()){
Last = 3;
last = 3;
}
else if(!this.builders.isEmpty()){
Last = 2;
last = 2;
}
else if(!this.artists.isEmpty()){
Last = 1;
last = 1;
}
else{
Last = 0;
last = 0;
}
if(Last == 0){
if(last == 0){
table.addSeparator();
}
table.addRow("CHARACTERS");
if(!this.artists.isEmpty()){
table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size());
if(Last == 1){
if(last == 1){
table.addSeparator();
}
}
if(!this.builders.isEmpty()){
table.addRow(this.builders.size() + " Builders: " + "\uD83D\uDD28:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());
if(Last == 2){
if(last == 2){
table.addSeparator();
}
}
if(!this.gatherers.isEmpty()){
table.addRow(this.gatherers.size() + " Gatherers: -\uD83E\uDD57:" + 3*this.gatherers.size());
if(Last == 3){
if(last == 3){
table.addSeparator();
}
}
if(!this.shamans.isEmpty()){
table.addRow(this.shamans.size() + " Shamans: " + "\uD83C\uDF1F:" + this.shamans.stream().mapToInt(Shaman::getIcon).sum());
if(Last == 4){
if(last == 4){
table.addSeparator();
}
}
@@ -336,14 +336,14 @@ public class Player implements Serializable {
if(!this.inventors.isEmpty()){
table.addRow(this.inventors.size() + " Inventors: " + this.inventors.stream()
.collect(Collectors.groupingBy(
Inventor::Icon,
Inventor::getIcon,
Collectors.counting()
))
.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(e -> e.getKey() + ":" + e.getValue())
.collect(Collectors.joining(", ")));
if(Last == 5){
if(last == 5){
table.addSeparator();
}
}