package thb.jeanluc.adventure.io.text;

/** Renders a {@link QuestView} as styled text for the console quest log. */
public final class QuestText {

    private QuestText() {
    }

    public static StyledText render(QuestView view) {
        if (view.active().isEmpty() && view.completed().isEmpty()) {
            return StyledText.of("You have no quests yet.");
        }
        StyledText.Builder b = StyledText.builder();
        b.heading("QUESTS");
        if (view.active().isEmpty()) {
            b.plain("\n").dim("  (none active)");
        }
        for (QuestEntry e : view.active()) {
            b.plain("\n").heading(e.title()).plain("\n").exit("  -> ").plain(e.objective());
        }
        if (!view.completed().isEmpty()) {
            b.plain("\n\n").dim("Completed:");
            for (String t : view.completed()) {
                b.plain("\n").dim("  ✓ " + t);
            }
        }
        return b.build();
    }
}
