예제 #1
0
        public void CorrectlyPrintsMessages_WhenAdded([Values(1, 3)] int statusDuration)
        {
            CounterAttackStatus status     = new CounterAttackStatus(statusDuration);
            StatusMove          statusMove = new StatusMove("foo", TargetType.Self, status);

            _humanFighter.SetMove(statusMove, 1);
            _chanceService.PushEventOccurs(true);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_doNothing);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            string turnOrTurns    = statusDuration == 1 ? "turn" : "turns";
            string expectedOutput = $"{_humanFighter.DisplayName} will counter any attack for {statusDuration} {turnOrTurns}!\n";

            Assert.AreEqual(expectedOutput, outputs[0].Message);
        }
예제 #2
0
        public void BattleManager_AppropriatelyExecutesDanceTechnique_ScreenOutputs()
        {
            _enemy1.SetMove(_testTechnique);
            _enemy1.SetSpeed(10);
            _enemy2.SetMove(_doNothingMove);

            _human1.SetMove(_basicAttack);
            _human1.SetMoveTarget(_enemy1);
            _human1.SetStrength(EnemyDefenseAfterDanceMove + _enemy1.MaxHealth);
            _human2.SetMove(_basicAttack);
            _human2.SetMoveTarget(_enemy2);
            _human2.SetStrength(EnemyDefenseAfterDanceMove + _enemy2.MaxHealth);
            _chanceService.PushEventsOccur(true, false, true, false); //set up attack hits, attack crits for both attacks

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

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(3, outputs.Length); //dance move has been performed, enemy's stats raised, human's stats lowered

            Assert.AreEqual($"{_enemy1.DisplayName} {FirstTurnMessage}\n", outputs[0].Message);
        }
        public void AutoEvadeStatus_CorrectlyPrintsMessage_WhenAdded([Values(1, 4)] int statusDuration, [Values(true, false)] bool shouldCounter)
        {
            AutoEvadeStatus evadeStatus = new AutoEvadeStatus(statusDuration, shouldCounter);
            StatusMove      statusMove  = new StatusMove("foo", TargetType.Self, evadeStatus);

            _humanFighter.SetMove(statusMove, 1);
            //status move hits
            _chanceService.PushEventOccurs(true);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_doNothing);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            string turnOrTurns      = statusDuration == 1 ? "turn" : "turns";
            string andCounterString = shouldCounter ? " and counter" : "";
            string expectedOutput   = $"{_humanFighter.DisplayName} will evade{andCounterString} all attacks for {statusDuration} {turnOrTurns}!\n";

            Assert.AreEqual(expectedOutput, outputs[0].Message);
        }
예제 #4
0
        public void BattleManager_PrintsCorrectExecutionText_ShieldFortifyingMove()
        {
            _level1ShieldGuy.SetBattleShield(new IronBattleShield(5, 1, 0));
            _chanceService.PushWhichEventsOccur(2, 0); //index 0 is attack, 1 is "equip with shield", and 2 is "fortify." Second index supplied so it won't error when selecting second turn's move

            _ally1.SetMove(_doNothingMove);
            _ally2.SetMove(_doNothingMove);

            _humanFighter.SetMove(_doNothingMove, 1);
            _humanFighter.SetMove(_runawayMove);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            string displayName    = _level1ShieldGuy.DisplayName;
            string expectedOutput = $"{displayName} strengthened {displayName}'s shield!\n";

            Assert.AreEqual(expectedOutput, outputs[0].Message);
        }
예제 #5
0
        public void BattleManager_CorrectlyPrintsDamageOutput()
        {
            int damage = (_shield.MaxHealth + _shield.Defense) - 1;

            _enemyPlayer1.SetMove(_basicAttackMove);
            _enemyPlayer1.SetStrength(damage);
            _enemyPlayer1.SetMoveTarget(_humanPlayer1);
            _chanceService.PushEventsOccur(true, false); //attack hits, not crit

            _humanPlayer1.SetBattleShield(_shield as BattleShield);
            BattleShield fighterShield = _humanPlayer1.BattleShield;

            _humanPlayer1.SetMove(_doNothingMove, 1);
            _humanPlayer1.SetMove(_runawayMove);
            _humanPlayer1.SetMoveTarget(_humanPlayer1);

            _humanTeam = new Team(_menuManager, _humanPlayer1);
            _enemyTeam = new Team(_menuManager, _enemyPlayer1);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(2, outputs.Length); //enemy attacks and shield took damage message

            MockOutputMessage output = outputs[1];

            Assert.AreEqual($"{fighterShield.Owner.DisplayName}'s {fighterShield.GetDisplayText(false)} took {damage} damage!\n", output.Message);
        }
