Exemplo n.º 1
0
        public Team GetTeam(SubRegion region)
        {
            var enemyList = new List <IFighter>();

            int numEnemies = _chanceService.WhichEventOccurs(region.NumberEnemyFighterChances);

            for (var i = 0; i < numEnemies; ++i)
            {
                enemyList.Add(GetEnemy(region));
            }

            //TODO: MenuManager should probably be supplied, perhaps?
            return(new Team(new MenuManager(new ConsoleInput(), new ConsoleOutput(), _menuFactory), enemyList));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines which move will be used for the current turn
        /// </summary>
        /// <param name="ownTeam"></param>
        /// <param name="enemyTeam"></param>
        /// <returns></returns>
        public virtual BattleMove SelectMove(Team ownTeam, Team enemyTeam)
        {
            var index = 0;

            List <BattleMove> executableMoves = GetExecutableMoves(enemyTeam);

            if (executableMoves.Count > 1)
            {
                index = ChanceService.WhichEventOccurs(executableMoves.Count);
            }

            var move = executableMoves[index];

            return(move);
        }
Exemplo n.º 3
0
        public FighterGrouping GetGrouping(FighterGroupingConfiguration config)
        {
            FighterGrouping generatedGrouping = null;

            ShadeGroupingConfiguration shadeConfig = config as ShadeGroupingConfiguration;

            if (shadeConfig != null)
            {
                List <Shade> generatedFighters = new List <Shade>();
                int          minLevel          = shadeConfig.MinLevel;

                for (int i = 0; i < shadeConfig.NumberOfShades; ++i)
                {
                    int level = shadeConfig.MaxLevel == null ?
                                minLevel :
                                _chanceService.WhichEventOccurs(shadeConfig.MaxLevel.Value - minLevel) + minLevel;

                    Shade generatedShade = FighterFactory.GetShade(level);
                    generatedFighters.Add(generatedShade);
                }

                generatedGrouping = new ShadeFighterGrouping(_chanceService, generatedFighters.ToArray());
            }

            return(generatedGrouping);
        }
Exemplo n.º 4
0
        /// <summary>
        /// first round, 2/3rds chance of fighting 2 enemies, 1/3 chance fighting 3.
        /// second round, 3/4th to fight 3, 1/4 to fight 4
        /// third round, 1/6 chance to fight 3, 5/6 to fight 4
        /// </summary>
        /// <param name="round"></param>
        /// <returns></returns>
        public int GetNumOpponents(int round)
        {
            var odds = new double[2];
            var rets = new int[2];

            switch (round)
            {
            default:
                odds[0] = 2.0 / 3.0;
                rets[0] = 2;
                rets[1] = 3;
                break;

            case 2:
                odds[0] = 3.0 / 4.0;
                rets[0] = 3;
                rets[1] = 4;
                break;

            case 3:
                odds[0] = 1.0 / 6.0;
                rets[0] = 3;
                rets[1] = 4;
                break;
            }

            odds[1] = 1.0 - odds[0];

            var outcome = _chanceService.WhichEventOccurs(odds);

            var ret = rets[outcome];

            return(ret);
        }
Exemplo n.º 5
0
        private void OnShadeDeath(object sender, KilledEventArgs e)
        {
            Shade senderAsShade = sender as Shade;

            if (senderAsShade == null)
            {
                throw new InvalidOperationException("ShadeFighterGrouping.OnShadeDeath should only subscribe to a Shade fighters' Killed event!");
            }

            List <Shade> stillAliveShades         = _shades.FindAll(s => s.IsAlive());
            int          numberOfShadesStillAlive = stillAliveShades.Count;

            if (numberOfShadesStillAlive > 0)
            {
                int chosenShadeIndex = _chanceService.WhichEventOccurs(numberOfShadesStillAlive);
                stillAliveShades[chosenShadeIndex].AbsorbShade(senderAsShade);
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public static IFighter GetFighter(FighterType type,
                                          int level,
                                          string name               = null,
                                          MagicType magicType       = MagicType.None,
                                          FighterClass fighterClass = FighterClass.None,
                                          IMenuFactory menuFactory  = null)
        {
            IFighter ret;

            switch (type)
            {
            case FighterType.Goblin:
                ret = new Goblin(level, ChanceService);
                break;

            case FighterType.Golem:     //high defense, low attack, low speed, low health
                ret = new Golem(level, ChanceService);
                break;

            case FighterType.Ogre:     //high attack, low speed, low defense
                ret = new Ogre(level, ChanceService);
                break;

            case FighterType.Fairy:     //high speed, high evade, low attack, low defense
                ret = new Fairy(level, ChanceService);
                break;

            case FighterType.HumanControlledPlayer:
                ret = new HumanFighter(name ?? "Player", level);
                GodRelationshipManager?.InitializeForFighter((HumanFighter)ret);
                break;

            case FighterType.HumanControlledEnemy:
                ret = new HumanControlledEnemyFighter(name ?? "Player", Input, Output, menuFactory ?? Globals.MenuFactory);
                break;

            case FighterType.MegaChicken:
                ret = new MegaChicken(level, ChanceService);
                break;

            case FighterType.Egg:
                if (magicType == MagicType.None)
                {
                    int magicIndex = ChanceService.WhichEventOccurs(Globals.EggMagicTypes.Length);
                    magicType = Globals.EggMagicTypes[magicIndex];
                }
                ret = new Egg(magicType);
                break;

            case FighterType.DancerBoss:
                ret = new DancerBoss(fighterClass, level, ChanceService);
                break;

            case FighterType.Zombie:
                ret = new Zombie(level, ChanceService);
                break;

            case FighterType.Warrior:
                ret = new Warrior(level, ChanceService);
                break;

            case FighterType.ShieldGuy:
                ret = new ShieldGuy(level, ChanceService);
                break;

            case FighterType.Barbarian:
                ret = new Barbarian(level, ChanceService);
                break;

            case FighterType.Shade:
                ret = GetShade(level, name);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type,
                                                      "The specified type is invalid for FighterFactory to initialize!");
            }

            return(ret);
        }
Exemplo n.º 8
0
        public void PersonalityQuiz(HumanFighter fighter1, HumanFighter fighter2,
                                    bool randomizeAnswers = false, IChanceService chanceService = null)
        {
            if (randomizeAnswers)
            {
                _output.WriteLine("Alright- in case you were wondering, here's what was generated:\n");
            }

            foreach (PersonalityQuizQuestionAndBonus quizQuestionAndBonus in PersonalityQuizQuestionsAndBonuses)
            {
                List <HumanFighter> selectedFighters = new List <HumanFighter>();

                if (!randomizeAnswers)
                {
                    List <MenuAction> additionalMenuActions = new List <MenuAction>();

                    if (quizQuestionAndBonus.AllowBonusOptions)
                    {
                        additionalMenuActions.Add(new MenuAction(_bothMenuActionText, "both"));
                        additionalMenuActions.Add(new MenuAction(_neitherMenuActionText, "neither"));
                    }

                    FighterSelectionMenu menu = new FighterSelectionMenu(quizQuestionAndBonus.Question, _input, _output, additionalMenuActions.ToArray(),
                                                                         fighter1, fighter2);
                    MenuSelection selection = menu.GetInput();

                    if (quizQuestionAndBonus.AllowBonusOptions && selection.Target == null)
                    {
                        if (selection.Description == _bothMenuActionText)
                        {
                            selectedFighters.Add(fighter1);
                            selectedFighters.Add(fighter2);
                        }
                    }
                    else
                    {
                        HumanFighter selectedFighter = selection.Target as HumanFighter;
                        selectedFighters.Add(selectedFighter);

                        if (selectedFighter == null)
                        {
                            throw new InvalidCastException(
                                      "DecisionManager.PersonalityQuiz() was somehow provided with a fighter that wasn't a HumanFighter!");
                        }
                    }
                }
                else
                {
                    if (chanceService == null)
                    {
                        throw new InvalidOperationException("PersonalityQuiz must be supplied a chanceService if randomizeAnswers is set to true");
                    }

                    int numberOptions = quizQuestionAndBonus.AllowBonusOptions ? 4 : 2;

                    int selectedFighterIndex = chanceService.WhichEventOccurs(numberOptions);

                    if (quizQuestionAndBonus.AllowBonusOptions && selectedFighterIndex > 1)
                    {
                        if (selectedFighterIndex == 2)
                        {
                            selectedFighters.Add(fighter1);
                            selectedFighters.Add(fighter2);

                            _output.WriteLine($"both fighters {quizQuestionAndBonus.PersonalityStatement}");
                        }
                        else
                        {
                            _output.WriteLine($"neither fighter {quizQuestionAndBonus.PersonalityStatement}");
                        }
                    }
                    else
                    {
                        HumanFighter selectedFighter = selectedFighterIndex == 0 ? fighter1 : fighter2;
                        selectedFighters.Add(selectedFighter);

                        _output.WriteLine($"{selectedFighter.DisplayName} {quizQuestionAndBonus.PersonalityStatement}");
                    }
                }

                DecisionBonus[] selectedFighterBonus = quizQuestionAndBonus.SelectedPlayerBonuses;

                foreach (DecisionBonus bonus in selectedFighterBonus)
                {
                    selectedFighters.ForEach(f => bonus.ApplyBonus(f, _relationshipManager, true));
                }

                DecisionBonus[]     notSelectedFighterBonus = quizQuestionAndBonus.NotSelectedPlayerBonuses;
                List <HumanFighter> notSelectedFighters     = new List <HumanFighter>();

                if (!selectedFighters.Contains(fighter1))
                {
                    notSelectedFighters.Add(fighter1);
                }
                if (!selectedFighters.Contains(fighter2))
                {
                    notSelectedFighters.Add(fighter2);
                }

                foreach (DecisionBonus bonus in notSelectedFighterBonus)
                {
                    notSelectedFighters.ForEach(f => bonus.ApplyBonus(f, _relationshipManager, true));
                }
            }

            if (randomizeAnswers)
            {
                _input.WaitAndClear(_output);
            }
        }