예제 #1
0
        private void SetEncounterMoves(PKM pk, GameVersion version, int level)
        {
            var moves = Moves.Count > 0 ? Moves : MoveLevelUp.GetEncounterMoves(pk, level, version);

            pk.SetMoves(moves);
            pk.SetMaximumPPCurrent(moves);
        }
예제 #2
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
        }
예제 #3
0
        private static CheckMoveResult[] ParseMovesGenGB(PKM pkm, IReadOnlyList <int> currentMoves, LegalInfo info)
        {
            var res          = new CheckMoveResult[4];
            var G1Encounter  = info.EncounterMatch;
            var InitialMoves = Array.Empty <int>();
            var SpecialMoves = GetSpecialMoves(info.EncounterMatch);
            var games        = info.EncounterMatch.Generation == 1 ? GBRestrictions.GetGen1Versions(info) : GBRestrictions.GetGen2Versions(info, pkm.Korean);

            foreach (var ver in games)
            {
                var VerInitialMoves = MoveLevelUp.GetEncounterMoves(G1Encounter.Species, 0, G1Encounter.LevelMin, ver);
                if (VerInitialMoves.Intersect(InitialMoves).Count() == VerInitialMoves.Length)
                {
                    return(res);
                }

                var source = new MoveParseSource
                {
                    CurrentMoves  = currentMoves,
                    SpecialSource = SpecialMoves,
                    Base          = VerInitialMoves,
                };
                res = ParseMoves(pkm, source, info);
                if (res.All(r => r.Valid))
                {
                    return(res);
                }
                InitialMoves = VerInitialMoves;
            }
            return(res);
        }
예제 #4
0
        private static int[] GetSuggestedMoves(PKM pkm, IReadOnlyList <IReadOnlyList <EvoCriteria> > evoChains, MoveSourceType types, IEncounterTemplate enc)
        {
            if (pkm.IsEgg && pkm.Format <= 5) // pre relearn
            {
                return(MoveList.GetBaseEggMoves(pkm, pkm.Species, 0, (GameVersion)pkm.Version, pkm.CurrentLevel));
            }

            if (types != MoveSourceType.None)
            {
                return(GetValidMoves(pkm, evoChains, types).Skip(1).ToArray()); // skip move 0
            }
            // try to give current moves
            if (enc.Generation <= 2)
            {
                var lvl = pkm.Format >= 7 ? pkm.Met_Level : pkm.CurrentLevel;
                var ver = enc.Version;
                return(MoveLevelUp.GetEncounterMoves(enc.Species, 0, lvl, ver));
            }

            if (pkm.Species == enc.Species)
            {
                return(MoveLevelUp.GetEncounterMoves(pkm.Species, pkm.Form, pkm.CurrentLevel, (GameVersion)pkm.Version));
            }

            return(GetValidMoves(pkm, evoChains, types).Skip(1).ToArray()); // skip move 0
        }
예제 #5
0
        internal static int[] GetSuggestedMoves(PKM pkm, IReadOnlyList <EvoCriteria>[] evoChains, bool tm, bool tutor, bool reminder, IEncounterable enc)
        {
            if (pkm.IsEgg && pkm.Format <= 5) // pre relearn
            {
                return(MoveList.GetBaseEggMoves(pkm, pkm.Species, 0, (GameVersion)pkm.Version, pkm.CurrentLevel));
            }

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

                if (pkm.Species == enc.Species)
                {
                    return(MoveLevelUp.GetEncounterMoves(pkm.Species, pkm.AltForm, pkm.CurrentLevel, (GameVersion)pkm.Version));
                }
            }

            return(GetValidMoves(pkm, evoChains, Tutor: tutor, Machine: tm, MoveReminder: reminder).Skip(1).ToArray()); // skip move 0
        }
예제 #6
0
 private static void AddEdgeCaseMoves(List <int> moves, IEncounterable encounter, PKM pkm)
 {
     switch (encounter)
     {
     case EncounterStatic8N r when !EncounterStatic8N.IsHighestLevelTier(pkm.Met_Level) && r.IsDownLeveled(pkm):     // Downleveled Raid can happen for shared raids and self-hosted raids.
         moves.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, r.Species, -1, -1, r.LevelMax, r.Form, GameVersion.SW, false, 8));
         break;
     }
 }
예제 #7
0
 private static void AddEdgeCaseMoves(List <int> moves, IEncounterable encounter, PKM pkm)
 {
     switch (encounter)
     {
     case EncounterStatic8N r when pkm.Met_Location == Encounters8Nest.SharedNest && !EncounterStatic8N.IsHighestLevelTier(pkm.Met_Level):
         moves.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, r.Species, -1, -1, 60, r.Form, GameVersion.SW, false, 8));
         break;
     }
 }
