public RegionManager(
            IRegionFactory regionFactory,
            IMapManager mapManager,
            ITeamFactory teamFactory,
            IMenuFactory menuFactory,
            IDecisionManager decisionManager,
            BattlefieldFactory battlefieldFactory,
            IInput input,
            IOutput output,
            IChanceService chanceService)
        {
            _mapManager         = mapManager;
            _teamFactory        = teamFactory;
            _decisionManager    = decisionManager;
            _menuFactory        = menuFactory;
            _battlefieldFactory = battlefieldFactory;

            _input         = input;
            _output        = output;
            _chanceService = chanceService;

            IEnumerable <WorldRegion> allRegionEnums = EnumHelperMethods.GetAllValuesForEnum <WorldRegion>();
            IEnumerable <Region>      allRegions     = regionFactory.GetRegions(allRegionEnums);

            _regionalMap = mapManager.GetRegionalMap(allRegions.ToArray());
        }
        public void GetGroupingMethod_ReturnsSingleton()
        {
            //arrange
            List <Region> regions = _regionFactory.GetRegions(EnumHelperMethods.GetAllValuesForEnum <WorldRegion>()).ToList();

            _mapManager.GetRegionalMap(regions.ToArray());

            Region desertRegion = regions.First(r => r.AreaId == WorldRegion.Desert);

            _mapManager.GetSubRegionalMap(WorldRegion.Desert, desertRegion.SubRegions);

            int regionalGroupingId = Globals.GroupingKeys.MainRegionalMapGroupingId;
            int groupingId         = Globals.GroupingKeys.FirstDesertGroupingId;

            MapGrouping <SubRegion, WorldSubRegion> originalSubRegionalGrouping = _mapManager.GetGrouping <SubRegion, WorldSubRegion>(groupingId);

            originalSubRegionalGrouping.Lock(sr => sr.AreaId != WorldSubRegion.Oasis);

            MapGrouping <Region, WorldRegion> originalRegionalGrouping = _mapManager.GetGrouping <Region, WorldRegion>(regionalGroupingId);

            originalRegionalGrouping.Lock(sr => sr.AreaId != WorldRegion.Casino);

            //act
            MapGrouping <SubRegion, WorldSubRegion> secondSubRegionalGrouping = _mapManager.GetGrouping <SubRegion, WorldSubRegion>(groupingId);
            MapGrouping <Region, WorldRegion>       secondRegionalGrouping    = _mapManager.GetGrouping <Region, WorldRegion>(regionalGroupingId);

            //Assert
            Assert.AreEqual(1, secondSubRegionalGrouping.GetAvaialableAreas().Count());
            Assert.AreEqual(1, secondRegionalGrouping.GetAvaialableAreas().Count());
        }
Exemple #3
0
        public SelectEnemyFighterMenu(IInput input, IOutput output, bool allowBack) : base(allowBack, false, false, "Select an enemy type", null, null, null, input, output)
        {
            IEnumerable <FighterType> fighterTypes = EnumHelperMethods.GetAllValuesForEnum <FighterType>();

            fighterTypes = fighterTypes.Where(ft => ft != FighterType.HumanControlledPlayer && ft != FighterType.HumanControlledEnemy && ft != FighterType.DancerBoss);
            MenuActions  = new List <MenuAction>();

            NumberInputMenu numberSubMenu = new NumberInputMenu("select a level for this fighter (between 1 and 5)", input, output, 1, 5);

            foreach (FighterType fighterType in fighterTypes)
            {
                string fighterTypeString = fighterType.ToString();
                if (fighterType == FighterType.Barbarian)
                {
                    MenuAction menuAction = new TypedMenuAction <BattleConfigurationSpecialFlag>(BattleConfigurationSpecialFlag.FirstBarbarianBattle, fighterType + " (first battle)", fighterTypeString, subMenu: numberSubMenu);
                    MenuActions.Add(menuAction);
                }
                else
                {
                    MenuAction menuAction = new TypedMenuAction <BattleConfigurationSpecialFlag>(BattleConfigurationSpecialFlag.None, fighterTypeString, fighterTypeString, subMenu: numberSubMenu);
                    MenuActions.Add(menuAction);
                }
            }

            _hasBeenBuilt = true;
        }
Exemple #4
0
        public void SetUp()
        {
            _relationshipManager = new GodRelationshipManager();
            _allGodValues        = EnumHelperMethods.GetAllValuesForEnum <GodEnum>();

            FighterFactory.SetGodRelationshipManager(_relationshipManager);
            _fighter = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1);
        }