예제 #6
0
        public void CorrectlyPrintsIntro_UponEnteringRegion(
            [Values("Welcome to the Jungle!", "flee, for you have entered the graveyard!")] string regionIntroMessage,
            [Values("Welcome to a smaller subset of the jungle", "Spooky ghosts watch your every step")] string subRegionIntroMessage)
        {
            TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1));
            SubRegion         subRegion         = new SubRegion(WorldSubRegion.Fields, 1, new [] { new ChanceEvent <int>(1, 1) }, new[] { FighterType.Egg }, new BattlefieldConfiguration(bossConfiguration, null),
                                                                regionIntro: subRegionIntroMessage);

            SubRegion[] subRegions = { subRegion };

            Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions, regionIntroMessage);

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            _teamFactory.PushTeams(_oneEnemyTeam);
            _regionManager = GetRegionManager();

            _humanFighter1.SetMove(_runawayMove);
            _humanFighter1.SetMoveTarget(_humanFighter1);

            _humanFighter2.SetMove(_doNothingMove);

            _regionManager.Battle(_battleManager, _humanTeam);

            MockOutputMessage[] outputs = _output.GetOutputs();

            MockOutputMessage output = outputs[0];

            Assert.AreEqual(regionIntroMessage + "\n", output.Message);

            output = outputs[1];

            Assert.AreEqual(subRegionIntroMessage + "\n", output.Message);
        }
        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);
        }
        public void CorrectlyPrintsMessage_StatBonusAdded([Values] StatType statType, [Values(1, 3)] int bonusAmount)
        {
            StatBonusAppliedEventArgs e = new StatBonusAppliedEventArgs(statType, bonusAmount, false);

            _fighter.OnStatBonusApplied(e);

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            MockOutputMessage output = outputs[0];

            Assert.AreEqual($"{_fighter.DisplayName} gained +{bonusAmount} {statType.ToString().ToLower()}\n", output.Message);
        }
        public void CorrectlyDisallowsEmptyInput()
        {
            _input.Push("", "2");

            _menu.GetInput();

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(3, outputs.Length);

            MockOutputMessage output = outputs[1];

            Assert.AreEqual("input is required\n", output.Message);
            Assert.AreEqual(ConsoleColor.Red, Globals.ErrorColor);
        }
예제 #10
0
        public void BlindnessStatusCorrectlyPrintsMessage([Values(1, 3)] int statusDuration)
        {
            StatusMove blindnessMove = new StatusMove("foo", TargetType.SingleEnemy, new BlindStatus(statusDuration));

            _humanFighter.SetMove(blindnessMove, 1);
            _chanceService.PushEventOccurs(true);
            _humanFighter.SetMoveTarget(_enemy);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetMove(_doNothing);

            SilentBattleConfiguration config = new SilentBattleConfiguration();

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            MockOutputMessage output = outputs[0];

            string turnOrTurns     = statusDuration == 1 ? "turn" : "turns";
            string expectedMessage = $"{_enemy.DisplayName} has been afflicted with blindness for {statusDuration} {turnOrTurns}!\n";

            Assert.AreEqual(expectedMessage, output.Message);
        }
예제 #11
0
        public void StatusMove_AppropriatelyDisplaysExecutionText()
        {
            const string executionText = "performs the foo ritual";
            Status       status        = new MagicMultiplierStatus(2, MagicType.Water, 2);
            StatusMove   move          = new StatusMove("foo", TargetType.Self, status, executionText);

            _team1Fighter.SetMove(move, 1);
            _team1Fighter.SetMove(_runawayMove);

            _team2Fighter.SetMove(_doNothingMove);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false,
                ShowExpAndLevelUpMessages = false
            };

            //status move hits
            _chanceService.PushEventOccurs(true);

            _battleManager.Battle(_team1, _team2, config: config);

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(2, outputs.Length);

            string expectedStatusOutput = $"{_team1Fighter.DisplayName} {executionText}!\n";

            Assert.AreEqual(expectedStatusOutput, outputs[0].Message);
        }
        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);
            }
        }
