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

namespace eagle.Notifications.ARNNotifications {
    public static class OutlawApprehendedDetailsNotificationGenerator {
        public static readonly ARNNotificationGenerator Generator = GenerateNotifications;

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

        private static IEnumerable<Notification> GenerateNotifications(
                Net.Eagle0.Eagle.Common.Notification notification,
                IGameModel currentModel) {
            var details = notification.Details.OutlawApprehendedDetails;
            var province = currentModel.Provinces[details.ProvinceId];
            var apprehended = currentModel.Heroes[details.ApprehendedHeroId];
            var apprehending = currentModel.Heroes[details.ApprehendingHeroId];

            string noteTitle = "Outlaw Apprehended";
            var textTemplate = DynamicTextTemplate.Parsed(
                    $"{DynamicTextTemplate.Placeholder(Placeholders.ApprehendingHero)} apprehended the outlaw {DynamicTextTemplate.Placeholder(Placeholders.ApprehendedHero)} in {province.Name}. The captured outlaw reflects:\n\n");

            var heroPlaceholders = new List<DynamicPlaceholder> {
                DynamicPlaceholder.HeroName(Placeholders.ApprehendedHero, apprehended, "an outlaw"),
                DynamicPlaceholder.HeroName(Placeholders.ApprehendingHero, apprehending, "a hero")
            };

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