Ejemplo n.º 1
0
        public void ConditionalDanceMove_ExecutesAppropriateEffectWhenDanceInEffect([Values(DanceEffectType.Fire, DanceEffectType.Danger)] DanceEffectType danceEffectType)
        {
            _testTechnique.ClearEffects();
            _testTechnique.SetDanceEffect(danceEffectType);

            RestorationBattleMoveEffect conditionalHealEffect = GetRestoreHealthEffect(danceEffectType);
            AttackBattleMove            attackWithHeal        = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0, effects: conditionalHealEffect);

            _human2.SetMove(_testTechnique, 1);
            _human2.SetSpeed(1);

            _human1.SetHealth(100, 10);
            _human1.SetMove(attackWithHeal, 1);
            _chanceService.PushEventsOccur(true, false); //attack hits, is not crit
            _human1.SetStrength(_enemy1.MaxHealth);
            _human1.SetMoveTarget(_enemy1);

            _enemyTeam = new Team(_menuManager, _enemy1);

            _enemy1.SetDefense(0);
            _enemy1.SetMove(_doNothingMove);
            _enemy1.SetMoveTarget(_enemy1);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(20, _human1.CurrentHealth, "Human1 should have regained 10 HP when the attack was successful and the dance effect was active");
        }
Ejemplo n.º 2
0
        public void BattleManager_StopsDanceEffectsIfOwnerDies()
        {
            const int         expectedHuman2RemainingHealth = 2;
            const int         human2Health       = 4;
            int               enemy2Strength     = (human2Health + _human2.Defense) - expectedHuman2RemainingHealth;
            TestDoNothingMove doNothing1         = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing);
            string            dangerDanceMessage = "danced the danger dance";

            doNothing1.SetMessage(dangerDanceMessage);
            TestDanceMove dangerDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance);

            dangerDance.SetDuration(2);
            dangerDance.AddEffect(new StatMultiplierFieldEffect(TargetType.EnemyTeam, "danger dance", StatType.Strength, 2));
            dangerDance.SetDanceEffect(DanceEffectType.Danger);

            dangerDance.AddMove(doNothing1);
            _human1.SetMove(dangerDance);
            _human1.SetMoveTarget(_human1);
            _human1.SetSpeed(2);
            _human1.SetHealth(10);

            _human2.SetHealth(human2Health);
            _human2.SetMove(_doNothingMove, 1);
            //end the battle after the first round
            _human2.SetMove(_runawayMove);
            _human2.SetMoveTarget(_human2);
            _human2.SetSpeed(3);

            _enemy1.SetMove(_basicAttack);
            _enemy1.SetMoveTarget(_human1);
            int human1DefenseAndHealth = _human1.Defense + _human1.MaxHealth;
            int enemy1Strength         = human1DefenseAndHealth / 2;

            _enemy1.SetStrength(enemy1Strength);
            _enemy1.SetSpeed(1);

            _enemy2.SetMove(_basicAttack);
            _enemy2.SetMoveTarget(_human2);
            _enemy2.SetStrength(enemy2Strength);

            _chanceService.PushEventsOccur(true, false, true, false); //set up attacks hitting and not crit'ing

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(0, _human1.CurrentHealth, "enemy1 attack should have doubled, causing enough damage to kill human1");
            Assert.AreEqual(expectedHuman2RemainingHealth, _human2.CurrentHealth, "The effect raising enemy attack should have been lifted when _human1 died");
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            _input         = new MockInput();
            _output        = new MockOutput();
            _menuManager   = new TestMenuManager(_input, _output);
            _chanceService = new MockChanceService();
            _battleManager = new TestBattleManager(_chanceService, _input, _output);
            _combiner      = new TestFieldEffectCombiner();
            _logger        = new EventLogger();

            _enemy1 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
            _enemy1.SetDefense(OriginalDefense);
            _enemy2 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
            _enemy2.SetDefense(OriginalDefense);

            _enemyTeam = new Team(_menuManager, _enemy1, _enemy2);

            _human1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            _human1.SetDefense(OriginalDefense);
            _human2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            _human2.SetDefense(OriginalDefense);

            _humanTeam = new TestTeam(_human1, _human2);

            _testTechnique = (TestDanceMove)TestMoveFactory.Get(TargetType.Field, moveType: BattleMoveType.Dance);
            _testTechnique.AddEffect(_raiseTeamDefense50Percent);
            _testTechnique.AddEffect(_lowerEnemyDefense50Percent);
            _testTechnique.SetDuration(_testTechniqueDefaultDuration);
            _testTechnique.SetDanceEffect(DanceEffectType.Fire);

            var firstTurn = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing);

            firstTurn.SetMessage(FirstTurnMessage);
            _testTechnique.AddMove(firstTurn);
            var secondTurn = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing);

            secondTurn.SetMessage("Continue the Defense dance");
            _testTechnique.AddMove(secondTurn);
        }
        public void MultipleEffects_OnlyEffectsWhoseConditionsAreMet_AreFired([Values(10, 20)] int restoreAmount)
        {
            _human.SetHealth(100, 10);
            _human.SetMana(100, 10);
            _restoreManaEffect   = new RestorationBattleMoveEffect(RestorationType.Mana, restoreAmount, BattleMoveEffectActivationType.OnAttackHit, new DanceBattleCondition(DanceEffectType.Soul));
            _restoreHealthEffect = new RestorationBattleMoveEffect(RestorationType.Health, restoreAmount, BattleMoveEffectActivationType.OnAttackHit, new DanceBattleCondition(DanceEffectType.Fire));
            BattleMove attackWithRestoreEffects = new AttackBattleMove("", TargetType.SingleEnemy, 100, 0, effects: new BattleMoveEffect[] { _restoreManaEffect, _restoreHealthEffect });

            _human.SetMove(attackWithRestoreEffects);
            _human.SetMoveTarget(_enemy);
            _chanceService.PushAttackHitsNotCrit(); //attack hits, not a crit

            TestHumanFighter dancer =
                (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "dancer");

            TestDanceMove danceMove = new TestDanceMove("bar", TargetType.Field, 2);

            danceMove.SetDanceEffect(DanceEffectType.Fire);
            danceMove.AddMove(_doNothingMove);

            dancer.SetSpeed(1);
            dancer.SetMove(danceMove);
            dancer.SetMoveTarget(dancer);

            _humanTeam.Add(dancer, false);

            _enemy.SetMove(_doNothingMove);
            _enemy.SetMoveTarget(_enemy);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            int expectedCurrentAmount = 10 + restoreAmount;

            Assert.AreEqual(10, _human.CurrentMana, "humman player's mana should not have been restored, the dance condition wasn't met!");
            Assert.AreEqual(expectedCurrentAmount, _human.CurrentHealth, $"humman player's health should have been restored by {restoreAmount} when the attack hit!");
        }