Coverage Summary for Class: Hunt (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)

Class Class, % Method, % Branch, % Line, %
Hunt 100% (1/1) 100% (7/7) 100% (6/6) 100% (19/19)


 package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
 
 import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
 import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
 import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
 import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
 import it.polimi.ingsw.gc14.Model.Player;
 import java.util.ArrayList;
 
 /**
  * When activated, gives Food and Prestige Points to every player.
  *
  * @see EventCard
  */
 public class Hunt extends EventCard {
     /** Base food units granted per Hunter. Always 1; increased by Building 7. */
     private static final int BASE_FOOD_PER_HUNTER = 1;
 
     /** Prestige Points multiplier used during the event. */
     private final int prestigeMultiplier;
 
     /**Gets Prestige Points multiplier used during the event.
      * @return  int {@code PrestigeMultiplier}
      */
     int getPrestigeMultiplier() { return prestigeMultiplier; }
 
     /**
      * Creates a new Hunt event card.
      *
      * @param Era                      the era of the card
      * @param prestigeMultiplier    prestige points multiplicator used during the event
      */
     public Hunt(int Era, int prestigeMultiplier) {
         super(Era, EventType.HUNT);
         this.prestigeMultiplier = prestigeMultiplier;
     }
 
     /**
      * Creates a new Hunt event card.
      *
      * @param idIMG the image identifier of the Hunt event card.
      * @param Era the era of the card.
      * @param prestigeMultiplier the prestige points multiplier used during the event.
      */
     public Hunt(String idIMG, int Era, int prestigeMultiplier) {
         super(idIMG, Era, EventType.HUNT);
         this.prestigeMultiplier = prestigeMultiplier;
     }
 
     /**
      * Activates the event card "Hunt".
      * Each player gains Food and Prestige Points for each Hunter in their tribe,
      * multiplied by the respective multipliers (base food per hunter is 1).
      * Buildings influence:
      *      Building 7: adds 1 to both the food and prestige multiplier for each copy owned.
      *
      * @param playerList the list of all players in the game.
      */
     @Override
     public void activateEvent (ArrayList <Player> playerList){
         for (Player player : playerList) {
             int tmpFoodMultiplier = BASE_FOOD_PER_HUNTER;
             int tmpPrestigeMultiplier = prestigeMultiplier;
 
             ArrayList <BuildingCard> buildingList = player.getBuildingCards();
             int hunterCounter=player.getNType(CharacterType.HUNTER);
 
             for (BuildingCard buildingCard : buildingList) {
                 if (buildingCard.getEffectId() == 7) {
                     tmpFoodMultiplier++;
                     tmpPrestigeMultiplier++;
                 }
             }
 
             player.addFood(tmpFoodMultiplier * hunterCounter);
             player.addPrestige(tmpPrestigeMultiplier * hunterCounter);
         }
     }
 
     /**
      * Creates and returns a copy of this Hunt card.
      *
      * @return a new Hunt card with the same era and prestige multiplier
      */
     @Override
     public EventCard clone() {
         return new Hunt(getIdIMG(),getEra(), prestigeMultiplier);
     }
 
     @Override
     public String toStringPlayer() {
         return "HUNT";
     }
 
     @Override
     public String toStringBoard() {
         return "\033[38;5;180mHUNT 1\uD83C\uDF56+" + prestigeMultiplier + "\uD83C\uDFC5×\uD83C\uDFF9" + "\033[0m";
     }
 
 }