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 292e1a7..9ae8e89 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 @@ -2,13 +2,10 @@ 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. @@ -22,7 +19,7 @@ public class Building0 extends BuildingCard { boolean purchased ; /** - * The numSet attribute indicates how many complete sets the player already has. + * The numSet attribute indicates how many complete sets the player has. */ private int numSet; 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 33fa499..df86b6f 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 @@ -2,15 +2,26 @@ 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 when you purchase this Building, every time you obtain a pair of identical + * Inventors, you gain 3 Food. + * This effect doesn't apply on 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 Inventors pairs the player has. + */ int numPair; /** @@ -25,6 +36,11 @@ public class Building4 extends BuildingCard { effectId=4; } + /** + * Initializes the building by counting the number of Inventors pairs 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 pairs. + */ public void initialize(Player player) { if(purchased) @@ -72,7 +88,12 @@ public class Building4 extends BuildingCard { 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))