Beispiel #1
0
        private static void FindNestPIDIV(PKM pk, EncounterStatic8N enc, bool shiny)
        {
            // Preserve Nature, Altform, Ability (only if HA)
            // Nest encounter RNG generation
            int       iv_count = enc.FlawlessIVCount;
            int       ability_param;
            int       gender_ratio = pk.PersonalInfo.Gender;
            const int nature_param = 255; // random nature in raids

            // TODO: Ability param for A2 raids
            if (enc.Ability == 0)
            {
                ability_param = 255;
            }
            else if (enc.Ability == -1)
            {
                ability_param = 254;
            }
            else
            {
                ability_param = enc.Ability >> 1;
            }

            var iterPKM = pk.Clone();

            while (true)
            {
                ulong seed = GetRandomULong();
                var   RNG  = new XOROSHIRO(seed);
                if (!shiny)
                {
                    SetValuesFromSeed8Unshiny(pk, RNG, iv_count, ability_param, gender_ratio, nature_param);
                }
                if (!(pk.Nature == iterPKM.Nature && pk.AltForm == iterPKM.AltForm))
                {
                    continue;
                }
                if (iterPKM.AbilityNumber == 4 && !(pk.Ability == iterPKM.Ability && pk.AbilityNumber == iterPKM.AbilityNumber))
                {
                    continue;
                }
                // can be ability capsuled
                pk.RefreshAbility(pk.AbilityNumber >> 1);
                break;
            }
        }
Beispiel #2
0
        public void CheckMatch(string raw, ulong seed)
        {
            byte[] data = raw.ToByteArray();
            var    pk8  = new PK8(data);

            var la  = new LegalityAnalysis(pk8);
            var enc = la.EncounterMatch;

            var compare = enc switch
            {
                EncounterStatic8N r => r.Verify(pk8, seed),
                EncounterStatic8ND r => r.Verify(pk8, seed),
                EncounterStatic8NC r => r.Verify(pk8, seed),
                _ => throw new ArgumentException(nameof(enc)),
            };

            compare.Should().BeTrue();
        }