Esempio n. 1
0
        public static VoteInfo GetVoteInfo(this Vote vote, IEnumerable<Player> players)
        {
            VoteInfo result = new VoteInfo
            {
                VoterFactionName = string.Empty,
                TargetAllegiance = Allegiance.Unknown,
                TargetFactionName = string.Empty,
            };

            var voter = players.FirstOrDefault(p => p.Name == vote.Voter);
            if (voter == null)
            {
                return result;
            }

            var voterRecruitment = DetermineRecruitment(voter, vote.ForumPostNumber);
            result.VoterFactionName = voterRecruitment.FactionName;
            result.VoterFactionAllegiance = voterRecruitment.Allegiance;

            var recipient = players.FirstOrDefault(p => p.Name == vote.Recipient);
            if (recipient == null)
            {
                return result;
            }

            var recruitment = DetermineRecruitment(recipient, vote.ForumPostNumber);

            result.TargetAllegiance = recruitment.Allegiance;
            result.TargetFactionName = recruitment.FactionName;

            return result;
        }