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 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";
            string textTemplate =
                    $"{{ApprehendingHero}} apprehended the outlaw {{ApprehendedHero}} in {province.Name}. The captured outlaw reflects:\n\n";

            var heroPlaceholders = new Dictionary<string, (string nameTextId, string fallback)> {
                { "ApprehendedHero", (apprehended.NameTextId, "an outlaw") },
                { "ApprehendingHero", (apprehending.NameTextId, "a hero") }
            };

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