Esempio n. 1
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");
        }
Esempio n. 2
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!");
        }
Esempio n. 4
0
        /// <summary>
        /// Fake moves include targetType = self/description = "test" for a test self-target
        /// moveType = "Special" and description = "test" for a test special move (target type field)
        /// and description = "testMultiTurn" to get a fake multi-turn move (2 turns do nothing, 3rd turn attack)
        /// </summary>
        /// <param name="targetType"></param>
        /// <param name="description"></param>
        /// <param name="moveType"></param>
        /// <returns></returns>
        public static BattleMove Get(TargetType targetType = TargetType.Self, string description = "test", BattleMoveType?moveType = null)
        {
            BattleMove ret;

            if (description == "test")
            {
                if (targetType == TargetType.Self && moveType == null)
                {
                    ret = FakeSelfTargetMove;
                }
                else if (targetType == TargetType.SingleAlly || targetType == TargetType.SingleAllyOrSelf)
                {
                    ret = new BattleMove(description, BattleMoveType.DoNothing, targetType);
                }
                else if (!moveType.HasValue)
                {
                    throw new ArgumentException(
                              "Either TargetType self must be specified or a valid moveType must be given");
                }
                else
                {
                    switch (moveType.Value)
                    {
                    case BattleMoveType.Special:
                        ret = FakeSpecialMove;
                        break;

                    case BattleMoveType.DoNothing:
                        ret = new TestDoNothingMove();
                        break;

                    case BattleMoveType.Field:
                        ret = new TestFieldEffectMove("foo", TargetType.OwnTeam, 2);
                        break;

                    case BattleMoveType.Dance:
                        ret = new TestDanceMove("foo dance", TargetType.Field, 0);
                        break;

                    default:
                        throw new ArgumentException(
                                  $"No test move found for the given inputs. TargetType: '{targetType}', moveType: '{moveType}'");
                    }
                }
            }
            else if (description == "testMultiTurn")
            {
                ret = FakeMultiTurnMove;
            }
            else if (moveType == null)
            {
                throw new ArgumentException(
                          "TestMoveFactory.Get() must either specify a moveType, or indicate it wants a test move!");
            }
            else
            {
                ret = MoveFactory.Get(moveType.Value);
            }

            return(ret);
        }
Esempio n. 5
0
 public void TearDown()
 {
     _testTechnique = null;
 }