From d0ca8403a9af4f2fb8b6f6452b208eb82ccbe5f6 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 19 Aug 2022 22:37:27 -0700 Subject: [PATCH] Minor tweaks Flag enigma berry on ck3/xk3 Suggest national ribbon if missing Flag N's pkm if any IV is != 30, even if sum is 180. --- .../Legality/Verifiers/Ball/BallVerifier.cs | 9 +++---- .../Verifiers/IndividualValueVerifier.cs | 6 ++--- PKHeX.Core/Legality/Verifiers/ItemVerifier.cs | 24 ++++++++++++------- .../Legality/Verifiers/NHarmoniaVerifier.cs | 10 ++++++-- PKHeX.Core/Legality/Verifiers/PIDVerifier.cs | 19 --------------- .../Verifiers/Ribbons/RibbonResultList.cs | 13 ++++++---- .../Verifiers/Ribbons/RibbonVerifierEvent3.cs | 5 ++-- PKHeX.Core/PKM/Interfaces/IAwakened.cs | 5 ++-- 8 files changed, 45 insertions(+), 46 deletions(-) diff --git a/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs b/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs index 7cba596e9..1ffbe0210 100644 --- a/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs @@ -113,11 +113,12 @@ private CheckResult VerifyBallEgg(LegalityAnalysis data) }; } - private CheckResult VerifyBallInherited(LegalityAnalysis data) => data.Info.Generation switch + private CheckResult VerifyBallInherited(LegalityAnalysis data) => data.Info.EncounterMatch.Context switch { - 6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules - 7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules - 8 => data.Entity.BDSP ? VerifyBallEggGen8BDSP(data) : VerifyBallEggGen8(data), + EntityContext.Gen6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules + EntityContext.Gen7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules + EntityContext.Gen8 => VerifyBallEggGen8(data), + EntityContext.Gen8b => VerifyBallEggGen8BDSP(data), _ => NONE, }; diff --git a/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs b/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs index fe4276b10..0c4d8f587 100644 --- a/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs @@ -1,4 +1,4 @@ -using System; +using System; using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core; @@ -33,8 +33,6 @@ public override void Verify(LegalityAnalysis data) } } - public static bool AllIVsEqual(PKM pk) => AllIVsEqual(pk, pk.IV_HP); - private static bool AllIVsEqual(PKM pk, int hpiv) { return (pk.IV_ATK == hpiv) && (pk.IV_DEF == hpiv) && (pk.IV_SPA == hpiv) && (pk.IV_SPD == hpiv) && (pk.IV_SPE == hpiv); @@ -94,7 +92,7 @@ private void VerifyIVsGen6(LegalityAnalysis data, EncounterSlot w) { if (w is EncounterSlot6XY xy) { - if (PersonalTable.XY[data.EncounterMatch.Species].IsEggGroup(15)) // Undiscovered + if (PersonalTable.XY[xy.Species].IsEggGroup(15)) // Undiscovered VerifyIVsFlawless(data, 3); if (xy.IsFriendSafari) VerifyIVsFlawless(data, 2); diff --git a/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs b/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs index d1554af63..bbf844bd1 100644 --- a/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs @@ -1,4 +1,4 @@ -using static PKHeX.Core.LegalityCheckStrings; +using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core; @@ -12,14 +12,22 @@ public sealed class ItemVerifier : Verifier public override void Verify(LegalityAnalysis data) { var pk = data.Entity; - if (!ItemRestrictions.IsHeldItemAllowed(pk)) - data.AddLine(GetInvalid(LItemUnreleased)); - - if (pk.Format == 3 && pk.HeldItem == 175) // Enigma Berry - VerifyEReaderBerry(data); - - if (pk.IsEgg && pk.HeldItem != 0) + var item = pk.HeldItem; + if (pk.IsEgg && item != 0) data.AddLine(GetInvalid(LItemEgg)); + + if (!ItemRestrictions.IsHeldItemAllowed(item, context: pk.Context)) + { + data.AddLine(GetInvalid(LItemUnreleased)); + } + else if (pk.Format == 3 && item == 175) // Enigma Berry + { + // A Pokémon holding this Berry cannot be traded to Pokémon Colosseum or Pokémon XD: Gale of Darkness, nor can it be stored in Pokémon Box Ruby & Sapphire. + if (pk is CK3 or XK3) + data.AddLine(GetInvalid(LItemUnreleased)); + else + VerifyEReaderBerry(data); + } } private void VerifyEReaderBerry(LegalityAnalysis data) diff --git a/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs b/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs index 2f0ef727a..a5c108ea8 100644 --- a/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs @@ -1,4 +1,4 @@ -using static PKHeX.Core.LegalityCheckStrings; +using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core; @@ -27,7 +27,7 @@ public override void Verify(LegalityAnalysis data) if (pk.OT_Gender != 0) data.AddLine(GetInvalid(LG5OTGenderN, CheckIdentifier.Trainer)); - if (pk.IVTotal != 30*6) + if (!VerifyNsPKMIVsValid(pk)) data.AddLine(GetInvalid(LG5IVAll30, CheckIdentifier.IVs)); if (!VerifyNsPKMOTValid(pk)) data.AddLine(GetInvalid(LG5ID_N, CheckIdentifier.Trainer)); @@ -35,6 +35,12 @@ public override void Verify(LegalityAnalysis data) data.AddLine(GetInvalid(LG5PIDShinyN, CheckIdentifier.Shiny)); } + private static bool VerifyNsPKMIVsValid(PKM pk) + { + // All are 30. + return pk.IV_HP == 30 && pk.IV_ATK == 30 && pk.IV_DEF == 30 && pk.IV_SPA == 30 && pk.IV_SPD == 30 && pk.IV_SPE == 30; + } + private static bool VerifyNsPKMOTValid(PKM pk) { if (pk.TID != 00002 || pk.SID != 00000) diff --git a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs index 462328aeb..aa9bd962f 100644 --- a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs @@ -153,25 +153,6 @@ private static void VerifyEC(LegalityAnalysis data) } } - /// - /// Returns the expected for a Gen3-5 transfer to Gen6. - /// - /// Entity to check - /// PID result - /// True if the is appropriate to use. - public static bool GetTransferPID(PKM pk, out uint pid) - { - var ver = pk.Version; - if (ver is 0 or >= (int) GameVersion.X) // Gen6+ ignored - { - pid = 0; - return false; - } - - var _ = GetExpectedTransferPID(pk, out pid); - return true; - } - /// /// Returns the expected for a Gen3-5 transfer to Gen6. /// diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs index 4f98907b1..5c557bd5d 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs @@ -2,9 +2,16 @@ namespace PKHeX.Core; +/// +/// List using a fixed-size span to store results. Only exposes ; the span is hidden, and only accessible if the span was already a known instance. +/// public ref struct RibbonResultList { private readonly Span Span; + + /// + /// Count of results that were added to the span. + /// public int Count { get; private set; } public RibbonResultList(Span span) @@ -13,11 +20,7 @@ public RibbonResultList(Span span) Count = 0; } - private void Add(RibbonResult item) - { - Span[Count] = item; - ++Count; - } + private void Add(RibbonResult item) => Span[Count++] = item; public void Add(RibbonIndex index, bool missing = false) => Add(new(index, missing)); public void Add(RibbonIndex3 index, bool missing = false) => Add(new(index, missing)); diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierEvent3.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierEvent3.cs index 790d98bbc..520a837f9 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierEvent3.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierEvent3.cs @@ -42,8 +42,9 @@ public static void Parse(this IRibbonSetEvent3 r, RibbonVerifierArguments args, if (r.RibbonEarth && enc.Generation != 3) list.Add(Earth); - if (r.RibbonNational != RibbonRules.GetValidRibbonStateNational(args.Entity, enc)) - list.Add(National); + var nationalRequired = RibbonRules.GetValidRibbonStateNational(args.Entity, enc); + if (r.RibbonNational != nationalRequired) + list.Add(National, nationalRequired); if (r.RibbonCountry) list.Add(Country); if (r.RibbonChampionBattle) diff --git a/PKHeX.Core/PKM/Interfaces/IAwakened.cs b/PKHeX.Core/PKM/Interfaces/IAwakened.cs index f07fbfad0..014fa94ae 100644 --- a/PKHeX.Core/PKM/Interfaces/IAwakened.cs +++ b/PKHeX.Core/PKM/Interfaces/IAwakened.cs @@ -208,11 +208,12 @@ public static bool IsAwakeningAboveOrEqual(this IAwakened current, IAwakened ini /// Entity to check public static void GetExpectedMinimumAVs(Span result, PB7 pk) { - // go park transfers have 2 AVs for all stats. - // leveling up in-game applies 1 AV to a "random" index. + // GO Park transfers start with 2 AVs for all stats. + // Every other encounter is either all 0, or can legally start at 0 (trades). if (pk.Version == (int)GameVersion.GO) result.Fill(2); + // Leveling up in-game applies 1 AV to a "random" index. var start = pk.Met_Level; var end = pk.CurrentLevel; if (start == end)