Exemple #1
0
        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);
        }
Exemple #2
0
 public Universe(string name)
 {
     this.Name     = name;
     this.kingdoms = new List <Kingdom>();
     ruller        = NullKingdom.Instance;
     Construct();
 }
Exemple #3
0
 void IKingdom.AddAllie(IKingdom allie)
 {
     if (allie is Kingdom)
     {
         this.AddAllie(allie as Kingdom);
     }
 }
Exemple #4
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
                }
            }
        }
Exemple #8
0
 public void WillGiveSupportTests(string name, string emblem, string message, bool expectedResult)
 {
     IKingdom iceKingdom = KingdomFactory.CreateKingdom(name, emblem);
 }
Exemple #9
0
 public void RemoveAlly(IKingdom ally)
 {
     throw new System.NotImplementedException();
 }
Exemple #10
0
 public void AddAlly(IKingdom ally)
 {
 }
Exemple #11
0
 public Message(IKingdom sender, IKingdom reciever)
 {
     this.sender   = sender;
     this.reciever = reciever;
     this.content  = possibleMessages[new Random().Next(possibleMessages.Length)];
 }
Exemple #12
0
 public Message(IKingdom sender, IKingdom reciever, string content)
 {
     this.sender   = sender;
     this.reciever = reciever;
     this.content  = content;
 }
 public void AddAllie(IKingdom allie)
 {
 }
Exemple #14
0
 public void RemoveAlly(IKingdom ally)
 {
 }
Exemple #15
0
 public void SetRandomRuller(IRullerStrategy ballotSystem)
 {
     ruller = ballotSystem.FindWinner();
 }
Exemple #16
0
 public Universe(string name)
 {
     this.Name     = name;
     this.kingdoms = new HashSet <IKingdom>();
     this.ruler    = KingdomFactory.CreateKingdom(null, null);
 }
Exemple #17
0
 public void AddAllie(IKingdom friend)
 {
 }