diff --git a/PKHeX.Core/Legality/Encounters/Information/ValidEncounterMoves.cs b/PKHeX.Core/Legality/Encounters/Information/ValidEncounterMoves.cs index db2b00b21..87ad67e8e 100644 --- a/PKHeX.Core/Legality/Encounters/Information/ValidEncounterMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Information/ValidEncounterMoves.cs @@ -17,17 +17,17 @@ namespace PKHeX.Core private const int EmptyCount = PKX.Generation + 1; // one for each generation index (and 0th) private static readonly IReadOnlyList[] Empty = Enumerable.Repeat((IReadOnlyList)new List(), EmptyCount).ToArray(); - public ValidEncounterMoves(PKM pkm, LevelUpRestriction restrict, IEncounterTemplate encounter) + public ValidEncounterMoves(PKM pkm, IEncounterTemplate encounter, IReadOnlyList[] chains) { - var level = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, minLvLG1: restrict.MinimumLevelGen1, minLvLG2: restrict.MinimumLevelGen2, types: MoveSourceType.Encounter, RemoveTransferHM: false); + var level = MoveList.GetValidMovesAllGens(pkm, chains, types: MoveSourceType.Encounter, RemoveTransferHM: false); int gen = encounter.Generation; if ((uint)gen < level.Length && level[gen] is List x) AddEdgeCaseMoves(x, encounter, pkm); LevelUpMoves = level; - TMHMMoves = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, types: MoveSourceType.AllMachines); - TutorMoves = MoveList.GetValidMovesAllGens(pkm, restrict.EvolutionChains, types: MoveSourceType.AllTutors); + TMHMMoves = MoveList.GetValidMovesAllGens(pkm, chains, types: MoveSourceType.AllMachines); + TutorMoves = MoveList.GetValidMovesAllGens(pkm, chains, types: MoveSourceType.AllTutors); } private static void AddEdgeCaseMoves(List moves, IEncounterTemplate encounter, PKM pkm) @@ -38,7 +38,7 @@ namespace PKHeX.Core 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)); + moves.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, r.Species, r.Form, r.LevelMax, 0, 0, GameVersion.SW, false, 8)); break; case EncounterSlot8GO g: moves.AddRange(MoveLevelUp.GetEncounterMoves(g.Species, g.Form, pkm.Met_Level, g.OriginGroup)); @@ -53,18 +53,4 @@ namespace PKHeX.Core public ValidEncounterMoves() : this(Empty) { } } - - public sealed class LevelUpRestriction - { - public readonly IReadOnlyList[] EvolutionChains; - public readonly int MinimumLevelGen1; - public readonly int MinimumLevelGen2; - - public LevelUpRestriction(PKM pkm, LegalInfo info) - { - MinimumLevelGen1 = info.Generation <= 2 ? info.EncounterMatch.LevelMin + 1 : 0; - MinimumLevelGen2 = ParseSettings.AllowGen2MoveReminder(pkm) ? 1 : info.EncounterMatch.LevelMin + 1; - EvolutionChains = info.EvoChainsAllGens; - } - } } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index d378b77aa..e97ce4289 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -40,28 +40,8 @@ namespace PKHeX.Core return ParseMovesForSmeargle(pkm, currentMoves, info); // Smeargle can have any moves except a few // gather valid moves for encounter species - var restrict = new LevelUpRestriction(pkm, info); - info.EncounterMoves = new ValidEncounterMoves(pkm, restrict, info.EncounterMatch); - - IReadOnlyList defaultG1LevelMoves = Array.Empty(); - IReadOnlyList defaultG2LevelMoves = Array.Empty(); + info.EncounterMoves = new ValidEncounterMoves(pkm, info.EncounterMatch, info.EvoChainsAllGens); var defaultTradeback = pkm.TradebackStatus; - bool gb = false; - int gen = info.EncounterMatch.Generation; - if (gen <= 2) - { - gb = true; - defaultG1LevelMoves = info.EncounterMoves.LevelUpMoves[1]; - if (pkm.InhabitedGeneration(2)) - defaultG2LevelMoves = info.EncounterMoves.LevelUpMoves[2]; - - // Generation 1 can have different minimum level in different encounter of the same species; update valid level moves - UpdateGen1LevelUpMoves(pkm, info.EncounterMoves, restrict.MinimumLevelGen1, gen, info); - - // The same for Generation 2; if move reminder from Stadium 2 is not allowed - if (!AllowGen2MoveReminder(pkm) && pkm.InhabitedGeneration(2)) - UpdateGen2LevelUpMoves(pkm, info.EncounterMoves, restrict.MinimumLevelGen2, gen, info); - } var res = info.Generation < 6 ? ParseMovesPre3DS(pkm, currentMoves, info) @@ -70,13 +50,6 @@ namespace PKHeX.Core if (res.All(x => x.Valid)) return res; - // not valid - if (gb) // restore generation 1 and 2 moves - { - info.EncounterMoves.LevelUpMoves[1] = defaultG1LevelMoves; - if (pkm.InhabitedGeneration(2)) - info.EncounterMoves.LevelUpMoves[2] = defaultG2LevelMoves; - } pkm.TradebackStatus = defaultTradeback; return res; } @@ -748,25 +721,5 @@ namespace PKHeX.Core res[i] = new CheckMoveResult(res[i], Invalid, LMoveSourceEmpty); } } - - private static void UpdateGen1LevelUpMoves(PKM pkm, ValidEncounterMoves EncounterMoves, int defaultLvlG1, int generation, LegalInfo info) - { - if (generation >= 3) - return; - var lvlG1 = info.EncounterMatch.LevelMin + 1; - if (lvlG1 == defaultLvlG1) - return; - EncounterMoves.LevelUpMoves[1] = MoveList.GetValidMoves(pkm, info.EvoChainsAllGens[1], generation: 1, minLvLG1: lvlG1, types: MoveSourceType.LevelUp).ToList(); - } - - private static void UpdateGen2LevelUpMoves(PKM pkm, ValidEncounterMoves EncounterMoves, int defaultLvlG2, int generation, LegalInfo info) - { - if (generation >= 3) - return; - var lvlG2 = info.EncounterMatch.LevelMin + 1; - if (lvlG2 == defaultLvlG2) - return; - EncounterMoves.LevelUpMoves[2] = MoveList.GetValidMoves(pkm, info.EvoChainsAllGens[2], generation: 2, minLvLG2: defaultLvlG2, types: MoveSourceType.LevelUp).ToList(); - } } } diff --git a/PKHeX.Core/Legality/MoveList.cs b/PKHeX.Core/Legality/MoveList.cs index 9e95bd0c0..16c99d29c 100644 --- a/PKHeX.Core/Legality/MoveList.cs +++ b/PKHeX.Core/Legality/MoveList.cs @@ -145,7 +145,7 @@ namespace PKHeX.Core return Array.Empty(); } - internal static IReadOnlyList[] GetValidMovesAllGens(PKM pkm, IReadOnlyList[] evoChains, int minLvLG1 = 1, int minLvLG2 = 1, MoveSourceType types = MoveSourceType.ExternalSources, bool RemoveTransferHM = true) + internal static IReadOnlyList[] GetValidMovesAllGens(PKM pkm, IReadOnlyList[] evoChains, MoveSourceType types = MoveSourceType.ExternalSources, bool RemoveTransferHM = true) { var result = new IReadOnlyList[evoChains.Length]; for (int i = 0; i < result.Length; i++) @@ -157,17 +157,17 @@ namespace PKHeX.Core if (evoChains[i].Count == 0) continue; - result[i] = GetValidMoves(pkm, evoChains[i], i, minLvLG1, minLvLG2, types, RemoveTransferHM).ToList(); + result[i] = GetValidMoves(pkm, evoChains[i], i, types, RemoveTransferHM).ToList(); } return result; } - internal static IEnumerable GetValidMoves(PKM pkm, IReadOnlyList evoChain, int generation, int minLvLG1 = 1, int minLvLG2 = 1, MoveSourceType types = MoveSourceType.ExternalSources, bool RemoveTransferHM = true) + internal static IEnumerable GetValidMoves(PKM pkm, IReadOnlyList evoChain, int generation, MoveSourceType types = MoveSourceType.ExternalSources, bool RemoveTransferHM = true) { GameVersion version = (GameVersion)pkm.Version; if (!pkm.IsUntraded) version = Any; - return GetValidMoves(pkm, version, evoChain, generation, minLvLG1: minLvLG1, minLvLG2: minLvLG2, types: types, RemoveTransferHM: RemoveTransferHM); + return GetValidMoves(pkm, version, evoChain, generation, types: types, RemoveTransferHM: RemoveTransferHM); } internal static IEnumerable GetValidRelearn(PKM pkm, int species, int form, GameVersion version = Any) @@ -175,6 +175,9 @@ namespace PKHeX.Core return GetValidRelearn(pkm, species, form, Breeding.GetCanInheritMoves(species), version); } + /// + /// ONLY CALL FOR GEN2 EGGS + /// internal static IEnumerable GetExclusivePreEvolutionMoves(PKM pkm, int Species, IReadOnlyList evoChain, int generation, GameVersion Version) { var preevomoves = new List(); @@ -182,15 +185,25 @@ namespace PKHeX.Core var index = EvolutionChain.GetEvoChainSpeciesIndex(evoChain, Species); for (int i = 0; i < evoChain.Count; i++) { + int minLvLG2; var evo = evoChain[i]; - var moves = GetMoves(pkm, evo.Species, 1, 1, evo.Level, evo.Form, Version: Version, types: MoveSourceType.ExternalSources, RemoveTransferHM: false, generation: generation); + if (ParseSettings.AllowGen2MoveReminder(pkm)) + minLvLG2 = 0; + else if (i == evoChain.Count - 1) // minimum level, otherwise next learnable level + minLvLG2 = 5; + else if (evo.RequiresLvlUp) + minLvLG2 = evo.Level + 1; + else + minLvLG2 = evo.Level; + + var moves = GetMoves(pkm, evo.Species, evo.Form, evo.Level, 0, minLvLG2, Version: Version, types: MoveSourceType.ExternalSources, RemoveTransferHM: false, generation: generation); var list = i >= index ? preevomoves : evomoves; list.AddRange(moves); } return preevomoves.Except(evomoves).Distinct(); } - internal static IEnumerable GetValidMoves(PKM pkm, GameVersion version, IReadOnlyList chain, int generation, int minLvLG1 = 1, int minLvLG2 = 1, MoveSourceType types = MoveSourceType.Reminder, bool RemoveTransferHM = true) + internal static IEnumerable GetValidMoves(PKM pkm, GameVersion version, IReadOnlyList chain, int generation, MoveSourceType types = MoveSourceType.Reminder, bool RemoveTransferHM = true) { var r = new List { 0 }; int species = pkm.Species; @@ -207,15 +220,32 @@ namespace PKHeX.Core formCount = pkm.PersonalInfo.FormCount; for (int form = 0; form < formCount; form++) - r.AddRange(GetMoves(pkm, species, minLvLG1, minLvLG2, chain[0].Level, form, version, types, RemoveTransferHM, generation)); + r.AddRange(GetMoves(pkm, species, form, chain[0].Level, 0, 0, version, types, RemoveTransferHM, generation)); if (types.HasFlagFast(MoveSourceType.RelearnMoves)) r.AddRange(pkm.RelearnMoves); return r.Distinct(); } + // Generation 1 & 2 do not always have move relearning capability, so the bottom bound for learnable indexes needs to be determined. + var minLvLG1 = 0; + var minLvLG2 = 0; for (var i = 0; i < chain.Count; i++) { var evo = chain[i]; + if (generation <= 2) + { + bool encounteredEvo = i == chain.Count - 1; + if (encounteredEvo) // minimum level, otherwise next learnable level + minLvLG1 = pkm.HasOriginalMetLocation ? pkm.Met_Level : evo.MinLevel; + else if (evo.RequiresLvlUp) + minLvLG1 = evo.Level + 1; + else + minLvLG1 = evo.Level; + + if (!ParseSettings.AllowGen2MoveReminder(pkm)) + minLvLG2 = minLvLG1; + } + var moves = GetEvoMoves(pkm, version, types, chain, generation, minLvLG1, minLvLG2, RemoveTransferHM, i, evo); r.AddRange(moves); } @@ -234,42 +264,17 @@ namespace PKHeX.Core private static IEnumerable GetEvoMoves(PKM pkm, GameVersion Version, MoveSourceType types, IReadOnlyList chain, int generation, int minLvLG1, int minLvLG2, bool RemoveTransferHM, int i, EvoCriteria evo) { - int minlvlevo1 = GetEvoMoveMinLevel1(pkm, generation, minLvLG1, evo); - int minlvlevo2 = GetEvoMoveMinLevel2(pkm, generation, minLvLG2, evo); var maxLevel = evo.Level; if (i != 0 && chain[i - 1].RequiresLvlUp) // evolution ++maxLevel; // allow lvlmoves from the level it evolved to the next species - return GetMoves(pkm, evo.Species, minlvlevo1, minlvlevo2, maxLevel, evo.Form, Version, types, RemoveTransferHM, generation); + return GetMoves(pkm, evo.Species, evo.Form, maxLevel, minLvLG1, minLvLG2, Version, types, RemoveTransferHM, generation); } - /// - /// Returns the minimum level the move can be learned at based on the species encounter level. - /// - private static int GetEvoMoveMinLevel1(PKM pkm, int generation, int minLvLG1, EvoCriteria evo) - { - if (generation != 1) - return 1; - // For evolutions, return the lower of the two; current level should legally be >= - if (evo.MinLevel > 1) - return Math.Min(pkm.CurrentLevel, evo.MinLevel); - return minLvLG1; - } - - private static int GetEvoMoveMinLevel2(PKM pkm, int generation, int minLvLG2, EvoCriteria evo) - { - if (generation != 2 || ParseSettings.AllowGen2MoveReminder(pkm)) - return 1; - // For evolutions, return the lower of the two; current level should legally be >= - if (evo.MinLevel > 1) - return Math.Min(pkm.CurrentLevel, evo.MinLevel); - return minLvLG2; - } - - private static IEnumerable GetMoves(PKM pkm, int species, int minlvlG1, int minlvlG2, int lvl, int form, GameVersion Version, MoveSourceType types, bool RemoveTransferHM, int generation) + private static IEnumerable GetMoves(PKM pkm, int species, int form, int maxLevel, int minlvlG1, int minlvlG2, GameVersion Version, MoveSourceType types, bool RemoveTransferHM, int generation) { var r = new List(); if (types.HasFlagFast(MoveSourceType.LevelUp)) - r.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, species, minlvlG1, minlvlG2, lvl, form, Version, types.HasFlagFast(MoveSourceType.Reminder), generation)); + r.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, species, form, maxLevel, minlvlG1, minlvlG2, Version, types.HasFlagFast(MoveSourceType.Reminder), generation)); if (types.HasFlagFast(MoveSourceType.Machine)) r.AddRange(MoveTechnicalMachine.GetTMHM(pkm, species, form, generation, Version, RemoveTransferHM)); if (types.HasFlagFast(MoveSourceType.TechnicalRecord)) diff --git a/PKHeX.Core/Legality/MoveListSuggest.cs b/PKHeX.Core/Legality/MoveListSuggest.cs index d025f4f9d..1058300b4 100644 --- a/PKHeX.Core/Legality/MoveListSuggest.cs +++ b/PKHeX.Core/Legality/MoveListSuggest.cs @@ -35,10 +35,10 @@ namespace PKHeX.Core GameVersion version = (GameVersion)pkm.Version; if (!pkm.IsUntraded) version = GameVersion.Any; - return GetValidMoves(pkm, version, evoChains, minLvLG1: 1, minLvLG2: 1, types: types, RemoveTransferHM: RemoveTransferHM); + return GetValidMoves(pkm, version, evoChains, types: types, RemoveTransferHM: RemoveTransferHM); } - private static IEnumerable GetValidMoves(PKM pkm, GameVersion version, IReadOnlyList> evoChains, int minLvLG1 = 1, int minLvLG2 = 1, MoveSourceType types = MoveSourceType.Reminder, bool RemoveTransferHM = true) + private static IEnumerable GetValidMoves(PKM pkm, GameVersion version, IReadOnlyList> evoChains, MoveSourceType types = MoveSourceType.Reminder, bool RemoveTransferHM = true) { var r = new List { 0 }; if (types.HasFlagFast(MoveSourceType.RelearnMoves) && pkm.Format >= 6) @@ -55,7 +55,7 @@ namespace PKHeX.Core var chain = evoChains[generation]; if (chain.Count == 0) continue; - r.AddRange(MoveList.GetValidMoves(pkm, version, chain, generation, minLvLG1: minLvLG1, minLvLG2: minLvLG2, types: types, RemoveTransferHM: RemoveTransferHM)); + r.AddRange(MoveList.GetValidMoves(pkm, version, chain, generation, types: types, RemoveTransferHM: RemoveTransferHM)); } return r.Distinct(); diff --git a/PKHeX.Core/Legality/Moves/MoveLevelUp.cs b/PKHeX.Core/Legality/Moves/MoveLevelUp.cs index de5fc282b..2108cea09 100644 --- a/PKHeX.Core/Legality/Moves/MoveLevelUp.cs +++ b/PKHeX.Core/Legality/Moves/MoveLevelUp.cs @@ -10,44 +10,44 @@ namespace PKHeX.Core { private static readonly LearnLookup LearnSWSH = new(PersonalTable.SWSH, LevelUpSWSH, SWSH), - LearnSM = new(PersonalTable.SM, LevelUpSM, SM), + LearnSM = new(PersonalTable.SM, LevelUpSM, SM), LearnUSUM = new(PersonalTable.USUM, LevelUpUSUM, USUM), - LearnGG = new(PersonalTable.GG, LevelUpGG, Gen7b), - LearnXY = new(PersonalTable.XY, LevelUpXY, XY), - LearnAO = new(PersonalTable.AO, LevelUpAO, ORAS), - LearnBW = new(PersonalTable.BW, LevelUpBW, BW), + LearnGG = new(PersonalTable.GG, LevelUpGG, Gen7b), + LearnXY = new(PersonalTable.XY, LevelUpXY, XY), + LearnAO = new(PersonalTable.AO, LevelUpAO, ORAS), + LearnBW = new(PersonalTable.BW, LevelUpBW, BW), LearnB2W2 = new(PersonalTable.B2W2, LevelUpB2W2, B2W2), - LearnDP = new(PersonalTable.DP, LevelUpDP, DP), - LearnPt = new(PersonalTable.Pt, LevelUpPt, Pt), + LearnDP = new(PersonalTable.DP, LevelUpDP, DP), + LearnPt = new(PersonalTable.Pt, LevelUpPt, Pt), LearnHGSS = new(PersonalTable.HGSS, LevelUpHGSS, HGSS), - LearnRSE = new(PersonalTable.RS, LevelUpRS, RSE), - LearnFRLG = new(PersonalTable.LG, LevelUpLG, FRLG), - LearnGS = new(PersonalTable.GS, LevelUpGS, GS), - LearnC = new(PersonalTable.C, LevelUpC, C), - LearnRB = new(PersonalTable.RB, LevelUpRB, RB), - LearnY = new(PersonalTable.Y, LevelUpY, YW); + LearnRSE = new(PersonalTable.RS, LevelUpRS, RSE), + LearnFRLG = new(PersonalTable.LG, LevelUpLG, FRLG), + LearnGS = new(PersonalTable.GS, LevelUpGS, GS), + LearnC = new(PersonalTable.C, LevelUpC, C), + LearnRB = new(PersonalTable.RB, LevelUpRB, RB), + LearnY = new(PersonalTable.Y, LevelUpY, YW); - public static LearnVersion GetIsLevelUpMove(PKM pkm, int species, int form, int lvl, int generation, int move, int minlvlG1, int minlvlG2, GameVersion version = Any) + public static LearnVersion GetIsLevelUpMove(PKM pkm, int species, int form, int maxLevel, int generation, int move, int minlvlG1, int minlvlG2, GameVersion version = Any) { if (pkm.IsMovesetRestricted(generation)) version = (GameVersion)pkm.Version; return generation switch { - 1 => GetIsLevelUp1(species, move, lvl, form, minlvlG1, version), + 1 => GetIsLevelUp1(species, form, move, maxLevel, minlvlG1, version), 2 when move > MaxMoveID_1 && pkm.LearnMovesNew2Disallowed() => LearnNONE, - 2 => GetIsLevelUp2(species, move, lvl, form, minlvlG2, pkm.Korean, version), - 3 => GetIsLevelUp3(species, move, lvl, form, version), - 4 => GetIsLevelUp4(species, move, lvl, form, version), - 5 => GetIsLevelUp5(species, move, lvl, form, version), - 6 => GetIsLevelUp6(species, move, lvl, form, version), - 7 => GetIsLevelUp7(species, move, form, version), // move reminder can give any move 1-100 - 8 => GetIsLevelUp8(species, move, lvl, form, version), + 2 => GetIsLevelUp2(species, form, move, maxLevel, minlvlG2, version, pkm.Korean), + 3 => GetIsLevelUp3(species, form, move, maxLevel, version), + 4 => GetIsLevelUp4(species, form, move, maxLevel, version), + 5 => GetIsLevelUp5(species, form, move, maxLevel, version), + 6 => GetIsLevelUp6(species, form, move, maxLevel, version), + 7 => GetIsLevelUp7(species, form, move, version), // move reminder can give any move 1-100 + 8 => GetIsLevelUp8(species, form, move, maxLevel, version), _ => LearnNONE }; } - internal static LearnVersion GetIsLevelUp1(int species, int move, int max, int form, int min, GameVersion ver = Any) + internal static LearnVersion GetIsLevelUp1(int species, int form, int move, int maxLevel, int minLevel, GameVersion ver = Any) { if (move > MaxMoveID_1) return LearnNONE; @@ -55,8 +55,8 @@ namespace PKHeX.Core switch (ver) { case Any: case RBY: - var first = LearnRB.GetIsLevelUpG1(species, form, move, max, min); - var second = LearnY.GetIsLevelUpG1(species, form, move, max, min); + var first = LearnRB.GetIsLevelUpG1(species, form, move, maxLevel, minLevel); + var second = LearnY.GetIsLevelUpG1(species, form, move, maxLevel, minLevel); if (!first.IsLevelUp) return second; if (!second.IsLevelUp) @@ -64,116 +64,116 @@ namespace PKHeX.Core return first.Level > second.Level ? second : first; case RD or BU or GN or RB: - return LearnRB.GetIsLevelUpG1(species, form, move, max, min); + return LearnRB.GetIsLevelUpG1(species, form, move, maxLevel, minLevel); case YW: - return LearnY.GetIsLevelUpG1(species, form, move, max, min); + return LearnY.GetIsLevelUpG1(species, form, move, maxLevel, minLevel); } return LearnNONE; } - private static LearnVersion GetIsLevelUp2(int species, int move, int max, int form, int min, bool korean, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp2(int species, int form, int move, int maxLevel, int minLevel, GameVersion ver = Any, bool korean = false) { // No Korean Crystal switch (ver) { case Any: case GSC: - var first = LearnGS.GetIsLevelUpMin(species, move, max, min, form); + var first = LearnGS.GetIsLevelUpMin(species, move, maxLevel, minLevel, form); if (first.IsLevelUp || korean) return first; - return LearnC.GetIsLevelUpMin(species, move, max, min, form); + return LearnC.GetIsLevelUpMin(species, move, maxLevel, minLevel, form); case GD or SV or GS: - return LearnGS.GetIsLevelUpMin(species, move, max, min, form); + return LearnGS.GetIsLevelUpMin(species, move, maxLevel, minLevel, form); case C when !korean: - return LearnC.GetIsLevelUpMin(species, move, max, min, form); + return LearnC.GetIsLevelUpMin(species, move, maxLevel, minLevel, form); } return LearnNONE; } - private static LearnVersion GetIsLevelUp3(int species, int move, int lvl, int form, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp3(int species, int form, int move, int lvlLevel, GameVersion ver = Any) { if (species == (int)Species.Deoxys) - return GetIsLevelUp3Deoxys(form, move, lvl); + return GetIsLevelUp3Deoxys(form, move, lvlLevel); // Emerald level up tables are equal to R/S level up tables switch (ver) { case Any: - var first = LearnRSE.GetIsLevelUp(species, form, move, lvl); + var first = LearnRSE.GetIsLevelUp(species, form, move, lvlLevel); if (first.IsLevelUp) return first; - return LearnFRLG.GetIsLevelUp(species, form, move, lvl); + return LearnFRLG.GetIsLevelUp(species, form, move, lvlLevel); case R or S or E or RS or RSE: - return LearnRSE.GetIsLevelUp(species, form, move, lvl); + return LearnRSE.GetIsLevelUp(species, form, move, lvlLevel); case FR or LG or FRLG: - return LearnFRLG.GetIsLevelUp(species, form, move, lvl); + return LearnFRLG.GetIsLevelUp(species, form, move, lvlLevel); } return LearnNONE; } - private static LearnVersion GetIsLevelUp4(int species, int move, int lvl, int form, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp4(int species, int form, int move, int maxLevel, GameVersion ver = Any) { switch (ver) { case Any: case DPPt: - var first = LearnDP.GetIsLevelUp(species, form, move, lvl); + var first = LearnDP.GetIsLevelUp(species, form, move, maxLevel); if (first.IsLevelUp) return first; - var second = LearnPt.GetIsLevelUp(species, form, move, lvl); + var second = LearnPt.GetIsLevelUp(species, form, move, maxLevel); if (second.IsLevelUp) return second; if (ver == DPPt) // stop here return LearnNONE; - return LearnHGSS.GetIsLevelUp(species, form, move, lvl); + return LearnHGSS.GetIsLevelUp(species, form, move, maxLevel); case D or P or DP: - return LearnDP.GetIsLevelUp(species, form, move, lvl); + return LearnDP.GetIsLevelUp(species, form, move, maxLevel); case Pt: - return LearnPt.GetIsLevelUp(species, form, move, lvl); + return LearnPt.GetIsLevelUp(species, form, move, maxLevel); case HG or SS or HGSS: - return LearnHGSS.GetIsLevelUp(species, form, move, lvl); + return LearnHGSS.GetIsLevelUp(species, form, move, maxLevel); } return LearnNONE; } - private static LearnVersion GetIsLevelUp5(int species, int move, int lvl, int form, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp5(int species, int form, int move, int maxLevel, GameVersion ver = Any) { switch (ver) { case Any: - var first = LearnBW.GetIsLevelUp(species, form, move, lvl); + var first = LearnBW.GetIsLevelUp(species, form, move, maxLevel); if (first.IsLevelUp && species != 646) // Kyurem moves are same for both versions, but forme movepool not present. return first; - return LearnB2W2.GetIsLevelUp(species, form, move, lvl); + return LearnB2W2.GetIsLevelUp(species, form, move, maxLevel); case B or W or BW: - return LearnBW.GetIsLevelUp(species, form, move, lvl); + return LearnBW.GetIsLevelUp(species, form, move, maxLevel); case B2 or W2 or B2W2: - return LearnB2W2.GetIsLevelUp(species, form, move, lvl); + return LearnB2W2.GetIsLevelUp(species, form, move, maxLevel); } return LearnNONE; } - private static LearnVersion GetIsLevelUp6(int species, int move, int lvl, int form, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp6(int species, int form, int move, int maxLevel, GameVersion ver = Any) { switch (ver) { case Any: - var first = LearnXY.GetIsLevelUp(species, form, move, lvl); + var first = LearnXY.GetIsLevelUp(species, form, move, maxLevel); if (first.IsLevelUp) return first; - return LearnAO.GetIsLevelUp(species, form, move, lvl); + return LearnAO.GetIsLevelUp(species, form, move, maxLevel); case X or Y or XY: - return LearnXY.GetIsLevelUp(species, form, move, lvl); + return LearnXY.GetIsLevelUp(species, form, move, maxLevel); case OR or AS or ORAS: - return LearnAO.GetIsLevelUp(species, form, move, lvl); + return LearnAO.GetIsLevelUp(species, form, move, maxLevel); } return LearnNONE; } - private static LearnVersion GetIsLevelUp7(int species, int move, int form, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp7(int species, int form, int move, GameVersion ver = Any) { switch (ver) { @@ -203,7 +203,7 @@ namespace PKHeX.Core return LearnNONE; } - private static LearnVersion GetIsLevelUp8(int species, int move, int lvl, int form, GameVersion ver = Any) + private static LearnVersion GetIsLevelUp8(int species, int form, int move, int maxLevel, GameVersion ver = Any) { switch (ver) { @@ -212,7 +212,7 @@ namespace PKHeX.Core case SW or SH or SWSH: if (species > MaxSpeciesID_8) return LearnNONE; - return LearnSWSH.GetIsLevelUp(species, form, move, lvl); + return LearnSWSH.GetIsLevelUp(species, form, move, maxLevel); } return LearnNONE; } @@ -258,67 +258,67 @@ namespace PKHeX.Core return GameData.GetLearnsets(ver)[index]; } - public static IEnumerable GetMovesLevelUp(PKM pkm, int species, int minlvlG1, int minlvlG2, int lvl, int form, GameVersion version, bool MoveReminder, int generation) + public static IEnumerable GetMovesLevelUp(PKM pkm, int species, int form, int maxLevel, int minlvlG1, int minlvlG2, GameVersion version, bool MoveReminder, int generation) { if (pkm.IsMovesetRestricted(generation)) version = (GameVersion)pkm.Version; return generation switch { - 1 => GetMovesLevelUp1(species, form, lvl, minlvlG1, version), - 2 => GetMovesLevelUp2(species, form, lvl, minlvlG2, pkm.Korean, pkm.LearnMovesNew2Disallowed(), version), - 3 => GetMovesLevelUp3(species, form, lvl, version), - 4 => GetMovesLevelUp4(species, form, lvl, version), - 5 => GetMovesLevelUp5(species, form, lvl, version), - 6 => GetMovesLevelUp6(species, form, lvl, version), - 7 => GetMovesLevelUp7(species, form, lvl, MoveReminder, version), - 8 => GetMovesLevelUp8(species, form, lvl, version), + 1 => GetMovesLevelUp1(species, form, maxLevel, minlvlG1, version), + 2 => GetMovesLevelUp2(species, form, maxLevel, minlvlG2, pkm.Korean, pkm.LearnMovesNew2Disallowed(), version), + 3 => GetMovesLevelUp3(species, form, maxLevel, version), + 4 => GetMovesLevelUp4(species, form, maxLevel, version), + 5 => GetMovesLevelUp5(species, form, maxLevel, version), + 6 => GetMovesLevelUp6(species, form, maxLevel, version), + 7 => GetMovesLevelUp7(species, form, maxLevel, MoveReminder, version), + 8 => GetMovesLevelUp8(species, form, maxLevel, version), _ => Array.Empty() }; } private static bool LearnMovesNew2Disallowed(this PKM pkm) => pkm.Format == 1 || (pkm.Format >= 7 && pkm.VC1); - internal static List GetMovesLevelUp1(int species, int form, int max, int min, GameVersion ver = Any) + internal static List GetMovesLevelUp1(int species, int form, int maxLevel, int minLevel, GameVersion ver = Any) { - return AddMovesLevelUp1(new List(), ver, species, form, max, min); + return AddMovesLevelUp1(new List(), ver, species, form, maxLevel, minLevel); } - private static List GetMovesLevelUp2(int species, int form, int max, int min, bool korean, bool removeNewGSCMoves, GameVersion ver = Any) + private static List GetMovesLevelUp2(int species, int form, int maxLevel, int minLevel, bool korean, bool removeNewGSCMoves, GameVersion ver = Any) { - var moves = AddMovesLevelUp2(new List(), ver, species, form, max, min, korean); + var moves = AddMovesLevelUp2(new List(), ver, species, form, maxLevel, minLevel, korean); if (removeNewGSCMoves) moves.RemoveAll(m => m > MaxMoveID_1); return moves; } - private static List GetMovesLevelUp3(int species, int form, int max, GameVersion ver = Any) + private static List GetMovesLevelUp3(int species, int form, int maxLevel, GameVersion ver = Any) { - return AddMovesLevelUp3(new List(), ver, species, max, form); + return AddMovesLevelUp3(new List(), ver, species, form, maxLevel); } - private static List GetMovesLevelUp4(int species, int form, int max, GameVersion ver = Any) + private static List GetMovesLevelUp4(int species, int form, int maxLevel, GameVersion ver = Any) { - return AddMovesLevelUp4(new List(), ver, species, max, form); + return AddMovesLevelUp4(new List(), ver, species, form, maxLevel); } - private static List GetMovesLevelUp5(int species, int form, int max, GameVersion ver = Any) + private static List GetMovesLevelUp5(int species, int form, int maxLevel, GameVersion ver = Any) { - return AddMovesLevelUp5(new List(), ver, species, max, form); + return AddMovesLevelUp5(new List(), ver, species, form, maxLevel); } - private static List GetMovesLevelUp6(int species, int form, int max, GameVersion ver = Any) + private static List GetMovesLevelUp6(int species, int form, int maxLevel, GameVersion ver = Any) { - return AddMovesLevelUp6(new List(), ver, species, max, form); + return AddMovesLevelUp6(new List(), ver, species, form, maxLevel); } - private static List GetMovesLevelUp7(int species, int form, int max, bool MoveReminder, GameVersion ver = Any) + private static List GetMovesLevelUp7(int species, int form, int maxLevel, bool MoveReminder, GameVersion ver = Any) { - return AddMovesLevelUp7(new List(), ver, species, max, form, MoveReminder); + return AddMovesLevelUp7(new List(), ver, species, form, maxLevel, MoveReminder); } - private static List GetMovesLevelUp8(int species, int form, int max, GameVersion ver = Any) + private static List GetMovesLevelUp8(int species, int form, int maxLevel, GameVersion ver = Any) { - return AddMovesLevelUp8(new List(), ver, species, max, form); + return AddMovesLevelUp8(new List(), ver, species, form, maxLevel); } private static List AddMovesLevelUp1(List moves, GameVersion ver, int species, int form, int max, int min) @@ -355,13 +355,13 @@ namespace PKHeX.Core return moves; } - private static List AddMovesLevelUp3(List moves, GameVersion ver, int species, int max, int form) + private static List AddMovesLevelUp3(List moves, GameVersion ver, int species, int form, int maxLevel) { if (species == (int)Species.Deoxys) { var learn = GetDeoxysLearn3(form, ver); if (learn != null) - moves.AddRange(learn.GetMoves(max)); + moves.AddRange(learn.GetMoves(maxLevel)); return moves; } @@ -369,103 +369,103 @@ namespace PKHeX.Core switch (ver) { case Any: - LearnRSE.AddMoves(moves, species, form, max); - return LearnFRLG.AddMoves(moves, species, form, max); + LearnRSE.AddMoves(moves, species, form, maxLevel); + return LearnFRLG.AddMoves(moves, species, form, maxLevel); case R or S or E or RS or RSE: - return LearnRSE.AddMoves(moves, species, form, max); + return LearnRSE.AddMoves(moves, species, form, maxLevel); case FR or LG or FRLG: - return LearnFRLG.AddMoves(moves, species, form, max); + return LearnFRLG.AddMoves(moves, species, form, maxLevel); } return moves; } - private static List AddMovesLevelUp4(List moves, GameVersion ver, int species, int max, int form) + private static List AddMovesLevelUp4(List moves, GameVersion ver, int species, int form, int maxLevel) { switch (ver) { case Any: case DPPt: - LearnDP.AddMoves(moves, species, form, max); - LearnPt.AddMoves(moves, species, form, max); + LearnDP.AddMoves(moves, species, form, maxLevel); + LearnPt.AddMoves(moves, species, form, maxLevel); if (ver == DPPt) // stop here return moves; - return LearnHGSS.AddMoves(moves, species, form, max); + return LearnHGSS.AddMoves(moves, species, form, maxLevel); case D or P or DP: - return LearnDP.AddMoves(moves, species, form, max); + return LearnDP.AddMoves(moves, species, form, maxLevel); case Pt: - return LearnPt.AddMoves(moves, species, form, max); + return LearnPt.AddMoves(moves, species, form, maxLevel); case HG or SS or HGSS: - return LearnHGSS.AddMoves(moves, species, form, max); + return LearnHGSS.AddMoves(moves, species, form, maxLevel); } return moves; } - private static List AddMovesLevelUp5(List moves, GameVersion ver, int species, int max, int form) + private static List AddMovesLevelUp5(List moves, GameVersion ver, int species, int form, int maxLevel) { switch (ver) { case Any: if (species != 646) // Kyurem moves are same for both versions, but forme movepool not present. - LearnBW.AddMoves(moves, species, form, max); - return LearnB2W2.AddMoves(moves, species, form, max); + LearnBW.AddMoves(moves, species, form, maxLevel); + return LearnB2W2.AddMoves(moves, species, form, maxLevel); case B or W or BW: - return LearnBW.AddMoves(moves, species, form, max); + return LearnBW.AddMoves(moves, species, form, maxLevel); case B2 or W2 or B2W2: - return LearnB2W2.AddMoves(moves, species, form, max); + return LearnB2W2.AddMoves(moves, species, form, maxLevel); } return moves; } - private static List AddMovesLevelUp6(List moves, GameVersion ver, int species, int max, int form) + private static List AddMovesLevelUp6(List moves, GameVersion ver, int species, int form, int maxLevel) { switch (ver) { case Any: - LearnXY.AddMoves(moves, species, form, max); - return LearnAO.AddMoves(moves, species, form, max); + LearnXY.AddMoves(moves, species, form, maxLevel); + return LearnAO.AddMoves(moves, species, form, maxLevel); case X or Y or XY: - return LearnXY.AddMoves(moves, species, form, max); + return LearnXY.AddMoves(moves, species, form, maxLevel); case AS or OR or ORAS: - return LearnAO.AddMoves(moves, species, form, max); + return LearnAO.AddMoves(moves, species, form, maxLevel); } return moves; } - private static List AddMovesLevelUp7(List moves, GameVersion ver, int species, int max, int form, bool MoveReminder) + private static List AddMovesLevelUp7(List moves, GameVersion ver, int species, int form, int maxLevel, bool reminder) { - if (MoveReminder) - max = 100; // Move reminder can teach any level in movepool now! + if (reminder) + maxLevel = 100; // Move reminder can teach any level in movepool now! switch (ver) { case GP or GE or GG or GO: - return LearnGG.AddMoves(moves, species, form, max); + return LearnGG.AddMoves(moves, species, form, maxLevel); case Any: if (species > MaxSpeciesID_7_USUM) return moves; - LearnUSUM.AddMoves(moves, species, form, max); + LearnUSUM.AddMoves(moves, species, form, maxLevel); if (species > MaxSpeciesID_7) return moves; - return LearnSM.AddMoves(moves, species, form, max); + return LearnSM.AddMoves(moves, species, form, maxLevel); case SN or MN or SM: if (species > MaxSpeciesID_7) return moves; - return LearnSM.AddMoves(moves, species, form, max); + return LearnSM.AddMoves(moves, species, form, maxLevel); case US or UM or USUM: if (species > MaxSpeciesID_7_USUM) return moves; - LearnUSUM.AddMoves(moves, species, form, max); + LearnUSUM.AddMoves(moves, species, form, maxLevel); break; } return moves; } - private static List AddMovesLevelUp8(List moves, GameVersion ver, int species, int max, int form) + private static List AddMovesLevelUp8(List moves, GameVersion ver, int species, int form, int maxLevel) { // Move reminder can NOT teach any level like Gen7 switch (ver) @@ -475,7 +475,7 @@ namespace PKHeX.Core case SW or SH or SWSH: if (species > MaxSpeciesID_8) return moves; - return LearnSWSH.AddMoves(moves, species, form, max); + return LearnSWSH.AddMoves(moves, species, form, maxLevel); } return moves; } diff --git a/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs b/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs index 7bb2e857a..ef951ad15 100644 --- a/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs +++ b/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs @@ -119,7 +119,7 @@ namespace PKHeX.Core { var result = new int[moves.Count]; for (int i = 0; i < result.Length; i++) - result[i] = MoveLevelUp.GetIsLevelUp1(species, moves[i], 100, 0, 0).Level; + result[i] = MoveLevelUp.GetIsLevelUp1(species, 0, moves[i], 100, 0).Level; return result; } diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/031 - NIDOQUEEN - A016.pk2 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/031 - NIDOQUEEN - A016.pk2 new file mode 100644 index 000000000..a385fd0db Binary files /dev/null and b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/031 - NIDOQUEEN - A016.pk2 differ