Example #1
0
        public void RequestBot(Team team, AiHero hero, Difficulty difficulty, IBotRule rule, int minPlayersOnTeam,
                               int maxPlayersOnTeam)
        {
            BotRequest newRequest = new BotRequest(team, hero, difficulty, rule, minPlayersOnTeam, maxPlayersOnTeam);

            _botRequests.Requests.Add(newRequest);
        }
Example #2
0
 public void AddBot(AiHero hero, Difficulty difficulty, Team team)
 {
     if (_slots.Empty.Count(team) > 0)
     {
         _modifiedFlag.Flag();
         _deltin.AddAi(hero, difficulty, team);
     }
 }
Example #3
0
        public void InitTooLargeMax()
        {
            Team       team       = Team.Blue;
            AiHero     hero       = AiHero.Ana;
            Difficulty difficulty = Difficulty.Medium;
            IBotRule   rule       = new BotRuleEqualTeams();
            int        min        = 0;
            int        max        = 6;

            new BotRequest(team, hero, difficulty, rule, min, max);
        }
Example #4
0
        public void InitMinGreaterThanMax()
        {
            Team       team       = Team.Blue;
            AiHero     hero       = AiHero.Ana;
            Difficulty difficulty = Difficulty.Medium;
            IBotRule   rule       = new BotRuleEqualTeams();
            int        min        = 4;
            int        max        = 3;

            new BotRequest(team, hero, difficulty, rule, min, max);
        }
Example #5
0
        public void TestWhenNoTeamSpecifiedThenRequestAddedForDifferentTeams()
        {
            BotRequests  requests   = new BotRequests();
            BotRequester sut        = new BotRequester(requests);
            AiHero       hero       = AiHero.Reaper;
            Difficulty   difficulty = Difficulty.Hard;
            IBotRule     rule       = new BotRuleBothTeams();

            sut.RequestBot(hero, difficulty, rule);

            Assert.AreNotEqual(requests.Requests[0].BotTeam, requests.Requests[1].BotTeam);
        }
Example #6
0
        public void TestWhenNoTeamSpecifiedThenRequestAddedToBothTeams()
        {
            BotRequests  requests   = new BotRequests();
            BotRequester sut        = new BotRequester(requests);
            AiHero       hero       = AiHero.Reaper;
            Difficulty   difficulty = Difficulty.Hard;
            IBotRule     rule       = new BotRuleBothTeams();

            sut.RequestBot(hero, difficulty, rule);


            Assert.AreEqual(requests.Requests.Count, 2);
        }
Example #7
0
        public void TestCorrectRuleInRequest()
        {
            BotRequests  requests   = new BotRequests();
            BotRequester sut        = new BotRequester(requests);
            AiHero       hero       = AiHero.Reaper;
            Difficulty   difficulty = Difficulty.Hard;
            IBotRule     rule       = new BotRuleBothTeams();

            sut.RequestBot(hero, difficulty, rule);

            Assert.AreEqual(requests.Requests[0].Rule, rule);
            Assert.AreEqual(requests.Requests[1].Rule, rule);
        }
Example #8
0
        public void TestIfSameReturnEqual()
        {
            Team       team       = Team.Blue;
            AiHero     hero       = AiHero.Ana;
            IBotRule   rule       = new BotRuleEqualTeams();
            Difficulty difficulty = Difficulty.Medium;
            int        min        = 2;
            int        max        = 4;

            BotRequest sut1 = new BotRequest(team, hero, difficulty, rule, min, max);
            BotRequest sut2 = new BotRequest(team, hero, difficulty, rule, min, max);

            Assert.IsTrue(sut1.Equals(sut2));
        }
Example #9
0
        public void TestRequestHasCorrectTeam()
        {
            BotRequests  requests = new BotRequests();
            BotRequester sut      = new BotRequester(requests);


            AiHero     hero       = AiHero.Sombra;
            Difficulty difficulty = Difficulty.Hard;
            IBotRule   rule       = new BotRuleSmallerTeam();
            Team       team       = Team.Blue;

            sut.RequestBot(team, hero, difficulty, rule);

            Assert.AreEqual(requests.Requests[0].BotTeam, Team.Blue);
        }
Example #10
0
        public void TestIfDifferentDifficultyNotReturnEqual()
        {
            Team       team        = Team.Blue;
            AiHero     hero        = AiHero.Ana;
            IBotRule   rule        = new BotRuleEqualTeams();
            Difficulty difficulty1 = Difficulty.Medium;
            Difficulty difficulty2 = Difficulty.Hard;
            int        min         = 3;
            int        max         = 3;

            BotRequest sut1 = new BotRequest(team, hero, difficulty1, rule, min, max);
            BotRequest sut2 = new BotRequest(team, hero, difficulty2, rule, min, max);

            Assert.AreNotEqual(sut1, sut2);
        }
