Beispiel #1
0
        public void BattleManager_DoesNotError_IfDanceMovesCannotCombine()
        {
            TestDoNothingMove doNothing1         = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing);
            string            dangerDanceMessage = "danced the danger dance";

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

            dangerDance.SetDuration(2);
            dangerDance.SetDanceEffect(DanceEffectType.Danger);
            dangerDance.AddMove(doNothing1);
            _human1.SetMove(dangerDance);
            _human1.SetMoveTarget(_human1);
            _human1.SetSpeed(1);

            TestDoNothingMove doNothing2 = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing);
            var    mindDance             = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance);
            string mindDanceMessage      = "danced the mind dance";

            doNothing2.SetMessage(mindDanceMessage);
            mindDance.SetDuration(2);
            mindDance.SetDanceEffect(DanceEffectType.Mind);
            mindDance.AddMove(doNothing2);
            _human2.SetMove(mindDance);
            _human2.SetMoveTarget(_human2);
            _human2.SetSpeed(1);

            _enemy1.SetMove(_basicAttack);
            _enemy1.SetMoveTarget(_human1);
            _enemy1.SetStrength(_human1.Defense + _human1.MaxHealth + 1);
            _enemy2.SetMove(_basicAttack);
            _enemy2.SetMoveTarget(_human2);
            _enemy2.SetStrength(_human2.Defense + _human2.MaxHealth + 1);
            _chanceService.PushEventsOccur(true, false, true, false); //attacks hit, don't crit

            var combine = _combiner.Combine(DanceEffectType.Danger, DanceEffectType.Mind);

            Assert.That(combine, Is.Null);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                FieldEffectCombiner        = _combiner,
                ShowIntroAndOutroMessages  = false,
                ShowAttackMessages         = false,
                ShowDeathMessages          = false,
                ShowExpAndLevelUpMessages  = false,
                ShowPhysicalDamageMessages = false
            };

            Assert.DoesNotThrow(() => _battleManager.Battle(_humanTeam, _enemyTeam, config: config));

            //ensure dance moves were used before human team was defeated
            MockOutputMessage[] outputs = _output.GetOutputs();
            Assert.AreEqual(2, outputs.Length);
            Assert.AreEqual($"{_human1.DisplayName} {dangerDanceMessage}\n", outputs[0].Message);
            Assert.AreEqual($"{_human2.DisplayName} {mindDanceMessage}\n", outputs[1].Message);
        }
Beispiel #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");
        }
Beispiel #3
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);
        }