예제 #13
0
        public void CorrectlyOutputsColors_NoSubStrings()
        {
            const string       expectedOutput = "Hello World!";
            const ConsoleColor expectedColor  = ConsoleColor.Red;
            ColorString        colorString    = new ColorString(expectedOutput, expectedColor);

            _mockOutput.WriteLine(colorString);

            MockOutputMessage[] outputs = _mockOutput.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            MockOutputMessage output = outputs[0];

            Assert.AreEqual(expectedOutput + "\n", output.Message);
            Assert.AreEqual(expectedColor, output.Color);
        }
예제 #14
0
        public void BattleManager_CorrectlyPrintsMessages_ElementalBattleShield([Values("eats pudding", null)] string executionMessage,
                                                                                [Values(MagicType.Ice, MagicType.Fire, MagicType.Earth, MagicType.Lightning)] MagicType shieldMagicType)
        {
            const int             shieldDefense = 5;
            const int             shieldHealth  = 1;
            ElementalBattleShield shield        = new ElementalBattleShield(shieldHealth, shieldDefense, 0, shieldMagicType);
            ShieldMove            shieldMove    = new ShieldMove("foo", TargetType.Self, executionMessage, shield);

            _humanFighter.SetSpeed(1);
            _humanFighter.SetMove(shieldMove, 1);
            _humanFighter.SetMove(_runawayMove);

            _enemy.SetStrength(shieldHealth + shieldDefense);
            _enemy.SetMove(_basicAttackMove);
            _chanceService.PushEventsOccur(true, false); //attack hits, is not a crit

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false,
                ShowAttackMessages        = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedLength = 3; //damage taken, "equipped with shield," and "shield destroyed" messages

            if (executionMessage != null)
            {
                expectedLength++;
            }
            Assert.AreEqual(expectedLength, outputs.Length);

            int i = 0;

            if (executionMessage != null)
            {
                Assert.AreEqual($"{_humanFighter.DisplayName} {executionMessage}!\n", outputs[i++].Message);
            }

            string aOrAn = shieldMagicType == MagicType.Ice || shieldMagicType == MagicType.Earth ? "an" : "a";

            Assert.AreEqual($"{_humanFighter.DisplayName} was equipped with {aOrAn} {shieldMagicType.ToString().ToLower()} elemental battle shield!\n", outputs[i].Message);
        }
예제 #15
0
        public void TargetMenu_DoesNotDisplayDefeatedEnemies()
        {
            var enemy = _enemyTeam.Fighters[0];

            enemy.PhysicalDamage(enemy.MaxHealth);

            //should result in an error
            _menuInput.Push("Goblin A");
            _menuInput.Push("Goblin B");

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

            Assert.AreEqual(_enemyTeam.Fighters[1], ret.Target);

            var outputs = _menuOutput.GetOutputs();

            //5 for each time menu is printed (prompt, only one enemy displayed, back prompt, help prompt, status prompt)
            //1 for error message
            Assert.AreEqual(11, outputs.Length);

            Assert.AreEqual(MockOutputMessageType.Error, outputs[5].Type);
        }
예제 #16
0
        public void LayEgg_CorrectlyAddsEggsToEnemyTeam()
        {
            _chanceService.PushWhichEventOccurs(0);

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

            var move = _chicken.SetupMove(_enemyTeam, _humanTeam);

            _chicken.ExecuteMove(_battleManager, move, _enemyTeam, _humanTeam, _output);

            Assert.AreEqual(2, _enemyTeam.Fighters.Count);
            var egg = _enemyTeam.Fighters[1];

            Assert.IsAssignableFrom <Egg>(egg);
            Assert.AreEqual(MagicType.Fire, ((Egg)egg).MagicType);

            var outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);

            Assert.AreEqual($"{_chicken.DisplayName} laid a fire egg!\n", outputs[0].Message);
        }
