From c2500292f08d5c00a237b67539930b6ee11da6f6 Mon Sep 17 00:00:00 2001 From: MatteoPellegrino05 Date: Sun, 19 Apr 2026 15:29:28 +0200 Subject: [PATCH 1/4] Add: Javadoc for Slot class --- .../java/it/polimi/ingsw/gc14/Model/Slot.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java b/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java index 083e9f9..4f41da4 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Slot.java @@ -1,26 +1,79 @@ package it.polimi.ingsw.gc14.Model; +/** + * Represents a slot with a specific identifier and associated values + * for upper cards, lower cards, food, and minimum number of players. + * The slot configuration depends on the specified slot identifier. + */ public class Slot { // Getters + + /** + * The identifier of this slot. + */ private char slotId; + + /** + * Returns the identifier of this slot. + * + * @return the identifier of this slot. + */ public char getSlotId() { return slotId; } + + /** + * The number of upper cards associated with this slot. + */ private int NUpper; + /** + * Returns the number of upper cards associated with this slot. + * + * @return the number of upper cards associated with this slot. + */ public int getNUpper(){ return NUpper; } + + /** + * The minimum number of players required for this slot. + */ private int nMinPlayer; + + /** + * Returns the minimum number of players required for this slot. + * + * @return the minimum number of players required for this slot. + */ public int getNMinPlayer() { return nMinPlayer; } + + /** + * The number of lower cards associated with this slot. + */ private int NLower; + + /** + * Returns the number of lower cards associated with this slot. + * + * @return the number of lower cards associated with this slot. + */ public int getNLower(){ return NLower; } + /** + * The amount of Food associated with this slot. + */ private int Food; + + /** + * Returns the amount of Food associated with this slot. + * + * @return the amount of Food associated with this slot. + */ public int getFood(){ return Food; } @@ -28,7 +81,17 @@ public class Slot { // Setters // End setters + // Constructors + + /** + * Creates a slot with the specified identifier. + * The slot values for Food, NLower, NUpper, and minimum number of players + * are determined by the given slot identifier. + * + * @param slotId the identifier of the slot. + * @throws IllegalArgumentException if the specified slot identifier is not valid. + */ public Slot(char slotId) throws IllegalArgumentException { this.slotId = slotId; @@ -78,6 +141,14 @@ public class Slot { } } + + /** + * Returns the string representation of this slot. + * The returned string includes the slot identifier, number of upper cards, + * number of lower cards, food value, and minimum number of players. + * + * @return the string representation of this slot. + */ @Override public String toString() { return ("SlotID: "+this.getSlotId()+"\nNUpper: "+this.getNUpper()+"\nNLower: "+this.getNLower()+"\nFood: "+this.getFood()+"\nNMinPlayer: "+this.getNMinPlayer()+"\n"); From ec9c236932e85153a166a9e61adfa1acbf216013 Mon Sep 17 00:00:00 2001 From: MatteoPellegrino05 Date: Sun, 19 Apr 2026 15:34:49 +0200 Subject: [PATCH 2/4] Add: Javadoc for PlayableCard class --- .../polimi/ingsw/gc14/Model/PlayableCard.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java index 7d3b418..6df2330 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/PlayableCard.java @@ -1,10 +1,31 @@ package it.polimi.ingsw.gc14.Model; +/** + * Abstract base class for all playable cards. + * A PlayableCard is characterized by an era value. + */ public abstract class PlayableCard { + + /** + * The era associated with this playable card. + */ private int Era; + + /** + * Returns the era of this playable card. + * + * @return the era of this playable card. + */ public int getEra(){ return Era; } + + /** + * 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 (int Era) throws IllegalArgumentException{ if (Era>0 && Era<4) { this.Era = Era; @@ -13,6 +34,11 @@ public abstract class PlayableCard { } } + /** + * Returns the string representation of this playable card. + * + * @return the string representation of this playable card. + */ @Override public String toString() { return "Era:"+String.valueOf(Era); From 9809a409a4bd099cee668901a36015aa90df533c Mon Sep 17 00:00:00 2001 From: MatteoPellegrino05 Date: Sun, 19 Apr 2026 15:45:14 +0200 Subject: [PATCH 3/4] Add: Javadoc for OrderLogicCard class --- .../ingsw/gc14/Model/OrderLogicCard.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java b/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java index cfb298d..52fbf2b 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/OrderLogicCard.java @@ -4,25 +4,75 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import java.util.*; +/** + * Abstract base class for all order logic cards. + * An OrderLogicCard manages a queue of players and defines the effects + * applied when players are pushed back into the queue. + */ public abstract class OrderLogicCard { + + /** + * The queue of players associated with this order logic card. + */ private Queue players; + + /** + * Creates an order logic card with the specified list of players. + * The input list is shuffled before being inserted into the queue. + * + * @param players the list of players associated with this order logic card. + */ public OrderLogicCard(ArrayList players) { Collections.shuffle(players); this.players = new LinkedList<>(players); } + + /** + * Applies the effect associated with the current queue position of the player + * and then adds the player to the end of the queue. + * + * @param player the player to be pushed into the queue. + */ public void push(Player player){ effect(player,players.size()); players.add(player); } + + /** + * Removes and returns the first player in the queue. + * + * @return the first player in the queue, or {@code null} if the queue is empty. + */ public Player pull(){ return players.poll(); } + + /** + * Returns the first player in the queue without removing it. + * + * @return the first player in the queue, or {@code null} if the queue is empty. + */ public Player getFirst() { return players.peek(); } + + /** + * Applies the effect associated with the specified player and queue position. + * + * @param player the player to whom the effect is applied. + * @param index the queue position index associated with the effect. + * @throws IndexOutOfBoundsException if the specified index is not valid. + */ protected abstract void effect(Player player, int index) throws IndexOutOfBoundsException; + /** + * Applies the building-related effect to the specified player. + * For each building card owned by the player with effect id equal to 3, + * the player gains 1 Food. + * + * @param player the player to whom the building effect is applied. + */ protected void buildingEffect(Player player) { for(BuildingCard b : player.buildingCards.stream().filter(x->x.getEffectId()==3).toList()) From e9e0bc7405c16fb37e8589934e523d3f5a40efcc Mon Sep 17 00:00:00 2001 From: MatteoPellegrino05 Date: Sun, 19 Apr 2026 16:02:03 +0200 Subject: [PATCH 4/4] Add: Javadoc for CurrentState class --- .../gc14/Model/GamePackage/CurrentState.java | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java index c1039b7..0d171f0 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/GamePackage/CurrentState.java @@ -4,39 +4,108 @@ import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Slot; import it.polimi.ingsw.gc14.Model.GamePackage.GameStages; +/** + * Represents the current state of the game. + * A CurrentState object stores the current player, slot, era, round, + * remaining upper and lower cards, and the current game stage. + */ public class CurrentState { // region Getters + + /** + * The current player associated with the game state. + */ private Player player; + + /** + * Returns the current player. + * + * @return the current player. + */ public Player getCurrentPlayer(){ return player; } + /** + * The current slot associated with the game state. + */ private Slot slot; + + /** + * Returns the current slot. + * + * @return the current slot. + */ public Slot getSlot(){ return slot; } + /** + * The current era of the game. + */ private int Era; + + /** + * Returns the current era of the game. + * + * @return the current era of the game. + */ public int getEra(){ return Era; } + /** + * The current round of the game. + */ private int round; + + /** + * Returns the current round of the game. + * + * @return the current round of the game. + */ public int getRound(){ return round; } + /** + * The number of upper cards currently available. + */ private int NUpper; + + /** + * Returns the number of upper cards currently available. + * + * @return the number of upper cards currently available. + */ public int getNUpper(){ return NUpper; } + /** + * The number of lower cards currently available. + */ private int NLower; + + /** + * Returns the number of lower cards currently available. + * + * @return the number of lower cards currently available. + */ public int getNLower(){ return NLower; } + /** + * The current stage of the game. + */ private GameStages GameStage; + + /** + * Returns the current stage of the game. + * + * @return the current stage of the game. + */ public GameStages getGameStage(){ return GameStage; } @@ -44,28 +113,52 @@ public class CurrentState { // endregion getters // region Setters + + /** + * Increments the current era by 1. + */ public void EraUpdate(){ Era++; } + /** + * Increments the current round by 1. + */ public void RoundUpdate(){ round++; } + /** + * Decrements the number of upper cards by 1. + */ public void UpperDrawn(){ NUpper--; } + /** + * Decrements the number of lower cards by 1. + */ public void LowerDrawn(){ NLower--; } + /** + * Updates the current game stage. + * + * @param GameStage the new game stage. + */ public void GameStageUpdate(GameStages GameStage){ this.GameStage = GameStage; } // endregion setters // region Constructors + + /** + * Creates a new CurrentState object with default initial values. + * The initial player and slot are {@code null}, the era and round are set to 1, + * the number of upper and lower cards is set to 0, and the game stage is set to {@code WAITING}. + */ public CurrentState(){ this.player = null; this.slot = null; @@ -78,6 +171,15 @@ public class CurrentState { // endregion constructors // region Functions + + /** + * Updates the current player and slot. + * If the specified slot is {@code null}, the numbers of upper and lower cards are both set to 0. + * Otherwise, the numbers of upper and lower cards are updated using the values of the specified slot. + * + * @param player the new current player. + * @param slot the new current slot. + */ public void PlayerUpdate(Player player, Slot slot){ this.player = player; this.slot = slot;