Coverage Summary for Class: Building8 (it.polimi.ingsw.gc14.Model.Cards.Building.Effects)

Class Class, % Method, % Branch, % Line, %
Building8 100% (1/1) 100% (4/4) 100% (4/4) 100% (11/11)


 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.Builder;
 import it.polimi.ingsw.gc14.Model.Player;
 
 
 /**
  * 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;
     }
 
     /**
      * Constructor of the building.
      *
      * @param idIMG the image identifier 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(String idIMG,int era, int price,int prestigeValue) {
         super(idIMG,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(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
     }
 
     /**
      * Applies the building effect by granting additional Prestige Points equal to
      * the Prestige Value of each Builder card owned by the player.
      *
      * <p>This effectively doubles the contribution of Builder cards to the final score.
      *
      * @param player The player who owns the building.
      * @throws IllegalArgumentException Thrown if the specified player does not own this building.
      */
     public void applyEffect(Player player) throws IllegalArgumentException {
         if(!player.getBuildingCards().contains(this))
             throw new IllegalArgumentException();
         for (Builder builder : player.getBuilders()) {
             player.addPrestige(builder.getPrestigeValue());
         }
     }
 
 }