From 94b47d61da4629f9d048f3fbe7956f698ddea7e9 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 27 Mar 2025 18:43:37 -0500 Subject: [PATCH] Add smeargle verifier branch Add gen2 nosketch moves while we're here, and Stadium2's extra quirk one. --- .../Legality/LearnSource/Group/LearnGroup2.cs | 3 +++ .../Legality/LearnSource/LearnEnvironment.cs | 4 ++-- PKHeX.Core/Legality/Learnset/LearnsetStadium.cs | 17 +++++++++++++++-- PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 14 +++++++++++--- PKHeX.Core/Moves/MoveInfo.cs | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs index 55095c603..4a5f720a9 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup2.cs @@ -44,6 +44,9 @@ public sealed class LearnGroup2 : ILearnGroup // Uh-oh, not all moves are verified yet. // To visit Gen1, we need to invalidate moves that can't be learned in Gen1 or re-learned in Gen2. + if (GetPrevious(pk, history, enc, option) is null) + return true; // can't even visit, don't bother purging. + for (int i = 0; i < result.Length; i++) { if (current[i] <= Legal.MaxMoveID_1) diff --git a/PKHeX.Core/Legality/LearnSource/LearnEnvironment.cs b/PKHeX.Core/Legality/LearnSource/LearnEnvironment.cs index b4406627a..ca18a8a3b 100644 --- a/PKHeX.Core/Legality/LearnSource/LearnEnvironment.cs +++ b/PKHeX.Core/Legality/LearnSource/LearnEnvironment.cs @@ -31,7 +31,7 @@ public static class LearnEnvironmentExtensions public static byte GetGeneration(this LearnEnvironment value) => value switch { RB or YW => 1, - GS or C => 2, + GS or C or Stadium2 => 2, RS or E or FR or LG => 3, DP or Pt or HGSS => 4, BW or B2W2 => 5, @@ -45,7 +45,7 @@ public static class LearnEnvironmentExtensions public static ReadOnlySpan GetEvolutions(this LearnEnvironment value, EvolutionHistory history) => value switch { RB or YW => history.Gen1, - GS or C => history.Gen2, + GS or C or Stadium2 => history.Gen2, RS or E or FR or LG => history.Gen3, DP or Pt or HGSS => history.Gen4, BW or B2W2 => history.Gen5, diff --git a/PKHeX.Core/Legality/Learnset/LearnsetStadium.cs b/PKHeX.Core/Legality/Learnset/LearnsetStadium.cs index 724a984d5..026b8b3b0 100644 --- a/PKHeX.Core/Legality/Learnset/LearnsetStadium.cs +++ b/PKHeX.Core/Legality/Learnset/LearnsetStadium.cs @@ -84,8 +84,8 @@ public bool Validate(ReadOnlySpan moves, byte level, Span flag) { bool anyInvalid = false; - // todo: is stadium smart to disallow egg moves+event, or multiple event moves (pikachu)? - // Naive checker only checking individual moves in isolation. + // Stadium2 is not smart enough to disallow egg moves+event, or multiple event moves (Pikachu). + // Naive checker only checks if all individual moves are in its list with sufficient level. for (int i = 0; i < moves.Length; i++) { var move = moves[i]; @@ -100,6 +100,19 @@ public bool Validate(ReadOnlySpan moves, byte level, Span flag) return !anyInvalid; } + public static bool ValidateSmeargle(ReadOnlySpan moves, Span flag) + { + bool anyInvalid = false; + for (int i = 0; i < moves.Length; i++) + anyInvalid |= flag[i] = !IsSketchValid(moves[i]); + return !anyInvalid; + } + + /// + /// All others are covered by Mainline possibility. Baton Pass is the only error. + /// + public static bool IsSketchValid(ushort move) => move is not (ushort)Move.BatonPass; + /// /// Converts a into an array of . /// diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index 7e4e906ba..7fe9570da 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -176,9 +176,17 @@ private void VerifyIsMovesetAllowed(LegalityAnalysis data, SK2 sk2) sk2.GetMoves(moves); Span flags = stackalloc bool[4]; - var learn = LearnSource2Stadium.Instance.GetLearnsetStadium(sk2.Species, sk2.Form); - if (learn.Validate(moves, sk2.CurrentLevel, flags)) - return; + if (sk2.Species is (ushort)Species.Smeargle) + { + if (LearnsetStadium.ValidateSmeargle(moves, flags)) + return; + } + else + { + var learn = LearnSource2Stadium.Instance.GetLearnsetStadium(sk2.Species, sk2.Form); + if (learn.Validate(moves, sk2.CurrentLevel, flags)) + return; + } var parse = data.Info.Moves; for (int i = 0; i < flags.Length; i++) diff --git a/PKHeX.Core/Moves/MoveInfo.cs b/PKHeX.Core/Moves/MoveInfo.cs index d1f8dbdc7..c2a9153b1 100644 --- a/PKHeX.Core/Moves/MoveInfo.cs +++ b/PKHeX.Core/Moves/MoveInfo.cs @@ -183,6 +183,7 @@ public static bool IsSketchValid(ushort move, EntityContext context) /// Context currently present in private static bool IsSketchPossible(ushort move, EntityContext context) => context switch { + Gen2 when move is (int)SelfDestruct or (int)Explosion or (ushort)Mimic or (ushort)Metronome or (ushort)MirrorMove or (ushort)Transform or (ushort)SleepTalk => false, Gen6 when move is (int)ThousandArrows or (int)ThousandWaves or (int)LightofRuin => false, Gen7 when move is (int)LightofRuin => false, Gen8b when IsDummiedMove(MoveInfo8b.DummiedMoves, move) => false,