예제 #8
0
        private static CheckMoveResult[] ParseMovesGenGB(PKM pkm, IReadOnlyList <int> currentMoves, LegalInfo info)
        {
            var res          = new CheckMoveResult[4];
            var enc          = info.EncounterMatch;
            var level        = pkm.HasOriginalMetLocation ? pkm.Met_Level : enc.LevelMin;
            var InitialMoves = Array.Empty <int>();
            var SpecialMoves = GetSpecialMoves(enc);
            var games        = enc.Generation == 1 ? GBRestrictions.GetGen1Versions(enc) : GBRestrictions.GetGen2Versions(enc, pkm.Korean);

            foreach (var ver in games)
            {
                var VerInitialMoves = MoveLevelUp.GetEncounterMoves(enc.Species, 0, level, ver);
                if (VerInitialMoves.Intersect(InitialMoves).Count() == VerInitialMoves.Length)
                {
                    return(res);
                }

                var source = new MoveParseSource
                {
                    CurrentMoves  = currentMoves,
                    SpecialSource = SpecialMoves,
                    Base          = VerInitialMoves,
                };
                res = ParseMoves(pkm, source, info);

                // Must have a minimum count of moves, depending on the tradeback state.
                if (pkm is PK1 pk1)
                {
                    int count = GBRestrictions.GetRequiredMoveCount(pk1, source.CurrentMoves, info, source.Base);
                    if (count == 1)
                    {
                        return(res);
                    }

                    for (int m = 0; m < count; m++)
                    {
                        var move = source.CurrentMoves[m];
                        if (move == 0)
                        {
                            res[m] = new CheckMoveResult(None, pkm.Format, Invalid, LMoveSourceEmpty, CurrentMove);
                        }
                    }
                }
                if (res.All(r => r.Valid))
                {
                    return(res);
                }
                InitialMoves = VerInitialMoves;
            }
            return(res);
        }
예제 #9
0
        private static void AddEdgeCaseMoves(List <int> moves, IEncounterable encounter, PKM pkm)
        {
            switch (encounter)
            {
            case EncounterStatic8N r when r.IsDownLeveled(pkm):     // Downleveled Raid can happen for shared raids and self-hosted raids.
                moves.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, r.Species, -1, -1, r.LevelMax, r.Form, GameVersion.SW, false, 8));

                break;

            case EncounterSlot8GO g:
                moves.AddRange(MoveLevelUp.GetEncounterMoves(g.Species, g.Form, pkm.Met_Level, g.OriginGroup));
                break;
            }
        }
        private static int[] GetNeededMoves(PKM pk, IEnumerable <int> moves, IReadOnlyList <EvoCriteria> chain)
        {
            if (pk.Species == (int)Species.Smeargle)
            {
                return(moves.Where(z => !Legal.IsValidSketch(z, pk.Format)).ToArray()); // Can learn anything
            }
            // Roughly determine the generation the PKM is originating from
            var ver    = pk.Version;
            int origin = pk.Generation;

            if (origin < 0)
            {
                origin = ((GameVersion)ver).GetGeneration();
            }

            // Temporarily replace the Version for VC1 transfers, so that they can have VC2 moves if needed.
            bool vcBump = origin == 1 && pk.Format >= 7;

            if (vcBump)
            {
                pk.Version = (int)GameVersion.C;
            }

            var gens     = GenerationTraversal.GetVisitedGenerationOrder(pk, origin);
            var canlearn = gens.SelectMany(z => GetMovesForGeneration(pk, chain, z));

            if (origin is (1 or 2)) // gb initial moves
            {
                var max = origin == 1 ? Legal.MaxSpeciesID_1 : Legal.MaxSpeciesID_2;
                foreach (var evo in chain)
                {
                    var species = evo.Species;
                    if (species > max)
                    {
                        continue;
                    }
                    var enc = MoveLevelUp.GetEncounterMoves(species, 0, 1, (GameVersion)ver);
                    canlearn = canlearn.Concat(enc);
                }
            }
            var result = moves.Where(z => z != 0).Except(canlearn).ToArray();

            if (vcBump)
            {
                pk.Version = ver;
            }

            return(result);
        }
예제 #11
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);
        }
