Exemplo n.º 1
0
        //private bool[] valid = new bool[6] { false, false, false, false, false, false };
        //public bool[] Valid
        //{
        //    get { return valid; }
        //    set { valid = value; }
        //}
        public IVCheck(
            Pokemon pokemon, uint level, Nature nature,
            Characteristic characteristic, uint[] stats)
        {
            this.pokemon = pokemon;
            this.nature = nature;

            //  Initialize our possibilities lists.
            Possibilities = new List<List<uint>>
                {
                    new List<uint>(),
                    new List<uint>(),
                    new List<uint>(),
                    new List<uint>(),
                    new List<uint>(),
                    new List<uint>()
                };

            //  we are going to build out an array of all
            //  of the base stats based on the Pokemon.
            //
            var baseStats = new double[]
                {
                    pokemon.BaseHp, pokemon.BaseAtk, pokemon.BaseDef,
                    pokemon.BaseSpA, pokemon.BaseSpD, pokemon.BaseSpe
                };

            //uint minHp = 31;
            //uint maxHp = 0;

            //remains constant?
            double ev = 0;

            //  This is our internal storage for the IV ranges that
            //  we get with the initial set of data, before the
            //  characteristic correction.
            var minIvs = new uint[] {31, 31, 31, 31, 31, 31};
            var maxIvs = new uint[] {0, 0, 0, 0, 0, 0};

            //  hrm can we get rid of this?
            var valid = new[] {false, false, false, false, false, false};

            //  Do the iterative test on the Hit Points
            for (uint hpCnt = 0; hpCnt <= 31; hpCnt++)
            {
                uint hp = (uint) Math.Floor(((hpCnt + 2*baseStats[0] + Math.Floor((ev/4.0)))*level/100.0)) + 10 + level;

                if (hp == stats[0])
                {
                    valid[0] = true;

                    if (hpCnt >= maxIvs[0])
                    {
                        maxIvs[0] = hpCnt;
                    }
                    if (hpCnt <= minIvs[0])
                    {
                        minIvs[0] = hpCnt;
                    }
                }
            }

            //  Do the iterative test on all other IVs, since they are
            //  all the same we will iterate through our list of items
            for (int cnt = 1; cnt < 6; cnt++)
            {
                for (uint statCnt = 0; statCnt <= 31; statCnt++)
                {
                    var stat =
                        (uint)
                        Math.Floor((Math.Floor(((baseStats[cnt]*2.0 + statCnt + Math.Floor(ev/4.0))*level)/100.0) + 5.0)*
                                   nature.Adjustments[cnt]);

                    if (stat == stats[cnt])
                    {
                        valid[cnt] = true;

                        if (statCnt >= maxIvs[cnt])
                        {
                            maxIvs[cnt] = statCnt;
                        }
                        if (statCnt <= minIvs[cnt])
                        {
                            minIvs[cnt] = statCnt;
                        }
                    }
                }
            }

            uint characteristicHigh = 31;

            //  Correct for the characteristic, building
            //  our final array of the valid values for
            //  each.
            if (characteristic != null)
            {
                if (valid[characteristic.AffectedStat])
                {
                    //  Set this to zero so we can begin to keep track
                    characteristicHigh = 0;

                    //  If this is not null we need to iterate through the ranges
                    //  of the IV that is referenced and cull out those that are
                    //  not possible.
                    for (uint charCnt = minIvs[characteristic.AffectedStat];
                         charCnt <= maxIvs[characteristic.AffectedStat];
                         charCnt++)
                    {
                        if ((charCnt%5) == characteristic.Mod5result)
                        {
                            Possibilities[(int) characteristic.AffectedStat].Add(charCnt);

                            characteristicHigh = charCnt;
                        }
                    }
                }
            }

            //  Now we want to go and explode out all of the other items, skipping
            //  the characteristic affected stat is there was one.  We are also
            //  going to clip to the high mark of the characteristic stat
            for (uint statCnt = 0; statCnt <= 5; statCnt++)
            {
                if (valid[statCnt])
                {
                    //  Make sure we dont make any changes to the characteristic stat
                    if (characteristic == null || characteristic.AffectedStat != statCnt)
                    {
                        //
                        for (uint charCnt = minIvs[statCnt];
                             charCnt <= maxIvs[statCnt];
                             charCnt++)
                        {
                            if (charCnt <= characteristicHigh)
                            {
                                Possibilities[(int) statCnt].Add(charCnt);
                            }
                        }
                    }
                }
            }

            //  Should be done now, but may add the hidden power in the future
        }
