using Net.Eagle0.Eagle.Views;

namespace eagle.Notifications.ARNNotifications {
    public static class VictimHeroDescription {
        public static string WithFactionLeaderPlaceholder(
                FactionView victimFaction,
                HeroView hero,
                DynamicTextPlaceholderName heroName,
                DynamicTextPlaceholderName victimFactionLeader) {
            if (IsFactionHead(victimFaction, hero)) {
                return $"faction leader {DynamicTextTemplate.Placeholder(heroName)}";
            }

            if (victimFaction.Leaders.Contains(hero.Id)) {
                return $"{DynamicTextTemplate.Placeholder(victimFactionLeader)}'s sworn {DisplayNames.SiblingDescription(hero.PronounGender)} {DynamicTextTemplate.Placeholder(heroName)}";
            }

            return $"{DynamicTextTemplate.Placeholder(victimFactionLeader)}'s hero {DynamicTextTemplate.Placeholder(heroName)}";
        }

        public static string WithResolvedFactionName(
                FactionView victimFaction,
                HeroView hero,
                IGameModel currentModel,
                DynamicTextPlaceholderName heroName) {
            if (IsFactionHead(victimFaction, hero)) {
                return $"faction leader {DynamicTextTemplate.Placeholder(heroName)}";
            }

            var factionName = DisplayNames.ResolvedFactionString(victimFaction, currentModel);
            if (victimFaction.Leaders.Contains(hero.Id)) {
                return $"{factionName}'s sworn {DisplayNames.SiblingDescription(hero.PronounGender)} {DynamicTextTemplate.Placeholder(heroName)}";
            }

            return $"{factionName}'s hero {DynamicTextTemplate.Placeholder(heroName)}";
        }

        public static bool UsesFactionLeaderPlaceholder(FactionView victimFaction, HeroView hero) {
            return !IsFactionHead(victimFaction, hero);
        }

        private static bool IsFactionHead(FactionView victimFaction, HeroView hero) {
            return victimFaction.FactionHeadId == hero.Id;
        }
    }
}
