Fix and complete JavaDoc comments

This commit is contained in:
MatteoPellegrino05
2026-05-06 16:59:18 +02:00
parent b40ed99bc1
commit 51718699a3
35 changed files with 390 additions and 54 deletions
@@ -28,12 +28,20 @@ import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
*/
public class Game implements Serializable {
/**
* List of observers registered to receive updates when the game state changes.
*
* <p>The list is marked as {@code transient} because observers should not be
* serialized with the game model.
*/
private transient List<Observer> observers = new ArrayList<>(); // transient! non serializzare
public void addObserver(Observer observer) {
observers.add(observer);
}
private void notifyObservers() {
for (Observer o : observers) {
o.update(this);
@@ -42,7 +50,8 @@ public class Game implements Serializable {
/**
* Returns the list of players participating in the game.
* @return
*
* @return a copy of the list of players currently participating in the game.
*/
public List<Player> getPlayers() {
return playersList;
@@ -149,6 +158,7 @@ public class Game implements Serializable {
*
* @param Username the username of the player to search for.
* @return the player with the specified username, or {@code null} if no such player exists.
* @throws IndexOutOfBoundsException if an index access error occurs.
*/
public Player getPlayerByUsername(String Username) throws IndexOutOfBoundsException {
return playersList.stream().filter(x->x.getUserName().equals(Username)).findFirst().orElse(null);