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:
Kurt
2021-06-06 23:36:59 -07:00
parent c98717bdc0
commit a07549f013
4 changed files with 23 additions and 7 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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>

View File

@@ -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;