From c09fb9a0ec6cb1b2209afe44e4860f72fa063c96 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 17 Oct 2020 13:40:12 -0700 Subject: [PATCH] Simplify "Flag" field in move source tracking --- PKHeX.Core/Legality/Analysis.cs | 2 +- .../Verifiers/VerifyCurrentMoves.cs | 6 +++--- .../Legality/Structures/CheckMoveResult.cs | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/Legality/Analysis.cs b/PKHeX.Core/Legality/Analysis.cs index bacf6fa54..0c3a71e88 100644 --- a/PKHeX.Core/Legality/Analysis.cs +++ b/PKHeX.Core/Legality/Analysis.cs @@ -456,7 +456,7 @@ public IReadOnlyList GetSuggestedRelearnMovesFromEncounter() return Info.RelearnBase; List window = new List(Info.RelearnBase.Where(z => z != 0)); - window.AddRange(pkm.Moves.Where((z, i) => z != 0 && !Info.Moves[i].Valid || Info.Moves[i].Flag)); + window.AddRange(pkm.Moves.Where((_, i) => Info.Moves[i].ShouldBeInRelearnMoves())); window = window.Distinct().ToList(); int[] moves = new int[4]; int start = Math.Max(0, window.Count - 4); diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index 0a11db263..1ab1e900b 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -232,7 +232,7 @@ private static CheckMoveResult[] ParseMovesRelearn(PKM pkm, IReadOnlyList c var relearn = pkm.RelearnMoves; for (int i = 0; i < 4; i++) { - if ((pkm.IsEgg || res[i].Flag) && !relearn.Contains(currentMoves[i])) + if ((pkm.IsEgg || res[i].IsRelearn) && !relearn.Contains(currentMoves[i])) res[i] = new CheckMoveResult(res[i], Invalid, string.Format(LMoveRelearnFMiss_0, res[i].Comment), res[i].Identifier); } @@ -259,7 +259,7 @@ private static CheckMoveResult[] ParseMoves(PKM pkm, MoveParseSource source, Leg if (source.CurrentMoves[m] == 0) res[m] = new CheckMoveResult(None, pkm.Format, m < required ? Fishy : Valid, LMoveSourceEmpty, Move); else if (reset == 0 && info.EncounterMoves.Relearn.Contains(source.CurrentMoves[m])) - res[m] = new CheckMoveResult(Relearn, info.Generation, Valid, LMoveSourceRelearn, Move) { Flag = true }; + res[m] = new CheckMoveResult(Relearn, info.Generation, Valid, LMoveSourceRelearn, Move); } if (AllParsed()) @@ -468,7 +468,7 @@ private static void ParseEggMoves(PKM pkm, CheckMoveResult[] res, int gen, Learn } else { - res[m] = new CheckMoveResult(EggMove, gen, Valid, LMoveSourceEgg, Move) { Flag = true }; + res[m] = new CheckMoveResult(EggMove, gen, Valid, LMoveSourceEgg, Move); } learnInfo.EggMovesLearned.Add(m); diff --git a/PKHeX.Core/Legality/Structures/CheckMoveResult.cs b/PKHeX.Core/Legality/Structures/CheckMoveResult.cs index e13dfaab7..38aca3796 100644 --- a/PKHeX.Core/Legality/Structures/CheckMoveResult.cs +++ b/PKHeX.Core/Legality/Structures/CheckMoveResult.cs @@ -26,9 +26,26 @@ public enum MoveSource /// public sealed class CheckMoveResult : CheckResult { + /// + /// Method of learning the move. + /// public readonly MoveSource Source; + + /// + /// Generation the move was learned in. + /// public readonly int Generation; - public bool Flag; + + /// + /// Indicates if the source of the move was validated from the + /// + public bool IsRelearn => Source == MoveSource.Relearn; + + /// + /// Checks if the Move should be present in a Relearn move pool (assuming Gen6+ origins). + /// + /// Invalid moves that can't be validated should be here, hence the inclusion. + public bool ShouldBeInRelearnMoves() => Source != MoveSource.None && (!Valid || IsRelearn); internal CheckMoveResult(MoveSource m, int g, CheckIdentifier i) : base(i)