Ejemplo n.º 1
0
        private static IEnumerable <EncounterArea> GetEncounterTableGSC(PKM pkm)
        {
            if (!ParseSettings.AllowGen2Crystal(pkm))
            {
                return(SlotsGS);
            }

            // Gen 2 met location is lost outside gen 2 games
            if (pkm.Format != 2)
            {
                return(SlotsGSC);
            }

            // Format 2 with met location, encounter should be from Crystal
            if (pkm.HasOriginalMetLocation)
            {
                return(SlotsC);
            }

            // Format 2 without met location but pokemon could not be tradeback to gen 1,
            // encounter should be from gold or silver
            if (pkm.Species > 151 && !FutureEvolutionsGen1.Contains(pkm.Species))
            {
                return(SlotsGS);
            }

            // Encounter could be any gen 2 game, it can have empty met location for have a g/s origin
            // or it can be a Crystal pokemon that lost met location after being tradeback to gen 1 games
            return(SlotsGSC);
        }
Ejemplo n.º 2
0
        public static IEnumerable <IEncounterable> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> chain)
        {
            var canBeEgg = GetCanBeEgg(pkm);

            if (!canBeEgg)
            {
                yield break;
            }

            var baseID = chain[chain.Count - 1];

            if ((baseID.Species >= MaxSpeciesID_2 || baseID.Form != 0) && chain.Count != 1)
            {
                baseID = chain[chain.Count - 2];
            }
            if (baseID.Form != 0)
            {
                yield break; // Forms don't exist in Gen2, besides Unown (which can't breed). Nothing can form-change.
            }
            int species = baseID.Species;

            if (ParseSettings.AllowGen2Crystal(pkm))
            {
                yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.C)); // gen2 egg
            }
            yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.GS));    // gen2 egg
        }
        private static IEnumerable <EncounterStatic> GetEncounterStaticTableGSC(PKM pkm)
        {
            if (!ParseSettings.AllowGen2Crystal(pkm))
            {
                return(StaticGS);
            }
            if (pkm.Format != 2)
            {
                return(StaticGSC);
            }

            if (pkm.HasOriginalMetLocation)
            {
                return(StaticC);
            }
            return(StaticGSC);
        }
Ejemplo n.º 4
0
        private static GameVersion GetIsTutor2(PKM pkm, int species, int move)
        {
            if (!ParseSettings.AllowGen2Crystal(pkm))
            {
                return(NONE);
            }
            var info = PersonalTable.C[species];

            for (int i = 0; i < Tutors_GSC.Length; i++)
            {
                if (Tutors_GSC[i] == move)
                {
                    return(info.TMHM[57 + i] ? GameVersion.C : NONE);
                }
            }
            return(GetIsTutor1(pkm, species, move));
        }
Ejemplo n.º 5
0
        public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> chain, bool all = false)
        {
            int species = pkm.Species;

            if (!Breeding.CanHatchAsEgg(species))
            {
                yield break;
            }

            var canBeEgg = all || GetCanBeEgg(pkm);

            if (!canBeEgg)
            {
                yield break;
            }

            // Gen2 was before split-breed species existed; try to ensure that the egg we try and match to can actually originate in the game.
            // Species must be < 251
            // Form must be 0 (Unown cannot breed).
            var baseID = chain[chain.Count - 1];

            if ((baseID.Species >= Legal.MaxSpeciesID_2 || baseID.Form != 0) && chain.Count != 1)
            {
                baseID = chain[chain.Count - 2];
            }
            if (baseID.Form != 0)
            {
                yield break; // Forms don't exist in Gen2, besides Unown (which can't breed). Nothing can form-change.
            }
            species = baseID.Species;
            if (species > Legal.MaxSpeciesID_2)
            {
                yield break;
            }
            if (ParseSettings.AllowGen2Crystal(pkm))
            {
                yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.C)); // gen2 egg
            }
            yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.GS));    // gen2 egg
        }
        public static IEnumerable <IEncounterable> GenerateEggs(PKM pkm, List <EvoCriteria> chain)
        {
            var canBeEgg = GetCanBeEgg(pkm);

            if (!canBeEgg)
            {
                yield break;
            }

            var baseID = chain[chain.Count - 1];

            if ((baseID.Species >= MaxSpeciesID_2 || baseID.Form != 0) && chain.Count != 1)
            {
                baseID = chain[chain.Count - 2];
            }
            int species = baseID.Species;

            if (ParseSettings.AllowGen2Crystal(pkm))
            {
                yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.C)); // gen2 egg
            }
            yield return(new EncounterEgg(species, 0, 5, 2, GameVersion.GS));    // gen2 egg
        }
Ejemplo n.º 7
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))
            {
                // 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;
                }
                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);
            }
            foreach (var e in GetValidWildEncounters12(pkm, vs, game))
            {
                yield return(e);
            }

            if (gsc)
            {
                var canBeEgg = GetCanBeEgg(pkm);
                if (canBeEgg)
                {
                    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);
            }
        }
Ejemplo n.º 8
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);
            }
        }