mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-20 20:58:30 -05:00
Simplify move checking
extract duplicated method and simplify empty checks within add z-moves to invalid sketch
This commit is contained in:
parent
79ef477d3d
commit
41d8cc96ca
|
|
@ -1876,23 +1876,8 @@ private CheckResult[] verifyMoves()
|
|||
int[] RelearnMoves = pkm.RelearnMoves;
|
||||
foreach (MysteryGift mg in EventGiftMatch)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (Moves[i] == Legal.Struggle)
|
||||
res[i] = new CheckResult(Severity.Invalid, "Invalid Move: Struggle.", CheckIdentifier.Move);
|
||||
else if (RelearnMoves.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "Relearn Move.", CheckIdentifier.Move) { Flag = true };
|
||||
else if (validMoves.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "Level-up.", CheckIdentifier.Move);
|
||||
else if (validTMHM.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "TM/HM.", CheckIdentifier.Move);
|
||||
else if (validTutor.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "Tutor.", CheckIdentifier.Move);
|
||||
else if (mg.Moves.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "Wonder Card Non-Relearn Move.", CheckIdentifier.Move);
|
||||
else
|
||||
res[i] = new CheckResult(Severity.Invalid, "Invalid Move.", CheckIdentifier.Move);
|
||||
}
|
||||
int[] GiftMoves = mg.Moves;
|
||||
res = parseMoves(Moves, validMoves, RelearnMoves, validTMHM, validTutor, GiftMoves);
|
||||
if (res.Any(r => !r.Valid))
|
||||
continue;
|
||||
|
||||
|
|
@ -1904,25 +1889,8 @@ private CheckResult[] verifyMoves()
|
|||
else
|
||||
{
|
||||
int[] RelearnMoves = pkm.RelearnMoves;
|
||||
MysteryGift MatchedGift = EncounterMatch as MysteryGift;
|
||||
int[] GiftMoves = MatchedGift?.Moves ?? new int[0];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (Moves[i] == Legal.Struggle)
|
||||
res[i] = new CheckResult(Severity.Invalid, "Invalid Move: Struggle.", CheckIdentifier.Move);
|
||||
else if (RelearnMoves.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "Relearn Move.", CheckIdentifier.Move) { Flag = true };
|
||||
else if (validMoves.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "Level-up.", CheckIdentifier.Move);
|
||||
else if (validTMHM.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "TM/HM.", CheckIdentifier.Move);
|
||||
else if (validTutor.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, Moves[i] == 0 ? "Empty" : "Tutor.", CheckIdentifier.Move);
|
||||
else if (GiftMoves.Contains(Moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "Wonder Card Non-Relearn Move.", CheckIdentifier.Move);
|
||||
else
|
||||
res[i] = new CheckResult(Severity.Invalid, "Invalid Move.", CheckIdentifier.Move);
|
||||
}
|
||||
int[] GiftMoves = (EncounterMatch as MysteryGift)?.Moves ?? new int[0];
|
||||
res = parseMoves(Moves, validMoves, RelearnMoves, validTMHM, validTutor, GiftMoves);
|
||||
}
|
||||
if (Moves[0] == 0) // None
|
||||
res[0] = new CheckResult(Severity.Invalid, "Invalid Move.", CheckIdentifier.Move);
|
||||
|
|
@ -1938,6 +1906,28 @@ private CheckResult[] verifyMoves()
|
|||
|
||||
return res;
|
||||
}
|
||||
private CheckResult[] parseMoves(int[] moves, int[] learn, int[] relearn, int[] tmhm, int[] tutor, int[] giftmoves)
|
||||
{
|
||||
CheckResult[] res = new CheckResult[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (moves[i] == 0)
|
||||
res[i] = new CheckResult(Severity.Valid, "Empty", CheckIdentifier.Move);
|
||||
else if (relearn.Contains(moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "Relearn Move.", CheckIdentifier.Move) { Flag = true };
|
||||
else if (learn.Contains(moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "Level-up.", CheckIdentifier.Move);
|
||||
else if (tmhm.Contains(moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "TM/HM.", CheckIdentifier.Move);
|
||||
else if (tutor.Contains(moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "Tutor.", CheckIdentifier.Move);
|
||||
else if (giftmoves.Contains(moves[i]))
|
||||
res[i] = new CheckResult(Severity.Valid, "Mystery Gift Non-Relearn Move.", CheckIdentifier.Move);
|
||||
else
|
||||
res[i] = new CheckResult(Severity.Invalid, "Invalid Move.", CheckIdentifier.Move);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
private CheckResult[] verifyRelearn()
|
||||
{
|
||||
RelearnBase = null;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public static partial class Legal
|
||||
{
|
||||
|
|
@ -197,6 +199,7 @@ public static partial class Legal
|
|||
695, 696, 697, 698, 699, 700, 701, 702, 703,
|
||||
719,
|
||||
};
|
||||
internal static readonly int[] InvalidSketch = new[] { 165, 448 }.Concat(Z_Moves).ToArray(); // Struggle & Chatter
|
||||
|
||||
public static readonly int[] Legends =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -225,17 +225,7 @@ public static partial class Legal
|
|||
};
|
||||
|
||||
#endregion
|
||||
|
||||
// Legality
|
||||
internal const int Struggle = 165;
|
||||
internal const int Chatter = 448;
|
||||
internal static readonly int[] InvalidSketch =
|
||||
{
|
||||
// Regular Moves
|
||||
Struggle, Chatter
|
||||
// Z-Moves
|
||||
// TODO
|
||||
};
|
||||
|
||||
internal static readonly int[] EggLocations = {60002, 30002};
|
||||
internal static readonly int[] ValidMet_XY =
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user