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

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

        private static IEnumerable<Notification> GenerateNotifications(
                Net.Eagle0.Eagle.Common.Notification notification,
                IGameModel currentModel) {
            var details = notification.Details.SwearBrotherhoodDetails;
            var factionName = currentModel.FactionName(details.FactionId);
            var newBrother = currentModel.Heroes[details.NewBrotherHeroId];

            var factionHeadId = currentModel.MaybeDestroyedFaction(details.FactionId).FactionHeadId;
            var factionHead = currentModel.Heroes[factionHeadId];

            var affectedProvinces = currentModel.ProvincesForFaction(details.FactionId);

            string textTemplate =
                    $"{{NewBrother}} has sworn brotherhood with {factionName}'s leader {{FactionHead}}.\n\n";

            var heroPlaceholders = new Dictionary<string, (string nameTextId, string fallback)> {
                { "NewBrother", (newBrother.NameTextId, "A hero") },
                { "FactionHead", (factionHead.NameTextId, "the leader") }
            };

            yield return DynamicTextNotification.StreamingDynamicNotification(
                    title: "Swore Brotherhood",
                    textTemplate: textTemplate,
                    heroPlaceholders: heroPlaceholders,
                    llmId: notification.LlmId,
                    provinceIds: affectedProvinces,
                    displayedHeroes: new List<HeroView> { newBrother, factionHead });
        }
    }
}