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

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

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

        private static IEnumerable<Notification> GenerateNotifications(
                Net.Eagle0.Eagle.Common.Notification notification,
                IGameModel currentModel) {
            var details = notification.Details.VassalExiledDetails;
            var province = currentModel.Provinces[details.ProvinceId];
            var factionName = currentModel.FactionName(details.FactionId);
            var exiledHero = currentModel.Heroes[details.ExiledHeroId];
            var factionHead =
                    currentModel.Heroes[currentModel.MaybeDestroyedFaction(details.FactionId)
                                                .FactionHeadId];

            string noteTitle = "Vassal Exiled";
            string textTemplate =
                    $"{factionName} sent {{ExiledHero}} into exile from {province.Name}\n\n";

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

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