Split Analysis into two separate classes

Will rename in next commit
This commit is contained in:
Kurt 2020-11-27 12:00:49 -08:00
parent 9b178fefe2
commit fa36b70b29
10 changed files with 50 additions and 49 deletions

View file

@ -201,7 +201,7 @@ namespace PKHeX.Core
private static bool UpdateIsValid(LegalityAnalysis la) private static bool UpdateIsValid(LegalityAnalysis la)
{ {
LegalityAnalysis.Ribbon.Verify(la); LegalityAnalyzers.Ribbon.Verify(la);
return la.Results.All(z => z.Valid); return la.Results.All(z => z.Valid);
} }

View file

@ -17,7 +17,7 @@ namespace PKHeX.Core
GameInfo.FilteredSources = new FilteredGameDataSource(sav, GameInfo.Sources, hax); GameInfo.FilteredSources = new FilteredGameDataSource(sav, GameInfo.Sources, hax);
// Update Legality Analysis strings // Update Legality Analysis strings
LegalityAnalysis.ChangeLocalizationStrings(str.movelist, str.specieslist); LegalityAnalyzers.ChangeLocalizationStrings(str.movelist, str.specieslist);
// Update Legality Strings // Update Legality Strings
Task.Run(() => Task.Run(() =>

View file

@ -4,13 +4,14 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static PKHeX.Core.LegalityCheckStrings; using static PKHeX.Core.LegalityCheckStrings;
using static PKHeX.Core.LegalityAnalyzers;
namespace PKHeX.Core namespace PKHeX.Core
{ {
/// <summary> /// <summary>
/// Legality Check object containing the <see cref="CheckResult"/> data and overview values from the parse. /// Legality Check object containing the <see cref="CheckResult"/> data and overview values from the parse.
/// </summary> /// </summary>
public partial class LegalityAnalysis public sealed class LegalityAnalysis
{ {
internal readonly PKM pkm; internal readonly PKM pkm;
internal readonly PersonalInfo PersonalInfo; internal readonly PersonalInfo PersonalInfo;
@ -204,7 +205,7 @@ namespace PKHeX.Core
Level.Verify(this); Level.Verify(this);
Level.VerifyG1(this); Level.VerifyG1(this);
Trainer.VerifyOTG1(this); Trainer.VerifyOTG1(this);
Misc.VerifyMiscG1(this); MiscValues.VerifyMiscG1(this);
if (pkm.Format == 2) if (pkm.Format == 2)
Item.Verify(this); Item.Verify(this);
} }
@ -307,20 +308,20 @@ namespace PKHeX.Core
{ {
PIDEC.Verify(this); PIDEC.Verify(this);
Nickname.Verify(this); Nickname.Verify(this);
Language.Verify(this); LanguageIndex.Verify(this);
Trainer.Verify(this); Trainer.Verify(this);
IndividualValues.Verify(this); IndividualValues.Verify(this);
EffortValues.Verify(this); EffortValues.Verify(this);
Level.Verify(this); Level.Verify(this);
Ribbon.Verify(this); Ribbon.Verify(this);
Ability.Verify(this); AbilityValues.Verify(this);
Ball.Verify(this); BallIndex.Verify(this);
Form.Verify(this); FormValues.Verify(this);
Misc.Verify(this); MiscValues.Verify(this);
Gender.Verify(this); GenderValues.Verify(this);
Item.Verify(this); Item.Verify(this);
if (pkm.Format <= 6 && pkm.Format >= 4) 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); Contest.Verify(this);
@ -341,7 +342,7 @@ namespace PKHeX.Core
return; return;
HyperTraining.Verify(this); HyperTraining.Verify(this);
Misc.VerifyVersionEvolution(this); MiscValues.VerifyVersionEvolution(this);
if (pkm.Format < 8) if (pkm.Format < 8)
return; return;

View file

@ -4,38 +4,38 @@ using static PKHeX.Core.LegalityCheckStrings;
namespace PKHeX.Core namespace PKHeX.Core
{ {
public partial class LegalityAnalysis internal static class LegalityAnalyzers
{ {
private static readonly Verifier Language = new LanguageVerifier(); public static readonly Verifier LanguageIndex = new LanguageVerifier();
private static readonly Verifier Nickname = new NicknameVerifier(); public static readonly Verifier Nickname = new NicknameVerifier();
private static readonly Verifier EffortValues = new EffortValueVerifier(); public static readonly Verifier EffortValues = new EffortValueVerifier();
private static readonly Verifier IndividualValues = new IndividualValueVerifier(); public static readonly Verifier IndividualValues = new IndividualValueVerifier();
private static readonly Verifier Ball = new BallVerifier(); public static readonly Verifier BallIndex = new BallVerifier();
private static readonly Verifier Form = new FormVerifier(); public static readonly Verifier FormValues = new FormVerifier();
private static readonly Verifier ConsoleRegion = new ConsoleRegionVerifier(); public static readonly Verifier ConsoleRegion = new ConsoleRegionVerifier();
private static readonly Verifier Ability = new AbilityVerifier(); public static readonly Verifier AbilityValues = new AbilityVerifier();
private static readonly Verifier Medal = new MedalVerifier(); public static readonly Verifier Medal = new MedalVerifier();
public static readonly Verifier Ribbon = new RibbonVerifier(); public static readonly Verifier Ribbon = new RibbonVerifier();
private static readonly Verifier Item = new ItemVerifier(); public static readonly Verifier Item = new ItemVerifier();
private static readonly Verifier EncounterType = new EncounterTypeVerifier(); public static readonly Verifier Gen4EncounterType = new EncounterTypeVerifier();
private static readonly Verifier HyperTraining = new HyperTrainingVerifier(); public static readonly Verifier HyperTraining = new HyperTrainingVerifier();
private static readonly Verifier Gender = new GenderVerifier(); public static readonly Verifier GenderValues = new GenderVerifier();
private static readonly Verifier PIDEC = new PIDVerifier(); public static readonly Verifier PIDEC = new PIDVerifier();
private static readonly Verifier NHarmonia = new NHarmoniaVerifier(); public static readonly Verifier NHarmonia = new NHarmoniaVerifier();
private static readonly Verifier CXD = new CXDVerifier(); public static readonly Verifier CXD = new CXDVerifier();
private static readonly Verifier Memory = new MemoryVerifier(); public static readonly Verifier Memory = new MemoryVerifier();
private static readonly Verifier History = new HistoryVerifier(); public static readonly Verifier History = new HistoryVerifier();
private static readonly Verifier Contest = new ContestStatVerifier(); public static readonly Verifier Contest = new ContestStatVerifier();
private static readonly TrainerNameVerifier Trainer = new TrainerNameVerifier(); public static readonly TrainerNameVerifier Trainer = new TrainerNameVerifier();
private static readonly LevelVerifier Level = new LevelVerifier(); public static readonly LevelVerifier Level = new LevelVerifier();
private static readonly MiscVerifier Misc = new MiscVerifier(); public static readonly MiscVerifier MiscValues = new MiscVerifier();
private static readonly TransferVerifier Transfer = new TransferVerifier(); public static readonly TransferVerifier Transfer = new TransferVerifier();
private static readonly MarkVerifier Mark = new MarkVerifier(); public static readonly MarkVerifier Mark = new MarkVerifier();
internal static IReadOnlyList<string> MoveStrings = Util.GetMovesList(GameLanguage.DefaultLanguage); public static IReadOnlyList<string> MoveStrings = Util.GetMovesList(GameLanguage.DefaultLanguage);
internal static IReadOnlyList<string> SpeciesStrings = Util.GetSpeciesList(GameLanguage.DefaultLanguage); public static IReadOnlyList<string> SpeciesStrings = Util.GetSpeciesList(GameLanguage.DefaultLanguage);
internal static IEnumerable<string> GetMoveNames(IEnumerable<int> moves) => moves.Select(m => (uint)m >= MoveStrings.Count ? L_AError : MoveStrings[m]); public static IEnumerable<string> GetMoveNames(IEnumerable<int> moves) => moves.Select(m => (uint)m >= MoveStrings.Count ? L_AError : MoveStrings[m]);
public static void ChangeLocalizationStrings(IReadOnlyList<string> moves, IReadOnlyList<string> species) public static void ChangeLocalizationStrings(IReadOnlyList<string> moves, IReadOnlyList<string> species)
{ {

View file

@ -306,7 +306,7 @@ namespace PKHeX.Core
{ {
// Pokemon that evolve on trade can not be in the phase evolution after the trade // 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 // 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 unevolved = species[pkm.Species];
var evolved = species[pkm.Species + 1]; var evolved = species[pkm.Species + 1];
return new CheckResult(Severity.Invalid, string.Format(LEvoTradeReq, unevolved, evolved), CheckIdentifier.Encounter); return new CheckResult(Severity.Invalid, string.Format(LEvoTradeReq, unevolved, evolved), CheckIdentifier.Encounter);

View file

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static PKHeX.Core.LegalityCheckStrings; using static PKHeX.Core.LegalityCheckStrings;
using static PKHeX.Core.LegalityAnalysis; using static PKHeX.Core.LegalityAnalyzers;
using static PKHeX.Core.MoveSource; using static PKHeX.Core.MoveSource;
using static PKHeX.Core.Severity; using static PKHeX.Core.Severity;

View file

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static PKHeX.Core.LegalityCheckStrings; using static PKHeX.Core.LegalityCheckStrings;
using static PKHeX.Core.LegalityAnalysis; using static PKHeX.Core.LegalityAnalyzers;
namespace PKHeX.Core namespace PKHeX.Core
{ {
@ -47,7 +47,7 @@ namespace PKHeX.Core
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
res[i] = relearn[i] != required[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); : new CheckResult(CheckIdentifier.RelearnMove);
} }

View file

@ -100,8 +100,8 @@ namespace PKHeX.Core
return; return;
// Pokemon have been traded but it is not evolved, trade evolutions are sequential dex numbers // Pokemon have been traded but it is not evolved, trade evolutions are sequential dex numbers
var evolved = LegalityAnalysis.SpeciesStrings[pkm.Species + 1]; var evolved = LegalityAnalyzers.SpeciesStrings[pkm.Species + 1];
var unevolved = LegalityAnalysis.SpeciesStrings[pkm.Species]; var unevolved = LegalityAnalyzers.SpeciesStrings[pkm.Species];
data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved))); data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved)));
} }
} }

View file

@ -227,7 +227,7 @@ namespace PKHeX.Core
if (pkm.Format >= 6 && EncounterMatch is EncounterEgg && !pkm.Moves.SequenceEqual(pkm.RelearnMoves)) 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); var msg = string.Format(LMoveFExpect_0, moves);
data.AddLine(GetInvalid(msg, Egg)); data.AddLine(GetInvalid(msg, Egg));
} }
@ -430,7 +430,7 @@ namespace PKHeX.Core
continue; 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 // weight/height scalars can be legally 0 (1:65536) so don't bother checking

View file

@ -102,7 +102,7 @@ namespace PKHeX.Core
// Indicate what it will evolve into // Indicate what it will evolve into
uint evoVal = WurmpleUtil.GetWurmpleEvoVal(pkm.EncryptionConstant); uint evoVal = WurmpleUtil.GetWurmpleEvoVal(pkm.EncryptionConstant);
var evolvesTo = evoVal == 0 ? (int)Species.Beautifly : (int)Species.Dustox; 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); var msg = string.Format(L_XWurmpleEvo_0, spec);
data.AddLine(GetValid(msg, CheckIdentifier.EC)); data.AddLine(GetValid(msg, CheckIdentifier.EC));
} }