Пример #1
0
        public void TargetMenu_CorrectlyBuildsMenuActions_SingleAllyTargetType_OneAllyDead()
        {
            _ally1.PhysicalDamage(_ally1.MaxHealth);
            SingleAllyTargetType_Setup("1");

            List <MenuAction> menuActions = _menu.MenuActions;

            int expectedCount = _playerTeamWithAllies.Fighters.Count - 2; //exclude both the owner and the dead ally

            Assert.AreEqual(expectedCount, menuActions.Count);

            Assert.AreEqual(_ally2, menuActions[0].Fighter);
        }
Пример #2
0
        //TODO: Delete this method. Should be handled by the BattleManager
        public int Attack(IFighter opponent, double attackMultiplier = 1.0, bool isCrit = false)
        {
            var damage = Strength - opponent.Defense;

            if (isCrit)
            {
                OnCriticalAttack(new CriticalAttackEventArgs());
            }

            damage = (int)(damage * attackMultiplier);

            if (damage < 0)
            {
                damage = 0;
            }

            var damageDealt = opponent.PhysicalDamage(damage);

            OnAttackSuccessful(new AttackSuccessfulEventArgs(opponent, damageDealt));

            if (!opponent.IsAlive())
            {
                OnEnemyKilled(new EnemyKilledEventArgs(opponent));
            }

            return(damageDealt);
        }
Пример #3
0
        public void CorrectNumberOfBattlesBeforeBoss([Range(1, 3)] int numberBattles)
        {
            TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Barbarian, 5), new EnemyConfiguration(FighterType.ShieldGuy, 2), new EnemyConfiguration(FighterType.ShieldGuy, 3));
            SubRegion         subRegion         = new SubRegion(WorldSubRegion.Fields, numberBattles, new[] { new ChanceEvent <int>(1, 1) }, new[] { FighterType.Egg },
                                                                new BattlefieldConfiguration(bossConfiguration));

            SubRegion[] subRegions = { subRegion };

            Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions);

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            for (int i = 0; i < numberBattles; ++i)
            {
                Team team = GetSingleEnemyTeam();
                _teamFactory.PushTeams(team);
                _chanceService.PushWhichEventOccurs(0);
            }

            _regionManager = GetRegionManager();

            IFighter target = TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            target.PhysicalDamage(target.MaxHealth);

            _humanFighter1.SetMove(_basicAttackMove, numberBattles);
            _humanFighter1.SetMoveTarget(target);
            _chanceService.PushAttackHitsNotCrit(numberBattles);
            _humanFighter1.SetMove(_runawayMove);

            _humanFighter2.SetMove(_doNothingMove);

            _chanceService.PushWhichEventsOccur(0, 0, 0, 0, 0, 0); //used for when the bosses are selecting their moves

            _regionManager.Battle(_battleManager, _humanTeam);

            List <Team> enemyTeams = _battleManager.GetAllEnemyTeams();

            Assert.AreEqual(numberBattles + 1, enemyTeams.Count);

            Team bossTeam = enemyTeams[numberBattles];

            Assert.AreEqual(3, bossTeam.Fighters.Count);

            Assert.True(bossTeam.Fighters.Exists(f => f is Barbarian && f.Level == 5));
            Assert.True(bossTeam.Fighters.Exists(f => f is ShieldGuy && f.Level == 2));
            Assert.True(bossTeam.Fighters.Exists(f => f is ShieldGuy && f.Level == 3));
        }