Class Building0
java.lang.Object
it.polimi.ingsw.gc14.Model.PlayableCard
it.polimi.ingsw.gc14.Model.Cards.BuildingCard
it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building0
- All Implemented Interfaces:
BuildingEffect, Serializable, Cloneable
Building effect that grants 5 food for each new complete set of
6 different character types obtained after purchasing this building.
Character sets already completed before the building is purchased are stored during initialization and do not provide food.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intFood units granted per newly completed character set.private intNumber of complete character sets already counted by this building effect.private booleanIndicates whether the building effect has already been initialized after purchase.Fields inherited from class BuildingCard
effectId, effectType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyEffect(Player player) Applies the building effect to the specified player.booleanAttempts to purchase the building and initializes its effect if the purchase succeeds.clone()Creates a new building instance with the same configuration values as this card.voidinitialize(Player player) Initializes the building effect by storing the number of complete character sets already owned by the player at the moment of purchase.Methods inherited from class BuildingCard
getEffectId, getEffectType, getPrestigeValue, getPrice, toStringBoard, toStringPlayerMethods inherited from class PlayableCard
getEra, getIdIMG
-
Field Details
-
FOOD_PER_CHARACTER_SET
private static final int FOOD_PER_CHARACTER_SETFood units granted per newly completed character set.- See Also:
-
purchased
private boolean purchasedIndicates whether the building effect has already been initialized after purchase. -
numSet
private int numSetNumber of complete character sets already counted by this building effect.
-
-
Constructor Details
-
Building0
Creates a building with the specified image identifier, era, price and prestige value.- Parameters:
idImage- the image identifier of the building.era- the game era of the building.price- the price in food of the building.prestigeValue- the number of Prestige Points granted by this building at the end of the game.
-
Building0
public Building0(int era, int price, int prestigeValue) Creates a building with the specified era, price and prestige value.- Parameters:
era- the game era of the building.price- the price in food of the building.prestigeValue- the number of Prestige Points granted by this building at the end of the game.
-
-
Method Details
-
buy
Attempts to purchase the building and initializes its effect if the purchase succeeds.- Overrides:
buyin classBuildingCard- Parameters:
player- the player who attempts to buy the building.- Returns:
trueif the building is successfully purchased and initialized,falseotherwise.
-
initialize
Initializes the building effect by storing the number of complete character sets already owned by the player at the moment of purchase.The initialization is performed only once.
- Parameters:
player- the player who owns the building.
-
clone
Creates a new building instance with the same configuration values as this card.The runtime state of the effect, such as initialization status and counted character sets, is not copied.
- Overrides:
clonein classBuildingCard- Returns:
- a new building card with the same base properties.
-
applyEffect
Applies the building effect to the specified player.The method counts the complete character sets currently owned by the player and grants 5 food for each set completed since the last stored value.
- Overrides:
applyEffectin classBuildingCard- Parameters:
player- the player who owns the building.- Throws:
IllegalArgumentException- if the specified player does not own this card.
-