package Server.Cards;

import Server.Era;
import Server.Utils.LoadingCardsException;

public class CharacterCard extends Card{
    private final CharacterType characterType;
    private final int iconValue;
    private final int prestigePoints;

    public CharacterCard(int cardId, int forMinPlayer, Era era, CharacterType characterType, int iconValue, int prestigePoints) {
        super(cardId, forMinPlayer, era);
        this.characterType = characterType;
        this.iconValue = iconValue;
        this.prestigePoints = prestigePoints;
    }

    public CharacterType getCharacterType() {
        return characterType;
    }

    public int getIconValue() {
        return iconValue;
    }

    public int getPrestigePoints() {
        return prestigePoints;
    }

    public static CharacterCard parsRow(String row){

                String cleanRow = row.trim();
                String[] values = cleanRow.split(";");

                if(!values[0].equals("C")){
                    throw new LoadingCardsException("Not a character card");
                }

                int cardId = Integer.parseInt(values[1]);
                int forMinPlayer = Integer.parseInt(values[2]);
                Era era = Era.valueOf(values[3]);
                CharacterType characterType = CharacterType.valueOf(values[4]);
                int iconValue = Integer.parseInt(values[5]);
                int prestigePoints = Integer.parseInt(values[6]);

                return new CharacterCard(cardId, forMinPlayer, era, characterType, iconValue, prestigePoints);

    }

    @Override
    public String toString() {
        return "CharacterCard{" +
                "characterType=" + characterType +
                ", value=" + iconValue +
                ", points=" + prestigePoints +
                '}';
    }
}