Example #11
0
        public void TestIfDifferentHeroNotReturnEqual()
        {
            Team       team       = Team.Blue;
            AiHero     hero1      = AiHero.Ana;
            AiHero     hero2      = AiHero.Bastion;
            IBotRule   rule       = new BotRuleEqualTeams();
            Difficulty difficulty = Difficulty.Medium;
            int        min        = 0;
            int        max        = 3;

            BotRequest sut1 = new BotRequest(team, hero1, difficulty, rule, min, max);
            BotRequest sut2 = new BotRequest(team, hero2, difficulty, rule, min, max);

            Assert.AreNotEqual(sut1, sut2);
        }
Example #12
0
        public void TestMinAndMaxPlayersForRequest()
        {
            BotRequests  requests = new BotRequests();
            BotRequester sut      = new BotRequester(requests);

            AiHero     hero       = AiHero.Sombra;
            Difficulty difficulty = Difficulty.Hard;
            IBotRule   rule       = new BotRuleSmallerTeam();
            int        minPlayers = 1;
            int        maxPlayers = 4;

            sut.RequestBot(hero, difficulty, rule, minPlayers, maxPlayers);


            Assert.AreEqual(requests.Requests[0].MinPlayersOnTeam, minPlayers);
            Assert.AreEqual(requests.Requests[0].MaxPlayersOnTeam, maxPlayers);
        }
Example #13
0
        public void TestClearBotRequestsLeavesNoBotRequests()
        {
            BotRequests  requests = new BotRequests();
            BotRequester sut      = new BotRequester(requests);


            AiHero     hero       = AiHero.Sombra;
            Difficulty difficulty = Difficulty.Hard;
            IBotRule   rule       = new BotRuleSmallerTeam();

            sut.RequestBot(hero, difficulty, rule);

            AiHero     hero2       = AiHero.Bastion;
            Difficulty difficulty2 = Difficulty.Easy;
            IBotRule   rule2       = new BotRuleLargerTeam();

            sut.RequestBot(hero2, difficulty2, rule2);

            sut.ClearBotRequests();

            Assert.AreEqual(requests.Requests.Count, 0);
        }
Example #14
0
        internal BotRequest(Team team, AiHero hero, Difficulty difficulty, IBotRule rule, int minPlayersOnTeam, int maxPlayersOnTeam)
        {
            if (minPlayersOnTeam < 0 || minPlayersOnTeam > 5)
            {
                throw (new ArgumentOutOfRangeException(nameof(minPlayersOnTeam), "Must be in range 0 - 5 inclusive."));
            }
            if (maxPlayersOnTeam < 0 || maxPlayersOnTeam > 5)
            {
                throw (new ArgumentOutOfRangeException(nameof(maxPlayersOnTeam), "Must be in range 0 - 5 inclusive."));
            }
            if (minPlayersOnTeam > maxPlayersOnTeam)
            {
                throw (new ArgumentOutOfRangeException(nameof(minPlayersOnTeam),
                                                       "Must not be greater than maxPlayers"));
            }

            BotTeam          = team;
            Hero             = hero;
            Difficulty       = difficulty;
            Rule             = rule;
            MinPlayersOnTeam = minPlayersOnTeam;
            MaxPlayersOnTeam = maxPlayersOnTeam;
        }
Example #15
0
 public void RequestBot(AiHero hero, Difficulty difficulty, IBotRule rule)
 {
     RequestBot(Team.Blue, hero, difficulty, rule);
     RequestBot(Team.Red, hero, difficulty, rule);
 }
Example #16
0
 public void RequestBot(AiHero hero, Difficulty difficulty, IBotRule rule, int minPlayersOnTeam,
                        int maxPlayersOnTeam)
 {
     RequestBot(Team.Blue, hero, difficulty, rule, minPlayersOnTeam, maxPlayersOnTeam);
     RequestBot(Team.Red, hero, difficulty, rule, minPlayersOnTeam, maxPlayersOnTeam);
 }
Example #17
0
 public void AddAi(AiHero hero, Difficulty difficulty, Team team)
 {
     _ai.AddAI(hero.ToDeltin(), difficulty.ToDeltin(), team.ToBotTeam());
 }
Example #18
0
 public void RequestBot(Team team, AiHero hero, Difficulty difficulty, IBotRule rule)
 {
     RequestBot(team, hero, difficulty, rule, _defaultMinPlayersOnTeam, _defaultMaxPlayersOnTeam);
 }
Example #19
0
 public void AddBot(AiHero hero, Difficulty difficulty, Team team)
 {
     AddedBotsCount++;
 }
Example #20
0
 public static Deltin.CustomGameAutomation.AIHero ToDeltin(this AiHero lindholmHero)
 {
     Deltin.CustomGameAutomation.AIHero deltinHero = (Deltin.CustomGameAutomation.AIHero)Enum.Parse(typeof(Deltin.CustomGameAutomation.AIHero), lindholmHero.ToString());
     return(deltinHero);
 }