Esempio n. 1
0
        public void DarkCastleRegion_UnlockedAfterBeatingOtherAreas()
        {
            Region fieldsRegion       = new Region(WorldRegion.Fields, new BattleMove[0], new SubRegion[0]);
            Region desertRegion       = new Region(WorldRegion.Desert, new BattleMove[0], new SubRegion[0]);
            Region casinoRegion       = new Region(WorldRegion.Casino, new BattleMove[0], new SubRegion[0]);
            Region crystalCavesRegion = new Region(WorldRegion.CrystalCaves, new BattleMove[0], new SubRegion[0]);
            Region darkCastleRegion   = new Region(WorldRegion.DarkCastle, new BattleMove[0], new SubRegion[0]);

            AreaMap <Region, WorldRegion> regionalMap = _mapManager.GetRegionalMap(fieldsRegion, desertRegion, casinoRegion, crystalCavesRegion, darkCastleRegion);

            MapGroupingItem <Region, WorldRegion> darkCastleGroupItem = regionalMap.MapPaths.First(mp => mp.To.Values.FirstOrDefault(gi => gi.Item == darkCastleRegion) != null).To.Values.First(gi => gi.Item == darkCastleRegion);

            MockDecisionManager decisionManager = new MockDecisionManager(new GodRelationshipManager());

            int i = 0;

            for (; i < 3; ++i)
            {
                Assert.True(darkCastleGroupItem.IsLocked, "Dark Castle should be locked, not all requisite areas have been completed");
                decisionManager.SetGroupingChoice(i);
                regionalMap.Advance(decisionManager, new TestTeam());
            }

            decisionManager.SetGroupingChoice(i);
            Region finalRegion = null;

            Assert.DoesNotThrow(() => finalRegion = regionalMap.Advance(decisionManager, new TestTeam()));

            Assert.False(darkCastleGroupItem.IsLocked, "Dark Castle should be unlocked, all requisite areas have been completed");

            Assert.AreEqual(darkCastleRegion, finalRegion);
        }
        public void CorrectlyMovesToNextSubRegion_MultipleNextSubRegions([Values(1, 2)] int selectedArea)
        {
            const int groupingId = 10;

            _decisionManager.SetGroupingChoice(selectedArea - 1);
            TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, MagicType.Fire));
            SubRegion         firstSubRegion         = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration));

            FighterType       bossA   = FighterType.Barbarian;
            WorldSubRegion    regionA = WorldSubRegion.DesertCrypt;
            TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(bossA, 1));
            SubRegion         subRegionA = new SubRegion(regionA, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration));

            FighterType       bossB   = FighterType.MegaChicken;
            WorldSubRegion    regionB = WorldSubRegion.Oasis;
            TeamConfiguration thirdBossConfiguration = new TeamConfiguration(new EnemyConfiguration(bossB, 1));
            SubRegion         subRegionB             = new SubRegion(regionB, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(thirdBossConfiguration));

            SubRegion[] subRegions = { firstSubRegion, 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));

            MapGrouping <SubRegion, WorldSubRegion> grouping = new MapGrouping <SubRegion, WorldSubRegion>(groupingId, subRegionA, subRegionB);

            AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(firstSubRegion, new MapPath <SubRegion, WorldSubRegion>(firstSubRegion, grouping));

            _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 <Team> enemyTeams = _battleManager.GetAllEnemyTeams();

            Assert.AreEqual(2, enemyTeams.Count);

            IFighter secondBoss = enemyTeams[1].Fighters[0];

            FighterType    selectedBossType   = selectedArea == 1 ? bossA : bossB;
            WorldSubRegion selectedBossRegion = selectedArea == 1 ? regionA : regionB;

            Assert.NotNull(secondBoss);
            Assert.True(selectedBossType.IsCorrectType(secondBoss));
            Assert.AreEqual(selectedBossRegion, subRegionMap.CurrentArea.AreaId);
        }