Exemplo n.º 1
0
        private void ForAllFightPermutations(Predicate <Fight> stateUpdate, FightDifficulty difficulty)
        {
            var player = new Player();
            var boss   = bossStats.CreateBoss();
            var fight  = new Fight(player, boss);

            Iterate(fight);

            void Iterate(Fight fight)
            {
                foreach (var spell in AvailableSpells.Spells)
                {
                    var clonedFight = fight.Clone();

                    if (!clonedFight.PlayTurn(spell, difficulty))
                    {
                        continue;
                    }

                    if (!stateUpdate(clonedFight))
                    {
                        continue;
                    }

                    Iterate(clonedFight);
                }
            }
        }
Exemplo n.º 2
0
        private void PickAFight(FightDifficulty difficulty)
        {
            int n = 0;

            switch (difficulty)
            {
            case FightDifficulty.Easy:
                n = Random.Range(0, easyFights.Count);
                fights.Add(easyFights[n]);
                easyFights.RemoveAt(n);
                test += "easy ";
                break;

            case FightDifficulty.Normal:
                n = Random.Range(0, normalFights.Count);
                fights.Add(normalFights[n]);
                normalFights.RemoveAt(n);
                test += "normal ";
                break;

            case FightDifficulty.Hard:
                n = Random.Range(0, hardFights.Count);
                fights.Add(hardFights[n]);
                hardFights.RemoveAt(n);
                test += "hard ";
                break;

            case FightDifficulty.Boss:
                n = Random.Range(0, bossFights.Count);
                fights.Add(bossFights[n]);
                bossFights.RemoveAt(n);
                test += "boss ";
                break;
            }
        }
Exemplo n.º 3
0
        private int FindMinWinnableManaCost(FightDifficulty difficulty)
        {
            int minCost = int.MaxValue;

            ForAllFightPermutations(IterateFightPermutation, difficulty);
            return(minCost);

            bool IterateFightPermutation(Fight fight)
            {
                if (fight.PlayerManaCost >= minCost)
                {
                    return(false);
                }

                if (fight.PlayerWon)
                {
                    minCost = fight.PlayerManaCost;
                }
                return(!fight.Over);
            }
        }