public void SetupMove_PrintsCorrectPrompts()
        {
            Fairy fairy = (Fairy)FighterFactory.GetFighter(FighterType.Fairy, 1);

            _fighter.SetEnemy(fairy);

            _input.Push("1", "1");

            _fighter.SetupMove(_ownTeam, _enemyTeam);

            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedOutputLength = 5;

            //menu prompt for both menus, plus "back," "help," and "status" option from target menu
            expectedOutputLength += fairy.AvailableMoves.Count + _enemyTeam.Fighters.Count;
            Assert.AreEqual(expectedOutputLength, outputs.Length);

            int i = 0;

            MockOutputMessage output = outputs[i++];

            Assert.AreEqual($"You are currently selecting a move for {fairy.DisplayName}. What move will you use?\n", output.Message);
            Assert.AreEqual(ConsoleColor.Cyan, output.Color);

            for (int j = 0; j < fairy.AvailableMoves.Count; ++j)
            {
                BattleMove move = fairy.AvailableMoves[j];

                output = outputs[i++];
                Assert.AreEqual($"{j + 1}. {move.Description}\n", output.Message);
            }
        }
        public void ReturnsAppopriateResponse()
        {
            _input.Push("1");

            MenuSelection menuSelection = _menu.GetInput();

            NumberInputMenuSelection numberInputSelection = menuSelection as NumberInputMenuSelection;

            Assert.NotNull(numberInputSelection);

            Assert.AreEqual(1, numberInputSelection.Number);
        }
Beispiel #3
0
        public void CorrectlyKeysOffOwnersHealth([Values(10, 50)] int maxHealth)
        {
            _owner.SetHealth(maxHealth);

            _menu.Build(_owner, _ownerTeam, _enemyTeam, null);

            _input.Push($"{maxHealth}", $"{maxHealth - 1}");

            NumberInputMenuSelection selection = _menu.GetInput() as NumberInputMenuSelection;

            Assert.AreEqual(maxHealth - 1, selection?.Number);
        }
        public void BattleManagerCorrectlyExecutesBellSealingMove()
        {
            //Arrange
            List <Shade> shades = _shadeGrouping.GetShades();

            _humanFighter.SetSpeed(shades[0].Speed + 1);

            List <Bell> bells = GetBells(BellType.Copper, BellType.Silver);

            _input.Push("special", "pray copper", "1", "run", "y");

            _chanceService.PushEventOccurs(true); //sealing is effective
            int attackIndex = shades[0].AvailableMoves.FindIndex(am => am.MoveType == BattleMoveType.Attack);

            _chanceService.PushWhichEventsOccur(attackIndex, attackIndex, attackIndex);
            _chanceService.PushEventsOccur(false, false); //both remaining shades will attack

            //Act
            _battleManager.Battle(_humanTeam, _shadeTeam, bells.Cast <TerrainInteractable>().ToList());

            //Assert

            //1st shade was sealed
            Assert.AreEqual(0, shades[0].CurrentHealth);

            //other shades did not absorb its power
            Assert.AreEqual(1, shades[1].ShadeExperience);
            Assert.AreEqual(1, shades[2].ShadeExperience);
        }
Beispiel #5
0
        public void ReturnsAppropriateTeam_SingleEnemy()
        {
            _menuInput.Push("yes", "goblin", "1", "no");

            BattleConfigurationSpecialFlag battleFlag;
            Team returnedTeam = _menuManager.GetTeam(TestMenuManager.GetTestMenuManager(), _menuInput, _menuOutput, out battleFlag);

            Assert.AreEqual(1, returnedTeam.Fighters.Count);

            HumanControlledEnemyFighter humanControlledFighter = returnedTeam.Fighters[0] as HumanControlledEnemyFighter;

            Assert.NotNull(humanControlledFighter);

            Assert.IsTrue(humanControlledFighter.Fighter is Goblin);
        }
        public void CorrectlyRenamesEnemiesIfMultipleEnemiesOfSameType()
        {
            _menuInput.Push("Goblin A");

            var ret = _menu.GetInput(MoveFactory.Get(BattleMoveType.Attack), null);

            Assert.AreEqual(_enemyTeam.Fighters[0], ret.Target);
        }
