diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java index 15f09ad..465da3e 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java @@ -49,7 +49,8 @@ public class Game implements Serializable { } /** - * The current number of players. + * Returns the current number of players participating in the game. + * @return the current number of players. */ public int getCurrentPlayerNumber() { return playersList.size(); @@ -318,6 +319,18 @@ public class Game implements Serializable { return true; } + /** + * Skips the upper card draw for the specified player when no drawable cards are available. + * The operation succeeds only if the current game stage is {@code RESOLVING_ACTIONS}, + * the specified player is the current player, at least one upper draw is still available, + * and there are no drawable upper tribe cards (i.e. all remaining upper tribe cards are event cards) + * and no upper building cards that the player can afford. + * If successful, the upper draw counter is decremented. + * If both upper and lower draws become zero (or no cards remain drawable), the next player setup is triggered. + * + * @param player the player skipping the upper draw. + * @return {@code true} if the skip succeeds, {@code false} otherwise. + */ public boolean SkipUpperDrawing(Player player) { if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) { @@ -337,6 +350,18 @@ public class Game implements Serializable { return true; } + /** + * Skips the lower card draw for the specified player when no drawable cards are available. + * The operation succeeds only if the current game stage is {@code RESOLVING_ACTIONS}, + * the specified player is the current player, at least one lower draw is still available, + * and there are no drawable lower tribe cards (i.e. all remaining lower tribe cards are event cards) + * and no lower building cards that the player can afford. + * If successful, the lower draw counter is decremented. + * If both upper and lower draws become zero (or no cards remain drawable), the next player setup is triggered. + * + * @param player the player skipping the lower draw. + * @return {@code true} if the skip succeeds, {@code false} otherwise. + */ public boolean SkipLowerDrawing(Player player) { if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS) { @@ -696,13 +721,32 @@ public class Game implements Serializable { } return; - +/** + * Checks whether there are any drawable lower tribe cards on the board, + * i.e. lower tribe cards that are not event cards. + * + * @return {@code true} if at least one non-event lower tribe card is available, {@code false} otherwise. + */ } } + + /** + * Checks whether there are any drawable upper tribe cards on the board, + * i.e. upper tribe cards that are not event cards. + * + * @return {@code true} if at least one non-event upper tribe card is available, {@code false} otherwise. + */ private boolean hasDrawableUp() { return getUpperListTribeCards().stream().filter(x-> !x.IsEventCard()).count()!=0; } + + /** + * Checks whether there are any drawable lower tribe cards on the board, + * i.e. lower tribe cards that are not event cards. + * + * @return {@code true} if at least one non-event lower tribe card is available, {@code false} otherwise. + */ private boolean hasDrawableDown() { return getLowerListTribeCards().stream().filter(x-> !x.IsEventCard()).count()!=0; @@ -817,6 +861,14 @@ public class Game implements Serializable { public String toString() { return PlayersStamp()+"\n"+BoardStamp()+"\n"; } + + /** + * Returns a string representation of all the players currently in the game, + * arranged side by side in pairs. + * If the number of players is odd, the last player is printed on its own line. + * + * @return {@code String} - a string representation of all the players. + */ public String PlayersStamp() { StringBuilder stringBuilder=new StringBuilder(); @@ -832,6 +884,14 @@ public class Game implements Serializable { } return stringBuilder.toString(); } + + /** + * Returns a string representation of the board, including the current state, + * the offer track with slot assignments, the upper and lower tribe card lists, + * and the upper and lower building card lists. + * + * @return {@code String} - a string representation of the board. + */ public String BoardStamp() { var offerTrack = new AsciiTable(BorderStyle.UNICODE, slotMap.size());