Exemplo n.º 1
0
 public void AddMessageToBallot(Kingdom sender, Kingdom receiver, string message)
 {
     if (!CompetingKingdom.Contains(receiver))
     {
         BallotBox.Add(BallotMessage.Create(sender, receiver, message));
     }
 }
Exemplo n.º 2
0
        public Kingdom GetKingdomWithMaxAllies()
        {
            Kingdom kingdom = CompetingKingdom
                              .OrderByDescending(x => x.GetAlliesCount())
                              .First();

            return(kingdom);
        }
Exemplo n.º 3
0
        private IEnumerable <IGrouping <int, Kingdom> > GetTiedQuery()
        {
            IEnumerable <IGrouping <int, Kingdom> > tiedQuery = CompetingKingdom
                                                                .Where(x => x.GetAlliesCount() > 0)
                                                                .GroupBy(x => x.GetAlliesCount())
                                                                .Where(x => x.Count() > 1);

            return(tiedQuery);
        }
Exemplo n.º 4
0
 public void ReElectionSetup()
 {
     Round++;
     if (IsTie())
     {
         CompetingKingdom = GetTiedQuery().OrderByDescending(x => x.Key).First().ToList();
     }
     CompetingKingdom.ForEach(Kingdom => Kingdom.ClearAllies());
     BallotBox.Clear();
 }
Exemplo n.º 5
0
        public void RecordRoundsResult()
        {
            string        round   = string.Format("Results after round {0} ballot count", Round.ToWords());
            List <string> results = new List <string>();

            CompetingKingdom.ForEach(Kingdom =>
            {
                results.Add(string.Format("Allies for {0} : {1}", Kingdom.Name, Kingdom.GetAlliesCount()));
            });
            RoundResults.Add(round, results);
        }