Exemplo n.º 1
0
        public void EnemyTeam_TeamDefeatedCorrectlyFiresAfter_AddingNewFighters()
        {
            _logger.Subscribe(EventType.TeamDefeated, _enemyTeam);

            _enemyTeam.Add((TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1));
            var fighters = _enemyTeam.Fighters;
            var count    = fighters.Count;

            var i = 0;

            for (; i < count - 1; ++i)
            {
                fighters[i].PhysicalDamage(fighters[i].MaxHealth);
                Assert.AreEqual(0, _logger.Logs.Count);
            }

            fighters[i].PhysicalDamage(fighters[i].MaxHealth);

            var logs = _logger.Logs;

            Assert.AreEqual(1, logs.Count);
            Assert.AreEqual(EventType.TeamDefeated, logs[0].Type);
        }
Exemplo n.º 2
0
        public void BattleMoveQueue_SortOperation_CorrectlyAcceptsMethodToCalculateEffectiveSpeed([Values(1, 3)] int numberOfMovesToPop)
        {
            TestHumanFighter fighter1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Jeff");
            TestHumanFighter fighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Bill");
            TestHumanFighter fighter3 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Mike");

            //sorted order is Mike (3), Jeff (1), then Bill (2),
            //which is different than the initial order and different from speed order
            fighter1.SetSpeed(0);
            fighter2.SetSpeed(2);
            fighter3.SetSpeed(1);

            List <BattleMoveWithTarget> initializerList = new List <BattleMoveWithTarget>
            {
                new BattleMoveWithTarget(_testMove, fighter1, fighter1),
                new BattleMoveWithTarget(_testMove, fighter2, fighter2),
                new BattleMoveWithTarget(_testMove, fighter3, fighter3)
            };

            BattleMoveQueue queue = new BattleMoveQueue(initializerList);

            Func <IFighter, int> sortHelperFunc = f =>
            {
                int ret = 0;

                switch (f.BaseName)
                {
                case "Mike":
                    ret = 100;
                    break;

                case "Jeff":
                    ret = 50;
                    break;

                case "Bill":
                    ret = 10;
                    break;
                }

                return(ret);
            };

            queue.Sort(sortHelperFunc);

            //sorted order is Mike (3), Jeff (1), then Bill (2)
            BattleMoveWithTarget firstSortedMove = queue.Pop();
            IFighter             owner           = firstSortedMove.Owner;

            Assert.AreEqual(fighter3, owner);

            BattleMoveWithTarget secondSortedMove = queue.Pop();

            owner = secondSortedMove.Owner;
            Assert.AreEqual(fighter1, owner);

            BattleMoveWithTarget thirdSortedMove = queue.Pop();

            owner = thirdSortedMove.Owner;
            Assert.AreEqual(fighter2, owner);
        }
Exemplo n.º 3
0
 public void SetUp()
 {
     _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
     _human = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
 }