mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 02:19:12 -05:00
Add smeargle verifier branch
Add gen2 nosketch moves while we're here, and Stadium2's extra quirk one.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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<EvoCriteria> 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,
|
||||
|
||||
@@ -84,8 +84,8 @@ public bool Validate(ReadOnlySpan<ushort> moves, byte level, Span<bool> 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<ushort> moves, byte level, Span<bool> flag)
|
||||
return !anyInvalid;
|
||||
}
|
||||
|
||||
public static bool ValidateSmeargle(ReadOnlySpan<ushort> moves, Span<bool> flag)
|
||||
{
|
||||
bool anyInvalid = false;
|
||||
for (int i = 0; i < moves.Length; i++)
|
||||
anyInvalid |= flag[i] = !IsSketchValid(moves[i]);
|
||||
return !anyInvalid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All others are covered by Mainline possibility. Baton Pass is the only error.
|
||||
/// </summary>
|
||||
public static bool IsSketchValid(ushort move) => move is not (ushort)Move.BatonPass;
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="BinLinkerAccessor"/> into an array of <see cref="LearnsetStadium"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -176,9 +176,17 @@ private void VerifyIsMovesetAllowed(LegalityAnalysis data, SK2 sk2)
|
||||
sk2.GetMoves(moves);
|
||||
Span<bool> 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++)
|
||||
|
||||
@@ -183,6 +183,7 @@ public static bool IsSketchValid(ushort move, EntityContext context)
|
||||
/// <param name="context">Context currently present in</param>
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user