Exemplo n.º 1
0
 private static IEnumerable <EncounterSlot> GetFilteredSlotsByForm(PKM pkm, IEnumerable <EncounterSlot> encounterSlots)
 {
     return(WildForms.Contains(pkm.Species)
         ? encounterSlots.Where(slot => slot.Form == pkm.AltForm)
         : encounterSlots);
 }
Exemplo n.º 2
0
        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:
            case 745 when form == 2:
                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;                                 // 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);
        }
Exemplo n.º 3
0
        private static IEnumerable <EncounterSlot> getValidEncounterSlots(PKM pkm, EncounterArea loc, bool DexNav)
        {
            const int fluteBoost  = 4;
            const int dexnavBoost = 30;

            int df = DexNav ? fluteBoost : 0;
            int dn = DexNav ? fluteBoost + dexnavBoost : 0;
            List <EncounterSlot> slotdata = new List <EncounterSlot>();

            // Get Valid levels
            IEnumerable <DexLevel> vs = getValidPreEvolutions(pkm);
            // Get slots where pokemon can exist
            IEnumerable <EncounterSlot> slots = loc.Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && evo.Level >= slot.LevelMin - df));

            // Filter for Met Level
            int lvl            = pkm.Met_Level;
            var encounterSlots = slots.Where(slot => slot.LevelMin - df <= lvl && lvl <= slot.LevelMax + (slot.AllowDexNav ? dn : df)).ToList();

            // Pressure Slot
            EncounterSlot slotMax = encounterSlots.OrderByDescending(slot => slot.LevelMax).FirstOrDefault();

            if (slotMax != null)
            {
                slotMax = new EncounterSlot(slotMax)
                {
                    Pressure = true, Form = pkm.AltForm
                }
            }
            ;

            if (!DexNav)
            {
                // Filter for Form Specific
                slotdata.AddRange(WildForms.Contains(pkm.Species)
                    ? encounterSlots.Where(slot => slot.Form == pkm.AltForm)
                    : encounterSlots);
                if (slotMax != null)
                {
                    slotdata.Add(slotMax);
                }
                return(slotdata);
            }

            List <EncounterSlot> eslots = encounterSlots.Where(slot => !WildForms.Contains(pkm.Species) || slot.Form == pkm.AltForm).ToList();

            if (slotMax != null)
            {
                eslots.Add(slotMax);
            }
            foreach (EncounterSlot s in eslots)
            {
                bool          nav  = s.AllowDexNav && (pkm.RelearnMove1 != 0 || pkm.AbilityNumber == 4);
                EncounterSlot slot = new EncounterSlot(s)
                {
                    DexNav = nav
                };

                if (slot.LevelMin > lvl)
                {
                    slot.WhiteFlute = true;
                }
                if (slot.LevelMax + 1 <= lvl && lvl <= slot.LevelMax + fluteBoost)
                {
                    slot.BlackFlute = true;
                }
                if (slot.LevelMax != lvl && slot.AllowDexNav)
                {
                    slot.DexNav = true;
                }
                slotdata.Add(slot);
            }
            return(slotdata);
        }