mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-20 10:55:13 -05:00
Extract sketch valid check
GetCanKnowMove should be checking for Smeargle knowing thousand arrows/waves. GetNeededMoves should also return 1ka/1kw for needed moves, and then no encounters. All uses of InvalidSketch are behind that method, so any future Smeargle modifications (like sketching a dummied move) will be checked (yay BDSP considerations).
This commit is contained in:
@@ -150,7 +150,7 @@ public static IEnumerable<IEncounterable> GenerateVersionEncounters(PKM pk, IEnu
|
||||
private static int[] GetNeededMoves(PKM pk, IEnumerable<int> moves, IReadOnlyList<EvoCriteria> chain)
|
||||
{
|
||||
if (pk.Species == (int)Species.Smeargle)
|
||||
return moves.Intersect(Legal.InvalidSketch).ToArray(); // Can learn anything
|
||||
return moves.Where(z => !Legal.IsValidSketch(z, pk.Format)).ToArray(); // Can learn anything
|
||||
|
||||
// Roughly determine the generation the PKM is originating from
|
||||
var ver = pk.Version;
|
||||
|
||||
@@ -136,9 +136,9 @@ private static CheckMoveResult[] ParseMovesSketch(PKM pkm, IReadOnlyList<int> cu
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
var move = currentMoves[i];
|
||||
res[i] = Legal.InvalidSketch.Contains(move) || (pkm.Format is 6 && move is (int)Move.ThousandArrows or (int)Move.ThousandWaves)
|
||||
? new CheckMoveResult(Unknown, pkm.Format, Invalid, LMoveSourceInvalidSketch, CurrentMove)
|
||||
: new CheckMoveResult(Sketch, pkm.Format, CurrentMove);
|
||||
res[i] = Legal.IsValidSketch(move, pkm.Format)
|
||||
? new CheckMoveResult(Sketch, pkm.Format, CurrentMove)
|
||||
: new CheckMoveResult(Unknown, pkm.Format, Invalid, LMoveSourceInvalidSketch, CurrentMove);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -81,9 +81,9 @@ public static partial class Legal
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Moves that can not be obtained by using Sketch with Smeargle.
|
||||
/// Moves that can not be obtained by using Sketch with Smeargle in any game.
|
||||
/// </summary>
|
||||
internal static readonly HashSet<int> InvalidSketch = new(Z_Moves)
|
||||
private static readonly HashSet<int> InvalidSketch = new(Z_Moves)
|
||||
{
|
||||
// Can't Sketch
|
||||
(int)Struggle,
|
||||
@@ -93,6 +93,22 @@ public static partial class Legal
|
||||
(int)LightofRuin,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks if Sketch can obtain the <see cref="move"/> in the requested <see cref="generation"/>
|
||||
/// </summary>
|
||||
/// <remarks>Doesn't bounds check the <see cref="generation"/> for max move ID.</remarks>
|
||||
/// <param name="move">Move ID</param>
|
||||
/// <param name="generation">Generation to check</param>
|
||||
/// <returns>True if can be sketched, false if not available.</returns>
|
||||
public static bool IsValidSketch(int move, int generation)
|
||||
{
|
||||
if (InvalidSketch.Contains(move))
|
||||
return false;
|
||||
if (generation is 6 && move is ((int)ThousandArrows or (int)ThousandWaves))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Species that are from Mythical Distributions (disallowed species for competitive rulesets)
|
||||
/// </summary>
|
||||
|
||||
@@ -105,7 +105,7 @@ public static bool GetCanRelearnMove(PKM pkm, int move, int generation, IReadOnl
|
||||
private static bool GetCanKnowMove(PKM pkm, int move, int generation, IReadOnlyList<IReadOnlyList<EvoCriteria>> evos, GameVersion version = GameVersion.Any)
|
||||
{
|
||||
if (pkm.Species == (int)Smeargle)
|
||||
return !Legal.InvalidSketch.Contains(move);
|
||||
return Legal.IsValidSketch(move, generation);
|
||||
|
||||
if (generation >= 8 && MoveEgg.GetIsSharedEggMove(pkm, generation, move))
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user