Exemple #5
0
        public void PickNextAreaMethod_CorrectGodRelationshipBonusesAssigned_DesertGroupings(
            [Values(1, 2)] int whichPlayerGetsFlag, [Range(1, 4)] int firstMenuSelection, [Range(1, 4)] int secondMenuSelection)
        {
            MapGrouping <SubRegion, WorldSubRegion> firstGrouping, secondGrouping;
            MockMenu menu1, menu2;

            List <WorldSubRegion> firstGroupingSubRegions =
                WorldSubRegions.GetSubRegionsByGroupingId(Globals.GroupingKeys.FirstDesertGroupingId).ToList();
            List <WorldSubRegion> secondGroupingSubRegions =
                WorldSubRegions.GetSubRegionsByGroupingId(Globals.GroupingKeys.SecondDesertGroupingId).ToList();

            WorldSubRegion firstSubRegion  = firstGroupingSubRegions[firstMenuSelection - 1];
            WorldSubRegion secondSubRegion = secondGroupingSubRegions[secondMenuSelection - 1];

            PickNextArea_GroupingSetup_DesertGroupings(out firstGrouping, out secondGrouping);
            PickNextArea_MenuSetup_DesertGroupings(firstSubRegion, secondSubRegion, out menu1, out menu2);
            Team team = PickNextArea_TeamSetup_DesertGroupings(whichPlayerGetsFlag, "Stan", "Bill");

            List <HumanFighter> humanFighters = team.Fighters.OfType <HumanFighter>().ToList();

            HumanFighter mazeSolverFighter    = humanFighters.First(f => f.PersonalityFlags.Contains(PersonalityFlag.MazeSolver));
            HumanFighter notMazeSolverFighter = humanFighters.First(f => !f.PersonalityFlags.Contains(PersonalityFlag.MazeSolver));

            menu1.SetNextSelection(new TypedMenuSelection <WorldSubRegion>(firstSubRegion, "", null, null));
            menu2.SetNextSelection(new TypedMenuSelection <WorldSubRegion>(secondSubRegion, "", null, null));

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

            List <GodEnum> allGodEnums = EnumHelperMethods.GetAllValuesForEnum <GodEnum>().ToList();

            GodEnum mazeSolverSelectedRelationship = WorldSubRegions.GetGodEnumBySubRegion(firstSubRegion);

            Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(mazeSolverFighter, mazeSolverSelectedRelationship));

            IEnumerable <GodEnum> notSelectedGods = allGodEnums.Where(g => g != mazeSolverSelectedRelationship);

            foreach (GodEnum notSelectedGod in notSelectedGods)
            {
                int relationshipValue = _relationshipManager.GetFighterRelationshipValue(mazeSolverFighter, notSelectedGod);
                Assert.AreEqual(0, relationshipValue, $"fighter {mazeSolverFighter.DisplayName} should not have any points assigned to {notSelectedGod}");
            }


            GodEnum notMazeSolverSelectedRelationship = WorldSubRegions.GetGodEnumBySubRegion(secondSubRegion);

            Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(notMazeSolverFighter, notMazeSolverSelectedRelationship));

            notSelectedGods = allGodEnums.Where(g => g != notMazeSolverSelectedRelationship);
            foreach (GodEnum notSelectedGod in notSelectedGods)
            {
                int relationshipValue = _relationshipManager.GetFighterRelationshipValue(notMazeSolverFighter, notSelectedGod);
                Assert.AreEqual(0, relationshipValue, $"fighter {notMazeSolverFighter.DisplayName} should not have any points assigned to {notSelectedGod}");
            }
        }
Exemple #6
0
        public void MagicSetGetsAppropriateDefaults_MagicRelationshipType()
        {
            var magicSet = new MagicSet <MagicRelationshipType>();

            IEnumerable <MagicType> magicTypes = EnumHelperMethods.GetAllValuesForEnum <MagicType>();

            foreach (MagicType magicType in magicTypes)
            {
                Assert.AreEqual(MagicRelationshipType.None, magicSet[magicType]);
            }
        }
            public FighterGodRelationship(HumanFighter fighter)
            {
                Fighter = fighter;
                _values = new Dictionary <GodEnum, int>();

                IEnumerable <GodEnum> godValues = EnumHelperMethods.GetAllValuesForEnum <GodEnum>();

                foreach (GodEnum god in godValues)
                {
                    _values[god] = 0;
                }
            }
Exemple #8
0
        private void PickNextArea_GroupingSetup_RegionalGroupings(out MapGrouping <Region, WorldRegion> grouping, bool castleUnlocked = false)
        {
            IRegionFactory                regionFactory = new RegionFactory(_decisionManager);
            IEnumerable <Region>          regions       = regionFactory.GetRegions(EnumHelperMethods.GetAllValuesForEnum <WorldRegion>());
            MapManager                    mapManager    = new MapManager(Globals.GroupingKeys);
            AreaMap <Region, WorldRegion> regionalMap   = mapManager.GetRegionalMap(regions.ToArray());

            grouping = regionalMap.MapPaths.First(p => p.From.AreaId == WorldRegion.Fields).To;

            if (castleUnlocked)
            {
                grouping.Unlock(r => r.AreaId == WorldRegion.DarkCastle);
            }
        }
        public void UnlockRegionMethod_CorrectlyUnlocksArea()
        {
            IEnumerable <WorldRegion>     allRegionEnums = EnumHelperMethods.GetAllValuesForEnum <WorldRegion>();
            IEnumerable <Region>          allRegions     = _regionFactory.GetRegions(allRegionEnums);
            AreaMap <Region, WorldRegion> regionalMap    = _mapManager.GetRegionalMap(allRegions.ToArray());

            MapGrouping <Region, WorldRegion> destinationGrouping =
                regionalMap.MapPaths.First(mp => mp.From.AreaId == WorldRegion.Fields).To;

            MapGroupingItem <Region, WorldRegion> darkCastleGroupingItem =
                destinationGrouping.Values.Single(gi => gi.Item.AreaId == WorldRegion.DarkCastle);

            Assert.True(darkCastleGroupingItem.IsLocked);

            _mapManager.UnlockRegion(destinationGrouping.GroupingId, WorldRegion.DarkCastle);

            Assert.False(darkCastleGroupingItem.IsLocked);
        }
Exemple #10
0
        public static IEnumerable <MagicType> GetBasicMagicTypes()
        {
            IEnumerable <MagicType> magicTypes = EnumHelperMethods.GetAllValuesForEnum <MagicType>();

            return(magicTypes.Where(mt => mt != MagicType.All && mt != MagicType.None));
        }