internal static int[] GetEggMoves(PKM pkm, int species, int formnum, GameVersion version)
        {
            int gen = pkm.Format <= 2 || pkm.VC ? 2 : pkm.GenNumber;

            if (!pkm.InhabitedGeneration(gen, species) || (pkm.PersonalInfo.Gender == 255 && !FixedGenderFromBiGender.Contains(species)))
            {
                return(Array.Empty <int>());
            }

            if (pkm.Version == 15 || pkm.GG)
            {
                return(Array.Empty <int>());
            }

            if (version == GameVersion.Any)
            {
                version = (GameVersion)pkm.Version;
            }
            return(GetEggMoves(gen, species, formnum, version));
        }
Esempio n. 2
0
        internal static List <EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspeciesorigin = -1, int lvl = -1, int minLevel = 1, bool skipChecks = false)
        {
            if (lvl < 0)
            {
                lvl = pkm.CurrentLevel;
            }
            if (pkm.IsEgg && !skipChecks)
            {
                return(new List <EvoCriteria>(1)
                {
                    new EvoCriteria {
                        Species = pkm.Species, Level = lvl, MinLevel = lvl
                    },
                });
            }

            // Shedinja's evolution case can be a little tricky; hard-code handling.
            if (pkm.Species == (int)Species.Shedinja && lvl >= 20 && (!pkm.HasOriginalMetLocation || pkm.Met_Level + 1 <= lvl))
            {
                return(new List <EvoCriteria>(2)
                {
                    new EvoCriteria {
                        Species = (int)Species.Shedinja, Level = lvl, MinLevel = 20
                    },
                    new EvoCriteria {
                        Species = (int)Species.Nincada, Level = lvl, MinLevel = 1
                    }
                });
            }

            if (maxspeciesorigin == -1 && pkm.InhabitedGeneration(2) && pkm.Format <= 2 && pkm.GenNumber == 1)
            {
                maxspeciesorigin = MaxSpeciesID_2;
            }

            int tree = pkm.Format <= 2 ? 2 : pkm.Format;
            var et   = EvolutionTree.GetEvolutionTree(pkm, tree);

            return(et.GetValidPreEvolutions(pkm, maxLevel: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks, minLevel: minLevel));
        }
Esempio n. 3
0
        internal static List <EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspeciesorigin = -1, int lvl = -1, bool skipChecks = false)
        {
            if (lvl < 0)
            {
                lvl = pkm.CurrentLevel;
            }
            if (pkm.IsEgg && !skipChecks)
            {
                return new List <EvoCriteria>
                       {
                           new EvoCriteria {
                               Species = pkm.Species, Level = lvl, MinLevel = lvl
                           },
                       }
            }
            ;
            if (pkm.Species == 292 && lvl >= 20 && (!pkm.HasOriginalMetLocation || pkm.Met_Level + 1 <= lvl))
            {
                return new List <EvoCriteria>
                       {
                           new EvoCriteria {
                               Species = 292, Level = lvl, MinLevel = 20
                           },
                           new EvoCriteria {
                               Species = 290, Level = pkm.GenNumber < 5 ? lvl : lvl - 1, MinLevel = 1
                           }
                           // Shedinja spawns after evolving, which is after level up moves were prompted. Not for future generations.
                       }
            }
            ;
            if (maxspeciesorigin == -1 && pkm.InhabitedGeneration(2) && pkm.Format <= 2 && pkm.GenNumber == 1)
            {
                maxspeciesorigin = MaxSpeciesID_2;
            }

            int tree = maxspeciesorigin == MaxSpeciesID_2 ? 2 : pkm.Format;
            var et   = EvolutionTree.GetEvolutionTree(tree);

            return(et.GetValidPreEvolutions(pkm, maxLevel: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks));
        }
Esempio n. 4
0
        internal static List <EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspeciesorigin = -1, int lvl = -1, bool skipChecks = false)
        {
            if (lvl < 0)
            {
                lvl = pkm.CurrentLevel;
            }
            if (pkm.IsEgg && !skipChecks)
            {
                return(new List <EvoCriteria>
                {
                    new EvoCriteria {
                        Species = pkm.Species, Level = lvl, MinLevel = lvl
                    },
                });
            }

            if (pkm.Species == 292 && lvl >= 20 && (!pkm.HasOriginalMetLocation || pkm.Met_Level + 1 <= lvl))
            {
                return(new List <EvoCriteria>
                {
                    new EvoCriteria {
                        Species = 292, Level = lvl, MinLevel = 20
                    },
                    new EvoCriteria {
                        Species = 290, Level = lvl, MinLevel = 1
                    }
                });
            }

            if (maxspeciesorigin == -1 && pkm.InhabitedGeneration(2) && pkm.Format <= 2 && pkm.GenNumber == 1)
            {
                maxspeciesorigin = MaxSpeciesID_2;
            }

            int tree = maxspeciesorigin == MaxSpeciesID_2 ? 2 : pkm.Format;
            var et   = EvolutionTree.GetEvolutionTree(tree);

            return(et.GetValidPreEvolutions(pkm, maxLevel: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks));
        }
