Class Building0

All Implemented Interfaces:
BuildingEffect, Serializable, Cloneable

public class Building0 extends BuildingCard
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 Details

    • FOOD_PER_CHARACTER_SET

      private static final int FOOD_PER_CHARACTER_SET
      Food units granted per newly completed character set.
      See Also:
    • purchased

      private boolean purchased
      Indicates whether the building effect has already been initialized after purchase.
    • numSet

      private int numSet
      Number of complete character sets already counted by this building effect.
  • Constructor Details

    • Building0

      public Building0(String idImage, int era, int price, int prestigeValue)
      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

      public boolean buy(Player player)
      Attempts to purchase the building and initializes its effect if the purchase succeeds.
      Overrides:
      buy in class BuildingCard
      Parameters:
      player - the player who attempts to buy the building.
      Returns:
      true if the building is successfully purchased and initialized, false otherwise.
    • initialize

      public void initialize(Player player)
      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

      public BuildingCard 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:
      clone in class BuildingCard
      Returns:
      a new building card with the same base properties.
    • applyEffect

      public void applyEffect(Player player) throws IllegalArgumentException
      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:
      applyEffect in class BuildingCard
      Parameters:
      player - the player who owns the building.
      Throws:
      IllegalArgumentException - if the specified player does not own this card.