Esempio n. 1
0
        public static EncounterStatic GetSuggestedMetInfo(PKM pkm)
        {
            if (pkm == null)
            {
                return(null);
            }

            int loc = GetSuggestedTransferLocation(pkm);

            if (pkm.WasEgg)
            {
                return(GetSuggestedEncounterEgg(pkm, loc));
            }

            var w = EncounterSlotGenerator.GetCaptureLocation(pkm);

            if (w != null)
            {
                return(GetSuggestedEncounterWild(w, loc));
            }

            var s = EncounterStaticGenerator.GetStaticLocation(pkm);

            if (s != null)
            {
                return(GetSuggestedEncounterStatic(s, loc));
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets an object containing met data properties that might be legal.
        /// </summary>
        public static EncounterSuggestionData?GetSuggestedMetInfo(PKM pkm)
        {
            int loc = GetSuggestedTransferLocation(pkm);

            if (pkm.WasEgg)
            {
                return(GetSuggestedEncounterEgg(pkm, loc));
            }

            var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true);
            var w     = EncounterSlotGenerator.GetCaptureLocation(pkm, chain);
            var s     = EncounterStaticGenerator.GetStaticLocation(pkm, chain);

            if (w is null)
            {
                return(s is null ? null : GetSuggestedEncounter(pkm, s, loc));
            }
            if (s is null)
            {
                return(GetSuggestedEncounter(pkm, w, loc));
            }

            bool           isDefinitelySlot   = chain.Any(z => z.Species == w.Species && z.Form == w.Form);
            bool           isDefinitelyStatic = chain.Any(z => z.Species == s.Species && z.Form == s.Form);
            IEncounterable obj = (isDefinitelySlot || !isDefinitelyStatic) ? w : s;

            return(GetSuggestedEncounter(pkm, obj, loc));
        }
Esempio n. 3
0
        private void UpdateVCTransferInfo()
        {
            EncounterOriginalGB = EncounterMatch;
            Info.EncounterMatch = EncounterStaticGenerator.GetVCStaticTransferEncounter(pkm);
            if (!(Info.EncounterMatch is EncounterStatic s) || !EncounterStaticGenerator.IsVCStaticTransferEncounterValid(pkm, s))
            {
                AddLine(Severity.Invalid, V80, CheckIdentifier.Encounter); return;
            }

            foreach (var z in VerifyVCEncounter(pkm, EncounterOriginalGB, s, Info.Moves))
            {
                AddLine(z);
            }
        }
Esempio n. 4
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. 5
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))
            {
                // Gen2 trades are strictly matched (OT/Nick), while Gen1 trades allow for deferral (shrug).
                if (t is EncounterTrade1 t1 && t1.IsMatchDeferred(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. 6
0
        private static IEnumerable <EncounterStatic> GenerateGBEvents(PKM pkm, IReadOnlyList <EvoCriteria> chain, GameVersion game)
        {
            if (pkm.Korean) // only GS; no events
            {
                yield break;
            }

            foreach (var e in EncounterStaticGenerator.GetValidGBGifts(pkm, chain, game))
            {
                foreach (var evo in chain)
                {
                    if (e.IsMatch(pkm, evo))
                    {
                        yield return(e);
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Gets possible encounters that allow all moves requested to be learned.
        /// </summary>
        /// <param name="pk">Rough Pokémon data which contains the requested species, gender, and form.</param>
        /// <param name="needs">Moves which cannot be taught by the player.</param>
        /// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
        private static IEnumerable <EncounterStatic> GetStatic(PKM pk, IReadOnlyCollection <int> needs)
        {
            var encs = EncounterStaticGenerator.GetPossible(pk);

            foreach (var enc in encs)
            {
                if (needs.Count == 0)
                {
                    yield return(enc);

                    continue;
                }

                var em = enc.Moves;
                if (em != null && !needs.Except(em).Any())
                {
                    yield return(enc);
                }
            }
        }
Esempio n. 8
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);
            }
        }