Пример #1
0
        public void MalevolenceCharge_CorrectlyRaisesMalevolenceAttackPower()
        {
            TestHumanFighter fighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            _humanFighter.SetHealth(100);
            fighter2.SetHealth(100);

            Team shadeTeam = new Team(TestMenuManager.GetTestMenuManager(), _shade1, _shade2);
            Team humanTeam = new Team(_menuManager, _humanFighter, fighter2);

            _humanFighter.SetMove(_doNothingMove, 3);
            _humanFighter.SetMove(_runawayMove);
            fighter2.SetMove(_doNothingMove);

            _chanceService.PushWhichEventsOccur(_malevolenceAttackIndex, 0, _malevolenceChargeIndex); //first round, _shade1 attacks HumanFighter1, _shade2 charges
            _chanceService.PushWhichEventsOccur(_malevolenceChargeIndex, _malevolenceChargeIndex);    //second round, both shades charge
            _chanceService.PushWhichEventsOccur(_malevolenceChargeIndex, _malevolenceAttackIndex, 1); //third round, _shade1 charges again, _shade2 attacks
            _chanceService.PushAttackHitsNotCrit(2);

            _battleManager.Battle(humanTeam, shadeTeam);

            int fighter1Damage = _humanFighter.MaxHealth - _humanFighter.CurrentHealth;
            int fighter2Damage = fighter2.MaxHealth - fighter2.CurrentHealth;

            Assert.Greater(fighter2Damage, fighter1Damage);
        }
Пример #2
0
        public void SetUp()
        {
            _input       = new MockInput();
            _output      = new MockOutput();
            _menuFactory = new MenuFactory();
            _manager     = new MenuManager(_input, _output, _menuFactory);
            _logger      = new EventLogger();
            _playerOne   = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "swordsman");
            Spell fireSpell = SpellFactory.GetSpell(MagicType.Fire, 1);

            _playerOne.AddSpell(fireSpell);
            _playerOne.SetMana(fireSpell.Cost);

            _playerTwo   = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "mage");
            _playerThree = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "alchemist");
            _playerTeam  = new Team(_manager, _playerOne, _playerTwo, _playerThree);

            _enemyTeam = new Team(_manager, new List <IFighter>
            {
                FighterFactory.GetFighter(FighterType.Goblin, 1),
                FighterFactory.GetFighter(FighterType.Goblin, 1),
                FighterFactory.GetFighter(FighterType.Goblin, 1)
            });

            _manager.InitializeForBattle(_playerTeam, _enemyTeam);
        }
Пример #3
0
        public void BattleMoveQueue_SortAndPopOperation_ReturnsCorrectMove()
        {
            TestHumanFighter fighter1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter3 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            //sorted order is 2, 3, 1
            fighter1.SetSpeed(0);
            fighter2.SetSpeed(2);
            fighter3.SetSpeed(1);

            List <BattleMoveWithTarget> initializerList = new List <BattleMoveWithTarget>
            {
                new BattleMoveWithTarget(_testMove, fighter1, fighter1),
                new BattleMoveWithTarget(_testMove, fighter2, fighter2),
                new BattleMoveWithTarget(_testMove, fighter3, fighter3)
            };

            BattleMoveQueue queue = new BattleMoveQueue(initializerList);

            BattleMoveWithTarget firstSortedMove = queue.SortAndPop();
            IFighter             owner           = firstSortedMove.Owner;

            Assert.AreEqual(fighter2, owner);

            Assert.AreEqual(2, queue.Count);
        }