예제 #12
0
파일: Core.cs 프로젝트: LLNet/PKHeX
        private static IEnumerable <int> GetMoves(PKM pkm, int species, int minlvlG1, int minlvlG2, int lvl, int form, bool moveTutor, GameVersion Version, bool LVL, bool specialTutors, bool Machine, bool MoveReminder, bool RemoveTransferHM, int Generation)
        {
            List <int> r = new List <int>();

            if (LVL)
            {
                r.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, species, minlvlG1, minlvlG2, lvl, form, Version, MoveReminder, Generation));
            }
            if (Machine)
            {
                r.AddRange(MoveTechnicalMachine.GetTMHM(pkm, species, form, Generation, Version, RemoveTransferHM));
            }
            if (moveTutor)
            {
                r.AddRange(MoveTutor.GetTutorMoves(pkm, species, form, specialTutors, Generation));
            }
            return(r.Distinct());
        }
예제 #13
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());
        }
예제 #14
0
        private static CheckMoveResult[] ParseMovesGenGB(PKM pkm, int[] Moves, LegalInfo info)
        {
            CheckMoveResult[] res = new CheckMoveResult[4];
            var G1Encounter       = info.EncounterMatch;

            if (G1Encounter == null)
            {
                return(ParseMovesSpecialMoveset(pkm, Moves, info));
            }
            var InitialMoves = Array.Empty <int>();

            int[] SpecialMoves = GetSpecialMoves(info.EncounterMatch);
            var   games        = info.EncounterMatch is IGeneration g && g.Generation == 1 ? Legal.GetGen1Versions(info) : Legal.GetGen2Versions(info);

            foreach (var ver in games)
            {
                var VerInitialMoves = MoveLevelUp.GetEncounterMoves(G1Encounter.Species, 0, G1Encounter.LevelMin, ver);
                if (VerInitialMoves.Intersect(InitialMoves).Count() == VerInitialMoves.Length)
                {
                    return(res);
                }

                var source = new MoveParseSource
                {
                    CurrentMoves  = Moves,
                    SpecialSource = SpecialMoves,
                    Base          = VerInitialMoves,
                };
                res = ParseMoves(pkm, source, info);
                if (res.All(r => r.Valid))
                {
                    return(res);
                }
                InitialMoves = VerInitialMoves;
            }
            return(res);
        }
예제 #15
0
        private static CheckMoveResult[] ParseMovesGenGB(PKM pkm, IReadOnlyList <int> currentMoves, LegalInfo info)
        {
            var res          = new CheckMoveResult[4];
            var enc          = info.EncounterMatch;
            var level        = pkm.HasOriginalMetLocation ? pkm.Met_Level : enc.LevelMin;
            var InitialMoves = Array.Empty <int>();
            var SpecialMoves = GetSpecialMoves(enc);
            var games        = enc.Generation == 1 ? GBRestrictions.GetGen1Versions(enc) : GBRestrictions.GetGen2Versions(enc, pkm.Korean);

            foreach (var ver in games)
            {
                var VerInitialMoves = enc is IMoveset {
                    Moves.Count : not 0
                } x ? (int[])x.Moves : MoveLevelUp.GetEncounterMoves(enc.Species, 0, level, ver);
                if (VerInitialMoves.Intersect(InitialMoves).Count() == VerInitialMoves.Length)
                {
                    return(res);
                }

                var source = new MoveParseSource
                {
                    CurrentMoves  = currentMoves,
                    SpecialSource = SpecialMoves,
                    Base          = VerInitialMoves,
                };
                res = ParseMoves(pkm, source, info);

                // Must have a minimum count of moves, depending on the tradeback state.
                if (pkm is PK1 pk1)
                {
                    int count = GBRestrictions.GetRequiredMoveCount(pk1, source.CurrentMoves, info, source.Base);
                    if (count == 1)
                    {
                        return(res);
                    }

                    // Reverse for loop and break instead of 0..count continue -- early-breaks for the vast majority of cases.
                    // We already flag for empty interstitial moveslots.
                    for (int m = count - 1; m >= 0; m--)
                    {
                        var move = source.CurrentMoves[m];
                        if (move != 0)
                        {
                            break;
                        }

                        // There are ways to skip level up moves by leveling up more than once.
                        // https://bulbapedia.bulbagarden.net/wiki/List_of_glitches_(Generation_I)#Level-up_learnset_skipping
                        // Evolution canceling also leads to incorrect assumptions in the above used method, so just indicate them as fishy in that case.
                        // Not leveled up? Not possible to be missing the move slot.
                        var severity = enc.LevelMin == pkm.CurrentLevel ? Invalid : Fishy;
                        res[m] = new CheckMoveResult(None, pkm.Format, severity, LMoveSourceEmpty, CurrentMove);
                    }
                }
                if (res.All(r => r.Valid))
                {
                    return(res);
                }
                InitialMoves = VerInitialMoves;
            }
            return(res);
        }