using System.Collections.Generic;
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 factionName = currentModel.FactionName(details.FactionId);
            var factionHead =
                    currentModel.Heroes[currentModel.MaybeDestroyedFaction(details.FactionId)
                                                .FactionHeadId];
            var apprehended = currentModel.Heroes[details.ApprehendedHeroId];

            string noteTitle = "Outlaw Apprehended";
            string textTemplate =
                    $"{factionName} apprehended the outlaw {{ApprehendedHero}} in {province.Name}.";

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

            yield return new DynamicTextNotification(
                    title: noteTitle,
                    textTemplate: textTemplate,
                    heroPlaceholders: heroPlaceholders,
                    singleProvinceId: details.ProvinceId,
                    displayedHeroes: new List<HeroView> { factionHead, apprehended });
        }
    }
}