Beispiel #1
0
        private static int[] GetFormEggMoves(int species, int formnum, EggMoves[] table)
        {
            var entry = table[species];

            if (formnum > 0 && AlolanOriginForms.Contains(species))
            {
                entry = table[entry.FormTableIndex + formnum - 1];
            }
            return(entry.Moves);
        }
        private static IEnumerable <EncounterSlot> GetFilteredSlots67(PKM pkm, IEnumerable <EncounterSlot> encounterSlots)
        {
            int species = pkm.Species;
            int form    = pkm.AltForm;

            // Edge Case Handling
            switch (species)
            {
            case 744 when form == 1:     // Rockruff Event
            case 745 when form == 2:     // Lycanroc Event
                yield break;
            }

            EncounterSlot slotMax = null;

            void CachePressureSlot(EncounterSlot s)
            {
                if (slotMax != null && s.LevelMax > slotMax.LevelMax)
                {
                    slotMax = s;
                }
            }

            if (AlolanVariantEvolutions12.Contains(species)) // match form if same species, else form 0.
            {
                foreach (var slot in encounterSlots)
                {
                    if (species == slot.Species ? slot.Form == form : slot.Form == 0)
                    {
                        yield return(slot);
                    }
                    CachePressureSlot(slot);
                }
            }
            else if (ShouldMatchSlotForm()) // match slot form
            {
                foreach (var slot in encounterSlots)
                {
                    if (slot.Form == form)
                    {
                        yield return(slot);
                    }
                    CachePressureSlot(slot);
                }
            }
            else
            {
                foreach (var slot in encounterSlots)
                {
                    yield return(slot); // no form checking

                    CachePressureSlot(slot);
                }
            }

            // Filter for Form Specific
            // Pressure Slot
            if (slotMax == null)
            {
                yield break;
            }

            if (AlolanVariantEvolutions12.Contains(species)) // match form if same species, else form 0.
            {
                if (species == slotMax.Species ? slotMax.Form == form : slotMax.Form == 0)
                {
                    yield return(GetPressureSlot(slotMax, pkm));
                }
            }
            else if (ShouldMatchSlotForm()) // match slot form
            {
                if (slotMax.Form == form)
                {
                    yield return(GetPressureSlot(slotMax, pkm));
                }
            }
            else
            {
                yield return(GetPressureSlot(slotMax, pkm));
            }

            bool ShouldMatchSlotForm() => WildForms.Contains(species) || AlolanOriginForms.Contains(species) || FormConverter.IsTotemForm(species, form);
        }