예제 #1
0
        public void HumanTeam_GetInputs_MultiTurnMove()
        {
            var multiMove = (MultiTurnBattleMove)TestMoveFactory.Get(description: "testMultiTurn");

            _humanPlayer1.AddSpecialMove(multiMove);

            _humanTeam = new Team(_menuManager, _humanPlayer1);
            _humanTeam.InitializeForBattle(_enemyTeam, _input, _output);

            _input.Push(new List <string> {
                "fight", "special", multiMove.Description, "1"
            });

            foreach (var move in multiMove.Moves)
            {
                var battleMove = _humanTeam.GetInputs(_enemyTeam)[0];

                Assert.AreEqual(move, battleMove.Move);

                switch (move.TargetType)
                {
                case TargetType.Self:
                    Assert.AreEqual(_humanPlayer1, battleMove.Target);
                    break;

                case TargetType.SingleEnemy:
                    Assert.AreEqual(_enemyTeam.Fighters[0], battleMove.Target);
                    break;
                }
            }
        }
예제 #2
0
        public void HumanTeam_MultiTurnMove_MembersOfTeamIsDead()
        {
            var multiMove  = (MultiTurnBattleMove)TestMoveFactory.Get(description: "testMultiTurn");
            var attackMove = TestMoveFactory.Get(TargetType.SingleEnemy, "", BattleMoveType.Attack);

            _humanPlayer1.AddSpecialMove(multiMove);

            _humanTeam = new Team(_menuManager, _humanPlayer1, _humanPlayer2);
            _humanTeam.InitializeForBattle(_enemyTeam, _input, _output);

            _input.Push(new List <string> {
                "fight", "special", multiMove.Description, "1"
            });
            _input.Push(new List <string> {
                "fight", "attack", "1"
            });

            var inputs = _humanTeam.GetInputs(_enemyTeam);

            Assert.AreEqual(2, inputs.Count);

            Assert.AreEqual(multiMove.Moves[0], inputs[0].Move);
            Assert.AreEqual(attackMove, inputs[1].Move);

            _humanPlayer1.PhysicalDamage(_humanPlayer1.MaxHealth);

            _input.Push(new List <string> {
                "fight", "attack", "1"
            });
            inputs = _humanTeam.GetInputs(_enemyTeam);

            Assert.AreEqual(1, inputs.Count);

            Assert.AreEqual(attackMove, inputs[0].Move);
        }
예제 #3
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);
        }
예제 #4
0
        private MenuSelection SingleAllyOrSelfTargetType_Setup(string menuInput)
        {
            var targetAllyOrSelfMove = TestMoveFactory.Get(TargetType.SingleAllyOrSelf);

            _menu.Build(_player, _playerTeamWithAllies, _enemyTeam, null);

            _menuInput.Push(menuInput);

            return(_menu.GetInput(targetAllyOrSelfMove, null));
        }
예제 #5
0
        public void SelectMove_CorrectlySelectsSelfAsTarget_IfTargetTypeIsSelf()
        {
            var selfTargetMove = TestMoveFactory.Get();

            _fighter.SetAvailableMove(selfTargetMove);

            var selectedMove = _fighter.SetupMove(_ownTeam, _singleEnemyTeam);

            Assert.That(selectedMove, Is.Not.Null);
            Assert.AreEqual(selfTargetMove, selectedMove.Move);
            Assert.AreEqual(_fighter, selectedMove.Target);
        }
예제 #6
0
        public void TargetMenu_CorrectlyHandlesTargetTypes_SelfTarget()
        {
            var selfTargetMove = TestMoveFactory.Get(TargetType.Self);

            _menuInput.Push("1");

            _menu.GetInput(selfTargetMove, null);

            var outputs = _menuOutput.GetOutputs();

            Assert.AreEqual(5, outputs.Length); //prompt text, option, status, back, help
        }
