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

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

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

        private static IEnumerable<Notification> GenerateNotifications(
                Net.Eagle0.Eagle.Common.Notification notification,
                IGameModel currentModel) {
            var note = notification.Details.PrisonerExchangeDetails;
            var hero1 = currentModel.Heroes[note.Hero1Id];
            var hero1Faction = currentModel.FactionName(note.Hero1FactionId);
            var hero2 = currentModel.Heroes[note.Hero2Id];
            var hero2Faction = currentModel.FactionName(note.Hero2FactionId);

            string noteTitle = "Prisoners Exchanged";
            string textTemplate =
                    $"{{Hero1}} ({hero1Faction}) and {{Hero2}} ({hero2Faction}) have agreed to a prisoner exchange.";

            var heroPlaceholders = new Dictionary<string, (string nameTextId, string fallback)> {
                { "Hero1", (hero1.NameTextId, "A hero") },
                { "Hero2", (hero2.NameTextId, "A hero") }
            };

            yield return new DynamicTextNotification(
                    title: noteTitle,
                    textTemplate: textTemplate,
                    heroPlaceholders: heroPlaceholders,
                    provinceIds: new List<
                            ProvinceId> { note.Hero1ProvinceId, note.Hero2ProvinceId },
                    displayedHeroes: new List<HeroView> { hero1, hero2 });
        }
    }
}