diff --git a/PKHeX.Core/Game/GameStrings/GameDataSource.cs b/PKHeX.Core/Game/GameStrings/GameDataSource.cs index faa39b31a..57b23cc92 100644 --- a/PKHeX.Core/Game/GameStrings/GameDataSource.cs +++ b/PKHeX.Core/Game/GameStrings/GameDataSource.cs @@ -42,15 +42,19 @@ public GameDataSource(GameStrings s) var moves = Util.GetCBList(s.movelist); HaXMoveDataSource = moves; - var legal = new List(moves); - legal.RemoveAll(m => MoveInfo.Z_Moves.Contains(m.Value)); + var legal = new List(moves.Count); + foreach (var m in moves) + { + if (MoveInfo.IsMoveKnowable((ushort)m.Value)) + legal.Add(m); + } LegalMoveDataSource = legal; VersionDataSource = GetVersionList(s); Met = new MetDataSource(s); - Empty = new ComboItem(s.Species[0], 0); + Empty = new ComboItem(s.itemlist[0], 0); } /// Strings that this object's lists were generated with. diff --git a/PKHeX.Core/Game/GameStrings/GameStrings.cs b/PKHeX.Core/Game/GameStrings/GameStrings.cs index 03c9415cb..15ca9dff5 100644 --- a/PKHeX.Core/Game/GameStrings/GameStrings.cs +++ b/PKHeX.Core/Game/GameStrings/GameStrings.cs @@ -43,6 +43,7 @@ public sealed class GameStrings : IBasicStrings private string[] Get(string ident) => GameLanguage.GetStrings(ident, lang); private const string NPC = "NPC"; + private const string EmptyIndex = "---"; /// /// Item IDs that correspond to the value. @@ -81,9 +82,14 @@ public GameStrings(string l) abilitylist = Get("abilities"); movelist = Get("moves"); - string[] ps = { "P", "S" }; // Distinguish Physical/Special + // Differentiate Physical/Special Z-Moves for (int i = 622; i < 658; i++) - movelist[i] += $" ({ps[i % 2]})"; + { + const string p = " (P)"; + const string s = " (S)"; + bool isPhysicalZMove = (i & 1) == 0; + movelist[i] += isPhysicalZMove ? p : s; + } itemlist = Get("items"); characteristics = Get("character"); @@ -159,6 +165,8 @@ public GameStrings(string l) private string[] GetG3CXD(string[] arr, string fileName) { + // Concatenate the Gen3 Item list with the CXD item array; CXD items starting at index 500. + // Empty slots between the two lists are marked as unused. string[] item500 = Get(fileName); var result = new string[500 + item500.Length]; for (int i = arr.Length; i < result.Length; i++) @@ -190,7 +198,7 @@ private void Sanitize() abilitylist[(int)Core.Ability.AsOneG] += $" ({specieslist[(int)Core.Species.Spectrier]})"; // Replace the Egg Name with ---; egg name already stored to eggname - specieslist[0] = "---"; + specieslist[0] = EmptyIndex; // Fix (None) tags var none = $"({itemlist[0]})"; abilitylist[0] = itemlist[0] = movelist[0] = metXY_00000[0] = metBW2_00000[0] = metHGSS_00000[0] = metCXD_00000[0] = puffs[0] = none; diff --git a/PKHeX.Core/Game/GameStrings/MemoryStrings.cs b/PKHeX.Core/Game/GameStrings/MemoryStrings.cs index 1cfd1930f..01338421c 100644 --- a/PKHeX.Core/Game/GameStrings/MemoryStrings.cs +++ b/PKHeX.Core/Game/GameStrings/MemoryStrings.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -20,16 +20,16 @@ public MemoryStrings(GameStrings strings) memories = new Lazy>(GetMemories); none = new Lazy>(() => Util.GetCBList(new[] {string.Empty})); species = new Lazy>(() => Util.GetCBList(s.specieslist)); - item6 = new Lazy>(() => GetItems(6)); - item8 = new Lazy>(() => GetItems(8)); + item6 = new Lazy>(() => GetItems(EntityContext.Gen6)); + item8 = new Lazy>(() => GetItems(EntityContext.Gen8)); genloc = new Lazy>(() => Util.GetCBList(s.genloc)); moves = new Lazy>(() => Util.GetCBList(s.movelist)); specific = new Lazy>(() => Util.GetCBList(s.metXY_00000, Locations6.Met0)); } - private List GetItems(int memoryGen) + private List GetItems(EntityContext context) { - var permit = Memories.GetMemoryItemParams(memoryGen); + var permit = Memories.GetMemoryItemParams(context); var asInt = permit.ToArray(); return Util.GetCBList(s.itemlist, asInt); } diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 31df1803d..ebb6d39de 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -140,19 +140,6 @@ internal static int GetMaxSpeciesOrigin(PKM pk) _ => -1, }; - internal static int GetMaxMoveID(int generation) => generation switch - { - 1 => MaxMoveID_1, - 2 => MaxMoveID_2, - 3 => MaxMoveID_3, - 4 => MaxMoveID_4, - 5 => MaxMoveID_5, - 6 => MaxMoveID_6_AO, - 7 => MaxMoveID_7b, - 8 => MaxMoveID_8a, - _ => -1, - }; - /// /// Checks if the relearn moves should be wiped. /// diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs index e7da69336..16e12fbe7 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs @@ -117,13 +117,13 @@ private static bool VerifySecondaryChecks(PKM pk, LegalInfo info, PeekEnumerator if (m is IMemoryOT o && MemoryPermissions.IsMemoryOfKnownMove(o.OT_Memory)) { var mem = MemoryVariableSet.Read(m, 0); - if (!MemoryPermissions.CanKnowMove(pk, mem, info.EncounterMatch.Generation, info)) + if (!MemoryPermissions.CanKnowMove(pk, mem, info.EncounterMatch.Context, info)) return false; } if (m is IMemoryHT h && MemoryPermissions.IsMemoryOfKnownMove(h.HT_Memory) && !pk.HasMove(h.HT_TextVar)) { var mem = MemoryVariableSet.Read(m, 1); - if (!MemoryPermissions.CanKnowMove(pk, mem, pk.Format, info)) + if (!MemoryPermissions.CanKnowMove(pk, mem, pk.Context, info)) return false; } } diff --git a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs index 122758245..3d3444d9c 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs @@ -160,7 +160,7 @@ private static bool IsPlausibleSmeargleMoveset(PKM pk, ReadOnlySpan moves) { foreach (var move in moves) { - if (!Legal.IsValidSketch(move, pk.Format)) + if (!MoveInfo.IsValidSketch((ushort)move, pk.Context)) return false; } return true; diff --git a/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs b/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs index 79a38e7bb..c428cdecf 100644 --- a/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs +++ b/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierHistory.cs @@ -119,7 +119,7 @@ private static void VerifySmeargle(Span result, ReadOnlySpan cu var move = current[i]; if (move == 0) result[i] = MoveResult.Empty; - else if (Legal.IsValidSketch(move, pk.Format)) + else if (MoveInfo.IsValidSketch((ushort)move, pk.Context)) result[i] = MoveResult.Sketch; else result[i] = MoveResult.Unobtainable(); diff --git a/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs b/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs index 107dc0ad4..0a9df9712 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; @@ -33,11 +33,11 @@ public static MemoryArgType GetMemoryArgType(int memory, int memoryGen) return MemoryArgType.None; } - public static MemoryContext GetContext(int memoryGen) => memoryGen switch + public static MemoryContext GetContext(EntityContext context) => context.Generation() switch { <=7 => Memory6, _ => Memory8, }; - public static IEnumerable GetMemoryItemParams(int memoryGen) => GetContext(memoryGen).GetMemoryItemParams(); + public static IEnumerable GetMemoryItemParams(EntityContext context) => GetContext(context).GetMemoryItemParams(); } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs index 563c9005f..89d52d8b2 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs @@ -16,58 +16,58 @@ public static class MemoryPermissions { public static bool IsMemoryOfKnownMove(int memory) => memory is 48 or 80 or 81; - public static bool CanWinLotoID(int generation, int item) + public static bool CanWinLotoID(EntityContext context, int item) { - var context = Memories.GetContext(generation); - return context.CanWinLotoID(item); + var mem = Memories.GetContext(context); + return mem.CanWinLotoID(item); } - public static bool CanHoldItem(int generation, int item) + public static bool CanHoldItem(EntityContext context, int item) { - var context = Memories.GetContext(generation); - return context.CanHoldItem(item); + var mem = Memories.GetContext(context); + return mem.CanHoldItem(item); } - public static bool CanPlantBerry(int generation, int item) + public static bool CanPlantBerry(EntityContext context, int item) { - var context = Memories.GetContext(generation); - return context.CanPlantBerry(item); + var mem = Memories.GetContext(context); + return mem.CanPlantBerry(item); } - public static bool CanUseItemGeneric(int generation, int item) + public static bool CanUseItemGeneric(EntityContext context, int item) { - var context = Memories.GetContext(generation); - return context.CanUseItemGeneric(item); + var mem = Memories.GetContext(context); + return mem.CanUseItemGeneric(item); } - public static bool CanUseItem(int generation, int item, int species) + public static bool CanUseItem(EntityContext context, int item, int species) { - if (IsUsedKeyItemUnspecific(generation, item)) + if (IsUsedKeyItemUnspecific(context, item)) return true; - if (IsUsedKeyItemSpecific(generation, item, species)) + if (IsUsedKeyItemSpecific(context, item, species)) return true; return true; // todo } - private static bool IsUsedKeyItemUnspecific(int generation, int item) + private static bool IsUsedKeyItemUnspecific(EntityContext context, int item) { - var context = Memories.GetContext(generation); - return context.IsUsedKeyItemUnspecific(item); + var mem = Memories.GetContext(context); + return mem.IsUsedKeyItemUnspecific(item); } - private static bool IsUsedKeyItemSpecific(int generation, int item, int species) + private static bool IsUsedKeyItemSpecific(EntityContext context, int item, int species) { - var context = Memories.GetContext(generation); - return context.IsUsedKeyItemSpecific(item, species); + var mem = Memories.GetContext(context); + return mem.IsUsedKeyItemSpecific(item, species); } - public static bool CanBuyItem(int generation, int item, GameVersion version = GameVersion.Any) + public static bool CanBuyItem(EntityContext context, int item, GameVersion version = GameVersion.Any) { - var context = Memories.GetContext(generation); - return context.CanBuyItem(item, version); + var mem = Memories.GetContext(context); + return mem.CanBuyItem(item, version); } - public static bool CanKnowMove(PKM pk, MemoryVariableSet memory, int gen, LegalInfo info, bool battleOnly = false) + public static bool CanKnowMove(PKM pk, MemoryVariableSet memory, EntityContext gen, LegalInfo info, bool battleOnly = false) { var move = memory.Variable; if (move == 0) @@ -105,7 +105,7 @@ public static bool CanKnowMove(PKM pk, MemoryVariableSet memory, int gen, LegalI case (int)BehemothBash when pk.Species == (int)Zamazenta: return true; } - if (gen == 8 && MoveInfo.IsDynamaxMove(move)) + if (gen == EntityContext.Gen8 && MoveInfo.IsMoveDynamax(move)) return true; if (pk.Species == (int)Ditto) { @@ -113,7 +113,7 @@ public static bool CanKnowMove(PKM pk, MemoryVariableSet memory, int gen, LegalI return false; return gen switch { - 8 => move <= Legal.MaxMoveID_8_R2 && !MoveInfo.IsDummiedMove(pk, move), + EntityContext.Gen8 => move <= Legal.MaxMoveID_8_R2 && !MoveInfo.IsDummiedMove(pk, move), _ => move <= Legal.MaxMoveID_6_AO, }; } @@ -129,16 +129,16 @@ private static bool IsSpecialEncounterMoveEggDeleted(PKM pk, IEncounterTemplate return enc is EncounterEgg { Generation: < 6 }; // egg moves that are no longer in the movepool } - public static bool GetCanRelearnMove(PKM pk, int move, int generation, EvolutionHistory history, IEncounterTemplate enc) + public static bool GetCanRelearnMove(PKM pk, int move, EntityContext context, EvolutionHistory history, IEncounterTemplate enc) { - if (generation == 6) + if (context == EntityContext.Gen6) { Span result = stackalloc MoveResult[1]; Span moves = stackalloc int[] { move }; LearnGroup6.Instance.Check(result, moves, pk, history, enc, MoveSourceType.Reminder, LearnOption.AtAnyTime); return result[0].Valid; } - if (generation == 8) + if (context == EntityContext.Gen8) { Span result = stackalloc MoveResult[1]; Span moves = stackalloc int[] { move }; @@ -148,15 +148,15 @@ public static bool GetCanRelearnMove(PKM pk, int move, int generation, Evolution return false; } - private static bool GetCanKnowMove(PKM pk, int move, int generation, EvolutionHistory history, IEncounterTemplate enc) + private static bool GetCanKnowMove(PKM pk, int move, EntityContext context, EvolutionHistory history, IEncounterTemplate enc) { if (pk.Species == (int)Smeargle) - return Legal.IsValidSketch(move, generation); + return MoveInfo.IsValidSketch((ushort)move, context); ILearnGroup game; - if (generation == 6) + if (context == EntityContext.Gen6) game = LearnGroup6.Instance; - else if (generation == 8) + else if (context == EntityContext.Gen8) game = LearnGroup8.Instance; else return false; @@ -167,9 +167,9 @@ private static bool GetCanKnowMove(PKM pk, int move, int generation, EvolutionHi return result[0].Valid; } - public static bool GetCanBeCaptured(int species, int gen, GameVersion version) => gen switch + public static bool GetCanBeCaptured(int species, EntityContext gen, GameVersion version) => gen switch { - 6 => version switch + EntityContext.Gen6 => version switch { GameVersion.Any => GetCanBeCaptured(species, SlotsX, StaticX) || GetCanBeCaptured(species, SlotsY, StaticY) || GetCanBeCaptured(species, SlotsA, StaticA) || GetCanBeCaptured(species, SlotsO, StaticO), @@ -181,7 +181,7 @@ private static bool GetCanKnowMove(PKM pk, int move, int generation, EvolutionHi GameVersion.OR => GetCanBeCaptured(species, SlotsO, StaticO), _ => false, }, - 8 => version switch + EntityContext.Gen8 => version switch { GameVersion.Any => GetCanBeCaptured(species, SlotsSW.Concat(SlotsSH), StaticSW.Concat(StaticSH)), GameVersion.SW => GetCanBeCaptured(species, SlotsSW, StaticSW), @@ -249,9 +249,9 @@ public static bool GetCanDynamaxTrainer(int species, int gen, GameVersion versio (int)Urshifu, }; - public static bool GetCanFishSpecies(int species, int gen, GameVersion version) => gen switch + public static bool GetCanFishSpecies(int species, EntityContext context, GameVersion version) => context switch { - 6 => version switch + EntityContext.Gen6 => version switch { GameVersion.Any => FishingSpecies_XY.Contains(species) || FishingSpecies_AO.Contains(species) || IsFishingSpeciesX(species) || IsFishingSpeciesY(species), @@ -262,7 +262,7 @@ public static bool GetCanDynamaxTrainer(int species, int gen, GameVersion versio GameVersion.OR or GameVersion.AS => FishingSpecies_AO.Contains(species), _ => false, }, - 8 => version switch + EntityContext.Gen8 => version switch { GameVersion.Any or GameVersion.SW or GameVersion.SH => FishingSpecies_SWSH.Contains(species), _ => false, diff --git a/PKHeX.Core/Legality/Tables/Tables.cs b/PKHeX.Core/Legality/Tables/Tables.cs index af4ce49a5..2d4e37dbd 100644 --- a/PKHeX.Core/Legality/Tables/Tables.cs +++ b/PKHeX.Core/Legality/Tables/Tables.cs @@ -21,30 +21,6 @@ public static partial class Legal (int)Meltan, (int)Melmetal, }; - /// - /// Checks if Sketch can obtain the in the requested - /// - /// Doesn't bounds check the for max move ID. - /// Move ID - /// Generation to check - /// True if can be sketched, false if not available. - public static bool IsValidSketch(int move, int generation) - { - if (MoveInfo.InvalidSketch.Contains(move)) - return false; - if (generation is 6 && move is ((int)ThousandArrows or (int)ThousandWaves)) - return false; - if (generation is 8) // can't Sketch unusable moves in BDSP, no Sketch in PLA - { - if (DummiedMoves_BDSP.Contains(move)) - return false; - if (move > MaxMoveID_8) - return false; - } - - return move <= GetMaxMoveID(generation); - } - /// /// Species that are from Mythical Distributions (disallowed species for competitive rulesets) /// diff --git a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs index 73ddda601..527634710 100644 --- a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs @@ -2,6 +2,7 @@ using System.Linq; using static PKHeX.Core.LegalityCheckStrings; using static PKHeX.Core.MemoryPermissions; +using static PKHeX.Core.EntityContext; namespace PKHeX.Core; @@ -32,7 +33,7 @@ private static bool ShouldHaveNoMemory(LegalityAnalysis data, PKM pk) return false; } - private CheckResult VerifyCommonMemory(PKM pk, int handler, int gen, LegalInfo info, MemoryContext context) + private CheckResult VerifyCommonMemory(PKM pk, int handler, EntityContext context, LegalInfo info, MemoryContext mem) { var memory = MemoryVariableSet.Read((ITrainerMemories)pk, handler); @@ -40,7 +41,7 @@ private CheckResult VerifyCommonMemory(PKM pk, int handler, int gen, LegalInfo i int hmIndex = Array.IndexOf(MemoryContext6.MoveSpecificMemoryHM, memory.MemoryID); if (hmIndex != -1) { - if (gen != 6) // Gen8 has no HMs, so this memory can never exist. + if (context != Gen6) // Gen8 has no HMs, so this memory can never exist. return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)); if (pk.Species != (int)Species.Smeargle) @@ -54,10 +55,10 @@ private CheckResult VerifyCommonMemory(PKM pk, int handler, int gen, LegalInfo i } } - if (context.IsInvalidGeneralLocationMemoryValue(memory.MemoryID, memory.Variable, info.EncounterMatch, pk)) + if (mem.IsInvalidGeneralLocationMemoryValue(memory.MemoryID, memory.Variable, info.EncounterMatch, pk)) return GetInvalid(string.Format(LMemoryArgBadLocation, memory.Handler)); - if (context.IsInvalidMiscMemory(memory.MemoryID, memory.Variable)) + if (mem.IsInvalidMiscMemory(memory.MemoryID, memory.Variable)) return GetInvalid(string.Format(LMemoryArgBadID, memory.Handler)); switch (memory.MemoryID) @@ -67,15 +68,15 @@ private CheckResult VerifyCommonMemory(PKM pk, int handler, int gen, LegalInfo i return GetInvalid(string.Format(LMemoryArgBadLocation, memory.Handler)); // {0} saw {2} carrying {1} on its back. {4} that {3}. - case 21 when gen != 6 || !PersonalTable.AO.GetFormEntry(memory.Variable, 0).TMHM[101]: // Fly + case 21 when context != Gen6 || !PersonalTable.AO.GetFormEntry(memory.Variable, 0).TMHM[101]: // Fly return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)); // {0} used {2} at {1}’s instruction, but it had no effect. {4} that {3}. // The Move Deleter that {0} met through {1} made it forget {2}. {4} that {3}. - case 16 or 48 when !CanKnowMove(pk, memory, gen, info, memory.MemoryID == 16): + case 16 or 48 when !CanKnowMove(pk, memory, context, info, memory.MemoryID == 16): return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)); - case 49 when memory.Variable == 0 || !GetCanRelearnMove(pk, memory.Variable, gen, info.EvoChainsAllGens, info.EncounterOriginal): + case 49 when memory.Variable == 0 || !GetCanRelearnMove(pk, memory.Variable, context, info.EvoChainsAllGens, info.EncounterOriginal): return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler)); // Dynamaxing @@ -88,18 +89,18 @@ private CheckResult VerifyCommonMemory(PKM pk, int handler, int gen, LegalInfo i // Move // {0} studied about how to use {2} in a Box, thinking about {1}. {4} that {3}. // {0} practiced its cool pose for the move {2} in a Box, wishing to be praised by {1}. {4} that {3}. - case 80 or 81 when !CanKnowMove(pk, memory, gen, info): + case 80 or 81 when !CanKnowMove(pk, memory, context, info): return Get(string.Format(LMemoryArgBadMove, memory.Handler), Severity.Invalid); // Species // With {1}, {0} went fishing, and they caught {2}. {4} that {3}. - case 7 when !GetCanFishSpecies(memory.Variable, gen, handler == 0 ? (GameVersion)pk.Version : GameVersion.Any): + case 7 when !GetCanFishSpecies(memory.Variable, context, handler == 0 ? (GameVersion)pk.Version : GameVersion.Any): return GetInvalid(string.Format(LMemoryArgBadSpecies, memory.Handler)); // {0} saw {1} paying attention to {2}. {4} that {3}. // {0} fought hard until it had to use Struggle when it battled at {1}’s side against {2}. {4} that {3}. // {0} was taken to a Pokémon Nursery by {1} and left with {2}. {4} that {3}. - case 9 or 60 or 75 when gen == 8 && !PersonalTable.SWSH.IsSpeciesInGame(memory.Variable): + case 9 or 60 or 75 when context == Gen8 && !PersonalTable.SWSH.IsSpeciesInGame(memory.Variable): return GetInvalid(string.Format(LMemoryArgBadSpecies, memory.Handler)); // {0} had a great chat about {1} with the {2} that it was in a Box with. {4} that {3}. @@ -109,29 +110,29 @@ private CheckResult VerifyCommonMemory(PKM pk, int handler, int gen, LegalInfo i return GetInvalid(string.Format(LMemoryArgBadSpecies, memory.Handler)); // {0} had a very hard training session with {1}. {4} that {3}. - case 53 when gen == 8 && pk is IHyperTrain t && !t.IsHyperTrained(): + case 53 when context == Gen8 && pk is IHyperTrain t && !t.IsHyperTrained(): return GetInvalid(string.Format(LMemoryArgBadID, memory.Handler)); // Item // {0} went to a Pokémon Center with {1} to buy {2}. {4} that {3}. - case 5 when !CanBuyItem(gen, memory.Variable, handler == 0 ? (GameVersion)pk.Version : GameVersion.Any): + case 5 when !CanBuyItem(context, memory.Variable, handler == 0 ? (GameVersion)pk.Version : GameVersion.Any): // {1} used {2} when {0} was in trouble. {4} that {3}. - case 15 when !CanUseItem(gen, memory.Variable, pk.Species): + case 15 when !CanUseItem(context, memory.Variable, pk.Species): // {0} saw {1} using {2}. {4} that {3}. - case 26 when !CanUseItemGeneric(gen, memory.Variable): + case 26 when !CanUseItemGeneric(context, memory.Variable): // {0} planted {2} with {1} and imagined a big harvest. {4} that {3}. - case 34 when !CanPlantBerry(gen, memory.Variable): + case 34 when !CanPlantBerry(context, memory.Variable): // {1} had {0} hold items like {2} to help it along. {4} that {3}. - case 40 when !CanHoldItem(gen, memory.Variable): + case 40 when !CanHoldItem(context, memory.Variable): // {0} was excited when {1} won prizes like {2} through Loto-ID. {4} that {3}. - case 51 when !CanWinLotoID(gen, memory.Variable): + case 51 when !CanWinLotoID(context, memory.Variable): // {0} was worried if {1} was looking for the {2} that it was holding in a Box. {4} that {3}. // When {0} was in a Box, it thought about the reason why {1} had it hold the {2}. {4} that {3}. case 84 or 88 when !Legal.HeldItems_SWSH.Contains(memory.Variable) || pk.IsEgg: return GetInvalid(string.Format(LMemoryArgBadItem, memory.Handler)); } - return VerifyCommonMemoryEtc(memory, context); + return VerifyCommonMemoryEtc(memory, mem); } private CheckResult VerifyCommonMemoryEtc(MemoryVariableSet memory, MemoryContext context) @@ -199,28 +200,28 @@ private void VerifyOTMemory(LegalityAnalysis data) return; } - int memoryGen = Info.Generation; + var context = Info.EncounterOriginal.Context; var memory = mem.OT_Memory; if (pk.IsEgg) { // Traded unhatched eggs in Gen8 have OT link trade memory applied erroneously. // They can also have the box-inspect memory! - if (memoryGen != 8 || !((pk.Met_Location == Locations.LinkTrade6 && memory == 4) || memory == 85)) + if (context != Gen8 || !((pk.Met_Location == Locations.LinkTrade6 && memory == 4) || memory == 85)) { VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty return; } } - else if (!CanHaveMemoryForOT(pk, memoryGen, memory, Info.EvoChainsAllGens)) + else if (!CanHaveMemoryForOT(pk, context, memory)) { VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty return; } // Bounds checking - var context = Memories.GetContext(memoryGen); - if (!context.CanObtainMemoryOT((GameVersion)pk.Version, memory)) + var mc = Memories.GetContext(context); + if (!mc.CanObtainMemoryOT((GameVersion)pk.Version, memory)) data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XOT))); // Verify memory if specific to OT @@ -228,7 +229,7 @@ private void VerifyOTMemory(LegalityAnalysis data) { // No Memory case 0: // SWSH trades don't set HT memories immediately, which is hilarious. - data.AddLine(Get(LMemoryMissingOT, memoryGen == 8 ? Severity.Fishy : Severity.Invalid)); + data.AddLine(Get(LMemoryMissingOT, context == Gen8 ? Severity.Fishy : Severity.Invalid)); VerifyOTMemoryIs(data, 0, 0, 0, 0); return; @@ -243,42 +244,39 @@ private void VerifyOTMemory(LegalityAnalysis data) return; // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}. - case 6 when !context.HasPokeCenter((GameVersion)pk.Version, mem.OT_TextVar): + case 6 when !mc.HasPokeCenter((GameVersion)pk.Version, mem.OT_TextVar): data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XOT))); return; // {0} was with {1} when {1} caught {2}. {4} that {3}. case 14: - var result = GetCanBeCaptured(mem.OT_TextVar, Info.Generation, (GameVersion)pk.Version) // Any Game in the Handling Trainer's generation + var result = GetCanBeCaptured(mem.OT_TextVar, context, (GameVersion)pk.Version) // Any Game in the Handling Trainer's generation ? GetValid(string.Format(LMemoryArgSpecies, L_XOT)) : GetInvalid(string.Format(LMemoryArgBadSpecies, L_XOT)); data.AddLine(result); return; } - data.AddLine(VerifyCommonMemory(pk, 0, Info.Generation, Info, context)); + data.AddLine(VerifyCommonMemory(pk, 0, context, Info, mc)); } - private static bool CanHaveMemoryForOT(PKM pk, int origin, int memory, EvolutionHistory evos) + private static bool CanHaveMemoryForOT(PKM pk, EntityContext origin, int memory) { - switch (origin) + // Eggs cannot have memories + if (pk.IsEgg) { - // Bank Memories only: Gen7 does not set memories. - case 1 or 2 or 7 when memory != 4: // VC transfers - - // Memories don't exist - case 7 when pk.GG: // LGPE does not set memories. - case 8 when pk.GO_HOME: // HOME does not set memories. - case 8 when pk.Met_Location == Locations.HOME8: // HOME does not set memories. - case 8 when pk.BDSP && !evos.HasVisitedSWSH: // BDSP does not set memories. - case 8 when pk.LA && !evos.HasVisitedSWSH: // LA does not set memories. - return false; - - // Eggs cannot have memories - // Cannot have memories if the OT was from a generation prior to Gen6. - default: - return origin >= 6 && !pk.IsEgg; + if (origin == Gen8) // Gen8 sets for traded eggs. + return pk.IsTradedEgg; + return false; } + + return origin switch + { + Gen1 or Gen2 or Gen7 => memory == 4, // VC transfers can only have Bank memory. + Gen6 => true, + Gen8 => !(pk.GO_HOME || pk.Met_Location == Locations.HOME8), // HOME does not set memories. + _ => false, + }; } private void VerifyHTMemory(LegalityAnalysis data) @@ -309,7 +307,7 @@ private void VerifyHTMemory(LegalityAnalysis data) return; } - var memoryGen = pk.Format >= 8 ? 8 : 6; + var memoryGen = pk.Format >= 8 ? Gen8 : Gen6; // Bounds checking var context = Memories.GetContext(memoryGen); @@ -321,7 +319,7 @@ private void VerifyHTMemory(LegalityAnalysis data) { // No Memory case 0: // SWSH memory application has an off-by-one error: [0,99] + 1 <= chance --> don't apply - data.AddLine(Get(LMemoryMissingHT, memoryGen == 8 ? ParseSettings.Gen8MemoryMissingHT : Severity.Invalid)); + data.AddLine(Get(LMemoryMissingHT, memoryGen == Gen8 ? ParseSettings.Gen8MemoryMissingHT : Severity.Invalid)); VerifyHTMemoryNone(data, mem); return; diff --git a/PKHeX.Core/Moves/MoveInfo.cs b/PKHeX.Core/Moves/MoveInfo.cs index 96b7a9cf4..b0b3a3374 100644 --- a/PKHeX.Core/Moves/MoveInfo.cs +++ b/PKHeX.Core/Moves/MoveInfo.cs @@ -1,10 +1,13 @@ -using System; +using System; using System.Collections.Generic; using static PKHeX.Core.Move; using static PKHeX.Core.EntityContext; namespace PKHeX.Core; +/// +/// Overall information about Moves +/// public static class MoveInfo { /// @@ -13,7 +16,7 @@ public static class MoveInfo /// Game context /// Move ID /// Amount of PP the move has by default (no PP Ups). - public static byte GetPP(EntityContext context, int move) + public static byte GetPP(EntityContext context, ushort move) { var table = GetPPTable(context); if ((uint)move >= table.Length) @@ -21,8 +24,9 @@ public static byte GetPP(EntityContext context, int move) return table[move]; } - public static ReadOnlySpan GetPPTable(PKM pk) => GetPPTable(pk.Context); - + /// + /// Gets the move PP table for the . + /// public static ReadOnlySpan GetPPTable(EntityContext context) => context switch { Gen1 => MoveInfo1.MovePP_RBY, @@ -40,96 +44,67 @@ public static byte GetPP(EntityContext context, int move) _ => throw new ArgumentOutOfRangeException(nameof(context)), }; - public static ICollection GetDummiedMovesHashSet(EntityContext context) => context switch + /// + /// Gets a collection that can be used to check if a move cannot be used in battle. + /// + public static ICollection GetDummiedMovesHashSet(EntityContext context) => context switch { Gen8 => MoveInfo8.DummiedMoves_SWSH, Gen8a => MoveInfo8a.DummiedMoves_LA, Gen8b => MoveInfo8b.DummiedMoves_BDSP, - _ => Array.Empty(), + _ => Array.Empty(), }; /// - /// Generation 7 Z Moves + /// Checks if the move is a Z-move. /// - public static readonly HashSet Z_Moves = new() + public static bool IsMoveZ(ushort move) => move switch { - (int)BreakneckBlitzP, - (int)BreakneckBlitzS, - (int)AllOutPummelingP, - (int)AllOutPummelingS, - (int)SupersonicSkystrikeP, - (int)SupersonicSkystrikeS, - (int)AcidDownpourP, - (int)AcidDownpourS, - (int)TectonicRageP, - (int)TectonicRageS, - (int)ContinentalCrushP, - (int)ContinentalCrushS, - (int)SavageSpinOutP, - (int)SavageSpinOutS, - (int)NeverEndingNightmareP, - (int)NeverEndingNightmareS, - (int)CorkscrewCrashP, - (int)CorkscrewCrashS, - (int)InfernoOverdriveP, - (int)InfernoOverdriveS, - (int)HydroVortexP, - (int)HydroVortexS, - (int)BloomDoomP, - (int)BloomDoomS, - (int)GigavoltHavocP, - (int)GigavoltHavocS, - (int)ShatteredPsycheP, - (int)ShatteredPsycheS, - (int)SubzeroSlammerP, - (int)SubzeroSlammerS, - (int)DevastatingDrakeP, - (int)DevastatingDrakeS, - (int)BlackHoleEclipseP, - (int)BlackHoleEclipseS, - (int)TwinkleTackleP, - (int)TwinkleTackleS, - - (int)Catastropika, - (int)SinisterArrowRaid, - (int)MaliciousMoonsault, - (int)OceanicOperetta, - (int)GuardianofAlola, - (int)SoulStealing7StarStrike, - (int)StokedSparksurfer, - (int)PulverizingPancake, - (int)ExtremeEvoboost, - (int)GenesisSupernova, - (int)TenMVoltThunderbolt, - (int)LightThatBurnstheSky, - (int)SearingSunrazeSmash, - (int)MenacingMoonrazeMaelstrom, - (int)LetsSnuggleForever, - (int)SplinteredStormshards, - (int)ClangorousSoulblaze, + >= (int)BreakneckBlitzP and <= (int)Catastropika => true, // [622-658] + >= (int)SinisterArrowRaid and <= (int)GenesisSupernova => true, // [695-703] + (int)TenMVoltThunderbolt => true, // [719] + >= (int)LightThatBurnstheSky and <= (int)ClangorousSoulblaze => true, // [723-728] + _ => false, }; - public static bool IsDynamaxMove(int move) => move is (>= (int)MaxFlare and <= (int)MaxSteelspike); + /// + /// Checks if the move is a Dynamax-only move. + /// + public static bool IsMoveDynamax(ushort move) => move is (>= (int)MaxFlare and <= (int)MaxSteelspike); /// - /// Moves that can not be obtained by using Sketch with Smeargle in any game. + /// Checks if the move can be known by anything in any context. /// - internal static readonly HashSet InvalidSketch = new(Z_Moves) + /// Assumes the move ID is within [0,max]. + public static bool IsMoveKnowable(ushort move) => !IsMoveZ(move) && !IsMoveDynamax(move); + + /// + /// Checks if the move can be sketched in any game. + /// + public static bool IsMoveSketch(ushort move) => move switch { // Can't Sketch - (int)Struggle, - (int)Chatter, + (int)Struggle => false, + (int)Chatter => false, // Unreleased - (int)LightofRuin, + (int)LightofRuin => false, + + _ => IsMoveKnowable(move), }; + /// + /// Checks if the is unable to be used in battle. + /// public static bool IsDummiedMove(PKM pk, ushort move) { var hashSet = GetDummiedMovesHashSet(pk.Context); return hashSet.Contains(move); } + /// + /// Checks if any Move in the currently known moves is an unusable move (yellow triangle). + /// public static bool IsDummiedMoveAny(PKM pk) { var hs = GetDummiedMovesHashSet(pk.Context); @@ -144,4 +119,43 @@ public static bool IsDummiedMoveAny(PKM pk) } return false; } + + /// + /// Checks if Sketch can obtain the in the requested + /// + /// Move ID + /// Generation to check + /// True if can be sketched, false if not available. + public static bool IsValidSketch(ushort move, EntityContext context) + { + if (!IsMoveSketch(move)) + return false; + if (context is Gen6 && move is ((int)ThousandArrows or (int)ThousandWaves)) + return false; + if (context is Gen8b) // can't Sketch unusable moves in BDSP, no Sketch in PLA + { + if (MoveInfo8b.DummiedMoves_BDSP.Contains(move)) + return false; + if (move > Legal.MaxMoveID_8) + return false; + } + + return move <= GetMaxMoveID(context); + } + + private static int GetMaxMoveID(EntityContext context) => context switch + { + Gen1 => Legal.MaxMoveID_1, + Gen2 => Legal.MaxMoveID_2, + Gen3 => Legal.MaxMoveID_3, + Gen4 => Legal.MaxMoveID_4, + Gen5 => Legal.MaxMoveID_5, + Gen6 => Legal.MaxMoveID_6_AO, + Gen7 => Legal.MaxMoveID_7_USUM, + Gen7b => Legal.MaxMoveID_7b, + Gen8 => Legal.MaxMoveID_8a, + Gen8a => Legal.MaxMoveID_8a, + Gen8b => Legal.MaxMoveID_8b, + _ => -1, + }; } diff --git a/PKHeX.Core/Moves/MoveInfo1.cs b/PKHeX.Core/Moves/MoveInfo1.cs index 08bb67e60..f4cc09735 100644 --- a/PKHeX.Core/Moves/MoveInfo1.cs +++ b/PKHeX.Core/Moves/MoveInfo1.cs @@ -1,8 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public static class MoveInfo1 +/// +/// Details about moves in +/// +internal static class MoveInfo1 { - internal static readonly byte[] MovePP_RBY = + public static readonly byte[] MovePP_RBY = { 0, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo2.cs b/PKHeX.Core/Moves/MoveInfo2.cs index f66fbc3ad..7e36cd841 100644 --- a/PKHeX.Core/Moves/MoveInfo2.cs +++ b/PKHeX.Core/Moves/MoveInfo2.cs @@ -1,8 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public static class MoveInfo2 +/// +/// Details about moves in +/// +internal static class MoveInfo2 { - internal static readonly byte[] MovePP_GSC = + public static readonly byte[] MovePP_GSC = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo3.cs b/PKHeX.Core/Moves/MoveInfo3.cs index c0468c7bd..4e9dbbd00 100644 --- a/PKHeX.Core/Moves/MoveInfo3.cs +++ b/PKHeX.Core/Moves/MoveInfo3.cs @@ -1,8 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public static class MoveInfo3 +/// +/// Details about moves in +/// +internal static class MoveInfo3 { - internal static readonly byte[] MovePP_RS = + public static readonly byte[] MovePP_RS = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo4.cs b/PKHeX.Core/Moves/MoveInfo4.cs index 5472c10fb..c719745b3 100644 --- a/PKHeX.Core/Moves/MoveInfo4.cs +++ b/PKHeX.Core/Moves/MoveInfo4.cs @@ -1,8 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public static class MoveInfo4 +/// +/// Details about moves in +/// +internal static class MoveInfo4 { - internal static readonly byte[] MovePP_DP = + public static readonly byte[] MovePP_DP = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 15, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo5.cs b/PKHeX.Core/Moves/MoveInfo5.cs index 8d7f18bfe..3a139f996 100644 --- a/PKHeX.Core/Moves/MoveInfo5.cs +++ b/PKHeX.Core/Moves/MoveInfo5.cs @@ -1,8 +1,11 @@ namespace PKHeX.Core; -public static class MoveInfo5 +/// +/// Details about moves in +/// +internal static class MoveInfo5 { - internal static readonly byte[] MovePP_BW = + public static readonly byte[] MovePP_BW = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 15, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo6.cs b/PKHeX.Core/Moves/MoveInfo6.cs index 14905d2c4..4cf31c852 100644 --- a/PKHeX.Core/Moves/MoveInfo6.cs +++ b/PKHeX.Core/Moves/MoveInfo6.cs @@ -1,8 +1,11 @@ namespace PKHeX.Core; -public static class MoveInfo6 +/// +/// Details about moves in +/// +internal static class MoveInfo6 { - internal static readonly byte[] MovePP = + public static readonly byte[] MovePP = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo7.cs b/PKHeX.Core/Moves/MoveInfo7.cs index 8754b32fc..f024e0db7 100644 --- a/PKHeX.Core/Moves/MoveInfo7.cs +++ b/PKHeX.Core/Moves/MoveInfo7.cs @@ -1,8 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public static class MoveInfo7 +/// +/// Details about moves in +/// +internal static class MoveInfo7 { - internal static readonly byte[] MovePP_SM = + public static readonly byte[] MovePP_SM = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, diff --git a/PKHeX.Core/Moves/MoveInfo7b.cs b/PKHeX.Core/Moves/MoveInfo7b.cs index 8f0de827a..464d86ee8 100644 --- a/PKHeX.Core/Moves/MoveInfo7b.cs +++ b/PKHeX.Core/Moves/MoveInfo7b.cs @@ -1,8 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public static class MoveInfo7b +/// +/// Details about moves in +/// +internal static class MoveInfo7b { - internal static readonly byte[] MovePP_GG = + public static readonly byte[] MovePP_GG = { // Absorb: 25 -> 15 (damage buffed from 20->40) // Mega Drain: 15 -> 10 (damage buffed from 40->75) diff --git a/PKHeX.Core/Moves/MoveInfo8.cs b/PKHeX.Core/Moves/MoveInfo8.cs index 77f2fa013..75ebe938e 100644 --- a/PKHeX.Core/Moves/MoveInfo8.cs +++ b/PKHeX.Core/Moves/MoveInfo8.cs @@ -1,10 +1,13 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; -public static class MoveInfo8 +/// +/// Details about moves in +/// +internal static class MoveInfo8 { - internal static readonly byte[] MovePP_SWSH = + public static readonly byte[] MovePP_SWSH = { 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, @@ -29,7 +32,7 @@ public static class MoveInfo8 /// /// Moves that are kill /// - public static readonly HashSet DummiedMoves_SWSH = new() + public static readonly HashSet DummiedMoves_SWSH = new() { 002, 003, 004, 013, 026, 027, 041, 049, 082, 096, 099, 112, 117, 119, 121, 125, 128, 131, 132, 134, diff --git a/PKHeX.Core/Moves/MoveInfo8a.cs b/PKHeX.Core/Moves/MoveInfo8a.cs index 9c2c25748..8ae570161 100644 --- a/PKHeX.Core/Moves/MoveInfo8a.cs +++ b/PKHeX.Core/Moves/MoveInfo8a.cs @@ -1,10 +1,13 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; -public static class MoveInfo8a +/// +/// Details about moves in +/// +internal static class MoveInfo8a { - internal static readonly byte[] MovePP_LA = + public static readonly byte[] MovePP_LA = { 00, 35, 25, 10, 15, 20, 20, 10, 10, 10, 35, 30, 05, 10, 20, 30, 25, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 30, 15, 20, 20, 10, 05, 30, 20, 20, 20, 30, 20, 40, 20, 15, 20, 20, 20, @@ -29,7 +32,7 @@ public static class MoveInfo8a /// /// Moves that are kill /// - public static readonly HashSet DummiedMoves_LA = new() + public static readonly HashSet DummiedMoves_LA = new() { 001, 002, 003, 004, 005, 006, 010, 011, 012, 013, 015, 017, 018, 019, 020, 021, 022, 023, 024, 025, diff --git a/PKHeX.Core/Moves/MoveInfo8b.cs b/PKHeX.Core/Moves/MoveInfo8b.cs index 4ccdca7ab..1d18b5e9c 100644 --- a/PKHeX.Core/Moves/MoveInfo8b.cs +++ b/PKHeX.Core/Moves/MoveInfo8b.cs @@ -1,13 +1,16 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; -public static class MoveInfo8b +/// +/// Details about moves in +/// +internal static class MoveInfo8b { /// /// Moves that are kill /// - public static readonly HashSet DummiedMoves_BDSP = new() + public static readonly HashSet DummiedMoves_BDSP = new() { 002, 003, 004, 013, 026, 027, 041, 049, 082, 096, 099, 112, 117, 119, 121, 125, 128, 131, 132, 140, diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs index 93168c34f..5350a2f4d 100644 --- a/PKHeX.Core/MysteryGifts/WC7.cs +++ b/PKHeX.Core/MysteryGifts/WC7.cs @@ -525,9 +525,9 @@ private void SetIVs(PKM pk) { Span finalIVs = stackalloc int[6]; GetIVs(finalIVs); - var ivflag = finalIVs.Find(iv => (byte)(iv - 0xFC) < 3); + var ivflag = finalIVs.Find(static iv => (byte)(iv - 0xFC) < 3); var rng = Util.Rand; - if (ivflag == 0) // Random IVs + if (ivflag == default) // Random IVs { for (int i = 0; i < finalIVs.Length; i++) { diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 0f3e900b0..830232363 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -850,7 +850,7 @@ protected void SetLinkTradeEgg(int day, int month, int y, int location) /// /// Move ID /// Amount of PP the move has by default (no PP Ups). - private int GetBasePP(int move) => MoveInfo.GetPP(Context, move); + private int GetBasePP(int move) => MoveInfo.GetPP(Context, (ushort)move); /// /// Applies a shiny to the . diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 0bc4d9b34..3c220f2a9 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -360,7 +360,7 @@ public void UpdateLegality(LegalityAnalysis? la = null, bool skipMoveRepop = fal { if (isIllegal) return Resources.warn; - if (pk.Format >= 8 && MoveInfo.GetDummiedMovesHashSet(pk.Context).Contains(pk.GetMove(index))) + if (pk.Format >= 8 && MoveInfo.GetDummiedMovesHashSet(pk.Context).Contains((ushort)pk.GetMove(index))) return Resources.hint; return null; }