public void AddMessageToBallot(Kingdom sender, Kingdom receiver, string message) { if (!CompetingKingdom.Contains(receiver)) { BallotBox.Add(BallotMessage.Create(sender, receiver, message)); } }
public Kingdom GetKingdomWithMaxAllies() { Kingdom kingdom = CompetingKingdom .OrderByDescending(x => x.GetAlliesCount()) .First(); return(kingdom); }
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); }
public void ReElectionSetup() { Round++; if (IsTie()) { CompetingKingdom = GetTiedQuery().OrderByDescending(x => x.Key).First().ToList(); } CompetingKingdom.ForEach(Kingdom => Kingdom.ClearAllies()); BallotBox.Clear(); }
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); }