Esempio n. 5
0
        public static int GetLevelLearnMove(PKM pkm, int gen, IEncounterable enc, CheckMoveResult[] res)
        {
            var index = Array.FindIndex(SpeciesEvolutionWithMove, p => p == pkm.Species);

            // Get the minimum level in any generation when the pokemon could learn the evolve move
            var levels = MinLevelEvolutionWithMove[index];
            var lvl    = 101;

            for (int g = gen; g <= pkm.Format; g++)
            {
                if (pkm.InhabitedGeneration(g) && levels[g] > 0)
                {
                    lvl = Math.Min(lvl, levels[g]);
                }
            }

            // Check also if the current encounter include the evolve move as an special move
            // That means the pokemon have the move from the encounter level
            var moves = MoveEvolutionWithMove[index];

            if (enc is IMoveset s && s.Moves.Any(m => moves.Contains(m)))
            {
                lvl = Math.Min(lvl, enc.LevelMin);
            }

            // If the encounter is a player hatched egg, check if the move could be an egg move or inherited level up move
            var allowegg = EggMoveEvolutionWithMove[index][gen];

            if (enc is EncounterEgg && allowegg)
            {
                if (IsMoveInherited(pkm, gen, res, moves))
                {
                    lvl = Math.Min(lvl, gen <= 3 ? 6 : 2);
                }
            }

            return(lvl);
        }
Esempio n. 6
0
        private static int GetMinLevelGeneration(PKM pkm, int generation)
        {
            if (!pkm.InhabitedGeneration(generation))
            {
                return(0);
            }

            if (pkm.Format <= 2)
            {
                return(2);
            }

            if (!pkm.HasOriginalMetLocation && generation != pkm.GenNumber)
            {
                return(pkm.Met_Level);
            }

            if (pkm.GenNumber <= 3)
            {
                return(2);
            }

            return(1);
        }
Esempio n. 7
0
File: Core.cs Progetto: LLNet/PKHeX
        internal static int[] GetBaseEggMoves(PKM pkm, int species, GameVersion gameSource, int lvl)
        {
            if (gameSource == GameVersion.Any)
            {
                gameSource = (GameVersion)pkm.Version;
            }

            switch (gameSource)
            {
            case GameVersion.GSC:
            case GameVersion.GS:
                // If checking back-transfer specimen (GSC->RBY), remove moves that must be deleted prior to transfer
                int[] getRBYCompatibleMoves(int[] moves) => pkm.Format == 1 ? moves.Where(m => m <= MaxMoveID_1).ToArray() : moves;

                if (pkm.InhabitedGeneration(2))
                {
                    return(getRBYCompatibleMoves(LevelUpGS[species].GetMoves(lvl)));
                }
                break;

            case GameVersion.C:
                if (pkm.InhabitedGeneration(2))
                {
                    return(getRBYCompatibleMoves(LevelUpC[species].GetMoves(lvl)));
                }
                break;

            case GameVersion.R:
            case GameVersion.S:
            case GameVersion.RS:
                if (pkm.InhabitedGeneration(3))
                {
                    return(LevelUpRS[species].GetMoves(lvl));
                }
                break;

            case GameVersion.E:
                if (pkm.InhabitedGeneration(3))
                {
                    return(LevelUpE[species].GetMoves(lvl));
                }
                break;

            case GameVersion.FR:
            case GameVersion.LG:
            case GameVersion.FRLG:
                // only difference in FR/LG is deoxys which doesn't breed.
                if (pkm.InhabitedGeneration(3))
                {
                    return(LevelUpFR[species].GetMoves(lvl));
                }
                break;

            case GameVersion.D:
            case GameVersion.P:
            case GameVersion.DP:
                if (pkm.InhabitedGeneration(4))
                {
                    return(LevelUpDP[species].GetMoves(lvl));
                }
                break;

            case GameVersion.Pt:
                if (pkm.InhabitedGeneration(4))
                {
                    return(LevelUpPt[species].GetMoves(lvl));
                }
                break;

            case GameVersion.HG:
            case GameVersion.SS:
            case GameVersion.HGSS:
                if (pkm.InhabitedGeneration(4))
                {
                    return(LevelUpHGSS[species].GetMoves(lvl));
                }
                break;

            case GameVersion.B:
            case GameVersion.W:
            case GameVersion.BW:
                if (pkm.InhabitedGeneration(5))
                {
                    return(LevelUpBW[species].GetMoves(lvl));
                }
                break;

            case GameVersion.B2:
            case GameVersion.W2:
            case GameVersion.B2W2:
                if (pkm.InhabitedGeneration(5))
                {
                    return(LevelUpB2W2[species].GetMoves(lvl));
                }
                break;

            case GameVersion.X:
            case GameVersion.Y:
            case GameVersion.XY:
                if (pkm.InhabitedGeneration(6))
                {
                    return(LevelUpXY[species].GetMoves(lvl));
                }
                break;

            case GameVersion.AS:
            case GameVersion.OR:
            case GameVersion.ORAS:
                if (pkm.InhabitedGeneration(6))
                {
                    return(LevelUpAO[species].GetMoves(lvl));
                }
                break;

            case GameVersion.SN:
            case GameVersion.MN:
            case GameVersion.SM:
                if (species > MaxSpeciesID_7)
                {
                    break;
                }
                if (pkm.InhabitedGeneration(7))
                {
                    int index = PersonalTable.SM.GetFormeIndex(species, pkm.AltForm);
                    return(LevelUpSM[index].GetMoves(lvl));
                }
                break;

            case GameVersion.US:
            case GameVersion.UM:
            case GameVersion.USUM:
                if (pkm.InhabitedGeneration(7))
                {
                    int index = PersonalTable.USUM.GetFormeIndex(species, pkm.AltForm);
                    return(LevelUpUSUM[index].GetMoves(lvl));
                }
                break;
            }
            return(Array.Empty <int>());
        }
