예제 #1
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);
        }
예제 #2
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
            }
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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);
        }