예제 #1
0
        public EggInfoSource(PKM pkm, IEnumerable <int> specialMoves, EncounterEgg e)
        {
            // Eggs with special moves cannot inherit levelup moves as the current moves are predefined.
            Special = specialMoves.Where(m => m != 0).ToList();
            bool notSpecial = Special.Count == 0;

            AllowInherited = notSpecial && !pkm.WasGiftEgg && pkm.Species != 489 && pkm.Species != 490;

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

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

            Egg     = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm, e.Version);
            LevelUp = AllowLevelUp
                ? Legal.GetBaseEggMoves(pkm, e.Species, e.Version, 100).Except(Base).ToList()
                : new List <int>();
            Tutor = e.Version == GameVersion.C
                ? MoveTutor.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2).ToList()
                : new List <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.AltForm, pkm.GenNumber, e.Version).ToList();

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

            if (volt)
            {
                Egg.Add(344); // Volt Tackle
            }
        }
예제 #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 = Legal.GetCanInheritMoves(e.Species);

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

            Egg     = MoveEgg.GetEggMoves(pkm, e.Species, e.Form, e.Version);
            LevelUp = AllowLevelUp
                ? Legal.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.AltForm, 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(344);       // Volt Tackle
            }
        }
예제 #3
0
        private static CheckMoveResult[] ParseMovesWasEggPreRelearn(PKM pkm, int[] Moves, LegalInfo info, EncounterEgg e)
        {
            var EventEggMoves = GetSpecialMoves(info.EncounterMatch);
            // Level up moves could not be inherited if Ditto is parent,
            // that means genderless species and male only species except Nidoran and Volbeat (they breed with female nidoran and illumise) could not have level up moves as an egg
            var AllowLevelUp         = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species);
            int BaseLevel            = AllowLevelUp ? 100 : e.LevelMin;
            var LevelUp              = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, BaseLevel);
            var TradebackPreevo      = pkm.Format == 2 && info.EncounterMatch.Species > 151;
            var NonTradebackLvlMoves = new int[0];

            if (TradebackPreevo)
            {
                NonTradebackLvlMoves = Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game).Where(m => m > Legal.MaxMoveID_1).ToArray();
            }
            var Egg = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm);

            bool volt    = (info.Generation > 3 || e.Game == GameVersion.E) && Legal.LightBall.Contains(pkm.Species);
            var  Special = volt && EventEggMoves.Length == 0 ? new[] { 344 } : new int[0]; // Volt Tackle for bred Pichu line

            var source = new MoveParseSource
            {
                CurrentMoves             = Moves,
                SpecialSource            = Special,
                NonTradeBackLevelUpMoves = NonTradebackLvlMoves,

                EggLevelUpSource = LevelUp,
                EggMoveSource    = Egg,
                EggEventSource   = EventEggMoves,
            };

            return(ParseMoves(pkm, source, info));
        }
예제 #4
0
파일: Analysis.cs 프로젝트: tools-env/PKHeX
        /// <summary>
        /// Gets four moves which can be learned depending on the input arguments.
        /// </summary>
        /// <param name="tm">Allow TM moves</param>
        /// <param name="tutor">Allow Tutor moves</param>
        /// <param name="reminder">Allow Move Reminder</param>
        public int[] GetSuggestedMoves(bool tm, bool tutor, bool reminder)
        {
            if (!Parsed)
            {
                return(new int[4]);
            }
            if (pkm.IsEgg && pkm.Format <= 5) // pre relearn
            {
                return(Legal.GetBaseEggMoves(pkm, pkm.Species, (GameVersion)pkm.Version, pkm.CurrentLevel));
            }

            if (!tm && !tutor && !reminder)
            {
                // try to give current moves
                if (Info.Generation <= 2)
                {
                    var lvl = pkm.Format >= 7 ? pkm.Met_Level : pkm.CurrentLevel;
                    var ver = EncounterOriginal is IVersion v ? v.Version : (GameVersion)pkm.Version;
                    return(MoveLevelUp.GetEncounterMoves(EncounterOriginal.Species, 0, lvl, ver));
                }
                if (pkm.Species == EncounterOriginal.Species)
                {
                    return(MoveLevelUp.GetEncounterMoves(pkm.Species, pkm.AltForm, pkm.CurrentLevel, (GameVersion)pkm.Version));
                }
            }
            var evos = Info.EvoChainsAllGens;

            return(Legal.GetValidMoves(pkm, evos, Tutor: tutor, Machine: tm, MoveReminder: reminder).Skip(1).ToArray()); // skip move 0
        }
