Add: complete javadoc on model and network

This commit is contained in:
2026-06-09 21:30:51 +02:00
parent cbf6cb3c5b
commit c099847cbd
21 changed files with 135 additions and 29 deletions
@@ -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;
};
@@ -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);
}
}
@@ -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);
}
}
@@ -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;
};
}
@@ -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));
@@ -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);
}
@@ -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;
@@ -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.
*
* <p>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);
@@ -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<TribeCard> upperListTribeCards,ArrayList<TribeCard>lowerListTribeCards,ArrayList<BuildingCard> upperListBuildingCards,ArrayList<BuildingCard>lowerListBuildingCards) {
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<Slot, Player> 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<String> disconnectedPlayers){
this.disconnectedPlayers=disconnectedPlayers;
}