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 50a8fd9..292e1a7 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 @@ -10,13 +10,28 @@ 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 already 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 +40,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 +54,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 +74,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))