Esempio n. 1
0
        public EggInfoSource(PKM pkm, EncounterEgg e)
        {
            // Eggs with special moves cannot inherit levelup moves as the current moves are predefined.
            AllowInherited = e.Species != 489 && e.Species != 490;

            // Level up moves can only be inherited if ditto is not the mother.
            bool AllowLevelUp = Breeding.GetCanInheritMoves(e.Species);

            Base = MoveList.GetBaseEggMoves(pkm, e.Species, e.Form, e.Version, e.Level);

            Egg     = MoveEgg.GetEggMoves(pkm.PersonalInfo, e.Species, e.Form, e.Version, e.Generation);
            LevelUp = AllowLevelUp
                ? MoveList.GetBaseEggMoves(pkm, e.Species, e.Form, e.Version, 100).Except(Base).ToList()
                : (IReadOnlyList <int>)Array.Empty <int>();
            Tutor = e.Version == GameVersion.C
                ? MoveTutor.GetTutorMoves(pkm, e.Species, 0, false, 2).ToList()
                : (IReadOnlyList <int>)Array.Empty <int>();

            // Only TM/HM moves from the source game of the egg, not any other games from the same generation
            TMHM = MoveTechnicalMachine.GetTMHM(pkm, pkm.Species, pkm.Form, e.Generation, e.Version).ToList();

            // Non-Base moves that can magically appear in the regular movepool
            bool volt = (e.Generation > 3 || e.Version == GameVersion.E) && Legal.LightBall.Contains(pkm.Species);

            if (volt)
            {
                Egg = Egg.ToList();            // array->list
                Egg.Add((int)Move.VoltTackle); // Volt Tackle
            }
        }
Esempio n. 2
0
        public static EggSource2[] Validate(int species, GameVersion version, int[] moves, out bool valid)
        {
            var count = Array.IndexOf(moves, 0);

            if (count == 0)
            {
                valid = false; // empty moveset
                return(Array.Empty <EggSource2>());
            }
            if (count == -1)
            {
                count = moves.Length;
            }

            var learn    = GameData.GetLearnsets(version);
            var table    = GameData.GetPersonal(version);
            var learnset = learn[species];
            var pi       = table[species];
            var egg      = (version == GameVersion.C ? Legal.EggMovesC : Legal.EggMovesGS)[species].Moves;

            var value = new BreedInfo <EggSource2>(count, learnset, moves, level);

            {
                bool inherit = Breeding.GetCanInheritMoves(species);
                MarkMovesForOrigin(value, egg, count, inherit, pi, version);
                valid = RecurseMovesForOrigin(value, count - 1);
            }

            if (!valid)
            {
                CleanResult(value.Actual, value.Possible);
            }
            return(value.Actual);
        }
Esempio n. 3
0
        public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> chain, int generation, bool all = false)
        {
            System.Diagnostics.Debug.Assert(generation >= 3); // if generating Gen2 eggs, use the other generator.
            int species = pkm.Species;

            if (!Breeding.CanHatchAsEgg(species))
            {
                yield break;
            }
            if (!Breeding.CanHatchAsEgg(species, pkm.Form, generation))
            {
                yield break; // can't originate from eggs
            }
            // version is a true indicator for all generation 3-5 origins
            var ver = (GameVersion)pkm.Version;

            if (!Breeding.CanGameGenerateEggs(ver))
            {
                yield break;
            }

            int lvl = generation <= 3 ? 5 : 1;
            int max = GetMaxSpeciesOrigin(generation);

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

            if (e.Species <= max && Breeding.CanHatchAsEgg(e.Species, e.Form, ver))
            {
                yield return(new EncounterEgg(e.Species, e.Form, lvl, generation, ver));

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

            if (!Breeding.GetSplitBreedGeneration(generation).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 && Breeding.CanHatchAsEgg(o.Species, o.Form, ver))
            {
                yield return(new EncounterEgg(o.Species, o.Form, lvl, generation, ver));

                if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver))
                {
                    yield return(new EncounterEgg(o.Species, o.Form, lvl, generation, GetOtherTradePair(ver)));
                }
            }
        }