Beispiel #7
0
        public void ReturnsCorrectMenuSelection()
        {
            _input.Push("Goblin", "1");

            MenuSelection menuSelection = _menu.GetInput();

            SelectEnemyFighterMenuSelection selectEnemyMenuSelection = menuSelection as SelectEnemyFighterMenuSelection;

            Assert.NotNull(selectEnemyMenuSelection);
            Assert.AreEqual(FighterType.Goblin, selectEnemyMenuSelection.FighterType);
            Assert.AreEqual(1, selectEnemyMenuSelection.FighterLevel);
        }
Beispiel #8
0
        public void PersonalityQuiz_ManualEntry_CorrectlySetsInitializationValues([Values("1", "2")] string selectedFighterInput)
        {
            HumanFighter dante   = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "Dante");
            HumanFighter arrokoh = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "Arrokoh");

            HumanFighter selectedFighter    = selectedFighterInput == "1" ? dante : arrokoh;
            HumanFighter notSelectedFighter = selectedFighterInput == "1" ? arrokoh : dante;

            int luckBefore = selectedFighter.Luck;

            for (var i = 0; i < 8; ++i)
            {
                _input.Push(selectedFighterInput);
            }

            _decisionManager.PersonalityQuiz(dante, arrokoh);

            int luckAfter = selectedFighter.Luck;

            //who is more enigmatic?
            Assert.Contains(PersonalityFlag.Enigmatic, selectedFighter.PersonalityFlags, "first question should assign enigmatic flag");
            //who always wins at cards?
            Assert.AreEqual(10, luckAfter - luckBefore, "second question should raise luck");
            //who is more likely to seek treasure?
            Assert.Contains(PersonalityFlag.Adventurous, selectedFighter.PersonalityFlags, "third question should assign adventurous flag");
            //who sometimes watches the stars at night?
            Assert.Contains(PersonalityFlag.Dreamer, selectedFighter.PersonalityFlags, "fourth question should assign dreamer flag");
            //who is better at solving maze puzzles?
            Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(selectedFighter, GodEnum.IntellectGod), "fifth question should raise IntellectGod relationship");
            Assert.Contains(PersonalityFlag.MazeSolver, selectedFighter.PersonalityFlags, "fifth quesiton should assign mazeSolver flag");
            //who would succumb to an evil gem?
            Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(selectedFighter, GodEnum.MalevolentGod), "sixth question should raise malevolent god relationship for selected fighter");
            Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(notSelectedFighter, GodEnum.MercyGod), "sixth question should raise mercy god relationship for not selected fighter");
            //who believes in ghosts?
            Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(notSelectedFighter, GodEnum.MachineGod), "seventh question should raise Machine God relationship for selected fighter");
            //who eats the last donut without asking?
            Assert.Contains(PersonalityFlag.SelfishDonutEater, selectedFighter.PersonalityFlags, "eigth question should assign selfishDonutEater flag");
        }
        public void HappyPath_SelectValidSpell([Values(MagicType.Fire, MagicType.Earth, MagicType.Water, MagicType.Wind)] MagicType spellType)
        {
            var spell     = SpellFactory.GetSpell(spellType, 1);
            var spellName = spell.Description;

            _player.AddSpell(spell);
            _player.SetMana(spell.Cost);

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

            _fullSpellMenuPrompt = new List <string>
            {
                $"Which spell would you like to cast?\n{_player.DisplayName} currently has {_player.CurrentMana} / {_player.MaxMana} Mana\n",
                "1. " + spellName + " " + spell.Cost + "\n",
                StatusPrompt,
                BackPrompt,
                HelpPrompt
            };
            var count = _fullSpellMenuPrompt.Count;

            var ret = _menu.GetInput();

            var outputs = _menuOutput.GetOutputs();

            for (var i = 0; i < count; ++i)
            {
                Assert.AreEqual(MockOutputMessageType.Normal, outputs[i].Type);
                Assert.AreEqual(_fullSpellMenuPrompt[i], outputs[i].Message);
            }

            Assert.AreEqual(spellName, ret.Move.Description);

            _player.RemoveSpell(spell);
        }
        public void ReturnsCorrectInput_FromSpecialMenu([Range(0, 1)] int selectedIndex)
        {
            List <string> specialMenuActionDisplays = new List <string>
            {
                "dance like no one's watching",
                "thumb wrestle"
            };

            List <MenuAction> specialMenuActions = specialMenuActionDisplays.Select(s => new MenuAction(s)).ToList();

            BuildMenu(specialMenuActions);
            _input.Push("special actions", $"{selectedIndex + 1}");

            MenuSelection menuSelection = _menu.GetInput();

            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedOutputLength = _fullMenuPromptLength + specialMenuActions.Count + 4;  //prompt, plus 'back', 'help' and 'status' options

            Assert.AreEqual(expectedOutputLength, outputs.Length);

            Assert.AreEqual(specialMenuActions[selectedIndex].DisplayText, menuSelection.Description);
        }
