diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs index 5b6543e3d..31fb86c9d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs @@ -22,21 +22,6 @@ namespace PKHeX.Core 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 ffb09db00..cf74e52a8 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs @@ -23,11 +23,6 @@ namespace PKHeX.Core OriginGroup = originGroup; } - /// - /// Gets the minimum IV (in GO) the encounter must have. - /// - public int GetMinIV() => Type.GetMinIV(); - /// /// Checks if the is compatible with the . /// @@ -49,26 +44,11 @@ namespace PKHeX.Core 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 0a4120b3c..b1a42309e 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs @@ -88,6 +88,34 @@ namespace PKHeX.Core pk.SetRandomIVsGO(Type.GetMinIV()); } - public abstract bool GetIVsValid(PKM pkm); + public bool GetIVsAboveMinimum(PKM pkm) + { + int min = Type.GetMinIV(); + return GetIVsAboveMinimum(pkm, min); + } + + private static bool GetIVsAboveMinimum(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 + } + + public static bool GetIVsValid(PKM pkm) + { + // HP * 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 + } } } diff --git a/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs b/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs index f77e0885b..b69313b54 100644 --- a/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/IndividualValueVerifier.cs @@ -109,7 +109,7 @@ namespace PKHeX.Core private void VerifyIVsGoTransfer(LegalityAnalysis data) { - if (data.EncounterMatch is EncounterSlotGO g && !g.GetIVsValid(data.pkm)) + if (data.EncounterMatch is EncounterSlotGO && EncounterSlotGO.GetIVsValid(data.pkm)) data.AddLine(GetInvalid(LIVNotCorrect)); } } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs b/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs index 36c752598..c4e63f679 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs @@ -89,9 +89,9 @@ namespace PKHeX.Core } } - public int IV1 => BitConverter.ToInt32(Data, 0x50); - public int IV2 => BitConverter.ToInt32(Data, 0x54); - public int IV3 => BitConverter.ToInt32(Data, 0x58); + public int IV_HP => BitConverter.ToInt32(Data, 0x50); + public int IV_ATK => BitConverter.ToInt32(Data, 0x54); + public int IV_DEF => BitConverter.ToInt32(Data, 0x58); public int Date => BitConverter.ToInt32(Data, 0x5C); // ####.##.## YYYY.MM.DD public int Year => Date / 1_00_00; public int Month => (Date / 1_00) % 1_00; @@ -123,12 +123,12 @@ namespace PKHeX.Core { string form = Form > 0 ? $"-{Form:00}" : string.Empty; string star = IsShiny ? " ★" : string.Empty; - return $"{Species:000}{form}{star} - {NickStr} - Lv. {Level:00} - {IV1:00}.{IV2:00}.{IV3:00} - CP {CP:0000} (Moves {Move1:000}, {Move2:000})"; + return $"{Species:000}{form}{star} - {NickStr} - Lv. {Level:00} - {IV_HP:00}.{IV_ATK:00}.{IV_DEF:00} - CP {CP:0000} (Moves {Move1:000}, {Move2:000})"; } } public string GeoTime => $"Captured in {GeoCityName} by {Username1} on {Year}/{Month:00}/{Day:00}"; - public string StatMove => $"{IV1:00}/{IV2:00}/{IV3:00}, CP {CP:0000} (Moves {Move1:000}, {Move2:000})"; + public string StatMove => $"{IV_HP:00}/{IV_ATK:00}/{IV_DEF:00}, CP {CP:0000} (Moves {Move1:000}, {Move2:000})"; public string Dump(IReadOnlyList speciesNames, int index) => $"{index:000} {Nickname} ({speciesNames[Species]}{FormString} {ShinyString}[{GenderString}]) @ Lv. {Level:00} - {StatMove}, {GeoTime}."; public PB7 ConvertToPB7(ITrainerInfo sav) => ConvertToPB7(sav, EncounterCriteria.Unrestricted); @@ -165,9 +165,9 @@ namespace PKHeX.Core pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, sav.Language, 7); } - pk.IV_DEF = pk.IV_SPD = (IV3 * 2) + 1; - pk.IV_ATK = pk.IV_SPA = (IV2 * 2) + 1; - pk.IV_HP = (IV1 * 2) + 1; + pk.IV_DEF = pk.IV_SPD = (IV_DEF * 2) + 1; + pk.IV_ATK = pk.IV_SPA = (IV_ATK * 2) + 1; + pk.IV_HP = (IV_HP * 2) + 1; pk.IV_SPE = Util.Rand.Next(32); var pi = pk.PersonalInfo;