Coverage Summary for Class: Hunter (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)

Class Class, % Method, % Branch, % Line, %
Hunter 100% (1/1) 100% (9/9) 100% (6/6) 100% (16/16)


 package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
 
 import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
 import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
 import it.polimi.ingsw.gc14.Model.Player;
 
 /**
  * Represents a Hunter character card.
  *
  * <p>A Hunter is a specific type of {@link Character} initialized with
  * {@link CharacterType#HUNTER}.
  */
 public class Hunter extends Character {
 
     /**
      * Describes whether the {@code Hunter Icon} is present or not. Whenever an
      * {@code Hunter} with an {@code Hunter Icon} is added to the tribe, 1 {@code Food token} is awarded for each Hunter in the tribe
      * (with or without an icon).
      */
     private final boolean icon;
 
     /**
      * Returns whether this Hunter card has the icon.
      *
      * @return {@code true} if this Hunter card has the icon, {@code false} otherwise.
      */
     public boolean getIcon() {
         return icon;
     }
 
     /**
      * Creates a Hunter character card with the specified era and icon value.
      *
      * @param Era the era of the Hunter card.
      * @param icon the icon value of the Hunter card.
      */
     public Hunter(int Era, boolean icon) {
         super(Era, CharacterType.HUNTER);
         this.icon = icon;
     }
 
     /**
      * Creates a Hunter character card with the specified era, icon value,
      * and minimum number of players.
      *
      * @param Era the era of the Hunter card.
      * @param icon the icon value of the Hunter card.
      * @param nMin the minimum number of players required for the card.
      */
     public Hunter(int Era, boolean icon, int nMin) {
         super(Era, CharacterType.HUNTER,nMin);
         this.icon = icon;
     }
 
     /**
      * Creates a Hunter character card with the specified image id, era and icon value.
      *
      * @param idIMG the image identifier of the Hunter card.
      * @param Era the era of the Hunter card.
      * @param icon the icon value of the Hunter card.
      */
     public Hunter(String idIMG,int Era, boolean icon) {
         super(idIMG,Era, CharacterType.HUNTER);
         this.icon = icon;
     }
 
     /**
      * Creates a Hunter character card with the specified image id, era, icon value,
      * and minimum number of players.
      *
      * @param idIMG the image identifier of the Hunter card.
      * @param Era the era of the Hunter card.
      * @param icon the icon value of the Hunter card.
      * @param nMin the minimum number of players required for the card.
      */
     public Hunter(String idIMG,int Era, boolean icon, int nMin) {
         super(idIMG,Era, CharacterType.HUNTER,nMin);
         this.icon = icon;
     }
 
     @Override
     public String toStringPlayer() {
         return this.icon ? "\uD83C\uDF56" : "";
     }
 
     @Override
     public String toStringBoard() {
         return "HUNTER" + (this.icon ? " \uD83C\uDF56" : "");
     }
 
     /**
      * Creates and returns a copy of this Hunter card.
      *
      * @return a clone of this Hunter card.
      */
     @Override
     public Character clone() {
         return new Hunter(getIdIMG(),getEra(), getIcon(), getNMin());
     }
 
     /**
      * Inserts this Hunter card into the specified player's Hunter collection.
      *
      * <p>If this card has the Hunter icon, the player gains 1 food for each
      * Hunter currently in their tribe. The method also applies any building
      * effects triggered by character set completion.
      *
      * @param player the player who receives the card.
      */
     @Override
     public void insert(Player player) {
         player.getHunters().add(this);
         if(this.getIcon()){
             player.addFood(player.getHunters().size());
         }
         player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
     }
 
 }