Example #1
0
        private Pokemon PickWildPowerLvlReplacement(
            IList <Pokemon> pokemonPool,
            Pokemon current,
            bool banSamePokemon,
            IList <Pokemon> usedUp)
        {
            //  start with within 10% and add 5% either direction till we find
            //  something
            var currentBst   = current.BstForPowerLevels();
            var minTarget    = currentBst - currentBst / 10;
            var maxTarget    = currentBst + currentBst / 10;
            var canPick      = new List <Pokemon>();
            var expandRounds = 0;

            while (canPick.Count == 0 ||
                   canPick.Count < 3 && expandRounds < 3)
            {
                foreach (var pk in pokemonPool)
                {
                    if (pk.BstForPowerLevels() >= minTarget &&
                        pk.BstForPowerLevels() <= maxTarget &&
                        (!banSamePokemon || !ReferenceEquals(pk, current)) &&
                        (usedUp == null || !usedUp.Contains(pk)) &&
                        !canPick.Contains(pk))
                    {
                        canPick.Add(pk);
                    }
                }

                minTarget = minTarget - currentBst / 20;
                maxTarget = maxTarget + currentBst / 20;
                expandRounds++;
            }

            return(canPick[Random.Next(canPick.Count)]);
        }
Example #2
0
        private Pokemon PickReplacement(
            Pokemon current,
            bool usePowerLevels,
            Typing type,
            bool noLegendaries,
            bool wonderGuard)
        {
            if (usePowerLevels)
            {
                //  start with within 10% and add 5% either direction till we find
                //  something
                var currentBst   = current.BstForPowerLevels();
                var minTarget    = currentBst - currentBst / 10;
                var maxTarget    = currentBst + currentBst / 10;
                var canPick      = new List <Pokemon>();
                var expandRounds = 0;

                while (canPick.Count == 0 || canPick.Count < 3 && expandRounds < 2)
                {
                    foreach (var pk in ValidPokemons)
                    {
                        if (pk.PrimaryType != type && pk.SecondaryType != type)
                        {
                            continue;
                        }
                        if (noLegendaries && pk.Legendary)
                        {
                            continue;
                        }
                        if (!wonderGuard && HasWonderGuard(pk))
                        {
                            continue;
                        }

                        var bst = pk.BstForPowerLevels();

                        if (bst >= minTarget && bst <= maxTarget)
                        {
                            canPick.Add(pk);
                        }
                    }

                    minTarget = minTarget - currentBst / 20;
                    maxTarget = maxTarget + currentBst / 20;
                    expandRounds++;
                }

                return(canPick[Random.Next(canPick.Count)]);
            }

            {
                Pokemon pk;

                while (true)
                {
                    pk = ValidPokemons[Random.Next(ValidPokemons.Count)];

                    if (pk.PrimaryType != type && pk.SecondaryType != type)
                    {
                        continue;
                    }
                    if (noLegendaries && pk.Legendary)
                    {
                        continue;
                    }
                    if (wonderGuard && HasWonderGuard(pk))
                    {
                        continue;
                    }

                    break;
                }

                return(pk);
            }
        }