コード例 #1
0
        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");
        }
コード例 #2
0
        public Team GetTeam(MenuManager menuManager, IInput input, IOutput output, out BattleConfigurationSpecialFlag battleFlag)
        {
            List <IFighter> fighters = new List <IFighter>
            {
                null,
                null,
                null,
                null,
                null
            };
            bool continuer = true;

            battleFlag = BattleConfigurationSpecialFlag.None;

            ConfirmationMenu humanControlledTeamConfirmationMenu = new ConfirmationMenu(false, "Do you want this team to be human controlled?", input, output);
            MenuSelection    confirmationInput = humanControlledTeamConfirmationMenu.GetInput();

            bool isHumanControlledTeam = confirmationInput.Description == "yes";

            for (var i = 0; i < 5 && continuer;)
            {
                SelectEnemyFighterMenu menu = Menus[i];

                MenuSelection menuSelection = menu.GetInput();

                if (i > 0 && menuSelection.Description == "back")
                {
                    --i;
                }
                else
                {
                    SelectEnemyFighterMenuSelection selectEnemyMenuSelection =
                        menuSelection as SelectEnemyFighterMenuSelection;

                    if (selectEnemyMenuSelection == null)
                    {
                        throw new InvalidOperationException(
                                  "SelectEnemyFighterMenu.GetInput() didn't return a SelectEnemyFighterMenuSelection");
                    }

                    FighterFactory.SetInput(input);
                    FighterFactory.SetOutput(output);

                    IFighter returnedEnemy = FighterFactory.GetFighter(selectEnemyMenuSelection.FighterType, selectEnemyMenuSelection.FighterLevel);

                    if (!(returnedEnemy is EnemyFighter))
                    {
                        throw new InvalidOperationException(
                                  $"The selected FighterType {selectEnemyMenuSelection.FighterType} cannot be cast to an EnemyFighter");
                    }
                    EnemyFighter enemy = (EnemyFighter)returnedEnemy;


                    IFighter fighterToAdd;
                    if (isHumanControlledTeam)
                    {
                        HumanControlledEnemyFighter humanControlledEnemy = (HumanControlledEnemyFighter)FighterFactory.GetFighter(FighterType.HumanControlledEnemy, 1);
                        humanControlledEnemy.SetEnemy(enemy);
                        fighterToAdd = humanControlledEnemy;
                    }
                    else
                    {
                        fighterToAdd = enemy;
                    }

                    fighters[i] = fighterToAdd;

                    if (selectEnemyMenuSelection.SpecialFlag != BattleConfigurationSpecialFlag.None &&
                        battleFlag == BattleConfigurationSpecialFlag.None)
                    {
                        battleFlag = selectEnemyMenuSelection.SpecialFlag;
                    }

                    if (i < 4)
                    {
                        ConfirmationMenu addAnotherFighrerConfirmationMenu = new ConfirmationMenu(false, "Do you want to add another fighter?", input, output);

                        confirmationInput = addAnotherFighrerConfirmationMenu.GetInput();

                        if (confirmationInput.Description == "no")
                        {
                            continuer = false;
                        }
                    }

                    ++i;
                }
            }

            fighters = fighters.Where(f => f != null).ToList();

            Team ret = new Team(menuManager, fighters);

            return(ret);
        }