package Server.Cards;

import Server.Era;
import Server.Player;

public class BuildingCard extends Card{
    private final int cost;
    private final int endPP;
    private final Trigger abilityTrigger;
    private final CharacterType effectTarget;
    private Player owner;

    public BuildingCard(int cardId, int forMinPlayer, Era era, int cost, int endPP, Trigger abilityTrigger,CharacterType characterType, Player owner) {
        super(cardId, forMinPlayer, era);
        this.cost = cost;
        this.endPP = endPP;
        this.abilityTrigger = abilityTrigger;
        this.effectTarget = characterType;
        this.owner = owner;
    }

    public BuildingCard(int cardId, int forMinPlayer, Era era, int cost, int endPP, Trigger abilityTrigger, CharacterType characterType) {
        super(cardId, forMinPlayer, era);
        this.cost = cost;
        this.endPP = endPP;
        this.abilityTrigger = abilityTrigger;
        this.effectTarget = characterType;
        this.owner = null;
    }

    public BuildingCard(int cardId, int forMinPlayer, Era era, int cost, int endPP, Trigger abilityTrigger) {
        super(cardId, forMinPlayer, era);
        this.cost = cost;
        this.endPP = endPP;
        this.abilityTrigger = abilityTrigger;
        this.effectTarget = null;
        this.owner = null;
    }

    public void setOwner(Player owner) {
        this.owner = owner;
    }

    public int getCost() {
        return cost;
    }

    public int getEndPP() {
        return endPP;
    }

    public Trigger getAbilityTrigger() {
        return abilityTrigger;
    }

    public Player getOwner() {
        return owner;
    }

    public CharacterType getEffectTarget() {
        return effectTarget;
    }

    public static BuildingCard parsRow(String row) {
        String cleanRow = row.trim();
        String[] values = cleanRow.split(";");

        int cardId = Integer.parseInt(values[1]);
        int forMinPlayer = Integer.parseInt(values[2]);
        Era era = Era.valueOf(values[3]);
        int cost = Integer.parseInt(values[4]);
        int endPP = Integer.parseInt(values[5]);
        Trigger abilityTrigger = Trigger.valueOf(values[6]);
        /* MANCA LA COLONNA 8 nel CSV
        if(abilityTrigger == Trigger.SUSTAIN_DISCOUNT || abilityTrigger == Trigger.ENDGAME_BONUS_CHARACTER){
            CharacterType effectTarget = CharacterType.valueOf(values[7]);
            return new BuildingCard(cardId, forMinPlayer, era, cost, endPP, abilityTrigger,  effectTarget);
        }
        */


        return new BuildingCard(cardId, forMinPlayer, era, cost, endPP, abilityTrigger);
    }
}