Exemplo n.º 2
0
        //private bool[] valid = new bool[6] { false, false, false, false, false, false };
        //public bool[] Valid
        //{
        //    get { return valid; }
        //    set { valid = value; }
        //}

        public IVCheck(
            Pokemon pokemon, uint level, Nature nature,
            Characteristic characteristic, uint[] stats)
        {
            this.pokemon = pokemon;
            this.nature  = nature;

            //  Initialize our possibilities lists.
            Possibilities = new List <List <uint> >
            {
                new List <uint>(),
                new List <uint>(),
                new List <uint>(),
                new List <uint>(),
                new List <uint>(),
                new List <uint>()
            };

            //  we are going to build out an array of all
            //  of the base stats based on the Pokemon.
            //
            var baseStats = new double[]
            {
                pokemon.BaseHp, pokemon.BaseAtk, pokemon.BaseDef,
                pokemon.BaseSpA, pokemon.BaseSpD, pokemon.BaseSpe
            };


            //uint minHp = 31;
            //uint maxHp = 0;

            //remains constant?
            double ev = 0;

            //  This is our internal storage for the IV ranges that
            //  we get with the initial set of data, before the
            //  characteristic correction.
            var minIvs = new uint[] { 31, 31, 31, 31, 31, 31 };
            var maxIvs = new uint[] { 0, 0, 0, 0, 0, 0 };

            //  hrm can we get rid of this?
            var valid = new[] { false, false, false, false, false, false };

            //  Do the iterative test on the Hit Points
            for (uint hpCnt = 0; hpCnt <= 31; hpCnt++)
            {
                uint hp = (uint)Math.Floor(((hpCnt + 2 * baseStats[0] + Math.Floor((ev / 4.0))) * level / 100.0)) + 10 + level;

                if (hp == stats[0])
                {
                    valid[0] = true;

                    if (hpCnt >= maxIvs[0])
                    {
                        maxIvs[0] = hpCnt;
                    }
                    if (hpCnt <= minIvs[0])
                    {
                        minIvs[0] = hpCnt;
                    }
                }
            }

            //  Do the iterative test on all other IVs, since they are
            //  all the same we will iterate through our list of items
            for (int cnt = 1; cnt < 6; cnt++)
            {
                for (uint statCnt = 0; statCnt <= 31; statCnt++)
                {
                    var stat =
                        (uint)
                        Math.Floor((Math.Floor(((baseStats[cnt] * 2.0 + statCnt + Math.Floor(ev / 4.0)) * level) / 100.0) + 5.0) *
                                   nature.Adjustments[cnt]);

                    if (stat == stats[cnt])
                    {
                        valid[cnt] = true;

                        if (statCnt >= maxIvs[cnt])
                        {
                            maxIvs[cnt] = statCnt;
                        }
                        if (statCnt <= minIvs[cnt])
                        {
                            minIvs[cnt] = statCnt;
                        }
                    }
                }
            }

            uint characteristicHigh = 31;

            //  Correct for the characteristic, building
            //  our final array of the valid values for
            //  each.
            if (characteristic != null)
            {
                if (valid[characteristic.AffectedStat])
                {
                    //  Set this to zero so we can begin to keep track
                    characteristicHigh = 0;

                    //  If this is not null we need to iterate through the ranges
                    //  of the IV that is referenced and cull out those that are
                    //  not possible.
                    for (uint charCnt = minIvs[characteristic.AffectedStat];
                         charCnt <= maxIvs[characteristic.AffectedStat];
                         charCnt++)
                    {
                        if ((charCnt % 5) == characteristic.Mod5result)
                        {
                            Possibilities[(int)characteristic.AffectedStat].Add(charCnt);

                            characteristicHigh = charCnt;
                        }
                    }
                }
            }

            //  Now we want to go and explode out all of the other items, skipping
            //  the characteristic affected stat is there was one.  We are also
            //  going to clip to the high mark of the characteristic stat
            for (uint statCnt = 0; statCnt <= 5; statCnt++)
            {
                if (valid[statCnt])
                {
                    //  Make sure we dont make any changes to the characteristic stat
                    if (characteristic == null || characteristic.AffectedStat != statCnt)
                    {
                        //
                        for (uint charCnt = minIvs[statCnt];
                             charCnt <= maxIvs[statCnt];
                             charCnt++)
                        {
                            if (charCnt <= characteristicHigh)
                            {
                                Possibilities[(int)statCnt].Add(charCnt);
                            }
                        }
                    }
                }
            }

            //  Should be done now, but may add the hidden power in the future
        }