Beispiel #11
0
        public void HappyPath_AllFightersAttack()
        {
            for (var i = 1; i <= 3; ++i)
            {
                _input.Push("fight");
                _input.Push("attack");
                _input.Push(i.ToString());
            }

            var selections = _manager.GetInputs();

            Assert.AreEqual(3, selections.Count);

            for (var i = 0; i < 3; ++i)
            {
                var selection = selections[i];
                var enemy     = _enemyTeam.Fighters[i];

                Assert.AreEqual(BattleMoveType.Attack, selection.Move.MoveType);
                Assert.AreEqual(enemy, selection.Target);
                Assert.AreEqual(_playerTeam.Fighters[i], selection.Owner);
            }
        }
        public void HappyPath_Attack_SingleOpponent()
        {
            _menuInput.Push("attack");
            _menuInput.Push("1");

            var ret = _menu.GetInput();

            var outputs = _menuOutput.GetOutputs();

            TestChooseAttackTypeMenuOutput(outputs, 0, true);

            Assert.AreEqual("attack", ret.Move.Description);
            Assert.AreEqual(BattleMoveType.Attack, ret.Move.MoveType);
        }
Beispiel #13
0
        public void HumanTeam_TestGetInputs()
        {
            var count = _humanTeam.Fighters.Count;

            for (var i = 0; i < count; ++i)
            {
                _input.Push("fight");
                _input.Push("attack");
                _input.Push("1");
            }

            var moves = _humanTeam.GetInputs(_enemyTeam);

            Assert.AreEqual(count, moves.Count);

            for (var i = 0; i < count; ++i)
            {
                Assert.AreEqual(BattleMoveType.Attack, moves[i].Move.MoveType);
                Assert.AreEqual(_enemyPlayer1, moves[i].Target);
            }
        }
        public void GetInput_ReturnsInputIfValidTextSpecified([Values("fight", "item", "run")] string input)
        {
            _menuInput.Push(input);
            MenuSelection ret = _menu.GetInput();

            var outputs      = _menuOutput.GetOutputs();
            var clearIndices = _menuOutput.GetClearIndices();

            Assert.AreEqual(_fullMenuPromptLength, outputs.Length);

            TestMenuOutput(outputs, 0, clearIndices, 0);

            Assert.AreEqual(input, ret.Description);
        }
        public void TestGetName_AppropriatelyDisplaysDefaultPrompt()
        {
            const string expected = "Alkeeros";

            _input.Push(expected);

            _menu.GetName();

            var outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);
            Assert.AreEqual(_outputtedPrompt, outputs[0].Message);
            Assert.AreEqual(MockOutputMessageType.Normal, outputs[0].Type);
        }