Пример #4
0
        public void Setup()
        {
            _logger = new EventLogger();

            _fighter = (HumanFighter)TestFighterFactory.GetFighter(TestFighterType.HumanControlledPlayer, 1, "Ted");
            _logger.SubscribeAll(_fighter);
        }
        private void MissedEvent_Setup(bool showAttackMessages)
        {
            Team             mixedPlayerTeam = new Team(_menuManager, _humanPlayer1, _enemyPlayer1);
            TestEnemyFighter enemy3          = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
            Team             enemyTeam       = new Team(_menuManager, _enemyPlayer2, enemy3);

            _humanPlayer1.SetSpeed(2);
            _humanPlayer1.SetMove(_basicAttackMove, 1);
            _humanPlayer1.SetMove(_runawayMove);
            _humanPlayer1.SetMoveTarget(_enemyPlayer2);
            _enemyPlayer1.SetSpeed(1);
            _enemyPlayer1.SetMove(_basicAttackMove);
            _enemyPlayer1.SetMoveTarget(enemy3);
            _mockChanceService.PushEventsOccur(false, false); //both attacks miss
            _logger.Subscribe(EventType.AttackMissed, _humanPlayer1);
            _logger.Subscribe(EventType.AttackMissed, _enemyPlayer1);

            _enemyPlayer2.SetMove(_doNothingMove);
            enemy3.SetMove(_doNothingMove);

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

            _battleManager.Battle(mixedPlayerTeam, enemyTeam, config: config);
        }
        public void Setup()
        {
            _input             = new MockInput();
            _output            = new MockOutput();
            _menuManager       = new TestMenuManager(_input, _output);
            _logger            = new EventLogger();
            _mockChanceService = new MockChanceService();
            TestFighterFactory.SetChanceService(_mockChanceService);

            _battleManager = new BattleManager(_mockChanceService, _input, _output);

            _humanPlayer1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Ted");
            _humanPlayer2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Jed");

            _humanPlayer2.AddSpell(_fireball);
            _humanPlayer2.SetMana(_fireball.Cost);

            _humanPlayer2.TurnEnded += TurnEndedEvents.RestoreManaOnTurnEnd;

            _enemyPlayer1 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "Enemy");
            _enemyPlayer2 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "Enemy");

            _humanTeam = new TestTeam(_menuManager, _humanPlayer1, _humanPlayer2);

            _enemyTeam = new Team(_menuManager, _enemyPlayer1, _enemyPlayer2);
        }
Пример #7
0
        private Team GetSingleEnemyTeam()
        {
            TestEnemyFighter enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            enemy.SetMove(_doNothingMove);
            return(new TestTeam(enemy));
        }
Пример #8
0
        public void Setup()
        {
            _fighter = new TestHumanFighter("Hero", 1);
            _fighter.SetHealth(FighterHealth);
            _fighter.SetMana(FighterMana);
            _fighter.SetStrength(FighterAttack);
            _fighter.SetDefense(FighterDefense);
            _fighter.SetSpeed(FighterSpeed);
            _fighter.SetEvade(FighterEvade);
            _fighter.SetLuck(FighterLuck);

            _factoryFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Ted");
            _factoryFighter.AddSpell(SpellFactory.GetSpell(MagicType.Fire, 1));
            _enemy             = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy");
            _armoredEnemy      = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "armored");
            _superArmoredEnemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "super armored");

            _input         = new MockInput();
            _output        = new MockOutput();
            _menuManager   = new TestMenuManager(_input, _output);
            _chanceService = new MockChanceService();

            _battleManager = new TestBattleManager(_chanceService, _input, _output);

            var humanTeam = new Team(_menuManager, _fighter);

            _battleManager.SetHumanTeam(humanTeam);

            var enemyTeam = new Team(_menuManager, _enemy);

            _battleManager.SetEnemyTeam(enemyTeam);

            _battleManager.SetConfig(new BattleManagerBattleConfiguration());
        }
Пример #9
0
        public void Setup()
        {
            _fighter = new TestHumanFighter("Hero", 1);
            _enemy   = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy");

            _logger = new EventLogger();
        }