예제 #17
0
        public void CorrectlyPrintsCurscenes()
        {
            //Arrange
            ColorString[] firstSceneLines =
            {
                new ColorString("There once was a man named Gold Roger"),
                new ColorString("He had fame, wealth, and power beyond your wildest dreams"),
                new ColorString("Before they hung him from the gallows,"),
                new ColorString("These were the words he said:")
            };

            SingleScene firstScene = new SingleScene(firstSceneLines);

            ColorString[] secondSceneLines =
            {
                new ColorString("If you want my treasure, you can have it!"),
                new ColorString("I left everything I had in that place")
            };

            SingleScene secondScene = new SingleScene(secondSceneLines);

            SingleScene[] scenes =
            {
                firstScene,
                secondScene
            };

            Cutscene cutscene = new Cutscene(scenes);

            //Act
            cutscene.ExecuteCutscene(_input, _output, (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1), (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1));

            //Assert
            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedNumberOfLines = firstSceneLines.Length + secondSceneLines.Length;

            Assert.AreEqual(expectedNumberOfLines, outputs.Length);

            int[] clearIndices = _output.GetClearIndices();
            Assert.AreEqual(scenes.Length, clearIndices.Length);

            int nextClearIndex = firstSceneLines.Length;

            Assert.AreEqual(nextClearIndex, clearIndices[0]);

            nextClearIndex += secondSceneLines.Length;
            Assert.AreEqual(nextClearIndex, clearIndices[1]);
        }
예제 #18
0
        public void BattleManager_AppropriatelyDisplaysAbsorbMessage()
        {
            _humanFighter.SetStrength(_shade1.MaxHealth + _shade1.Defense);
            _humanFighter.SetMove(_basicAttack, 1);
            _humanFighter.SetMoveTarget(_shade1);
            _humanFighter.SetMove(_runawayMove);
            _chanceService.PushAttackHitsNotCrit();

            //which moves will be selected by the shades
            _chanceService.PushWhichEventsOccur(_malevolenceChargeIndex, _malevolenceChargeIndex, _malevolenceChargeIndex);

            _chanceService.PushWhichEventsOccur(0, 0); //first is which remaining shade absorbs the fallen shade, second is which stat is boosted

            //define the expected string here, since the shade's display name will be updated after the absorption
            string expectedAbsorbMessage = $"{_shade1.DisplayName}'s essence was absorbed by {_shade2.DisplayName}!\n";

            _battleManager.Battle(_humanTeam, _shadeTeam, null, new SilentBattleConfiguration());

            MockOutputMessage[] outputs = _output.GetOutputs();

            MockOutputMessage absorbOutputMessage = outputs.FirstOrDefault(o => o.Message == expectedAbsorbMessage);

            Assert.NotNull(absorbOutputMessage);
        }
        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 BattleManagerCorrectlyIdentifiesBellInIntro()
        {
            List <Bell> bells = GetBells(BellType.Copper, BellType.Silver);

            _humanFighter.SetMove(_runawayMove);
            _enemy.SetMove(_doNothingMove);

            _battleManager.Battle(_humanTeam, _enemyTeam, bells.Cast <TerrainInteractable>().ToList());

            MockOutputMessage[] outputs = _output.GetOutputs();

            int bellIntroIndex = 1 + _enemyTeam.Fighters.Count; //"time for a battle" and then each "encountered ____"

            foreach (Bell bell in bells)
            {
                MockOutputMessage output = outputs[bellIntroIndex];

                Assert.AreEqual($"There is a {bell.DisplayName} on the field\n", output.Message);

                bellIntroIndex++;
            }

            Assert.AreEqual(bellIntroIndex, _output.GetClearIndices()[1]);
        }
예제 #21
0
        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);
        }
        public void CorrectlySubscribesToMultipleFighters()
        {
            _output = new MockOutput();
            EventHandlerPrinter printer = new EventHandlerPrinter(_output);

            HumanFighter fighter2 = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1);
            HumanFighter fighter3 = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1);

            printer.Subscribe(_fighter, fighter2, fighter3);

            StatBonusAppliedEventArgs e = new StatBonusAppliedEventArgs(StatType.Defense, 2, false);

            _fighter.OnStatBonusApplied(e);
            fighter2.OnStatBonusApplied(e);
            fighter3.OnStatBonusApplied(e);

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(3, outputs.Length);
        }
