Beispiel #1
0
        private uint GenerateRandom(MonsterGender gender, bool isShiny, short ability)
        {
            Generate:
            var random = new MersenneTwisterRandom();
            var thirtyBits = (uint) random.Next(1 << 30);
            var twoBits = (uint) random.Next(1 << 2);
            var result = (thirtyBits << 2) | twoBits;

            Check:
            var Gender = StaticData.MaleRate < 0.0f ? MonsterGender.Genderless : (result % 256 < (byte) (StaticData.MaleRate * byte.MaxValue) ? MonsterGender.Male : MonsterGender.Female);
            var FirstAbility = (result / 65536 % 2) == 0;
            var IsShiny = (result % 65536) < 16;

            if(gender != Gender || ((ability == StaticData.Abilities.Ability_0.Id) != FirstAbility) || isShiny != IsShiny)
                goto Generate;

            return result;
        }
Beispiel #2
0
        public MonsterInstanceData(short species)
        {
            Species = species;

            StaticData = MonsterStaticData.LoadStaticDataPokeApiV2(Species).Result;

            var random = new MersenneTwisterRandom();
            var thirtyBits = (uint) random.Next(1 << 30);
            var twoBits = (uint) random.Next(1 << 2);
            PersonalityValue = (thirtyBits << 2) | twoBits;

            Nature = GenerateNature();

            IV = new MonsterStats(
                (short) random.Next(0, 31),
                (short) random.Next(0, 31),
                (short) random.Next(0, 31),
                (short) random.Next(0, 31),
                (short) random.Next(0, 31),
                (short) random.Next(0, 31));
        }