package com.yaohun.storyline.data;

import com.yaohun.storyline.util.PlaceholderUtil;
import me.Demon.DemonPlugin.DemonAPI;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

public class DialogueData {

    private int questID;
    private String npcName;
    private List<String> npcContent;
    private String playerContent;

    private String title;
    private String subtitle;

    public DialogueData(int questID, String npcName, List<String> npcContent, String playerContent, String title, String subtitle) {
        this.questID = questID;
        this.npcName = npcName;
        List<String> stringList = new ArrayList<>(npcContent);
        for (int i = 0; i < stringList.size(); i++) {
            String s = stringList.get(i);
            if (s.contains("{day}")) {
                stringList.set(i,s.replace("{day}",String.valueOf(getDateDiff("2019-10-25"))));
            }
        }
        this.npcContent = DemonAPI.replaceColorList(stringList);
        this.playerContent = playerContent;
        this.title = title;
        this.subtitle = subtitle;
    }

    public int getQuestID() {
        return questID;
    }

    public String getNpcName() {
        return npcName;
    }

    public String getPlayerContent() {
        return playerContent;
    }

    public List<String> getNpcContent() {
        return npcContent;
    }

    public String getTitle() {
        return title;
    }

    public String getSubtitle() {
        return subtitle;
    }

    private long getDateDiff(String format){
        LocalDate pastDate = LocalDate.parse(format);
        LocalDate now = LocalDate.now();
        return ChronoUnit.DAYS.between(pastDate, now);
    }
}
