package Server.Cards;

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

public class EventCard extends Card {
    private final Event event;
    private final int firstValue;
    private final int secondValue;

    public EventCard(int cardId, int forMinPlayer, Era era, Event event, int firstValue, int secondValue) {
        super(cardId, forMinPlayer, era);
        this.event = event;
        this.firstValue = firstValue;
        this.secondValue = secondValue;
    }

    public Event getEvent() {
        return event;
    }
    public int getFirstValue() {
        return firstValue;
    }

    public int getSecondValue() {
        return secondValue;
    }

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

        if (!values[0].equals("E")) {
            throw new LoadingCardsException("Not an EventCard");
        }

        int cardId = Integer.parseInt(values[1]);
        int forMinPlayer = Integer.parseInt(values[2]);
        Era era = Era.valueOf(values[3]);
        Event event = Event.valueOf(values[4]);
        int firstValue = Integer.parseInt(values[5]);
        int secondValue = Integer.parseInt(values[6]);

        return new EventCard(cardId, forMinPlayer, era, event, firstValue, secondValue);
    }

    @Override
    public String toString() {
        return "EventCard{" +
                "event=" + event +
                ", firstValue=" + firstValue +
                ", secondValue=" + secondValue +
                '}';
    }
}
