Merge pull request #40 from rubenpirreram/JavaDOC-buildings

JavaDOC-buildings
This commit is contained in:
rubenpirreram
2026-04-22 16:06:14 +02:00
committed by GitHub
8 changed files with 125 additions and 15 deletions
Binary file not shown.
@@ -2,21 +2,33 @@ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist;
import it.polimi.ingsw.gc14.Model.Player;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import java.util.ArrayList;
import java.util.HashMap;
/**
* From the moment you buy this building, every time you complete a set of 6 different characters, you gain 5 food.
* Note: sets of characters already present before purchasing the building do not count.
*/
public class Building0 extends BuildingCard {
/**
* The purchased attribute is used to indicate whether the card has already been initialized.
*/
boolean purchased ;
/**
* The numSet attribute indicates how many complete sets the player has.
*/
private int numSet;
/**
* Constructor of the building
* @param era The game era of the building.
* @param price The price (in food) of the building.
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
*/
public Building0(int era,int price,int prestigeValue) {
super(era,price,prestigeValue);
effectType=EffectType.CARD_SET;
@@ -25,6 +37,11 @@ public class Building0 extends BuildingCard {
numSet = 0;
}
/**
* Method used to purchase the building. It also handles its initialization.
* @param player The player who buys the building.
* @return The outcome of the operation.
*/
@Override
public boolean buy(Player player)
{
@@ -34,6 +51,11 @@ public class Building0 extends BuildingCard {
return true;
}
/**
* Initializes the building by counting the number of complete sets at the moment of purchase.
* The building can only be initialized once.
* @param player The player who owns the building, whose cards are counted to determine the number of sets.
*/
public void initialize(Player player)
{
if(purchased)
@@ -49,10 +71,21 @@ public class Building0 extends BuildingCard {
purchased = true;
}
/**
* Method to clone the building: it creates an exact copy.
* @return The new copy of the building
*/
@Override
public BuildingCard clone() {
return new Building0(getEra(),getPrice(),getPrestigeValue());
}
/**
* Calculates the current number of card sets and subtracts the previous value (i.e., the number of newly obtained sets).
* The player gains an amount of food equal to 5 times this result.
* @param player The player who owns the building.
* @throws IllegalArgumentException thrown if the specified player does not own this card.
*/
@Override
public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.buildingCards.contains(this))
@@ -8,22 +8,43 @@ import it.polimi.ingsw.gc14.Model.Player;
import java.util.HashMap;
/**
* During the Sustenance Event, you have a discount of 1 food token on the total you
* would have to pay, for each of the indicated characters in your tribe.
*/
public class Building1 extends BuildingCard {
/**
* The icon attribute indicates the character type involved in the building effect.
*/
private CharacterType icon ;
/**
* @return The character type associated with this building effect.
*/
public CharacterType getIcon() {return icon;}
/**
* Constructor of the building.
* @param era The game era of the building.
* @param price The price (in food) of the building.
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
* @param icon The character type used by the building effect.
*/
public Building1(int era, int price,int prestigeValue, CharacterType icon) {
super(era,price,prestigeValue);
effectType = EffectType.ON_EVENT;
effectId = 1;
this.icon = icon;
}
/**
* Method to clone the building: it creates an exact copy.
* @return The new copy of the building.
*/
@Override
public BuildingCard clone() {
return new Building1(getEra(),getPrice(),getPrestigeValue(),getIcon());
}
@Override
public void applyEffect(Player player) {
};
}
@@ -57,4 +57,4 @@ public class Building10 extends BuildingCard {
player.addPrestige(6 * numSet);
}
}
}
@@ -65,4 +65,4 @@ public class Building11 extends BuildingCard {
throw new IllegalArgumentException();
player.addPrestige(player.getNType(getIcon()) * this.getPrestigeMul());
}
}
}
@@ -42,4 +42,4 @@ public class Building13 extends BuildingCard{
player.addPrestige(25);
}
}
}
@@ -2,22 +2,44 @@ package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.HashMap;
/**
* From the moment you purchase this building, every time you obtain a pair of identical inventors, you gain 3 food.
* This effect doesn't apply to already owned pairs at the time of purchase.
*/
public class Building4 extends BuildingCard {
/**
* The purchased attribute is used to indicate whether the card has already been initialized.
*/
boolean purchased ;
/**
* The numPair attribute indicates how many pairs of inventors the player has.
*/
int numPair;
/**
* Constructor of the building
* @param era The game era of the building.
* @param price The price (in food) of the building.
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
*/
public Building4(int era, int price,int prestigeValue) {
super(era,price,prestigeValue);
effectType= EffectType.INVENTOR_PAIR;
effectId=4;
}
/**
* Initializes the building by counting the number of pairs of inventors at the moment of purchase.
* The building can only be initialized once.
* @param player the player who owns the building, whose inventors are counted to determine the number of pairs.
*/
public void initialize(Player player)
{
if(purchased)
@@ -42,6 +64,11 @@ public class Building4 extends BuildingCard {
}
/**
* Method used to purchase the building. It also handles its initialization.
* @param player The player who buys the building.
* @return The outcome of the operation.
*/
@Override
public boolean buy(Player player)
{
@@ -51,10 +78,21 @@ public class Building4 extends BuildingCard {
return true;
}
/**
* Method to clone the building: it creates an exact copy.
* @return The new copy of the building.
*/
@Override
public BuildingCard clone() {
return new Building4(getEra(),getPrice(),getPrestigeValue());
}
/**
* Calculates the current number of pairs and subtracts the previous value (i.e., the number of newly obtained pairs).
* The player gains an amount of food equal to 3 times this result.
* @param player The player who owns the building.
* @throws IllegalArgumentException Thrown if the specified player does not own this card.
*/
@Override
public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.buildingCards.contains(this))
@@ -5,20 +5,38 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList;
import java.util.stream.Collectors;
/**
* At the end of the game, you gain double the Prestige Points indicated on the Builder cards in your tribe.
*/
public class Building8 extends BuildingCard {
/**
* Constructor of the building
* @param era The game era of the building.
* @param price The price (in food) of the building.
* @param prestigeValue The number of Prestige Points gained from this building at the end of the game.
*/
public Building8(int era, int price,int prestigeValue) {
super(era,price,prestigeValue);
effectType= EffectType.FINAL;
effectId=8;
}
/**
* Method to clone the building: it creates an exact copy.
* @return The new copy of the building.
*/
@Override
public BuildingCard clone() {
return new Building8(getEra(),getPrice(),getPrestigeValue());
}
/**
* For each builder in the player's hand, the player gains double the Prestige Point indicated on the builder card.
* @param player The player who owns the building.
* @throws IllegalArgumentException Thrown if the specified player does not own this building.
*/
@Override
public void applyEffect(Player player) throws IllegalArgumentException {
if(!player.buildingCards.contains(this))