Пример #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
                    }
                }
                ;
            }
        }
        public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> chain, 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 (NoHatchFromEggForm(species, pkm.AltForm, gen))
            {
                yield break; // can't originate from eggs
            }
            // version is a true indicator for all generation 3-5 origins
            var ver = (GameVersion)pkm.Version;
            int lvl = gen <= 3 ? 5 : 1;
            int max = GetMaxSpeciesOrigin(gen);

            var e = EvoBase.GetBaseSpecies(chain, 0);

            if (e.Species <= max && !NoHatchFromEggFormGen(e.Species, e.Form, ver))
            {
                yield return(new EncounterEgg(e.Species, e.Form, lvl, gen, ver));

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

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

            if (o.Species == e.Species)
            {
                yield break;
            }

            if (o.Species <= max && !NoHatchFromEggFormGen(o.Species, o.Form, ver))
            {
                yield return(new EncounterEggSplit(o.Species, o.Form, lvl, gen, ver, e.Species));

                if (gen > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver))
                {
                    yield return(new EncounterEggSplit(o.Species, o.Form, lvl, gen, GetOtherTradePair(ver), e.Species));
                }
            }
        }
        private static bool GetCanBeEgg(PKM pkm)
        {
            bool canBeEgg = !pkm.Gen1_NotTradeback && GetCanBeEgg2(pkm) && !NoHatchFromEgg.Contains(pkm.Species);

            if (!canBeEgg)
            {
                return(false);
            }

            if (!IsEvolutionValid(pkm))
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
        private static bool GetCanBeEgg(PKM pkm)
        {
            bool canBeEgg = !pkm.Gen1_NotTradeback && GetCanBeEgg23(pkm) && !NoHatchFromEgg.Contains(pkm.Species);

            if (!canBeEgg)
            {
                return(false);
            }

            // Further Filtering
            if (pkm.Format < 3)
            {
                canBeEgg &= pkm.Met_Location == 0 || pkm.Met_Level == 1; // 2->1->2 clears met info
                canBeEgg &= pkm.CurrentLevel >= 5;
            }

            return(canBeEgg);
        }
Пример #5
0
        private static IEnumerable <GBEncounterData> GenerateRawEncounters12(PKM pkm, GameVersion game)
        {
            bool gsc = GameVersion.GSC.Contains(game);
            var  gen = gsc ? 2 : 1;

            // Since encounter matching is super weak due to limited stored data in the structure
            // Calculate all 3 at the same time and pick the best result (by species).
            // Favor special event move gifts as Static Encounters when applicable
            var           maxspeciesorigin = gsc ? MaxSpeciesID_2 : MaxSpeciesID_1;
            var           vs      = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin);
            HashSet <int> species = new HashSet <int>(vs.Select(p => p.Species).ToList());

            var deferred = new List <IEncounterable>();

            foreach (var t in GetValidEncounterTrades(pkm, vs, game))
            {
                if (pkm.Format >= 7)
                {
                    deferred.Add(t);
                    continue;
                }
                yield return(new GBEncounterData(pkm, gen, t, t.Version));
            }
            foreach (var s in GetValidStaticEncounter(pkm, game).Where(z => species.Contains(z.Species)))
            {
                // Valid stadium and non-stadium encounters, return only non-stadium encounters, they are less restrictive
                switch (s.Version)
                {
                case GameVersion.Stadium:
                case GameVersion.Stadium2:
                    deferred.Add(s);
                    continue;

                case GameVersion.EventsGBGen2:
                    if (!s.EggEncounter && !pkm.HasOriginalMetLocation)
                    {
                        continue;
                    }
                    if (pkm.Japanese)
                    {
                        deferred.Add(s);
                    }
                    continue;

                case GameVersion.C when gsc && pkm.Format == 2:     // Crystal specific data needs to be present
                    if (!s.EggEncounter && !pkm.HasOriginalMetLocation)
                    {
                        continue;
                    }
                    if (s.Species == 251 && AllowGBCartEra)     // no celebi, the GameVersion.EventsGBGen2 will pass thru
                    {
                        continue;
                    }
                    break;
                }
                yield return(new GBEncounterData(pkm, gen, s, s.Version));
            }
            // clear egg flag
            // necessary for static egg gifts which appear in wild, level 8 GS clefairy
            // GetValidWildEncounters immediately returns empty otherwise
            pkm.WasEgg = false;
            foreach (var e in GetValidWildEncounters(pkm, game).OfType <EncounterSlot1>())
            {
                if (!species.Contains(e.Species))
                {
                    continue;
                }
                yield return(new GBEncounterData(pkm, gen, e, e.Version));
            }

            if (gsc)
            {
                bool WasEgg = !pkm.Gen1_NotTradeback && GetWasEgg23(pkm) && !NoHatchFromEgg.Contains(pkm.Species);
                if (WasEgg)
                {
                    // Further Filtering
                    if (pkm.Format < 3)
                    {
                        WasEgg &= pkm.Met_Location == 0 || pkm.Met_Level == 1; // 2->1->2 clears met info
                        WasEgg &= pkm.CurrentLevel >= 5;
                    }
                }
                if (WasEgg)
                {
                    int eggspec = GetBaseEggSpecies(pkm);
                    if (AllowGen2Crystal(pkm))
                    {
                        yield return(new GBEncounterData(eggspec, GameVersion.C)); // gen2 egg
                    }
                    yield return(new GBEncounterData(eggspec, GameVersion.GS));    // gen2 egg
                }
            }

            foreach (var d in deferred)
            {
                yield return(new GBEncounterData(pkm, gen, d, game));
            }
        }