Пример #10
0
        public void HumanTeam_TestAdd_ThenGetInputs()
        {
            var newFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            _humanTeam.Add(newFighter);

            var newFighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            _humanTeam.Add(newFighter2);

            var newEnemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            _enemyTeam.Add(newEnemy);

            var count = _humanTeam.Fighters.Count;

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

            var inputs = _humanTeam.GetInputs(_enemyTeam);

            Assert.AreEqual(count, inputs.Count);

            foreach (var input in inputs)
            {
                Assert.AreEqual(newEnemy, input.Target);
            }
        }
        public void CorrectlyOmitsSpellSelectionWhenPlayerHasNoSpells()
        {
            var player     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            var playerTeam = new Team(_menuManager, player);

            Assert.AreEqual(0, player.Spells.Count, "Menu factory incorrectly assigned spells to player fighter.");

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

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

            //should generate error
            _menuInput.Push("magic");
            _menuInput.Push("attack");
            _menuInput.Push("1");

            var ret = _menu.GetInput();

            Assert.AreEqual(BattleMoveType.Attack, ret.Move.MoveType);

            var outputs = _menuOutput.GetOutputs();

            //1 for error message, 5 for target menu
            var expectedLength = (fullMenuPromptLength * 2) + 1 + _fullTargetMenuPrompt.Count;

            Assert.AreEqual(expectedLength, outputs.Length);

            var i = 0;

            for (; i < fullMenuPromptLength; ++i)
            {
                Assert.AreEqual(fullMenuPrompt[i], outputs[i].Message);
                Assert.AreEqual(MockOutputMessageType.Normal, outputs[i].Type);
            }

            Assert.AreEqual(ErrorMessage, outputs[i].Message);
            Assert.AreEqual(MockOutputMessageType.Error, outputs[i++].Type);

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

            for (var j = 0; j < fullMenuPromptLength; ++j, ++i)
            {
                Assert.AreEqual(_fullTargetMenuPrompt[j], outputs[i].Message);
                Assert.AreEqual(MockOutputMessageType.Normal, outputs[i].Type);
            }
        }
Пример #12
0
        public void CorrectlyExecutesCutscene_SubRegionCompleted()
        {
            const MagicType firstBossEggType  = MagicType.Fire;
            const MagicType secondBossEggType = MagicType.Ice;

            ColorString[] firstSceneLines  = { new ColorString("foo"), new ColorString("bar") };
            SingleScene   firstSingleScene = new SingleScene(firstSceneLines);

            ColorString[] secondSceneLines  = { new ColorString("baz"), new ColorString("fwee") };
            SingleScene   secondSingleScene = new SingleScene(secondSceneLines);

            SingleScene[] scenes          = { firstSingleScene, secondSingleScene };
            Cutscene      regionACutscene = new Cutscene(scenes);

            TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType));
            SubRegion         subRegionA             = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration), regionCompletedCutscene: regionACutscene);

            TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType));
            SubRegion         subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration));

            SubRegion[] subRegions = { subRegionA, subRegionB };

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

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion));

            AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB));

            _mapManager.SetRegionalMap(regionMap);
            _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap);

            _regionManager = GetRegionManager();

            TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            target.SetHealth(1, 0);

            _humanFighter1.SetMove(_basicAttackMove, 1);
            _humanFighter1.SetMove(_runawayMove, 1);
            _humanFighter1.SetMoveTarget(target);

            _humanFighter2.SetMove(_doNothingMove);

            _chanceService.PushAttackHitsNotCrit();

            _regionManager.Battle(_battleManager, _humanTeam);

            List <MockOutputMessage> outputs = _output.GetOutputs().ToList();

            List <ColorString> allCutsceneLines = firstSceneLines.Concat(secondSceneLines).ToList();

            foreach (ColorString cutsceneLine in allCutsceneLines)
            {
                Assert.NotNull(outputs.FirstOrDefault(output => output.Message == cutsceneLine.Value + "\n" && output.Color == cutsceneLine.Color));
            }
        }
Пример #13
0
        public void FighterFactory_CorrectlyRandomizesEggType_IfNoneSpecified()
        {
            TestFighterFactory.SetChanceService(_chanceService);
            _chanceService.PushWhichEventOccurs(0);

            Egg egg = (Egg)FighterFactory.GetFighter(FighterType.Egg, 1);

            Assert.AreEqual(Globals.EggMagicTypes[0], egg.MagicType);
        }
