Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        public TArea PickNextArea <TArea, TAreaId>(MapGrouping <TArea, TAreaId> grouping, Team advancingTeam) where TArea : Area <TAreaId>
        {
            TArea ret = _groupingChoiceIndex == -1
                ? _realDecisionManager.PickNextArea <TArea, TAreaId>(grouping, advancingTeam)
                : grouping.GetAvaialableAreas().ToList()[_groupingChoiceIndex];

            return(ret);
        }
Esempio n. 3
0
        private Region ChooseNextRegion(MapGrouping <Region, WorldRegion> grouping)
        {
            IEnumerable <MenuAction> menuActions =
                grouping.GetAvaialableAreas().Select(r => new TypedMenuAction <WorldRegion>(r.AreaId, r.AreaId.ToString(), isHidden: r.AreaId == WorldRegion.Casino || r.AreaId == WorldRegion.CrystalCaves)).ToList();

            IMenu menu = _menuFactory.GetMenu(MenuType.NonSpecificMenu, _input, _output, allowHelp: false, allowBack: false, allowStatus: false,
                                              prompt: "Which region would you like to visit next?", errorText: Globals.GenericErrorMessage,
                                              menuActions: menuActions.ToList());

            menu.Build(null, null, null, null);
            TypedMenuSelection <WorldRegion> menuSelection = menu.GetInput() as TypedMenuSelection <WorldRegion>;

            if (menuSelection == null)
            {
                throw new InvalidCastException("DecisionManager.ChooseNextRegion() should have generated menus that would return a TypedMenuSeleciton<WorldRegion> but it did not!");
            }

            return(grouping.GetAvaialableAreas().First(sr => sr.AreaId == menuSelection.Item));
        }
Esempio n. 4
0
        public T PickNextArea <T, TAreaId>(MapGrouping <T, TAreaId> grouping, Team advancingTeam) where T : Area <TAreaId>
        {
            T ret;

            if (grouping.GroupingId == Globals.GroupingKeys.FirstDesertGroupingId)
            {
                ret = ChooseDesertSubRegions(advancingTeam, grouping as MapGrouping <SubRegion, WorldSubRegion>) as T;
            }
            else if (grouping.GroupingId == Globals.GroupingKeys.MainRegionalMapGroupingId)
            {
                ret = ChooseNextRegion(grouping as MapGrouping <Region, WorldRegion>) as T;
            }
            else
            {
                ret = _chanceService.WhichEventOccurs(grouping.GetAvaialableAreas());
            }

            return(ret);
        }
