Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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);
        }
Ejemplo 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))
            {
                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);
            }
        }
Ejemplo 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))
            {
                // 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);
            }
        }
Ejemplo n.º 5
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 <EncounterSlot> GetSlots(PKM pk, IReadOnlyCollection <int> needs)
        {
            var slots = EncounterSlotGenerator.GetPossible(pk);

            foreach (var slot in slots)
            {
                if (needs.Count == 0)
                {
                    yield return(slot);

                    continue;
                }

                if (slot is IMoveset m && needs.Except(m.Moves).Any())
                {
                    yield return(slot);
                }
            }
        }
Ejemplo n.º 6
0
        public static CheckResult[] VerifyRelearn(PKM pkm, LegalInfo info)
        {
            if (info.Generation < 6 || pkm.VC1)
            {
                return(VerifyRelearnNone(pkm, info));
            }

            switch (info.EncounterMatch)
            {
            case EncounterLink l:
                return(VerifyRelearnSpecifiedMoveset(pkm, info, l.RelearnMoves));

            case MysteryGift g:
                return(VerifyRelearnSpecifiedMoveset(pkm, info, g.RelearnMoves));

            case EncounterStatic s when s.Relearn.Length > 0:
                return(VerifyRelearnSpecifiedMoveset(pkm, info, s.Relearn));

            case EncounterEgg e:
                return(VerifyRelearnEggBase(pkm, info, e));

            case EncounterSlot z when pkm.RelearnMove1 != 0 && z.Permissions.DexNav && EncounterSlotGenerator.IsDexNavValid(pkm):
                return(VerifyRelearnDexNav(pkm, info));
            }
            return(VerifyRelearnNone(pkm, info));
        }
Ejemplo n.º 7
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);
            }
        }