Пример #14
0
        public void BattleMoveQueue_SortOperation_DefaultsBySpeedAndPriority()
        {
            TestHumanFighter fighter1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter3 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter4 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter5 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter6 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter7 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter8 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter9 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            TestHumanFighter[] expectedOrderedFighters =
            {
                fighter9, fighter6, fighter3, //the high priority
                fighter8, fighter5, fighter2, //the med priority
                fighter7, fighter4, fighter1  //the low priority
            };

            fighter1.SetSpeed(0);
            fighter2.SetSpeed(0);
            fighter3.SetSpeed(0);
            fighter4.SetSpeed(1);
            fighter5.SetSpeed(1);
            fighter6.SetSpeed(1);
            fighter7.SetSpeed(2);
            fighter8.SetSpeed(2);
            fighter9.SetSpeed(2);

            BattleMove lowPriorityMove  = new BattleMove("foo", BattleMoveType.DoNothing, TargetType.Self, -1);
            BattleMove medPriorityMove  = new BattleMove("bar", BattleMoveType.DoNothing, TargetType.Self);
            BattleMove highPriorityMove = new BattleMove("baz", BattleMoveType.DoNothing, TargetType.Self, 1);

            List <BattleMoveWithTarget> initializerList = new List <BattleMoveWithTarget>
            {
                new BattleMoveWithTarget(lowPriorityMove, fighter1, fighter1),
                new BattleMoveWithTarget(lowPriorityMove, fighter4, fighter4),
                new BattleMoveWithTarget(lowPriorityMove, fighter7, fighter7),
                new BattleMoveWithTarget(medPriorityMove, fighter2, fighter2),
                new BattleMoveWithTarget(medPriorityMove, fighter5, fighter5),
                new BattleMoveWithTarget(medPriorityMove, fighter8, fighter8),
                new BattleMoveWithTarget(highPriorityMove, fighter3, fighter3),
                new BattleMoveWithTarget(highPriorityMove, fighter6, fighter6),
                new BattleMoveWithTarget(highPriorityMove, fighter9, fighter9)
            };

            BattleMoveQueue queue = new BattleMoveQueue(initializerList);

            queue.Sort();

            for (int i = 0; i < 9; ++i)
            {
                BattleMoveWithTarget move  = queue.Pop();
                IFighter             owner = move.Owner;
                Assert.AreEqual(expectedOrderedFighters[i], owner, $"i: {i}");
            }
        }
        public void SetUp()
        {
            _menuInput   = new MockInput();
            _menuOutput  = new MockOutput();
            _menuManager = new TestMenuManager(_menuInput, _menuOutput);

            _player = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            Spell fireball   = SpellFactory.GetSpell(MagicType.Fire, 1);
            Spell earthSpell = SpellFactory.GetSpell(MagicType.Earth, 1);

            _player.AddSpell(fireball);
            _player.AddSpell(earthSpell);
            _player.SetMana(fireball.Cost);

            _playerTeam = new Team(_menuManager, _player);
            _enemyTeam  = new Team(_menuManager, (EnemyFighter)FighterFactory.GetFighter(FighterType.Goblin, 1));

            _menu = (Menu)Globals.MenuFactory.GetMenu(MenuType.ChooseAttackTypeMenu, _menuInput, _menuOutput);
            _menu.Build(_player, _playerTeam, _enemyTeam, null);

            _fullSpellMenuPrompt = new List <string>
            {
                $"Which spell would you like to cast?\n{_player.DisplayName} currently has {_player.CurrentMana} / {_player.MaxMana} Mana\n",
            };

            var spellMenu = (SpellSelectionMenu)Globals.MenuFactory.GetMenu(MenuType.ChooseSpellMenu);

            spellMenu.Build(_player, _playerTeam, _enemyTeam, null);

            var spellMenuActions = spellMenu.MenuActions;

            for (var i = 0; i < spellMenuActions.Count; ++i)
            {
                _fullSpellMenuPrompt.Add((i + 1) + ". " + spellMenuActions[i].DisplayText + "\n");
            }

            _fullSpellMenuPrompt.Add(StatusPrompt);
            _fullSpellMenuPrompt.Add(HelpPrompt);

            _fullMenuPrompt = new List <string>
            {
                "How would you like to fight?\n",
                "1. attack\n",
                "2. magic\n",
                StatusPrompt,
                HelpPrompt
            };

            _fullTargetMenuPrompt = new List <string>
            {
                "Who will you target for this action?\n",
                "1. " + _enemyTeam.Fighters[0].DisplayName + "\n",
                StatusPrompt,
                BackPrompt,
                HelpPrompt
            };
        }
