diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8g.cs b/PKHeX.Core/Legality/Areas/EncounterArea8g.cs index 0a7ba4dfc..a910d8889 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8g.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8g.cs @@ -117,8 +117,10 @@ public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyLi } } - private static bool IsDeferredSlot(IEncounterable slot, PKM pk) + private static bool IsDeferredSlot(EncounterSlotGO slot, PKM pk) { + if (!slot.GetIVsValid(pk)) + return true; if (slot.Species == (int) Core.Species.Wurmple) return !WurmpleUtil.IsWurmpleEvoValid(pk); diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs index 8d27e8062..637677cfa 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs @@ -24,6 +24,21 @@ protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteri pb.WeightScalar = PokeSizeUtil.GetRandomScalar(); } + public override bool GetIVsValid(PKM pkm) + { + // Stamina*2 | 1 -> HP + // ATK * 2 | 1 -> ATK&SPA + // DEF * 2 | 1 -> DEF&SPD + // Speed is random. + + // All IVs must be odd (except speed) and equal to their counterpart. + if ((pkm.GetIV(1) & 1) != 1 || pkm.GetIV(1) != pkm.GetIV(4)) // ATK=SPA + return false; + if ((pkm.GetIV(2) & 1) != 1 || pkm.GetIV(2) != pkm.GetIV(5)) // DEF=SPD + return false; + return (pkm.GetIV(0) & 1) == 1; // HP + } + protected override void SetEncounterMoves(PKM pk, GameVersion version, int level) { var moves = MoveLevelUp.GetEncounterMoves(pk, level, GameVersion.GG); diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs index 6649cdabd..cf54a4910 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs @@ -52,11 +52,26 @@ protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteri pk8.WeightScalar = PokeSizeUtil.GetRandomScalar(); } + public override bool GetIVsValid(PKM pkm) + { + var minIV = GetMinIV(); + return IsGoIVSetValid(pkm, minIV); + } + protected override void SetEncounterMoves(PKM pk, GameVersion version, int level) { var moves = MoveLevelUp.GetEncounterMoves(pk, level, OriginGroup); pk.SetMoves(moves); pk.SetMaximumPPCurrent(moves); } + + private static bool IsGoIVSetValid(PKM pkm, int min) + { + if (pkm.IV_ATK >> 1 < min) // ATK + return false; + if (pkm.IV_DEF >> 1 < min) // DEF + return false; + return pkm.IV_HP >> 1 >= min; // HP + } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs index d8583ca20..94457f7a7 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs @@ -90,5 +90,7 @@ protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteri pk.MetDate = GetRandomValidDate(); pk.SetRandomIVsGO(Type.GetMinIV()); } + + public abstract bool GetIVsValid(PKM pkm); } -} \ No newline at end of file +} diff --git a/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs b/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs index fa11fbcb1..f77e0885b 100644 --- a/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs @@ -109,41 +109,8 @@ private void VerifyIVsStatic(LegalityAnalysis data, EncounterStatic s) private void VerifyIVsGoTransfer(LegalityAnalysis data) { - var pkm = data.pkm; - if (!IsGoIVSetValid(pkm)) - { + if (data.EncounterMatch is EncounterSlotGO g && !g.GetIVsValid(data.pkm)) data.AddLine(GetInvalid(LIVNotCorrect)); - } - else if (data.EncounterMatch is EncounterSlot8GO g) - { - var minIV = g.GetMinIV(); - if (!IsGoIVSetValid(pkm, minIV)) - data.AddLine(GetInvalid(LIVNotCorrect)); - } - } - - private static bool IsGoIVSetValid(PKM pkm) - { - // Stamina*2 | 1 -> HP - // ATK * 2 | 1 -> ATK&SPA - // DEF * 2 | 1 -> DEF&SPD - // Speed is random. - - // All IVs must be odd (except speed) and equal to their counterpart. - if ((pkm.GetIV(1) & 1) != 1 || pkm.GetIV(1) != pkm.GetIV(4)) // ATK=SPA - return false; - if ((pkm.GetIV(2) & 1) != 1 || pkm.GetIV(2) != pkm.GetIV(5)) // DEF=SPD - return false; - return (pkm.GetIV(0) & 1) == 1; // HP - } - - private static bool IsGoIVSetValid(PKM pkm, int min) - { - if (pkm.IV_ATK >> 1 < min) // ATK - return false; - if (pkm.IV_DEF >> 1 < min) // DEF - return false; - return pkm.IV_HP >> 1 >= min; // HP } } -} \ No newline at end of file +} diff --git a/PKHeX.Core/Resources/byte/encounter_go_home.pkl b/PKHeX.Core/Resources/byte/encounter_go_home.pkl index 05385df42..8f46d7131 100644 Binary files a/PKHeX.Core/Resources/byte/encounter_go_home.pkl and b/PKHeX.Core/Resources/byte/encounter_go_home.pkl differ diff --git a/PKHeX.Core/Resources/byte/encounter_go_lgpe.pkl b/PKHeX.Core/Resources/byte/encounter_go_lgpe.pkl index ada0264f2..9d3e9dcd7 100644 Binary files a/PKHeX.Core/Resources/byte/encounter_go_lgpe.pkl and b/PKHeX.Core/Resources/byte/encounter_go_lgpe.pkl differ