예제 #23
0
        public void BattleManager_CorrectlyPrintsMessages_TargetHasShield([Values("eats pudding", null)] string executionMessage)
        {
            const int        shieldDefense    = 5;
            const int        shieldHealth     = 1;
            IronBattleShield shield           = new IronBattleShield(shieldHealth, shieldDefense, 0);
            ShieldBusterMove shieldBusterMove = new ShieldBusterMove("foo", TargetType.SingleEnemy, executionMessage);

            _humanFighter.SetSpeed(1);
            _humanFighter.SetMove(shieldBusterMove, 1);
            _humanFighter.SetMove(_runawayMove);
            _humanFighter.SetMoveTarget(_enemy);

            _enemy.SetBattleShield(shield);
            //_logger.SubscribeAll(_enemy.BattleShield);
            _enemy.SetMove(_doNothingMove);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedLength = 1;

            if (executionMessage != null)
            {
                expectedLength++;
            }
            Assert.AreEqual(expectedLength, outputs.Length);

            int i = 0;

            if (executionMessage != null)
            {
                Assert.AreEqual($"{_humanFighter.DisplayName} {executionMessage}!\n", outputs[i++].Message);
            }
            Assert.AreEqual($"{_enemy.DisplayName}'s shield was destroyed!\n", outputs[i].Message);
        }
예제 #24
0
        public void BattleManager_CorrectlyPrintsErrorMessage_TargetHasNoShieldEquipped()
        {
            ShieldFortifyingMove shieldFortifyingMove = new ShieldFortifyingMove("foo", TargetType.Self, null, ShieldFortifyingType.Defense, 5);

            _humanFighter.SetMove(shieldFortifyingMove, 1);
            _humanFighter.SetMove(_runawayMove);
            _humanFighter.SetMoveTarget(_humanFighter);

            _enemy.SetMove(_doNothing);

            BattleManagerBattleConfiguration config = new BattleManagerBattleConfiguration
            {
                ShowIntroAndOutroMessages = false
            };

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

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.AreEqual(1, outputs.Length);
            Assert.AreEqual($"But it failed because {_humanFighter.DisplayName} did not have a battleShield equipped!\n", outputs[0].Message);
        }
예제 #25
0
        public void PickNextAreaMethod_CorrectMenuPromptsDisplayed_DesertGroupings([Values(1, 2)] int whichPlayerGetsFlag)
        {
            //arrange
            MapGrouping <SubRegion, WorldSubRegion> firstGrouping, secondGrouping;
            MockMenu menu1, menu2;
            string   name1 = "Jeff";
            string   name2 = "Daniel";

            PickNextArea_GroupingSetup_DesertGroupings(out firstGrouping, out secondGrouping);
            PickNextArea_MenuSetup_DesertGroupings(WorldSubRegion.DesertCrypt, WorldSubRegion.CliffsOfAThousandPushups, out menu1, out menu2);
            Team team = PickNextArea_TeamSetup_DesertGroupings(whichPlayerGetsFlag, name1, name2);

            //Act
            _decisionManager.PickNextArea(firstGrouping, team);

            //Assert
            string expectedName1, expectedName2;

            if (whichPlayerGetsFlag == 1)
            {
                expectedName1 = name1;
                expectedName2 = name2;
            }
            else
            {
                expectedName1 = name2;
                expectedName2 = name1;
            }

            MockOutputMessage[] outputs = _output.GetOutputs();

            MockOutputMessage firstPrompt = outputs[0];

            Assert.True(firstPrompt.Message.StartsWith(expectedName1 + ":"));

            MockOutputMessage secondPrompt = outputs[4]; //first menu prompt, 3 visible options

            Assert.True(secondPrompt.Message.StartsWith(expectedName2 + ":"));
        }
예제 #26
0
        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);
        }
        public void PhysicalDamageEvent_CorrectlyPrintsMessage([Values(2, 4)] int expectedDamage)
        {
            PhysicalDamageEvent_Setup(expectedDamage, true);

            Assert.AreEqual(2, _logger.Logs.Count);

            MockOutputMessage[] messages = _output.GetOutputs();

            Assert.AreEqual(2, messages.Length);

            Assert.AreEqual($"It did {expectedDamage} damage!\n", messages[0].Message);
            Assert.AreEqual($"It did {expectedDamage} damage!\n", messages[1].Message);
        }
예제 #28
0
        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);
        }