Exemplo n.º 1
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}");
            }
        }
Exemplo n.º 2
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);
        }