예제 #5
0
        public EggInfoSource(PKM pkm, IEnumerable <int> specialMoves, EncounterEgg e)
        {
            // Eggs with special moves cannot inherit levelup moves as the current moves are predefined.
            Special = specialMoves.Where(m => m != 0).ToList();
            bool notSpecial = Special.Count == 0;

            AllowInherited = notSpecial && !pkm.WasGiftEgg && pkm.Species != 489 && pkm.Species != 490;

            // Level up moves can only be inherited if ditto is not the mother.
            var  ratio        = pkm.PersonalInfo.Gender; // Genderless/Male Only (except a few) cannot inherit.
            bool AllowLevelUp = ratio > 0 && ratio < 255 || Legal.MixedGenderBreeding.Contains(e.Species);

            Base = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, e.LevelMin).ToList();

            Egg     = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm).ToList();
            LevelUp = AllowLevelUp
                ? Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 100).Where(x => !Base.Contains(x)).ToList()
                : new List <int>();
            Tutor = e.Game == GameVersion.C
                ? Legal.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2).ToList()
                : new List <int>();

            // Only TM/HM moves from the source game of the egg, not any other games from the same generation
            TMHM = Legal.GetTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, e.Game, false).ToList();

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

            if (volt)
            {
                Egg.Add(344); // Volt Tackle
            }
        }
예제 #6
0
파일: EncounterEgg.cs 프로젝트: antwa/PKHeX
        private int[] GetCurrentEggMoves(PKM pk)
        {
            var moves = MoveEgg.GetEggMoves(pk, Species, pk.AltForm, Version);

            if (moves.Length == 0)
            {
                moves = MoveLevelUp.GetEncounterMoves(pk, Level, Version);
            }
            else if (moves.Length < 4 && pk.Format >= 6)
            {
                // Sprinkle in some default level up moves
                var lvl = Legal.GetBaseEggMoves(pk, Species, Version, Level);
                moves = lvl.Concat(moves).ToArray();
            }
            return(moves);
        }
예제 #7
0
        private int[] GetCurrentEggMoves(PKM pk, GameVersion version)
        {
            var moves = MoveEgg.GetEggMoves(pk, Species, Form, version);

            if (moves.Length == 0)
            {
                return(MoveLevelUp.GetEncounterMoves(pk, Level, version));
            }
            if (moves.Length >= 4 || pk.Format < 6)
            {
                return(moves);
            }

            // Sprinkle in some default level up moves
            var lvl = Legal.GetBaseEggMoves(pk, Species, Form, version, Level);

            return(lvl.Concat(moves).ToArray());
        }
예제 #8
0
        private static CheckResult[] VerifyRelearnEggBase(PKM pkm, LegalInfo info, EncounterEgg e)
        {
            int[]         RelearnMoves = pkm.RelearnMoves;
            CheckResult[] res          = new CheckResult[4];
            // Level up moves cannot be inherited if Ditto is the parent
            // that means genderless species and male only species except Nidoran and Volbeat (they breed with female nidoran and illumise) could not have level up moves as an egg
            bool inheritLvlMoves = Legal.GetCanInheritMoves(e.Species);

            // Obtain level1 moves
            var baseMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Version, 1);
            int baseCt    = Math.Min(4, baseMoves.Length);

            // Obtain Inherited moves
            var inheritMoves = Legal.GetValidRelearn(pkm, e.Species, inheritLvlMoves, e.Version).ToList();
            int reqBase      = GetRequiredBaseMoves(RelearnMoves, baseMoves, baseCt, inheritMoves);

            // Check if the required amount of Base Egg Moves are present.
            FlagBaseEggMoves(res, reqBase, baseMoves, RelearnMoves);

            // Non-Base moves that can magically appear in the regular movepool
            if (Legal.LightBall.Contains(pkm.Species))
            {
                inheritMoves.Add(344); // Volt Tackle
            }
            // If any splitbreed moves are invalid, flag accordingly
            var splitMoves = e is EncounterEggSplit s
                ? Legal.GetValidRelearn(pkm, s.OtherSpecies, inheritLvlMoves, e.Version).ToList()
                : (IReadOnlyList <int>)Array.Empty <int>();

            // Inherited moves appear after the required base moves.
            // If the pkm is capable of split-species breeding and any inherited move is from the other split scenario, flag accordingly.
            bool splitInvalid = FlagInvalidInheritedMoves(res, reqBase, RelearnMoves, inheritMoves, splitMoves);

            if (splitInvalid)
            {
                FlagSplitbreedMoves(res, reqBase, e, pkm);
            }

            info.RelearnBase = baseMoves;
            return(res);
        }
