Coverage Summary for Class: Hunt (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
| Hunt |
100%
(1/1)
|
100%
(6/6)
|
100%
(6/6)
|
100%
(18/18)
|
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 int 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);
}
/**
* Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
* toString to print a more detailed version.
* <p>includes:
* <li>{@link #prestigeMultiplier}
* </p>
* @return {@code String} - a string representation of this {@code TribeCard}.
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
* @see it.polimi.ingsw.gc14.Model.Game Game
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
*/
@Override
public String toStringBoard() {
return super.toStringBoard()+" 1\uD83C\uDF56+"+prestigeMultiplier+"\uD83C\uDFC5"+"×\uD83C\uDFF9";
}
}