예제 #7
0
        public void BattleManager_AppropriatelyCancelsCombinationEffect_IfEitherOwnerDies()
        {
            var windDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance);

            windDance.SetDuration(2);
            windDance.SetDanceEffect(DanceEffectType.Wind);
            windDance.AddMove(_doNothingMove);
            _human1.SetHealth(100, 10);
            _human1.SetSpeed(1);
            _human1.SetMove(windDance);
            _human1.SetMoveTarget(_human1);

            var fireDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance);

            fireDance.SetDuration(2);
            fireDance.SetDanceEffect(DanceEffectType.Fire);
            fireDance.AddMove(_doNothingMove);
            fireDance.AddMove(_runawayMove);
            _human2.SetHealth(100, 10);
            _human2.SetSpeed(1);
            _human2.SetMove(fireDance);
            _human2.SetMoveTarget(_human2);

            _enemy1.SetStrength(_human1.Defense + _human1.MaxHealth + 1);
            _enemy1.SetMove(_basicAttack);
            _enemy1.SetMoveTarget(_human1);
            _chanceService.PushEventsOccur(true, false); //attack hits, not a crit

            _enemyTeam = new Team(TestMenuManager.GetTestMenuManager(), _enemy1);

            RestoreHealthPercentageFieldEffect restoreHealthEffect =
                new RestoreHealthPercentageFieldEffect(TargetType.OwnTeam, "heal dance", 20, 10);

            CombinedFieldEffect testCombo = new CombinedFieldEffect("heal dance", restoreHealthEffect);

            _combiner.AddFakeCombination(DanceEffectType.Wind, DanceEffectType.Fire, testCombo);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                FieldEffectCombiner = _combiner
            };

            _battleManager.Battle(_humanTeam, _enemyTeam, config: config);

            //will be 30 if the dance effect isn't interrupted
            Assert.AreEqual(10, _human2.CurrentHealth);
        }
예제 #8
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");
        }
        public void CorrectlyDisplaysSpecialAttackSubMenu_WhenUserHasSpecialMoves()
        {
            var player     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            var playerTeam = new Team(_menuManager, player);

            player.AddSpecialMove((SpecialMove)TestMoveFactory.Get(TargetType.Field, "test", BattleMoveType.Special));

            Assert.AreEqual(1, player.SpecialMoves.Count);

            var fullMenuPrompt = new List <string>
            {
                "How would you like to fight?\n",
                "1. attack\n",
                "2. special move\n",
                StatusPrompt,
                BackPrompt,
                HelpPrompt
            };
            var fullMenuPromptLength = fullMenuPrompt.Count;

            _menu.Build(player, playerTeam, _enemyTeam, null);

            _menuInput.Push(new List <string> {
                "back"
            });

            var ret = _menu.GetInput();

            Assert.AreEqual("back", ret.Description);

            var outputs = _menuOutput.GetOutputs();

            Assert.AreEqual(fullMenuPromptLength, outputs.Length);

            var i = 0;

            while (i < fullMenuPromptLength)
            {
                Assert.AreEqual(fullMenuPrompt[i], outputs[i].Message);
                Assert.AreEqual(MockOutputMessageType.Normal, outputs[i++].Type);
            }
        }
예제 #10
0
        private void CombineDanceMove_Setup(string doNothingMessage = "")
        {
            var doNothing = (TestDoNothingMove)TestMoveFactory.Get(moveType: BattleMoveType.DoNothing);

            doNothing.SetMessage(doNothingMessage);
            var windDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance);

            windDance.SetDuration(2);
            windDance.SetDanceEffect(DanceEffectType.Wind);
            windDance.AddMove(doNothing);
            windDance.AddMove(doNothing);
            _human1.SetMove(windDance, 1);
            _human1.SetMove(_runawayMove);
            _human1.SetMoveTarget(_human1);
            _human1.SetHealth(100, 10);

            var fireDance = (TestDanceMove)TestMoveFactory.Get(moveType: BattleMoveType.Dance);

            fireDance.SetDuration(2);
            fireDance.SetDanceEffect(DanceEffectType.Fire);
            fireDance.AddMove(doNothing);
            fireDance.AddMove(doNothing);
            _human2.SetMove(fireDance);
            _human2.SetMoveTarget(_human2);
            _human2.SetHealth(100, 10);

            _enemy1.SetMove(_doNothingMove);
            _enemy2.SetMove(_doNothingMove);

            CombinedFieldEffect fakeCombinedEffect = new CombinedFieldEffect("fwee", new RestoreHealthPercentageFieldEffect(TargetType.OwnTeam, "fwee", 80, immediatelyExecuted: true));

            _combiner.AddFakeCombination(DanceEffectType.Wind, DanceEffectType.Fire, fakeCombinedEffect);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                FieldEffectCombiner       = _combiner,
                ShowIntroAndOutroMessages = false
            };

            _battleManager.Battle(_humanTeam, _enemyTeam, config: config);
        }
        public void CorrectlyReturnsSpecialAttack_WhenUserHasSpecialMoves()
        {
            var player     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            var playerTeam = new Team(_menuManager, player);

            var specialMove = (SpecialMove)TestMoveFactory.Get(TargetType.Field, "test", BattleMoveType.Special);

            player.AddSpecialMove(specialMove);

            Assert.AreEqual(1, player.SpecialMoves.Count);

            _menu.Build(player, playerTeam, _enemyTeam, null);

            _menuInput.Push(new List <string> {
                "special", specialMove.Description, "1"
            });

            var ret = _menu.GetInput();

            Assert.AreEqual(specialMove, ret.Move);
        }
예제 #12
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);
        }