예제 #9
0
        private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, int[] SpecialMoves, bool allowinherited, EncounterEgg e)
        {
            CheckMoveResult[] res = new CheckMoveResult[4];

            var baseEggMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List <int>();
            // Level up moves cannot be inherited if Ditto is parent, thus genderless/single gender species cannot have level up moves as an egg
            bool AllowLvlMoves     = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species);
            var  InheritedLvlMoves = !AllowLvlMoves? new List <int>() : Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 100)?.ToList() ?? new List <int>();

            InheritedLvlMoves.RemoveAll(x => baseEggMoves.Contains(x));

            var infoset = new MoveInfoSet
            {
                EggMoves       = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm)?.ToList() ?? new List <int>(),
                TutorMoves     = e.Game == GameVersion.C ? Legal.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2)?.ToList() : new List <int>(),
                TMHMMoves      = Legal.GetTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, e.Game, false)?.ToList(),
                LvlMoves       = InheritedLvlMoves,
                BaseMoves      = baseEggMoves,
                SpecialMoves   = SpecialMoves.Where(m => m != 0).ToList(),
                AllowInherited = allowinherited
            };

            // Only TM Hm moves from the source game of the egg, not any other games from the same generation

            if (pkm.Format > 2 || SpecialMoves.Any())
            {
                // For gen 2 is not possible to difference normal eggs from event eggs
                // If there is no special moves assume normal egg
                res = VerifyPreRelearnEggBase(pkm, Moves, infoset, e.Game);
            }
            else if (pkm.Format == 2)
            {
                infoset.SpecialMoves.Clear();
                infoset.AllowInherited = true;
                res = VerifyPreRelearnEggBase(pkm, Moves, infoset, e.Game);
            }

            return(res);
        }
예제 #10
0
        private static CheckMoveResult[] ParseMovesWasEggPreRelearn(PKM pkm, int[] Moves, LegalInfo info, EncounterEgg e)
        {
            var  EventEggMoves = GetSpecialMoves(info.EncounterMatch);
            bool notEvent      = EventEggMoves.Length == 0;
            // Level up moves could not be inherited if Ditto is parent,
            // that means genderless species and male only species (except Nidoran-M and Volbeat; they breed with Nidoran-F and Illumise) could not have level up moves as an egg
            var pi           = pkm.PersonalInfo;
            var AllowLevelUp = notEvent && !pi.Genderless && !(pi.OnlyMale && Legal.MixedGenderBreeding.Contains(e.Species));
            int BaseLevel    = AllowLevelUp ? 100 : e.LevelMin;
            var LevelUp      = Legal.GetBaseEggMoves(pkm, e.Species, e.Version, BaseLevel);

            var TradebackPreevo      = pkm.Format == 2 && info.EncounterMatch.Species > 151;
            var NonTradebackLvlMoves = TradebackPreevo
                ? Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Version).Where(m => m > Legal.MaxMoveID_1).ToArray()
                : Array.Empty <int>();

            var Egg = MoveEgg.GetEggMoves(pkm, e.Species, pkm.AltForm, e.Version);

            if (info.Generation < 3 && pkm.Format >= 7 && pkm.VC1)
            {
                Egg = Egg.Where(m => m <= Legal.MaxMoveID_1).ToArray();
            }

            bool volt    = (info.Generation > 3 || e.Version == GameVersion.E) && Legal.LightBall.Contains(pkm.Species);
            var  Special = volt && notEvent ? new[] { 344 } : Array.Empty <int>(); // Volt Tackle for bred Pichu line

            var source = new MoveParseSource
            {
                CurrentMoves             = Moves,
                SpecialSource            = Special,
                NonTradeBackLevelUpMoves = NonTradebackLvlMoves,

                EggLevelUpSource = LevelUp,
                EggMoveSource    = Egg,
                EggEventSource   = EventEggMoves,
            };

            return(ParseMoves(pkm, source, info));
        }
예제 #11
0
        private static CheckMoveResult[] ParseMovesWasEggPreRelearn(PKM pkm, int[] Moves, LegalInfo info, EncounterEgg e)
        {
            var EventEggMoves = (info.EncounterMatch as IMoveset)?.Moves ?? new int[0];
            // Level up moves could not be inherited if Ditto is parent,
            // that means genderless species and male only species except Nidoran and Volbet (they breed with female nidoran and illumise) could not have level up moves as an egg
            var inheritLvlMoves      = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species);
            int BaseLvlMoves         = inheritLvlMoves ? 100 : pkm.GenNumber <= 3 ? 5 : 1;
            var LvlupEggMoves        = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, BaseLvlMoves);
            var TradebackPreevo      = pkm.Format == 2 && info.EncounterMatch.Species > 151;
            var NonTradebackLvlMoves = new int[0];

            if (TradebackPreevo)
            {
                NonTradebackLvlMoves = Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game).Where(m => m > Legal.MaxMoveID_1).ToArray();
            }
            var EggMoves = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm);

            bool volt         = (pkm.GenNumber > 3 || e.Game == GameVersion.E) && Legal.LightBall.Contains(pkm.Species);
            var  SpecialMoves = volt && EventEggMoves.Length == 0 ? new[] { 344 } : new int[0]; // Volt Tackle for bred Pichu line

            return(ParseMoves(pkm, Moves, SpecialMoves, LvlupEggMoves, EggMoves, NonTradebackLvlMoves, EventEggMoves, new int[0], info));
        }