Пример #16
0
        public void CorrectlyMovesToNextSubRegion_OnlyOneNextSubRegion()
        {
            const MagicType firstBossEggType  = MagicType.Fire;
            const MagicType secondBossEggType = MagicType.Ice;

            TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType));
            SubRegion         subRegionA             = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration));

            const string      secondRegionIntro       = "Who wants donuts?!?";
            TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType));
            SubRegion         subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration), regionIntro: secondRegionIntro);

            SubRegion[] subRegions = { subRegionA, subRegionB };

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

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion));

            AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB));

            _mapManager.SetRegionalMap(regionMap);
            _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap);

            _regionManager = GetRegionManager();

            TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            target.SetHealth(1, 0);

            _humanFighter1.SetMove(_basicAttackMove, 1);
            _humanFighter1.SetMove(_runawayMove, 1);
            _humanFighter1.SetMoveTarget(target);

            _humanFighter2.SetMove(_doNothingMove);

            _chanceService.PushAttackHitsNotCrit();

            _regionManager.Battle(_battleManager, _humanTeam);

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.NotNull(outputs.FirstOrDefault(o => o.Message == secondRegionIntro + "\n"));

            List <Team> enemyTeams = _battleManager.GetAllEnemyTeams();

            Assert.AreEqual(2, enemyTeams.Count);

            Egg secondBoss = enemyTeams[1].Fighters[0] as Egg;

            Assert.NotNull(secondBoss);
            Assert.AreEqual(secondBossEggType, secondBoss.MagicType);

            Assert.AreEqual(WorldSubRegion.DesertCrypt, subRegionMap.CurrentArea.AreaId);
        }
Пример #17
0
        public void SetUp()
        {
            _chanceService = new MockChanceService();
            _logger        = new EventLogger();
            TestFighterFactory.SetChanceService(_chanceService);
            _copperBell = new Bell(CopperBellDisplayName, BellType.Copper, new MenuFactory(), _chanceService);
            _silverBell = new Bell(SilverBellDisplayName, BellType.Silver, new MenuFactory(), _chanceService);

            _fighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
        }
Пример #18
0
        public void Setup()
        {
            _mockChanceService = new MockChanceService();
            TestFighterFactory.SetChanceService(_mockChanceService);

            _zombie     = (Zombie)TestFighterFactory.GetFighter(TestFighterType.Zombie, 1);
            _zombieTeam = new Team(TestMenuManager.GetTestMenuManager(), _zombie);

            _humanTeam = new Team(new TestMenuManager(new MockInput(), new MockOutput()), (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1));
        }
Пример #19
0
        public void Setup()
        {
            _mockChanceService = new MockChanceService();
            TestFighterFactory.SetChanceService(_mockChanceService);

            _fairy     = (Fairy)TestFighterFactory.GetFighter(TestFighterType.Fairy, 1);
            _fairyTeam = new Team(TestMenuManager.GetTestMenuManager(), _fairy);

            _humanTeam = new Team(new TestMenuManager(new MockInput(), new MockOutput()), (HumanFighter)TestFighterFactory.GetFighter(TestFighterType.HumanControlledPlayer, 1));
        }
Пример #20
0
        public void AddMethod_CorrectlySetsTeamPropertyOfFighters()
        {
            IFighter newFighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            Assert.IsNull(newFighter.Team);

            _humanTeam.Add(newFighter);

            Assert.AreEqual(_humanTeam, newFighter.Team);
        }
        public void GreatswordShouldHaveWinrateAgainstGreatsword(int level, int fightCount, double expectedWinrate)
        {
            var greatsword = TestFighterFactory.GetGreatswordFighter(level, ItemRarity.Mythic);
            var other      = TestFighterFactory.GetGreatswordFighter(level, ItemRarity.Mythic);

            var balanceResults = CalculateBalance(greatsword, other, fightCount);

            var greatswordResults = balanceResults.First(o => o.Fighter.Id == greatsword.Id);

            Assert.Equal(greatswordResults.WinRate, expectedWinrate, 1);
        }
