Beispiel #1
0
        public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <DexLevel> vs, bool all = false)
        {
            if (NoHatchFromEgg.Contains(pkm.Species))
            {
                yield break;
            }
            if (FormConverter.IsTotemForm(pkm.Species, pkm.AltForm, pkm.GenNumber))
            {
                yield break; // no totem eggs
            }
            int gen = pkm.GenNumber;

            if (gen <= 1)
            {
                yield break; // can't get eggs
            }
            // version is a true indicator for all generation 3-5 origins
            var ver = (GameVersion)pkm.Version;
            int max = GetMaxSpeciesOrigin(gen);

            var baseSpecies = GetBaseSpecies(pkm, vs, 0);
            int lvl         = GetEggHatchLevel(gen);

            if (baseSpecies <= max)
            {
                yield return(new EncounterEgg {
                    Version = ver, Level = lvl, Species = baseSpecies
                });

                if (gen > 5 && (pkm.WasTradedEgg || all))
                {
                    yield return new EncounterEgg {
                               Version = GetOtherTradePair(ver), Level = lvl, Species = baseSpecies
                    }
                }
                ;
            }

            if (!GetSplitBreedGeneration(pkm).Contains(pkm.Species))
            {
                yield break; // no other possible species
            }
            var other = GetBaseSpecies(pkm, vs, 1);

            if (other <= max)
            {
                yield return(new EncounterEggSplit {
                    Version = ver, Level = lvl, Species = other, OtherSpecies = baseSpecies
                });

                if (gen > 5 && (pkm.WasTradedEgg || all))
                {
                    yield return new EncounterEggSplit {
                               Version = GetOtherTradePair(ver), Level = lvl, Species = other, OtherSpecies = baseSpecies
                    }
                }
                ;
            }
        }
Beispiel #2
0
 private static bool NoHatchFromEggForm(int species, int form, int gen)
 {
     if (FormConverter.IsTotemForm(species, form, gen))
     {
         return(true);
     }
     if ((species == (int)Species.Sinistea || species == (int)Species.Polteageist) && form != 0) // Chipped = impossible
     {
         return(true);                                                                           // can't get Chipped eggs
     }
     return(false);
 }
Beispiel #3
0
        protected override bool IsMatchForm(PKM pkm, DexLevel evo)
        {
            if (SkipFormCheck)
            {
                return(true);
            }

            if (FormConverter.IsTotemForm(Species, Form, Generation))
            {
                var expectForm = pkm.Format == 7 ? Form : FormConverter.GetTotemBaseForm(Species, Form);
                return(expectForm == evo.Form);
            }

            return(Form == evo.Form || Legal.IsFormChangeable(Species, Form, pkm.AltForm, pkm.Format));
        }
 private static bool NoHatchFromEggForm(int species, int form, int gen)
 {
     if (form == 0)
     {
         return(false);
     }
     if (FormConverter.IsTotemForm(species, form, gen))
     {
         return(true);
     }
     if (species == (int)Species.Pichu)
     {
         return(true);                                                            // can't get Spiky Ear Pichu eggs
     }
     if (species == (int)Species.Sinistea || species == (int)Species.Polteageist) // Antique = impossible
     {
         return(true);                                                            // can't get Antique eggs
     }
     return(false);
 }
        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);
        }
Beispiel #6
0
        public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> vs, bool all = false)
        {
            int species = pkm.Species;

            if (NoHatchFromEgg.Contains(species))
            {
                yield break;
            }

            int gen = pkm.GenNumber;

            if (gen <= 1)
            {
                yield break; // can't get eggs
            }
            if (FormConverter.IsTotemForm(species, pkm.AltForm, gen))
            {
                yield break; // no totem eggs
            }
            // version is a true indicator for all generation 3-5 origins
            var ver = (GameVersion)pkm.Version;
            int lvl = GetEggHatchLevel(gen);
            int max = GetMaxSpeciesOrigin(gen);

            var e = GetBaseSpecies(species, vs, 0);

            if (e.Species <= max)
            {
                yield return(new EncounterEgg(e.Species, e.Form, lvl)
                {
                    Version = ver
                });

                if (gen > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver))
                {
                    yield return new EncounterEgg(e.Species, e.Form, lvl)
                           {
                               Version = GetOtherTradePair(ver)
                           }
                }
                ;
            }

            if (!GetSplitBreedGeneration(gen).Contains(species))
            {
                yield break; // no other possible species
            }
            var o = GetBaseSpecies(species, vs, 1);

            if (o.Species <= max)
            {
                yield return(new EncounterEggSplit(o.Species, o.Form, lvl, e.Species)
                {
                    Version = ver
                });

                if (gen > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver))
                {
                    yield return new EncounterEggSplit(o.Species, o.Form, lvl, e.Species)
                           {
                               Version = GetOtherTradePair(ver)
                           }
                }
                ;
            }
        }