From 97be69bca19e6b7f4d86a779fc191fa77bbe6da1 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 2 Jan 2021 14:47:39 -0800 Subject: [PATCH] Use EncounterMatch when EncounterOriginal doesn't matter --- .../Editing/Applicators/CatchRateApplicator.cs | 2 +- PKHeX.Core/Legality/BulkAnalysis.cs | 4 ++-- PKHeX.Core/Legality/MoveListSuggest.cs | 2 +- PKHeX.Core/Legality/Structures/LegalInfo.cs | 2 +- PKHeX.Core/Legality/Verifiers/FormVerifier.cs | 8 ++++---- PKHeX.Core/Legality/Verifiers/LevelVerifier.cs | 14 +++++++------- PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs b/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs index 9ac037a04..48b570af9 100644 --- a/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs @@ -19,7 +19,7 @@ public static int GetSuggestedCatchRate(PK1 pk1, SaveFile sav, LegalityAnalysis if (la.Info.Generation == 2) return 0; - var v = la.EncounterOriginal; + var v = la.EncounterMatch; switch (v) { case EncounterTrade1 c: diff --git a/PKHeX.Core/Legality/BulkAnalysis.cs b/PKHeX.Core/Legality/BulkAnalysis.cs index 9bdfb305f..08daa512b 100644 --- a/PKHeX.Core/Legality/BulkAnalysis.cs +++ b/PKHeX.Core/Legality/BulkAnalysis.cs @@ -115,8 +115,8 @@ private void CheckDuplicateOwnedGifts() { var dupes = AllAnalysis.Where(z => z.Info.Generation >= 3 - && z.EncounterOriginal is MysteryGift {EggEncounter: true} && !z.pkm.WasTradedEgg) - .GroupBy(z => ((MysteryGift)z.EncounterOriginal).CardTitle); + && z.EncounterMatch is MysteryGift {EggEncounter: true} && !z.pkm.WasTradedEgg) + .GroupBy(z => ((MysteryGift)z.EncounterMatch).CardTitle); foreach (var dupe in dupes) { diff --git a/PKHeX.Core/Legality/MoveListSuggest.cs b/PKHeX.Core/Legality/MoveListSuggest.cs index bfa0abdbc..718c02502 100644 --- a/PKHeX.Core/Legality/MoveListSuggest.cs +++ b/PKHeX.Core/Legality/MoveListSuggest.cs @@ -114,7 +114,7 @@ public static IReadOnlyList GetSuggestedRelearnMovesFromEncounter(this Lega return new int[4]; var pkm = analysis.pkm; - var enc = info.EncounterOriginal; + var enc = info.EncounterMatch; var parsed = VerifyRelearnMoves.GetSuggestedRelearn(pkm, enc, info.Relearn); if (parsed.Count == 0) // Always true for Origins < 6 and encounters without relearn permitted. return new int[4]; diff --git a/PKHeX.Core/Legality/Structures/LegalInfo.cs b/PKHeX.Core/Legality/Structures/LegalInfo.cs index dbc7a3094..3b2fc5930 100644 --- a/PKHeX.Core/Legality/Structures/LegalInfo.cs +++ b/PKHeX.Core/Legality/Structures/LegalInfo.cs @@ -49,7 +49,7 @@ public IEncounterable EncounterMatch private static readonly ValidEncounterMoves NONE = new(); public ValidEncounterMoves EncounterMoves { get; internal set; } = NONE; - public IReadOnlyList[] EvoChainsAllGens => _evochains ??= EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterOriginal); + public IReadOnlyList[] EvoChainsAllGens => _evochains ??= EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterMatch); private IReadOnlyList[]? _evochains; /// related information that generated the / value(s). diff --git a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs index c03e4a7cb..73c2c3640 100644 --- a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs @@ -181,19 +181,19 @@ private CheckResult VerifyForm(LegalityAnalysis data) // everything below here is not Form 0, so it has a form. if (format >= 7 && Info.Generation < 7) { - if (species == 25 || Legal.AlolanOriginForms.Contains(species) || Legal.AlolanVariantEvolutions12.Contains(data.EncounterOriginal.Species)) + if (species == 25 || Legal.AlolanOriginForms.Contains(species) || Legal.AlolanVariantEvolutions12.Contains(data.EncounterMatch.Species)) return GetInvalid(LFormInvalidGame); } if (format >= 8 && Info.Generation < 8) { - var orig = data.EncounterOriginal.Species; + var orig = data.EncounterMatch.Species; if (Legal.GalarOriginForms.Contains(species) || Legal.GalarVariantFormEvolutions.Contains(orig)) { - if (species == (int)Species.Meowth && data.EncounterOriginal.Form != 2) + if (species == (int)Species.Meowth && data.EncounterMatch.Form != 2) { // We're okay here. There's also Alolan Meowth... } - else if ((orig is (int) Species.MrMime or (int)Species.MimeJr) && pkm.CurrentLevel > data.EncounterOriginal.LevelMin && Info.Generation >= 4) + else if ((orig is (int) Species.MrMime or (int)Species.MimeJr) && pkm.CurrentLevel > data.EncounterMatch.LevelMin && Info.Generation >= 4) { // We're okay with a Mime Jr. that has evolved via level up. } diff --git a/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs b/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs index 3ad9ab2a4..8dfb2b929 100644 --- a/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs @@ -12,8 +12,8 @@ public sealed class LevelVerifier : Verifier public override void Verify(LegalityAnalysis data) { var pkm = data.pkm; - var EncounterMatch = data.EncounterOriginal; - if (EncounterMatch is MysteryGift gift) + var enc = data.EncounterOriginal; + if (enc is MysteryGift gift) { if (gift.Level != pkm.Met_Level && pkm.HasOriginalMetLocation) { @@ -39,14 +39,14 @@ public override void Verify(LegalityAnalysis data) if (pkm.IsEgg) { - int elvl = EncounterMatch.LevelMin; + int elvl = enc.LevelMin; if (elvl != pkm.CurrentLevel) { data.AddLine(GetInvalid(string.Format(LEggFMetLevel_0, elvl))); return; } - var reqEXP = EncounterMatch is EncounterStatic {Version: GameVersion.C} + var reqEXP = enc is EncounterStatic {Version: GameVersion.C} ? 125 // Gen2 Dizzy Punch gifts always have 125 EXP, even if it's more than the Lv5 exp required. : Experience.GetEXP(elvl, pkm.PersonalInfo.EXPGrowth); if (reqEXP != pkm.EXP) @@ -57,7 +57,7 @@ public override void Verify(LegalityAnalysis data) int lvl = pkm.CurrentLevel; if (lvl < pkm.Met_Level) data.AddLine(GetInvalid(LLevelMetBelow)); - else if (!EncounterMatch.IsWithinRange(pkm) && lvl != 100 && pkm.EXP == Experience.GetEXP(lvl, pkm.PersonalInfo.EXPGrowth)) + else if (!enc.IsWithinRange(pkm) && lvl != 100 && pkm.EXP == Experience.GetEXP(lvl, pkm.PersonalInfo.EXPGrowth)) data.AddLine(Get(LLevelEXPThreshold, Severity.Fishy)); else data.AddLine(GetValid(LLevelMetSane)); @@ -66,7 +66,7 @@ public override void Verify(LegalityAnalysis data) public void VerifyG1(LegalityAnalysis data) { var pkm = data.pkm; - var EncounterMatch = data.EncounterOriginal; + var enc = data.EncounterMatch; if (pkm.IsEgg) { const int elvl = 5; @@ -83,7 +83,7 @@ public void VerifyG1(LegalityAnalysis data) // There is no way to prevent a gen1 trade evolution as held items (everstone) did not exist. // Machoke, Graveler, Haunter and Kadabra captured in the second phase evolution, excluding in-game trades, are already checked - if (pkm.Format <= 2 && EncounterMatch is not EncounterTrade && EncounterMatch.Species == pkm.Species && GBRestrictions.Trade_Evolution1.Contains(EncounterMatch.Species)) + if (pkm.Format <= 2 && enc is not EncounterTrade && enc.Species == pkm.Species && GBRestrictions.Trade_Evolution1.Contains(enc.Species)) VerifyG1TradeEvo(data); } diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index 639dd9b4a..4661ce047 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -118,7 +118,6 @@ private void VerifyMiscG1Types(LegalityAnalysis data, PK1 pk1) private void VerifyMiscG1CatchRate(LegalityAnalysis data, PK1 pk1) { - var e = data.EncounterMatch; var catch_rate = pk1.Catch_Rate; var result = pk1.TradebackStatus == TradebackType.Gen1_NotTradeback ? GetWasNotTradeback() @@ -137,6 +136,7 @@ CheckResult GetWasTradeback() CheckResult GetWasNotTradeback() { + var e = data.EncounterMatch; if (e is EncounterStatic1E {Version: GameVersion.Stadium} || e is EncounterTrade1) return GetValid(LG1CatchRateMatchPrevious); // Encounters detected by the catch rate, cant be invalid if match this encounters @@ -218,7 +218,7 @@ private static void VerifyMiscEggCommon(LegalityAnalysis data) if (pkm.Move1_PP != pkm.GetMovePP(pkm.Move1, 0) || pkm.Move2_PP != pkm.GetMovePP(pkm.Move2, 0) || pkm.Move3_PP != pkm.GetMovePP(pkm.Move3, 0) || pkm.Move4_PP != pkm.GetMovePP(pkm.Move4, 0)) data.AddLine(GetInvalid(LEggPP, Egg)); - var EncounterMatch = data.EncounterOriginal; + var EncounterMatch = data.EncounterMatch; var HatchCycles = EncounterMatch is EncounterStatic s ? s.EggCycles : 0; if (HatchCycles == 0) // no value set HatchCycles = pkm.PersonalInfo.HatchCycles;