Esempio n. 4
0
        public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, ReadOnlySpan <int> moves, out bool valid)
        {
            var count = moves.IndexOf(0);

            if (count == 0)
            {
                valid = false; // empty moveset
                return(Array.Empty <EggSource6>());
            }
            if (count == -1)
            {
                count = moves.Length;
            }

            var learn    = GameData.GetLearnsets(version);
            var table    = GameData.GetPersonal(version);
            var index    = table.GetFormIndex(species, form);
            var learnset = learn[index];
            var egg      = MoveEgg.GetEggMoves(generation, species, form, version);

            var         actual   = new EggSource6[count];
            Span <byte> possible = stackalloc byte[count];
            var         value    = new BreedInfo <EggSource6>(actual, possible, learnset, moves, level);

            if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle)
            {
                actual[--count] = VoltTackle;
            }

            if (count == 0)
            {
                valid = VerifyBaseMoves(value);
            }
            else
            {
                bool inherit = Breeding.GetCanInheritMoves(species);
                MarkMovesForOrigin(value, egg, count, inherit);
                valid = RecurseMovesForOrigin(value, count - 1);
            }

            if (!valid)
            {
                CleanResult(actual, possible);
            }
            return(value.Actual);
        }
Esempio n. 5
0
        public static EggSource34[] Validate(int species, GameVersion version, int[] moves, out bool valid)
        {
            var count = Array.IndexOf(moves, 0);

            if (count == 0)
            {
                valid = false; // empty moveset
                return(Array.Empty <EggSource34>());
            }
            if (count == -1)
            {
                count = moves.Length;
            }

            var learn    = GameData.GetLearnsets(version);
            var table    = GameData.GetPersonal(version);
            var learnset = learn[species];
            var pi       = table[species];
            var egg      = Legal.EggMovesRS[species].Moves;

            var value = new BreedInfo <EggSource34>(count, learnset, moves, level);

            if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle && version == GameVersion.E)
            {
                value.Actual[--count] = VoltTackle;
            }

            if (count == 0)
            {
                valid = VerifyBaseMoves(value);
            }
            else
            {
                bool inherit = Breeding.GetCanInheritMoves(species);
                MarkMovesForOrigin(value, egg, count, inherit, pi);
                valid = RecurseMovesForOrigin(value, count - 1);
            }

            if (!valid)
            {
                CleanResult(value.Actual, value.Possible);
            }
            return(value.Actual);
        }
Esempio n. 6
0
        public static int[] GetEggMoves(PersonalInfo pi, int species, int form, GameVersion version, int generation)
        {
            if (species > GetMaxSpeciesOrigin(generation))
            {
                return(Array.Empty <int>());
            }

            if (pi.Genderless && !FixedGenderFromBiGender.Contains(species))
            {
                return(Array.Empty <int>());
            }

            if (!Breeding.CanGameGenerateEggs(version))
            {
                return(Array.Empty <int>());
            }

            return(GetEggMoves(generation, species, form, version));
        }
Esempio n. 7
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[^ 1];
Esempio n. 8
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
        }
Esempio n. 9
0
        public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, int[] moves, out bool valid)
        {
            var count = Array.IndexOf(moves, 0);

            if (count == 0)
            {
                valid = false; // empty moveset
                return(Array.Empty <EggSource6>());
            }
            if (count == -1)
            {
                count = moves.Length;
            }

            var learn    = GameData.GetLearnsets(version);
            var table    = GameData.GetPersonal(version);
            var index    = table.GetFormIndex(species, form);
            var learnset = learn[index];
            var egg      = MoveEgg.GetEggMoves(generation, species, form, version);

            var value = new BreedInfo <EggSource6>(count, learnset, moves, 1);

            if (moves[count - 1] is (int)Move.VoltTackle)
            {
                if (--count == 0)
                {
                    valid = false; // must have base moves; sanity check
                    return(Array.Empty <EggSource6>());
                }
                value.Actual[count] = VoltTackle;
            }

            bool inherit = Breeding.GetCanInheritMoves(species);

            MarkMovesForOrigin(value, egg, count, inherit);

            valid = RecurseMovesForOrigin(value, count - 1);
            return(value.Actual);
        }
