package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;

import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist;
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;

public class CavePaintings extends EventCard {
    private int NLower;
    private int NPrestigeRem; // NPrestigeLower
    private int NPrestigeMul; // NPrestigeUpper
    public CavePaintings(int Era, int NLower, int NPrestigeRem, int NPrestigeMul) {
        super(Era, EventType.CAVE_PAINTINGS);
        this.NLower = NLower;
        this.NPrestigeRem = NPrestigeRem;
        this.NPrestigeMul = NPrestigeMul;
    }

    @Override
    public void activateEvent (ArrayList <Player> playerList){
        for (Player player : playerList){
            int NArtists = player.getNType(CharacterType.ARTIST);
            int NBuildings = 0;
            ArrayList<BuildingCard> buildingCards = player.buildingCards;

            for(BuildingCard card : buildingCards){
                if(card.getEffectId() == 9){
                    NBuildings++;
                }
            }
            player.addFood(NBuildings * NArtists);
            if (NArtists < NLower){
                player.removePrestige(NPrestigeRem);
            }
            else{
                player.addPrestige(NPrestigeMul * NArtists);
            }
        }
    }
}
