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;

import java.util.HashMap;

public class Building10 extends BuildingCard {

    /**
     * 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 and returns a copy of this Building10 card.
     *
     * @return a clone of this Building10 card.
     */
    @Override
    public BuildingCard clone() {
        return new Building10(getEra(),getPrice(),getPrestigeValue());
    }

    /**
     * Applies the effect of this building card to the specified player.
     * 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.
     */
    @Override
    public void applyEffect(Player player) throws IllegalArgumentException {
        if(!player.buildingCards.contains(this))
            throw new IllegalArgumentException();
        HashMap<CharacterType,Integer> map = new HashMap<CharacterType,Integer>();

        int numSet=player.getNType(CharacterType.INVENTOR);
        for(CharacterType type : CharacterType.values())
        {
            if(player.getNType(type)<=numSet)
                numSet=player.getNType(type);
        }

        player.addPrestige(6 * numSet);
    }

}