Esempio n. 5
0
        private SubRegion ChooseDesertSubRegions(Team advancingTeam, MapGrouping <SubRegion, WorldSubRegion> grouping)
        {
            SubRegion ret;

            if (_groupingChoicesDictionary.ContainsKey(Globals.GroupingKeys.FirstDesertGroupingId))
            {
                WorldSubRegion selectedRegion = _groupingChoicesDictionary[Globals.GroupingKeys.FirstDesertGroupingId];
                ret = grouping.GetAvaialableAreas().First(sr => sr.AreaId == selectedRegion);
            }
            else
            {
                HumanFighter mazeSolver =
                    advancingTeam.Fighters.OfType <HumanFighter>()
                    .First(f => f.PersonalityFlags.Contains(PersonalityFlag.MazeSolver));

                HumanFighter notMazeSolver =
                    advancingTeam.Fighters.OfType <HumanFighter>()
                    .First(f => !f.PersonalityFlags.Contains(PersonalityFlag.MazeSolver));

                IEnumerable <WorldSubRegion> firstGroupingSubRegions =
                    WorldSubRegions.GetSubRegionsByGroupingId(Globals.GroupingKeys.FirstDesertGroupingId);

                IEnumerable <MenuAction> firstGroupingMenuActions =
                    firstGroupingSubRegions.Select(
                        sr => new TypedMenuAction <WorldSubRegion>(sr, GetDisplayTextForMenu(sr), GetCommandTextForMenu(sr), isHidden: sr == WorldSubRegion.Oasis));

                IMenu firstGroupingMenu = _menuFactory.GetMenu(MenuType.NonSpecificMenu, _input, _output,
                                                               allowHelp: false, allowBack: false, allowStatus: false,
                                                               prompt:
                                                               $"{Globals.OwnerReplaceText}: We should focus on forming a strategy for our next battle, we should...",
                                                               errorText: Globals.GenericErrorMessage,
                                                               menuActions: firstGroupingMenuActions.ToList(), chanceService: _chanceService, shuffleOptions: true);

                firstGroupingMenu.Build(mazeSolver, null, null, null);
                TypedMenuSelection <WorldSubRegion> firstMenuSelection =
                    firstGroupingMenu.GetInput() as TypedMenuSelection <WorldSubRegion>;

                if (firstMenuSelection == null)
                {
                    throw new InvalidCastException(
                              "DecisionManager.ChooseDesertSubRegions() should have generated menus that would return a TypedMenuSeleciton<WorldSubRegion> but it did not!");
                }

                WorldSubRegion firstSelectedSubRegionEnum = firstMenuSelection.Item;
                grouping.Lock(sr => sr.AreaId != firstSelectedSubRegionEnum);
                _relationshipManager.UpdateRelationship(mazeSolver,
                                                        WorldSubRegions.GetGodEnumBySubRegion(firstSelectedSubRegionEnum), 1);

                _groupingChoicesDictionary.Add(Globals.GroupingKeys.FirstDesertGroupingId, firstSelectedSubRegionEnum);

                IEnumerable <WorldSubRegion> secondGroupingSubRegions =
                    WorldSubRegions.GetSubRegionsByGroupingId(Globals.GroupingKeys.SecondDesertGroupingId);

                IEnumerable <MenuAction> secondGroupingMenuActions =
                    secondGroupingSubRegions.Select(
                        sr => new TypedMenuAction <WorldSubRegion>(sr, GetDisplayTextForMenu(sr), GetCommandTextForMenu(sr), isHidden: sr == WorldSubRegion.BeastTemple));

                IMenu secondGroupingMenu = _menuFactory.GetMenu(MenuType.NonSpecificMenu, _input, _output,
                                                                allowHelp: false, allowBack: false, allowStatus: false,
                                                                prompt: $"{Globals.OwnerReplaceText}: I was thinking about how we could improve, what if we...",
                                                                errorText: Globals.GenericErrorMessage, menuActions: secondGroupingMenuActions.ToList(),
                                                                chanceService: _chanceService, shuffleOptions: true);

                secondGroupingMenu.Build(notMazeSolver, null, null, null);
                TypedMenuSelection <WorldSubRegion> secondMenuSelection =
                    secondGroupingMenu.GetInput() as TypedMenuSelection <WorldSubRegion>;
                if (secondMenuSelection == null)
                {
                    throw new InvalidCastException(
                              "DecisionManager.ChooseDesertSubRegions() should have generated menus that would return a TypedMenuSeleciton<WorldSubRegion> but it did not!");
                }

                WorldSubRegion secondSelectedSubRegionEnum = secondMenuSelection.Item;
                grouping.Parent.MapPaths.First(path => path.To.GroupingId == Globals.GroupingKeys.SecondDesertGroupingId)
                .To.Lock(sr => sr.AreaId != secondSelectedSubRegionEnum);
                _relationshipManager.UpdateRelationship(notMazeSolver,
                                                        WorldSubRegions.GetGodEnumBySubRegion(secondSelectedSubRegionEnum), 1);

                _groupingChoicesDictionary.Add(Globals.GroupingKeys.SecondDesertGroupingId, secondSelectedSubRegionEnum);

                ret = grouping.GetAvaialableAreas().First(sr => sr.AreaId == firstSelectedSubRegionEnum);
            }

            return(ret);
        }