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

namespace eagle.Notifications {
    public static class GameEndedNotificationGenerator {
        public static readonly NotificationGenerator Generator = GenerateNotification;

        private static IEnumerable<Notification> GenerateNotification(
                ActionResultView actionResultView,
                IGameModel currentModel) {
            var victor = actionResultView.GameStateDiff.NewVictor;
            var victorString = victor.HasValue ? currentModel.FactionName(victor.Value) : "Nobody";
            var victorHead =
                    currentModel
                            .Heroes[currentModel.MaybeDestroyedFaction(victor.Value).FactionHeadId];
            yield return new Notification(
                    title: "Game Over",
                    text: $"The game is over! {victorString} has won!",
                    provinceIds: null,
                    singleDisplayedHero: victorHead);
        }
    }
}