Пример #6
0
        private static IEnumerable <IEncounterable> GenerateRawEncounters12(PKM pkm, GameVersion game)
        {
            bool gsc = GameVersion.GSC.Contains(game);

            // Since encounter matching is super weak due to limited stored data in the structure
            // Calculate all 3 at the same time and pick the best result (by species).
            // Favor special event move gifts as Static Encounters when applicable
            var maxspeciesorigin = gsc ? MaxSpeciesID_2 : MaxSpeciesID_1;
            var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin);

            var deferred = new List <IEncounterable>();

            foreach (var t in GetValidEncounterTrades(pkm, vs, game))
            {
                if (pkm.Format >= 7 && (t.Generation == 2 || t.GetOT(pkm.Language) != pkm.OT_Name)) // ot length collision
                {
                    deferred.Add(t);
                    continue;
                }
                yield return(t);
            }
            foreach (var s in GetValidStaticEncounter(pkm, vs, game))
            {
                // Valid stadium and non-stadium encounters, return only non-stadium encounters, they are less restrictive
                switch (s.Version)
                {
                case GameVersion.Stadium:
                case GameVersion.Stadium2:
                    deferred.Add(s);
                    continue;

                case GameVersion.EventsGBGen2:
                    if (!s.EggEncounter && !pkm.HasOriginalMetLocation)
                    {
                        continue;
                    }
                    if (pkm.Japanese)
                    {
                        deferred.Add(s);
                    }
                    continue;

                case GameVersion.C when gsc && pkm.Format == 2:     // Crystal specific data needs to be present
                    if (!s.EggEncounter && !pkm.HasOriginalMetLocation)
                    {
                        continue;
                    }
                    if (s.Species == 251 && ParseSettings.AllowGBCartEra)     // no celebi, the GameVersion.EventsGBGen2 will pass thru
                    {
                        continue;
                    }
                    break;
                }
                yield return(s);
            }
            // clear egg flag
            // necessary for static egg gifts which appear in wild, level 8 GS clefairy
            // GetValidWildEncounters immediately returns empty otherwise
            pkm.WasEgg = false;
            foreach (var e in GetValidWildEncounters12(pkm, vs, game))
            {
                yield return(e);
            }

            if (gsc)
            {
                bool WasEgg = !pkm.Gen1_NotTradeback && GetWasEgg23(pkm) && !NoHatchFromEgg.Contains(pkm.Species);
                if (WasEgg)
                {
                    // Further Filtering
                    if (pkm.Format < 3)
                    {
                        WasEgg &= pkm.Met_Location == 0 || pkm.Met_Level == 1; // 2->1->2 clears met info
                        WasEgg &= pkm.CurrentLevel >= 5;
                    }
                }
                if (WasEgg)
                {
                    int eggspec = GetBaseEggSpecies(pkm);
                    if (ParseSettings.AllowGen2Crystal(pkm))
                    {
                        yield return new EncounterEgg {
                                   Species = eggspec, Version = GameVersion.C, Level = 5
                        }
                    }
                    ;                                                                                            // gen2 egg
                    yield return(new EncounterEgg {
                        Species = eggspec, Version = GameVersion.GS, Level = 5
                    });                                                                                       // gen2 egg
                }
            }

            foreach (var d in deferred)
            {
                yield return(d);
            }
        }
Пример #7
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)
                           }
                }
                ;
            }
        }