diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java
index 85cdfef..600c685 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building0.java
@@ -16,6 +16,9 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
*/
public class Building0 extends BuildingCard {
+ /** Food units granted per newly completed character set. */
+ private static final int FOOD_PER_CHARACTER_SET = 5;
+
/**
* Indicates whether the building effect has already been initialized
* after purchase.
@@ -138,7 +141,7 @@ public class Building0 extends BuildingCard {
{
return;
}
- player.addFood(5*(min_temp-numSet));
+ player.addFood(FOOD_PER_CHARACTER_SET *(min_temp-numSet));
numSet=min_temp;
};
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java
index 9348039..4c71355 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building10.java
@@ -15,6 +15,9 @@ import java.util.HashMap;
*/
public class Building10 extends BuildingCard {
+ /** Prestige points granted per complete character set at end of game. */
+ private static final int PRESTIGE_PER_CHARACTER_SET = 6;
+
/**
* Creates a Building10 card with the specified era, price, and prestige value.
*
@@ -75,7 +78,7 @@ public class Building10 extends BuildingCard {
numSet=player.getNType(type);
}
- player.addPrestige(6 * numSet);
+ player.addPrestige(PRESTIGE_PER_CHARACTER_SET * numSet);
}
}
\ No newline at end of file
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java
index c2167cb..4a5f977 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building13.java
@@ -10,6 +10,9 @@ import it.polimi.ingsw.gc14.Model.Player;
*/
public class Building13 extends BuildingCard{
+ /** Prestige points granted at end of game by this building. */
+ private static final int PRESTIGE_AWARD = 25;
+
/**
* Creates a Building13 card with the specified era, price, and prestige value.
*
@@ -58,7 +61,7 @@ public class Building13 extends BuildingCard{
public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.getBuildingCards().contains(this))
throw new IllegalArgumentException();
- player.addPrestige(25);
+ player.addPrestige(PRESTIGE_AWARD);
}
}
\ No newline at end of file
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java
index 15d0564..92fde36 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/Building/Effects/Building4.java
@@ -16,6 +16,9 @@ import java.util.HashMap;
*/
public class Building4 extends BuildingCard {
+ /** Food units granted per newly completed inventor pair. */
+ private static final int FOOD_PER_INVENTOR_PAIR = 3;
+
/**
* Indicates whether the building effect has already been initialized
* after purchase.
@@ -149,7 +152,7 @@ public class Building4 extends BuildingCard {
{
return;
}
- player.addFood(3*(temp-numPair));
+ player.addFood(FOOD_PER_INVENTOR_PAIR *(temp-numPair));
numPair = temp;
};
}
\ No newline at end of file
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java
index 52e4a84..aab81f5 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Characters/Builder.java
@@ -174,6 +174,7 @@ public class Builder extends Character {
*
* @param player the player who receives the card.
*/
+ @Override
public void insert(Player player) {
player.getBuilders().add(this);
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java
index 0ae6559..3e1544c 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java
@@ -15,6 +15,9 @@ import java.util.stream.Collectors;
* @see EventCard
*/
public class ShamanicRitual extends EventCard {
+ /** Bonus shaman icons granted per Building 5 owned during this event. */
+ private static final int BUILDING5_BONUS_ICONS = 3;
+
/** Prestige points awarded to the player with the most shaman icons. */
int prestigeToAdd;
@@ -73,7 +76,7 @@ public class ShamanicRitual extends EventCard {
tmpIcons = player.getShamans().stream().mapToInt(sh -> sh.getIcon()).sum();
tmpCount = (int) player.getBuildingCards().stream().filter(b -> b.getEffectId() == 5).count();
if (tmpCount >= 1) {
- tmpIcons = tmpIcons+(3*tmpCount);
+ tmpIcons = tmpIcons+(BUILDING5_BONUS_ICONS *tmpCount);
}
playerMap.put(player, tmpIcons);
}
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java
index d3d720b..7761805 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Sustenance.java
@@ -15,6 +15,9 @@ import java.util.ArrayList;
*/
public class Sustenance extends EventCard {
+ /** Food units covered by each Gatherer during the Sustenance event. */
+ private static final int FOOD_PER_GATHERER = 3;
+
/**
* The prestige penalty multiplier applied for each unpaid Food unit.
*/
@@ -80,7 +83,7 @@ public class Sustenance extends EventCard {
}
- int FoodDebt = NChar - (3 * NGatherers + NCharDiscount);
+ int FoodDebt = NChar - (FOOD_PER_GATHERER * NGatherers + NCharDiscount);
if(FoodDebt <= 0){
continue;
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 9ed6403..95ab655 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/Game.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/Game.java
@@ -471,7 +471,6 @@ public class Game implements Serializable {
* @param player the player performing the draw.
* @param cardIndex the index of the upper tribe card to draw.
* @return {@code true} if the draw succeeds, {@code false} otherwise.
- * TODO
*/
public boolean DrawUpperTribeCardByIndex(Player player,int cardIndex) {
if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
@@ -801,7 +800,14 @@ public class Game implements Serializable {
}
}
}
- //TODO
+ /**
+ * Transitions the game to the optional card phase or directly to the next round.
+ *
+ *
Builds a queue of non-disconnected players who own Building 12 (optional card effect).
+ * If such players exist, the first one is set as the current player for their optional action.
+ * Otherwise, if the round counter is below 10, the next round begins and the game stage
+ * is set to {@link GameStages#SLOT_CHOICE}; if round 10 has been completed, the game ends.
+ */
private synchronized void transitionToOptionalOrNextRound() {
currentState.GameStageUpdate(GameStages.OPT_CARD_E);
diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java b/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java
index 857fd51..30fa66a 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Model/MiniModel.java
@@ -62,7 +62,14 @@ public class MiniModel implements Serializable {
public MiniModel() {
}
- //TODO
+ /**
+ * Constructs a mini model with only the card lists populated.
+ *
+ * @param upperListTribeCards the upper row of tribe cards on the board.
+ * @param lowerListTribeCards the lower row of tribe cards on the board.
+ * @param upperListBuildingCards the upper row of building cards on the board.
+ * @param lowerListBuildingCards the lower row of building cards on the board.
+ */
public MiniModel(ArrayList upperListTribeCards,ArrayListlowerListTribeCards,ArrayList upperListBuildingCards,ArrayListlowerListBuildingCards) {
this.upperListTribeCards = upperListTribeCards;
this.lowerListTribeCards = lowerListTribeCards;
@@ -74,12 +81,16 @@ public class MiniModel implements Serializable {
/**
* Constructs a complete mini model from the current server-side game data.
*
- *TODO
- * @param slotPlayerMap the map associating occupied slots with players.
- * @param orderLogicCard the card managing player turn order.
- * @param currentState the current state of the game.
- * @param players the list of players in the match.
- * @param availableTotems the list of totems still available for selection.
+ * @param slotPlayerMap the map associating occupied slots with players.
+ * @param orderLogicCard the card managing player turn order.
+ * @param currentState the current state of the game.
+ * @param players the list of players in the match.
+ * @param availableTotems the list of totems still available for selection.
+ * @param upperListTribeCards the upper row of tribe cards on the board.
+ * @param lowerListTribeCards the lower row of tribe cards on the board.
+ * @param upperListBuildingCards the upper row of building cards on the board.
+ * @param lowerListBuildingCards the lower row of building cards on the board.
+ * @param disconnectedPlayers the list of usernames of currently disconnected players.
*/
public MiniModel(Map slotPlayerMap,
OrderLogicCard orderLogicCard,
@@ -101,7 +112,11 @@ public class MiniModel implements Serializable {
setPlayers(players);
}
- //TODO
+ /**
+ * Sets the last network event applied to the game state.
+ *
+ * @param lastEvent the most recent event received from the server.
+ */
public void setLastEvent(NetworkEvent lastEvent) {
this.lastEvent = lastEvent;
}
@@ -193,7 +208,11 @@ public class MiniModel implements Serializable {
return -1;
}
- //TODO
+ /**
+ * Sets the list of usernames of currently disconnected players.
+ *
+ * @param disconnectedPlayers the list of disconnected player usernames.
+ */
public void setDisconnectedPlayers (ArrayList disconnectedPlayers){
this.disconnectedPlayers=disconnectedPlayers;
}
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/IClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/IClient.java
index 977dbc5..cb0fbca 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/IClient.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/IClient.java
@@ -73,6 +73,6 @@ public interface IClient {
*/
void totemChoice(String playerUsername, String totem);
- //TODO
+ /** Notifies the server of a voluntary disconnection and closes the connection. */
void notifyDisconnection();
}
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java
index 10aa56f..b633813 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/AddPlayer.java
@@ -48,7 +48,13 @@ public class AddPlayer extends NetworkEvent implements Serializable {
return gameController.addPlayer(username);
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, updating players,
+ * turn order, game state, and slot map.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DisconnectedPlayer.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DisconnectedPlayer.java
index 8afb21d..0878eec 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DisconnectedPlayer.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DisconnectedPlayer.java
@@ -47,7 +47,13 @@ public class DisconnectedPlayer extends NetworkEvent implements Serializable{
return gameController.disconnectedPlayer(username);
}
- //TODO
+ /**
+ * Applies this disconnection event to the client-side mini model,
+ * updating player data, turn order, game state, and disconnected player list.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java
index cd54cf5..458189a 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerBuildingCard.java
@@ -37,7 +37,13 @@ public class DrawLowerBuildingCard extends NetworkEvent implements Serializable
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, removing the drawn card
+ * from the lower building list and updating players, turn order, game state, and slot map.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java
index 820ecf4..a651265 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawLowerTribeCard.java
@@ -36,7 +36,13 @@ public class DrawLowerTribeCard extends NetworkEvent implements Serializable{
public boolean apply(GameController gameController){
return gameController.drawLowerTribeCard(username, pos);
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, removing the drawn card
+ * from the lower tribe list and updating players, turn order, game state, and slot map.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java
index 69f68b3..1cfd378 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperBuildingCard.java
@@ -37,7 +37,13 @@ public class DrawUpperBuildingCard extends NetworkEvent implements Serializable
return gameController.drawUpperBuildingCard(username, pos);
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, removing the drawn card
+ * from the upper building list and updating players, turn order, game state, and slot map.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java
index 1324cb0..a7b82a3 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/DrawUpperTribeCard.java
@@ -36,7 +36,13 @@ public class DrawUpperTribeCard extends NetworkEvent implements Serializable{
public boolean apply(GameController gameController){
return gameController.drawUpperTribeCard(username, pos);
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, removing the drawn card
+ * from the upper tribe list and updating players, turn order, game state, and slot map.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipTurn.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipTurn.java
index 312c6ce..a36e818 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipTurn.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SkipTurn.java
@@ -31,7 +31,13 @@ public class SkipTurn extends NetworkEvent implements Serializable{
return gameController.skipTurn(username);
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, updating players,
+ * turn order, game state, and slot map after a skip turn action.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java
index e2a7f7e..6a5d714 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/NetworkEvents/SlotChoice.java
@@ -37,7 +37,13 @@ public class SlotChoice extends NetworkEvent implements Serializable {
return gameController.slotChoice(username, pos);
}
- //TODO
+ /**
+ * Applies this event to the client-side mini model, updating players,
+ * turn order, game state, and slot map after a slot selection.
+ *
+ * @param miniModel the client-side model to update.
+ * @return {@code false} if the event is marked as an error; {@code true} otherwise.
+ */
@Override
public boolean apply(MiniModel miniModel){
synchronized (miniModel) {
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java
index a1f9c9e..94e6a90 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Client/RMIClient.java
@@ -228,7 +228,12 @@ public class RMIClient implements IClient {
System.out.println("Error during remote slot choice");
}
}
- //TODO
+ /**
+ * Sends a totem choice to the server for the specified player via RMI.
+ *
+ * @param playerUsername the username of the player choosing the totem.
+ * @param totem the name of the chosen totem.
+ */
public void totemChoice(String playerUsername,String totem) {
try{
stub.totemChoice(playerUsername,totem);
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java
index 35e8a3f..f35e572 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java
@@ -287,11 +287,20 @@ public class TCPClient implements IClient {
}
}
- //TODO
+ /**
+ * Sends a totem choice event to the server for the specified player.
+ *
+ * @param playerUsername the username of the player choosing the totem.
+ * @param totems the name of the chosen totem.
+ */
public void totemChoice(String playerUsername,String totems) {
doEvent(new TotemChoice(playerUsername,totems));
}
+ /**
+ * Notifies the server of a voluntary disconnection by sending a sentinel value
+ * on the heartbeat channel, then closes the connection.
+ */
public void notifyDisconnection()
{
synchronized (heartbeatOut)
diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java
index ed811a5..1688d40 100644
--- a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java
+++ b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Server/ClientHandler.java
@@ -48,7 +48,7 @@ public class ClientHandler implements Runnable {
*/
List clientHandlers;
- //TODO
+ /** Maps each connected player's username to their connection state (true = connected). */
LimitedMap limitedMap;
/** Queue containing the events to be applied to the game model */