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

Class Class, % Method, % Branch, % Line, %
Building10 100% (1/1) 100% (4/4) 100% (6/6) 100% (14/14)


 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.CharacterType;
 import it.polimi.ingsw.gc14.Model.Player;
 
 
 /**
  * At the end of the game, the player gains 6 Prestige Points
  * for each complete set of character types in their tribe.
  *
  * <p>A complete set contains one character card of each {@link CharacterType}.
  */
 public class Building10 extends BuildingCard {
 
     /** Prestige points granted per complete character set at end of game. */
     private static final int PRESTIGE_PER_CHARACTER_SET = 6;
 
     /**
      * Creates a Building10 card with the specified era, price, and prestige value.
      *
      * @param era the era of the building card.
      * @param price the price of the building card.
      * @param prestigeValue the prestige value of the building card.
      */
     public Building10(int era, int price,int prestigeValue) {
         super(era,price,prestigeValue);
         effectType= EffectType.FINAL;
         effectId=10;
     }
 
     /**
      * Creates a Building10 card with the specified image id, era, price, and prestige value.
      *
      * @param idIMG the image identifier of the building card.
      * @param era the era of the building card.
      * @param price the price of the building card.
      * @param prestigeValue the prestige value of the building card.
      */
     public Building10(String idIMG,int era, int price,int prestigeValue) {
         super(idIMG,era,price,prestigeValue);
         effectType= EffectType.FINAL;
         effectId=10;
     }
 
     /**
      * Creates and returns a copy of this Building10 card.
      *
      * @return a clone of this Building10 card.
      */
     @Override
     public BuildingCard clone() {
         return new Building10(getIdIMG(),getEra(),getPrice(),getPrestigeValue());
     }
 
     /**
      * Applies the effect of this building card to the specified player.
      *
      * <p>The effect grants 6 Prestige Points for each complete set of character
      * cards owned by the player, where a complete set contains one card of each
      * {@link CharacterType}.
      *
      * @param player the player to whom the effect is applied.
      * @throws IllegalArgumentException if the player does not own this building card.
      */
     public void applyEffect(Player player) throws IllegalArgumentException {
         if(!player.getBuildingCards().contains(this))
             throw new IllegalArgumentException();
         int numSet=player.getNType(CharacterType.INVENTOR);
         for(CharacterType type : CharacterType.values())
         {
             if(player.getNType(type)<=numSet)
                 numSet=player.getNType(type);
         }
 
         player.addPrestige(PRESTIGE_PER_CHARACTER_SET * numSet);
     }
 
 }