Пример #22
0
        public void SetUp()
        {
            _input  = new MockInput();
            _output = new MockOutput();

            _fighter     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            _fighterTeam = new TestTeam(_fighter);

            _enemy     = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
            _enemyTeam = new TestTeam(_enemy);
        }
        public void CorrectlyDisplaysError_WhenPlayerHasNoSpecialMoves()
        {
            var player     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            var playerTeam = new Team(_menuManager, player);

            Assert.AreEqual(0, player.SpecialMoves.Count, "Menu factory incorrectly assigned special moves to player fighter.");

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

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

            //should generate error
            _menuInput.Push(new List <string> {
                "special", "back"
            });

            var ret = _menu.GetInput();

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

            var outputs = _menuOutput.GetOutputs();

            //display menu twice, display error
            var expectedLength = (fullMenuPromptLength * 2) + 1;

            Assert.AreEqual(expectedLength, outputs.Length);

            var i = 0;

            while (i < fullMenuPromptLength)
            {
                Assert.AreEqual(fullMenuPrompt[i], outputs[i].Message);
                Assert.AreEqual(MockOutputMessageType.Normal, outputs[i++].Type);
            }

            Assert.AreEqual(ErrorMessage, outputs[i].Message);
            Assert.AreEqual(MockOutputMessageType.Error, outputs[i++].Type);

            var j = 0;

            while (j < fullMenuPromptLength)
            {
                Assert.AreEqual(fullMenuPrompt[j++], outputs[i].Message);
                Assert.AreEqual(MockOutputMessageType.Normal, outputs[i++].Type);
            }
        }
        public void DaggerShouldHaveWinrateAgainstBow(int level, int fightCount, double expectedWinrate)
        {
            var dagger = TestFighterFactory.GetDaggerFighter(level, ItemRarity.Mythic);
            var bow    = TestFighterFactory.GetBowFighter(level, ItemRarity.Mythic);

            var balanceResults = CalculateBalance(dagger, bow, fightCount);

            var daggerResults = balanceResults.First(o => o.Fighter.Id == dagger.Id);

            Assert.Equal(daggerResults.WinRate, expectedWinrate, 1);
        }
        public void GlaiveShouldHaveWinrateAgainstBow(int level, int fightCount, double expectedWinrate)
        {
            var glaive = TestFighterFactory.GetGaiveFighter(level, ItemRarity.Mythic);
            var bow    = TestFighterFactory.GetBowFighter(level, ItemRarity.Mythic);

            var balanceResults = CalculateBalance(glaive, bow, fightCount);

            var glaiveResults = balanceResults.First(o => o.Fighter.Id == glaive.Id);

            Assert.Equal(glaiveResults.WinRate, expectedWinrate, 1);
        }
Пример #26
0
        public void SetUp()
        {
            _input  = new MockInput();
            _output = new MockOutput();

            _menu = new KeysOffOwnerNumberInputMenu("foo", _input, _output);

            _owner     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            _ownerTeam = new TestTeam(_owner);
            _enemyTeam = new TestTeam((TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1));
        }
Пример #27
0
 public void Setup()
 {
     _fighter = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Ted");
     _enemy   = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy");
     _logger  = new EventLogger();
     _logger.SubscribeAll(_fighter);
     _logger.SubscribeAll(_enemy);
     _fireballSpell = SpellFactory.GetSpell(MagicType.Fire, 1);
     _fighter.AddSpell(_fireballSpell);
     _fighter.SetMana(_fireballSpell.Cost);
     _logger.ClearLogs();
 }
        public void SetUp()
        {
            _menuInput   = new MockInput();
            _menuOutput  = new MockOutput();
            _menuManager = new TestMenuManager(_menuInput, _menuOutput);

            _enemyTeam  = new Team(_menuManager, FighterFactory.GetFighter(FighterType.Goblin, 1));
            _player     = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            _playerTeam = new Team(_menuManager, _player);

            _menu = (SpecialMoveSelectionMenu)Globals.MenuFactory.GetMenu(MenuType.ChooseSpecialAttackMenu, _menuInput, _menuOutput);
            _menu.Build(_player, _playerTeam, _enemyTeam, null);
        }
        public void Setup()
        {
            _input             = new MockInput();
            _output            = new MockOutput();
            _menuManager       = new TestMenuManager(_input, _output);
            _mockChanceService = new MockChanceService();
            TestFighterFactory.SetChanceService(_mockChanceService);
            FighterFactory.SetInput(_input);
            FighterFactory.SetOutput(_output);

            _fighter = (HumanControlledEnemyFighter)FighterFactory.GetFighter(FighterType.HumanControlledEnemy, 1, "hero");
            _enemy   = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy");
        }
Пример #30
0
        public void SetUp()
        {
            _chanceService = new MockChanceService();
            _output        = new MockOutput();
            _input         = new MockInput();

            _team1Fighter = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);
            _team2Fighter = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            _team1 = new Team(TestMenuManager.GetTestMenuManager(), _team1Fighter);
            _team2 = new Team(TestMenuManager.GetTestMenuManager(), _team2Fighter);

            _battleManager = new TestBattleManager(_chanceService, _input, _output);
        }