Esempio n. 8
0
File: Core.cs Progetto: LLNet/PKHeX
 internal static bool HasVisitedUSUM(this PKM pkm) => pkm.InhabitedGeneration(7) && (pkm.USUM || !pkm.IsUntraded);
Esempio n. 9
0
File: Core.cs Progetto: LLNet/PKHeX
 internal static bool HasVisitedORAS(this PKM pkm) => pkm.InhabitedGeneration(6) && (pkm.AO || !pkm.IsUntraded);
Esempio n. 10
0
File: Core.cs Progetto: LLNet/PKHeX
 internal static bool HasVisitedB2W2(this PKM pkm) => pkm.InhabitedGeneration(5);
Esempio n. 11
0
        private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, int[] Moves, LegalInfo info)
        {
            var emptyegg = new int[0];

            var e        = info.EncounterMatch as EncounterEgg;
            var EggMoves = e != null?Legal.GetEggMoves(pkm, e.Species, pkm.AltForm) : emptyegg;

            var TradebackPreevo      = pkm.Format == 2 && info.EncounterMatch.Species > 151 && pkm.InhabitedGeneration(1);
            var NonTradebackLvlMoves = TradebackPreevo ? Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game).Where(m => m > Legal.MaxMoveID_1).ToArray() : new int[0];

            int[] RelearnMoves = pkm.RelearnMoves;
            int[] SpecialMoves = GetSpecialMoves(info.EncounterMatch);

            CheckMoveResult[] res = ParseMoves(pkm, Moves, SpecialMoves, new int[0], EggMoves, NonTradebackLvlMoves, new int[0], new int[0], info);

            for (int i = 0; i < 4; i++)
            {
                if ((pkm.IsEgg || res[i].Flag) && !RelearnMoves.Contains(Moves[i]))
                {
                    res[i] = new CheckMoveResult(res[i], Severity.Invalid, string.Format(V170, res[i].Comment), res[i].Identifier);
                }
            }

            return(res);
        }
Esempio n. 12
0
        private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, int[] Moves, LegalInfo info)
        {
            var source = new MoveParseSource
            {
                CurrentMoves  = Moves,
                SpecialSource = GetSpecialMoves(info.EncounterMatch),
            };

            if (info.EncounterMatch is EncounterEgg e)
            {
                source.EggMoveSource = Legal.GetEggMoves(pkm, e.Species, pkm.AltForm);
                bool TradebackPreevo = pkm.Format == 2 && info.EncounterMatch.Species > 151 && pkm.InhabitedGeneration(1);
                if (TradebackPreevo)
                {
                    source.NonTradeBackLevelUpMoves = Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Game)
                                                      .Where(m => m > Legal.MaxMoveID_1).ToArray();
                }
            }
            CheckMoveResult[] res = ParseMoves(pkm, source, info);

            int[] RelearnMoves = pkm.RelearnMoves;
            for (int i = 0; i < 4; i++)
            {
                if ((pkm.IsEgg || res[i].Flag) && !RelearnMoves.Contains(Moves[i]))
                {
                    res[i] = new CheckMoveResult(res[i], Severity.Invalid, string.Format(V170, res[i].Comment), res[i].Identifier);
                }
            }

            return(res);
        }