private Dictionary <IKingdom, HashSet <IKingdom> > GetResults(HashSet <IMessage> messages) { Dictionary <IKingdom, HashSet <IKingdom> > results = new Dictionary <IKingdom, HashSet <IKingdom> >(); foreach (IKingdom kingdom in this.competingKingdoms) { results.Add(kingdom, new HashSet <IKingdom>()); } HashSet <IKingdom> votedKingdoms = new HashSet <IKingdom>(); foreach (IMessage message in messages) { IKingdom sender = message.Sender, reciever = message.Reciever; if (votedKingdoms.Contains(reciever)) { continue; } if (this.competingKingdoms.Contains(sender) && reciever.WillSupport(message.Content)) { votedKingdoms.Add(reciever); results[sender].Add(reciever); } } return(results); }
public Universe(string name) { this.Name = name; this.kingdoms = new List <Kingdom>(); ruller = NullKingdom.Instance; Construct(); }
void IKingdom.AddAllie(IKingdom allie) { if (allie is Kingdom) { this.AddAllie(allie as Kingdom); } }
public void AddAlly(IKingdom ally) { IKingdom allyToAdd = this.allies.FirstOrDefault(x => x.Name == ally.Name); if (allyToAdd is null) { this.allies.Add(ally); } }
public void SetUp() { var treasury = new Treasury(100); var economySettings = new EconomySettings { BaseFarmCost = Cost, BaseMarketplaceCost = Cost, BaseKnightCost = Cost, BaseArcherCost = Cost }; var economy = new Economy(economySettings); mockEndTurnCalculator = new Mock <IEndTurnCalculator>(); kingdom = new Kingdom(treasury, mockEndTurnCalculator.Object, economy); }
public static IKingdom CreateKingdom(string name, string emblem) { IKingdom kingdom = null; if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(emblem)) { kingdom = new NullKingdom(); } else { kingdom = new Kingdom(name, emblem); } return(kingdom); }
public Ballot(IKingdom competingKingdom, HashSet <IMessage> ballotBox) { this.electorate = new HashSet <IKingdom>(); this.competingKingdoms = new HashSet <IKingdom>(); this.competingKingdoms.Add(competingKingdom); this.winners = new Dictionary <IKingdom, HashSet <IKingdom> >(); this.result = new Dictionary <IKingdom, int>(); this.ballotBox = new HashSet <IMessage>(); this.ballotBox.UnionWith(ballotBox); foreach (IMessage message in ballotBox) { if (message.Sender.Equals(competingKingdom)) { this.electorate.Add(message.Reciever); } } }
public void WillGiveSupportTests(string name, string emblem, string message, bool expectedResult) { IKingdom iceKingdom = KingdomFactory.CreateKingdom(name, emblem); }
public void RemoveAlly(IKingdom ally) { throw new System.NotImplementedException(); }
public void AddAlly(IKingdom ally) { }
public Message(IKingdom sender, IKingdom reciever) { this.sender = sender; this.reciever = reciever; this.content = possibleMessages[new Random().Next(possibleMessages.Length)]; }
public Message(IKingdom sender, IKingdom reciever, string content) { this.sender = sender; this.reciever = reciever; this.content = content; }
public void AddAllie(IKingdom allie) { }
public void RemoveAlly(IKingdom ally) { }
public void SetRandomRuller(IRullerStrategy ballotSystem) { ruller = ballotSystem.FindWinner(); }
public Universe(string name) { this.Name = name; this.kingdoms = new HashSet <IKingdom>(); this.ruler = KingdomFactory.CreateKingdom(null, null); }
public void AddAllie(IKingdom friend) { }