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

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

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

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

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

            string textTemplate =
                    $"You failed to complete a {DisplayNames.QuestTypeString(details.FailedQuest)} quest for {{QuestHero}} in {province.Name}.\n\n";

            var heroPlaceholders = new Dictionary<string, (string nameTextId, string fallback)> {
                { "QuestHero", (hero.NameTextId, "the hero") }
            };

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