Esempio n. 1
0
        private static IEnumerable <IEncounterable> GenerateRawEncounters12(PKM pkm, GameVersion 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 chain = EncounterOrigin.GetOriginChain12(pkm, game);

            var deferred = new List <IEncounterable>();

            foreach (var t in EncounterTradeGenerator.GetValidEncounterTrades(pkm, chain, game))
            {
                // some OTs are longer than the keyboard entry; don't defer these
                if (pkm.Format >= 7 && pkm.OT_Name.Length <= (pkm.Japanese || pkm.Korean ? 5 : 7))
                {
                    deferred.Add(t);
                    continue;
                }
                if (t is EncounterTrade1 t1 && !t1.IsEncounterTrade1Valid(pkm))
                {
                    deferred.Add(t);
                    continue;
                }
                yield return(t);
            }
            foreach (var s in EncounterStaticGenerator.GetValidStaticEncounter(pkm, chain, game))
            {
                yield return(s);
            }
            foreach (var e in EncounterSlotGenerator.GetValidWildEncounters12(pkm, chain, game))
            {
                yield return(e);
            }
            if (game != GameVersion.RBY)
            {
                foreach (var e in EncounterEggGenerator2.GenerateEggs(pkm, chain))
                {
                    yield return(e);
                }
            }

            foreach (var s in GenerateGBEvents(pkm, chain, game))
            {
                yield return(s);
            }

            foreach (var d in deferred)
            {
                yield return(d);
            }
        }
Esempio n. 2
0
        private static IEnumerable <IEncounterable> GenerateRawEncounters12(PKM pkm, GameVersion 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 chain = EncounterOrigin.GetOriginChain12(pkm, game);

            IEncounterable?deferred = null;

            foreach (var t in GetValidEncounterTradesVC(pkm, chain, game))
            {
                // Gen2 trades are strictly matched (OT/Nick), while Gen1 trades allow for deferral (shrug).
                if (t is EncounterTrade1 t1 && t1.GetMatchRating(pkm) != Match)
                {
                    deferred ??= t;
                    continue;
                }
                yield return(t);
            }
            foreach (var s in GetValidStaticEncounter(pkm, chain, game))
            {
                yield return(s);
            }
            foreach (var e in GetValidWildEncounters12(pkm, chain, game))
            {
                yield return(e);
            }
            if (game != GameVersion.RBY)
            {
                foreach (var e in GenerateEggs(pkm, chain))
                {
                    yield return(e);
                }
            }

            foreach (var s in GenerateGBEvents(pkm, chain, game))
            {
                yield return(s);
            }

            if (deferred != null)
            {
                yield return(deferred);
            }
        }
Esempio n. 3
0
        private static IEnumerable <IEncounterable> GenerateRawEncounters12(PKM pkm, GameVersion 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 chain = EncounterOrigin.GetOriginChain12(pkm, game);

            var deferred = new List <IEncounterable>();

            foreach (var t in EncounterTradeGenerator.GetValidEncounterTrades(pkm, chain, game))
            {
                // some OTs are longer than the keyboard entry; don't defer these
                if (pkm.Format >= 7 && pkm.OT_Name.Length <= (pkm.Japanese || pkm.Korean ? 5 : 7))
                {
                    deferred.Add(t);
                    continue;
                }
                if (t is EncounterTrade1 t1 && !t1.IsEncounterTrade1Valid(pkm))
                {
                    deferred.Add(t);
                    continue;
                }
                yield return(t);
            }
            foreach (var s in EncounterStaticGenerator.GetValidStaticEncounter(pkm, chain, 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 pkm.Format == 2:     // Crystal specific data needs to be present
                    if (!s.EggEncounter && !pkm.HasOriginalMetLocation)
                    {
                        continue;
                    }
                    if (s.Species == (int)Species.Celebi && ParseSettings.AllowGBCartEra)     // no Celebi, the GameVersion.EventsGBGen2 will pass thru
                    {
                        continue;
                    }
                    break;
                }
                yield return(s);
            }
            foreach (var e in EncounterSlotGenerator.GetValidWildEncounters12(pkm, chain, game))
            {
                yield return(e);
            }
            if (game != GameVersion.RBY)
            {
                foreach (var e in EncounterEggGenerator2.GenerateEggs(pkm, chain))
                {
                    yield return(e);
                }
            }

            foreach (var d in deferred)
            {
                yield return(d);
            }
        }