using System;
using System.Collections.Generic;
using Net.Eagle0.Eagle.Views;

namespace eagle.Notifications.ARNNotifications {
    using ProvinceId = Int32;

    public static class QuestFulfilledDetailsNotificationGenerator {
        public static readonly ARNNotificationGenerator Generator = GenerateNotifications;

        private static class Placeholders {
            public static readonly DynamicTextPlaceholderName QuestHero = new(nameof(QuestHero));
        }

        private static IEnumerable<Notification> GenerateNotifications(
                Net.Eagle0.Eagle.Common.Notification notification,
                IGameModel currentModel) {
            string noteTitle = "Quest Completed";

            var details = notification.Details.QuestFulfilled;
            var hero = currentModel.Heroes[details.HeroId];
            var province = currentModel.Provinces[details.ProvinceId];

            var textTemplate = DynamicTextTemplate.Parsed(
                    $"You completed a {DisplayNames.QuestTypeString(details.FulfilledQuest)} quest for {DynamicTextTemplate.Placeholder(Placeholders.QuestHero)} in {province.Name}.\n\n");

            var heroPlaceholders = new List<DynamicPlaceholder> {
                DynamicPlaceholder.HeroName(Placeholders.QuestHero, hero, "the hero")
            };

            yield return DynamicTextNotification.StreamingDynamicNotification(
                    title: noteTitle,
                    textTemplate: textTemplate,
                    placeholders: heroPlaceholders,
                    llmId: notification.LlmId,
                    provinceIds: new List<ProvinceId> { province.Id },
                    displayedHeroes: new List<HeroView> { hero });
        }
    }
}
