From fa36b70b2938a60ea7c1ac8a1b993f3b158d5517 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 27 Nov 2020 12:00:49 -0800 Subject: [PATCH] Split Analysis into two separate classes Will rename in next commit --- .../Editing/Applicators/RibbonApplicator.cs | 2 +- PKHeX.Core/Editing/LocalizeUtil.cs | 2 +- PKHeX.Core/Legality/Analysis.cs | 21 +++---- PKHeX.Core/Legality/Checks.cs | 56 +++++++++---------- .../Encounters/Verifiers/EncounterVerifier.cs | 2 +- .../Verifiers/VerifyCurrentMoves.cs | 2 +- .../Verifiers/VerifyRelearnMoves.cs | 4 +- .../Legality/Verifiers/LevelVerifier.cs | 4 +- PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 4 +- PKHeX.Core/Legality/Verifiers/PIDVerifier.cs | 2 +- 10 files changed, 50 insertions(+), 49 deletions(-) diff --git a/PKHeX.Core/Editing/Applicators/RibbonApplicator.cs b/PKHeX.Core/Editing/Applicators/RibbonApplicator.cs index 6c47f4519..3bc2fbd0b 100644 --- a/PKHeX.Core/Editing/Applicators/RibbonApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/RibbonApplicator.cs @@ -201,7 +201,7 @@ namespace PKHeX.Core private static bool UpdateIsValid(LegalityAnalysis la) { - LegalityAnalysis.Ribbon.Verify(la); + LegalityAnalyzers.Ribbon.Verify(la); return la.Results.All(z => z.Valid); } diff --git a/PKHeX.Core/Editing/LocalizeUtil.cs b/PKHeX.Core/Editing/LocalizeUtil.cs index 9e7fe2d7a..cc683983e 100644 --- a/PKHeX.Core/Editing/LocalizeUtil.cs +++ b/PKHeX.Core/Editing/LocalizeUtil.cs @@ -17,7 +17,7 @@ namespace PKHeX.Core GameInfo.FilteredSources = new FilteredGameDataSource(sav, GameInfo.Sources, hax); // Update Legality Analysis strings - LegalityAnalysis.ChangeLocalizationStrings(str.movelist, str.specieslist); + LegalityAnalyzers.ChangeLocalizationStrings(str.movelist, str.specieslist); // Update Legality Strings Task.Run(() => diff --git a/PKHeX.Core/Legality/Analysis.cs b/PKHeX.Core/Legality/Analysis.cs index e067deeb1..d15300ceb 100644 --- a/PKHeX.Core/Legality/Analysis.cs +++ b/PKHeX.Core/Legality/Analysis.cs @@ -4,13 +4,14 @@ using System; using System.Collections.Generic; using System.Linq; using static PKHeX.Core.LegalityCheckStrings; +using static PKHeX.Core.LegalityAnalyzers; namespace PKHeX.Core { /// /// Legality Check object containing the data and overview values from the parse. /// - public partial class LegalityAnalysis + public sealed class LegalityAnalysis { internal readonly PKM pkm; internal readonly PersonalInfo PersonalInfo; @@ -204,7 +205,7 @@ namespace PKHeX.Core Level.Verify(this); Level.VerifyG1(this); Trainer.VerifyOTG1(this); - Misc.VerifyMiscG1(this); + MiscValues.VerifyMiscG1(this); if (pkm.Format == 2) Item.Verify(this); } @@ -307,20 +308,20 @@ namespace PKHeX.Core { PIDEC.Verify(this); Nickname.Verify(this); - Language.Verify(this); + LanguageIndex.Verify(this); Trainer.Verify(this); IndividualValues.Verify(this); EffortValues.Verify(this); Level.Verify(this); Ribbon.Verify(this); - Ability.Verify(this); - Ball.Verify(this); - Form.Verify(this); - Misc.Verify(this); - Gender.Verify(this); + AbilityValues.Verify(this); + BallIndex.Verify(this); + FormValues.Verify(this); + MiscValues.Verify(this); + GenderValues.Verify(this); Item.Verify(this); if (pkm.Format <= 6 && pkm.Format >= 4) - EncounterType.Verify(this); // Gen 6->7 transfer deletes encounter type data + Gen4EncounterType.Verify(this); // Gen 6->7 transfer deletes encounter type data Contest.Verify(this); @@ -341,7 +342,7 @@ namespace PKHeX.Core return; HyperTraining.Verify(this); - Misc.VerifyVersionEvolution(this); + MiscValues.VerifyVersionEvolution(this); if (pkm.Format < 8) return; diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 64ff4c04b..9af21f341 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -4,38 +4,38 @@ using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core { - public partial class LegalityAnalysis + internal static class LegalityAnalyzers { - private static readonly Verifier Language = new LanguageVerifier(); - private static readonly Verifier Nickname = new NicknameVerifier(); - private static readonly Verifier EffortValues = new EffortValueVerifier(); - private static readonly Verifier IndividualValues = new IndividualValueVerifier(); - private static readonly Verifier Ball = new BallVerifier(); - private static readonly Verifier Form = new FormVerifier(); - private static readonly Verifier ConsoleRegion = new ConsoleRegionVerifier(); - private static readonly Verifier Ability = new AbilityVerifier(); - private static readonly Verifier Medal = new MedalVerifier(); + public static readonly Verifier LanguageIndex = new LanguageVerifier(); + public static readonly Verifier Nickname = new NicknameVerifier(); + public static readonly Verifier EffortValues = new EffortValueVerifier(); + public static readonly Verifier IndividualValues = new IndividualValueVerifier(); + public static readonly Verifier BallIndex = new BallVerifier(); + public static readonly Verifier FormValues = new FormVerifier(); + public static readonly Verifier ConsoleRegion = new ConsoleRegionVerifier(); + public static readonly Verifier AbilityValues = new AbilityVerifier(); + public static readonly Verifier Medal = new MedalVerifier(); public static readonly Verifier Ribbon = new RibbonVerifier(); - private static readonly Verifier Item = new ItemVerifier(); - private static readonly Verifier EncounterType = new EncounterTypeVerifier(); - private static readonly Verifier HyperTraining = new HyperTrainingVerifier(); - private static readonly Verifier Gender = new GenderVerifier(); - private static readonly Verifier PIDEC = new PIDVerifier(); - private static readonly Verifier NHarmonia = new NHarmoniaVerifier(); - private static readonly Verifier CXD = new CXDVerifier(); - private static readonly Verifier Memory = new MemoryVerifier(); - private static readonly Verifier History = new HistoryVerifier(); - private static readonly Verifier Contest = new ContestStatVerifier(); + public static readonly Verifier Item = new ItemVerifier(); + public static readonly Verifier Gen4EncounterType = new EncounterTypeVerifier(); + public static readonly Verifier HyperTraining = new HyperTrainingVerifier(); + public static readonly Verifier GenderValues = new GenderVerifier(); + public static readonly Verifier PIDEC = new PIDVerifier(); + public static readonly Verifier NHarmonia = new NHarmoniaVerifier(); + public static readonly Verifier CXD = new CXDVerifier(); + public static readonly Verifier Memory = new MemoryVerifier(); + public static readonly Verifier History = new HistoryVerifier(); + public static readonly Verifier Contest = new ContestStatVerifier(); - private static readonly TrainerNameVerifier Trainer = new TrainerNameVerifier(); - private static readonly LevelVerifier Level = new LevelVerifier(); - private static readonly MiscVerifier Misc = new MiscVerifier(); - private static readonly TransferVerifier Transfer = new TransferVerifier(); - private static readonly MarkVerifier Mark = new MarkVerifier(); + public static readonly TrainerNameVerifier Trainer = new TrainerNameVerifier(); + public static readonly LevelVerifier Level = new LevelVerifier(); + public static readonly MiscVerifier MiscValues = new MiscVerifier(); + public static readonly TransferVerifier Transfer = new TransferVerifier(); + public static readonly MarkVerifier Mark = new MarkVerifier(); - internal static IReadOnlyList MoveStrings = Util.GetMovesList(GameLanguage.DefaultLanguage); - internal static IReadOnlyList SpeciesStrings = Util.GetSpeciesList(GameLanguage.DefaultLanguage); - internal static IEnumerable GetMoveNames(IEnumerable moves) => moves.Select(m => (uint)m >= MoveStrings.Count ? L_AError : MoveStrings[m]); + public static IReadOnlyList MoveStrings = Util.GetMovesList(GameLanguage.DefaultLanguage); + public static IReadOnlyList SpeciesStrings = Util.GetSpeciesList(GameLanguage.DefaultLanguage); + public static IEnumerable GetMoveNames(IEnumerable moves) => moves.Select(m => (uint)m >= MoveStrings.Count ? L_AError : MoveStrings[m]); public static void ChangeLocalizationStrings(IReadOnlyList moves, IReadOnlyList species) { diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs index 61b619784..c27ffed1f 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs @@ -306,7 +306,7 @@ namespace PKHeX.Core { // Pokemon that evolve on trade can not be in the phase evolution after the trade // If the trade holds an everstone EvolveOnTrade will be false for the encounter - var species = LegalityAnalysis.SpeciesStrings; + var species = LegalityAnalyzers.SpeciesStrings; var unevolved = species[pkm.Species]; var evolved = species[pkm.Species + 1]; return new CheckResult(Severity.Invalid, string.Format(LEvoTradeReq, unevolved, evolved), CheckIdentifier.Encounter); diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index 7f4fa8f6a..bf7eeaf8a 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using static PKHeX.Core.LegalityCheckStrings; -using static PKHeX.Core.LegalityAnalysis; +using static PKHeX.Core.LegalityAnalyzers; using static PKHeX.Core.MoveSource; using static PKHeX.Core.Severity; diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs index 11eaed97f..024d058d3 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using static PKHeX.Core.LegalityCheckStrings; -using static PKHeX.Core.LegalityAnalysis; +using static PKHeX.Core.LegalityAnalyzers; namespace PKHeX.Core { @@ -47,7 +47,7 @@ namespace PKHeX.Core for (int i = 0; i < 4; i++) { res[i] = relearn[i] != required[i] - ? new CheckResult(Severity.Invalid, string.Format(LMoveFExpect_0, MoveStrings[required[i]]), CheckIdentifier.RelearnMove) + ? new CheckResult(Severity.Invalid, string.Format(LMoveFExpect_0, LegalityAnalyzers.MoveStrings[required[i]]), CheckIdentifier.RelearnMove) : new CheckResult(CheckIdentifier.RelearnMove); } diff --git a/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs b/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs index 3cb66122d..0cb5345e9 100644 --- a/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs @@ -100,8 +100,8 @@ namespace PKHeX.Core return; // Pokemon have been traded but it is not evolved, trade evolutions are sequential dex numbers - var evolved = LegalityAnalysis.SpeciesStrings[pkm.Species + 1]; - var unevolved = LegalityAnalysis.SpeciesStrings[pkm.Species]; + var evolved = LegalityAnalyzers.SpeciesStrings[pkm.Species + 1]; + var unevolved = LegalityAnalyzers.SpeciesStrings[pkm.Species]; data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved))); } } diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index fcb9469cc..bbacc6ea0 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -227,7 +227,7 @@ namespace PKHeX.Core if (pkm.Format >= 6 && EncounterMatch is EncounterEgg && !pkm.Moves.SequenceEqual(pkm.RelearnMoves)) { - var moves = string.Join(", ", LegalityAnalysis.GetMoveNames(pkm.Moves)); + var moves = string.Join(", ", LegalityAnalyzers.GetMoveNames(pkm.Moves)); var msg = string.Format(LMoveFExpect_0, moves); data.AddLine(GetInvalid(msg, Egg)); } @@ -430,7 +430,7 @@ namespace PKHeX.Core continue; } - data.AddLine(GetInvalid(string.Format(LMoveSourceTR, LegalityAnalysis.MoveStrings[Legal.TMHM_SWSH[i + 100]]))); + data.AddLine(GetInvalid(string.Format(LMoveSourceTR, LegalityAnalyzers.MoveStrings[Legal.TMHM_SWSH[i + 100]]))); } // weight/height scalars can be legally 0 (1:65536) so don't bother checking diff --git a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs index 765b87c1a..1f5eaf1f9 100644 --- a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs @@ -102,7 +102,7 @@ namespace PKHeX.Core // Indicate what it will evolve into uint evoVal = WurmpleUtil.GetWurmpleEvoVal(pkm.EncryptionConstant); var evolvesTo = evoVal == 0 ? (int)Species.Beautifly : (int)Species.Dustox; - var spec = LegalityAnalysis.SpeciesStrings[evolvesTo]; + var spec = LegalityAnalyzers.SpeciesStrings[evolvesTo]; var msg = string.Format(L_XWurmpleEvo_0, spec); data.AddLine(GetValid(msg, CheckIdentifier.EC)); }