Esempio n. 10
0
        public static EggSource5[] Validate(int species, GameVersion version, int[] moves, out bool valid)
        {
            var count = Array.IndexOf(moves, 0);

            if (count == 0)
            {
                valid = false; // empty moveset
                return(Array.Empty <EggSource5>());
            }
            if (count == -1)
            {
                count = moves.Length;
            }

            var learn    = GameData.GetLearnsets(version);
            var table    = GameData.GetPersonal(version);
            var learnset = learn[species];
            var pi       = table[species];
            var egg      = Legal.EggMovesBW[species].Moves;

            var value = new BreedInfo <EggSource5>(count, learnset, moves, level);

            if (moves[count - 1] is (int)Move.VoltTackle)
            {
                if (--count == 0)
                {
                    valid = false; // must have base moves; sanity check
                    return(Array.Empty <EggSource5>());
                }
                value.Actual[count] = VoltTackle;
            }

            bool inherit = Breeding.GetCanInheritMoves(species);

            MarkMovesForOrigin(value, egg, count, inherit, pi);

            valid = RecurseMovesForOrigin(value, count - 1);
            return(value.Actual);
        }
Esempio n. 11
0
        public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, EvoCriteria[] chain, int generation, bool all = false)
        {
            System.Diagnostics.Debug.Assert(generation >= 3); // if generating Gen2 eggs, use the other generator.
            int currentSpecies = pkm.Species;

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

            var currentForm = pkm.Form;

            if (!Breeding.CanHatchAsEgg(currentSpecies, currentForm, generation))
            {
                yield break; // can't originate from eggs
            }
            // version is a true indicator for all generation 3-5 origins
            var ver = (GameVersion)pkm.Version;

            if (!Breeding.CanGameGenerateEggs(ver))
            {
                yield break;
            }

            var lvl = EggStateLegality.GetEggLevel(generation);
            int max = GetMaxSpeciesOrigin(generation);

            var(species, form) = GetBaseSpecies(chain, 0);
            if ((uint)species <= max)
            {
                // NOTE: THE SPLIT-BREED SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE BELOW SECTION
                if (FormInfo.IsBattleOnlyForm(species, form, generation))
                {
                    form = FormInfo.GetOutOfBattleForm(species, form, generation);
                }
                if (Breeding.CanHatchAsEgg(species, form, ver))
                {
                    yield return(new EncounterEgg(species, form, lvl, generation, ver));

                    if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver))
                    {
                        yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver)));
                    }
                }
            }

            if (!Breeding.GetSplitBreedGeneration(generation).Contains(currentSpecies))
            {
                yield break; // no other possible species
            }
            var otherSplit = species;

            (species, form) = GetBaseSpecies(chain, 1);
            if ((uint)species == otherSplit)
            {
                yield break;
            }

            if (species <= max)
            {
                // NOTE: THIS SECTION OF CODE SHOULD BE EXACTLY THE SAME AS THE ABOVE SECTION
                if (FormInfo.IsBattleOnlyForm(species, form, generation))
                {
                    form = FormInfo.GetOutOfBattleForm(species, form, generation);
                }
                if (Breeding.CanHatchAsEgg(species, form, ver))
                {
                    yield return(new EncounterEgg(species, form, lvl, generation, ver));

                    if (generation > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver))
                    {
                        yield return(new EncounterEgg(species, form, lvl, generation, GetOtherTradePair(ver)));
                    }
                }
            }
        }