예제 #12
0
        private static CheckResult[] VerifyRelearnEggBase(PKM pkm, LegalInfo info, EncounterEgg e)
        {
            int[] RelearnMoves = pkm.RelearnMoves;
            info.RelearnBase = new int[4];
            CheckResult[] res = new CheckResult[4];
            // Level up moves could not be inherited if Ditto is parent,
            // that means genderless species and male only species except Nidoran and Volbet (they breed with female nidoran and illumise) could not have level up moves as an egg
            var inheritLvlMoves = pkm.PersonalInfo.Gender > 0 && pkm.PersonalInfo.Gender < 255 || Legal.MixedGenderBreeding.Contains(e.Species);

            // Obtain level1 moves
            List <int> baseMoves = new List <int>(Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 1));
            int        baseCt    = baseMoves.Count;

            if (baseCt > 4)
            {
                baseCt = 4;
            }

            // Obtain Inherited moves
            var inheritMoves = Legal.GetValidRelearn(pkm, e.Species, inheritLvlMoves).ToList();
            var inherited    = RelearnMoves.Where(m => m != 0 && (!baseMoves.Contains(m) || inheritMoves.Contains(m))).ToList();
            int inheritCt    = inherited.Count;


            // Get required amount of base moves
            int unique  = baseMoves.Concat(inherited).Distinct().Count();
            int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt;

            if (RelearnMoves.Where(m => m != 0).Count() < Math.Min(4, baseMoves.Count))
            {
                reqBase = Math.Min(4, unique);
            }

            // Check if the required amount of Base Egg Moves are present.
            for (int i = 0; i < reqBase; i++)
            {
                if (baseMoves.Contains(RelearnMoves[i]))
                {
                    res[i] = new CheckResult(Severity.Valid, V179, CheckIdentifier.RelearnMove);
                }
                else
                {
                    // mark remaining base egg moves missing
                    for (int z = i; z < reqBase; z++)
                    {
                        res[z] = new CheckResult(Severity.Invalid, V180, CheckIdentifier.RelearnMove);
                    }

                    // provide the list of suggested base moves for the last required slot
                    string em = string.Join(", ", baseMoves.Select(m => m >= MoveStrings.Length ? V190 : MoveStrings[m]));
                    res[reqBase - 1].Comment += string.Format(Environment.NewLine + V181, em);
                    break;
                }
            }

            // Non-Base moves that can magically appear in the regular movepool
            if (Legal.LightBall.Contains(pkm.Species))
            {
                inheritMoves.Add(344);
            }

            // Begin verification of moves

            // If any splitbreed moves are invalid, flag accordingly
            var splitInvalid = false;
            var splitMoves   = e.SplitBreed ? Legal.GetValidRelearn(pkm, Legal.GetBaseEggSpecies(pkm), inheritLvlMoves).ToList() : new List <int>();

            // Inherited moves appear after the required base moves.
            for (int i = reqBase; i < 4; i++)
            {
                if (RelearnMoves[i] == 0) // empty
                {
                    res[i] = new CheckResult(Severity.Valid, V167, CheckIdentifier.RelearnMove);
                }
                else if (inheritMoves.Contains(RelearnMoves[i])) // inherited
                {
                    res[i] = new CheckResult(Severity.Valid, V172, CheckIdentifier.RelearnMove);
                }
                else if (e.SplitBreed && splitMoves.Contains(RelearnMoves[i])) // inherited
                {
                    splitInvalid = true;
                }
                else // not inheritable, flag
                {
                    res[i] = new CheckResult(Severity.Invalid, V182, CheckIdentifier.RelearnMove);
                }
            }

            if (splitInvalid)
            {
                var splitSpecies = Legal.GetBaseEggSpecies(pkm);
                for (int i = reqBase; i < 4; i++)
                {
                    if (inheritMoves.Contains(RelearnMoves[i]) && !splitMoves.Contains(RelearnMoves[i]))
                    {
                        res[i] = new CheckResult(Severity.Invalid, string.Format(V379, SpeciesStrings[splitSpecies], SpeciesStrings[e.Species]), CheckIdentifier.RelearnMove);
                    }
                    if (!inheritMoves.Contains(RelearnMoves[i]) && splitMoves.Contains(RelearnMoves[i]))
                    {
                        res[i] = new CheckResult(Severity.Invalid, string.Format(V379, SpeciesStrings[e.Species], SpeciesStrings[splitSpecies]), CheckIdentifier.RelearnMove);
                    }
                }
            }

            info.RelearnBase = baseMoves.ToArray();
            return(res);
        }