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

namespace eagle.Notifications {
    using HeroId = Int32;

    public static class RiotAvertedNotificationGenerator {
        public static readonly NotificationGenerator Generator = GenerateNotification;

        private static IEnumerable<Notification> GenerateNotification(
                ActionResultView actionResultView,
                IGameModel currentModel) {
            var province = currentModel.Provinces[actionResultView.Province.Value];
            HeroView leader = null;
            if (province.FullInfo != null && province.FullInfo.RulingHeroId is HeroId rulingHid) {
                leader = currentModel.Heroes[rulingHid];
            }
            string noteTitle = "Riot Averted";
            string noteText = $"We seem to have calmed the people down in {province.Name}.";

            yield return new Notification(
                    title: noteTitle,
                    text: noteText,
                    singleProvinceId: province.Id,
                    singleDisplayedHero: leader);
        }
    }
}