From 9efd49b0bcee95c66ab0b71c22df092d235d8994 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 21 Jun 2017 09:18:33 -0700 Subject: [PATCH] More egg related check changes Properly check for actual held item move unhittable check (verifyMisc isnt called when parsing pk1/pk2; verifyMiscG1 is) add egg PP check, add common method to be shared between gen1 checks and GBA+ #1257 --- PKHeX.Core/Legality/Checks.cs | 34 +++++++++++++------ PKHeX.Core/Legality/LegalityCheckStrings.cs | 1 + .../text/en/LegalityCheckStrings_en.txt | 1 + .../text/ko/LegalityCheckStrings_ko.txt | 1 + .../text/zh/LegalityCheckStrings_zh.txt | 1 + 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index b60ea2cd2..3b9a49867 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -47,7 +47,7 @@ private void VerifyItem() AddLine(Severity.Invalid, V204, CheckIdentifier.Form); if (pkm.Format == 3 && pkm.HeldItem == 175) VerifyEReaderBerry(); - if (pkm.IsEgg) + if (pkm.IsEgg && pkm.HeldItem != 0) AddLine(Severity.Invalid, V419, CheckIdentifier.Egg); } private void VerifyEReaderBerry() @@ -2138,6 +2138,12 @@ private void VerifyForm() } private void VerifyMiscG1() { + if (pkm.IsEgg) + { + VerifyMiscEggCommon(); + if (pkm.PKRS_Cured || pkm.PKRS_Infected) + AddLine(Severity.Invalid, V368, CheckIdentifier.Egg); + } if (pkm.Format > 1) return; @@ -2206,12 +2212,10 @@ private void VerifyMisc() if (pkm.IsEgg) { - if (new[] {pkm.Move1_PPUps, pkm.Move2_PPUps, pkm.Move3_PPUps, pkm.Move4_PPUps}.Any(ppup => ppup > 0)) - AddLine(Severity.Invalid, V319, CheckIdentifier.Egg); + VerifyMiscEggCommon(); + if (pkm.CNTs.Any(stat => stat > 0)) AddLine(Severity.Invalid, V320, CheckIdentifier.Egg); - if (pkm.Format == 2 && (pkm.PKRS_Cured || pkm.PKRS_Infected)) - AddLine(Severity.Invalid, V368, CheckIdentifier.Egg); if (pkm is PK4 pk4) { if (pk4.ShinyLeaf != 0) @@ -2219,12 +2223,6 @@ private void VerifyMisc() if (pk4.PokéathlonStat != 0) AddLine(Severity.Invalid, V415, CheckIdentifier.Egg); } - - var HatchCycles = (EncounterMatch as EncounterStatic)?.EggCycles; - if (HatchCycles == 0 || HatchCycles == null) - HatchCycles = pkm.PersonalInfo.HatchCycles; - if (pkm.CurrentFriendship > HatchCycles) - AddLine(Severity.Invalid, V374, CheckIdentifier.Egg); } if (!Encounter.Valid) @@ -2251,6 +2249,20 @@ private void VerifyMisc() return; } } + private void VerifyMiscEggCommon() + { + if (new[] {pkm.Move1_PPUps, pkm.Move2_PPUps, pkm.Move3_PPUps, pkm.Move4_PPUps}.Any(ppup => ppup > 0)) + AddLine(Severity.Invalid, V319, CheckIdentifier.Egg); + 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)) + AddLine(Severity.Invalid, V420, CheckIdentifier.Egg); + + var HatchCycles = (EncounterMatch as EncounterStatic)?.EggCycles; + if (HatchCycles == 0 || HatchCycles == null) + HatchCycles = pkm.PersonalInfo.HatchCycles; + if (pkm.CurrentFriendship > HatchCycles) + AddLine(Severity.Invalid, V374, CheckIdentifier.Egg); + } private void VerifyFatefulMysteryGift(MysteryGift g) { if (g is PGF p && p.IsShiny) diff --git a/PKHeX.Core/Legality/LegalityCheckStrings.cs b/PKHeX.Core/Legality/LegalityCheckStrings.cs index 70cb5c765..b03938fe6 100644 --- a/PKHeX.Core/Legality/LegalityCheckStrings.cs +++ b/PKHeX.Core/Legality/LegalityCheckStrings.cs @@ -401,6 +401,7 @@ public static class LegalityCheckStrings public static string V417 {get; set;} = "Suspicious Original Trainer details."; public static string V418 {get; set;} = "Individual EV without changing EXP cannot be greater than {0}."; public static string V419 {get; set;} = "Eggs cannot hold items."; + public static string V420 {get; set;} = "Eggs cannot have modified move PP counts."; public static string V600 { get; set; } = "Invalid Ribbons: {0}"; public static string V601 { get; set; } = "Missing Ribbons: {0}"; diff --git a/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt index 020959d35..d952d4e31 100644 --- a/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt @@ -339,6 +339,7 @@ V416 = Mystery Gift cannot be received by this version. V417 = Suspicious Original Trainer details. V418 = Individual EV without changing EXP cannot be greater than {0}. V419 = Eggs cannot hold items. +V420 = Eggs cannot have modified PP counts. V602 = All ribbons accounted for. V600 = Missing Ribbons: {0} V601 = Invalid Ribbons: {0} diff --git a/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt b/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt index 3d4cfd9b8..06f5c4d3c 100644 --- a/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt +++ b/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt @@ -339,6 +339,7 @@ V416 = Mystery Gift cannot be received by this version. V417 = Suspicious Original Trainer details. V418 = Individual EV without changing EXP cannot be greater than {0}. V419 = Eggs cannot hold items. +V419 = Eggs cannot have modified PP counts. V602 = 모든 리본이 채워졌습니다. V600 = 없는 리본: {0} V601 = 사용할 수 없는 리본: {0} diff --git a/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt b/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt index 7040e4ed2..615bbda41 100644 --- a/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt +++ b/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt @@ -339,6 +339,7 @@ V416 = Mystery Gift cannot be received by this version. V417 = Suspicious Original Trainer details. V418 = Individual EV without changing EXP cannot be greater than {0}. V419 = Eggs cannot hold items. +V420 = Eggs cannot have modified PP counts. V602 = 所有奖章合法。 V600 = 缺失奖章: {0} V601 = 不合法奖章: {0}