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;
    }

    /**
     * Method to clone the building: it creates an exact copy.
     * @return The new copy of the building.
     */
    @Override
    public BuildingCard clone() {
        return new Building8(getEra(),getPrice(),getPrestigeValue());
    }

    /**
     * For each builder in the player's hand, the player gains double the Prestige Point indicated on the builder card.
     * @param player The player who owns the building.
     * @throws IllegalArgumentException Thrown if the specified player does not own this building.
     */
    @Override
    public void applyEffect(Player player) throws IllegalArgumentException {
        if(!player.buildingCards.contains(this))
            throw new IllegalArgumentException();
        for (Builder builder : player.builders) {
            player.addPrestige(builder.getPrestigeValue() * 2);
        }
    }

}
