From 82c8bc01bde437a5094dbc21cf99ae9c94318d37 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 18 Jun 2017 21:13:53 -0700 Subject: [PATCH] Add gen1-4 EV check for untrained pkm Rework some checks for eggs, closes #1248 GetEggHatchLevel uses Format instead of Generation; should only be used on IsEgg=true pkm --- PKHeX.Core/Legality/Checks.cs | 37 ++++++++++++------- PKHeX.Core/Legality/Core.cs | 2 +- PKHeX.Core/Legality/LegalityCheckStrings.cs | 1 + .../text/en/LegalityCheckStrings_en.txt | 3 +- .../text/ko/LegalityCheckStrings_ko.txt | 1 + .../text/zh/LegalityCheckStrings_zh.txt | 1 + 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 86799326a..06f70845e 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -343,9 +343,16 @@ private void VerifyEVs() if (evs.Any(ev => ev > 100)) // EVs can only be increased by vitamins to a max of 100. AddLine(Severity.Invalid, V367, CheckIdentifier.EVs); } + else if (pkm.Format < 6) + { + var maxEV = pkm.Format <= 2 ? 25600 : 100; // Vitamin Max + // Cannot EV train above 100 without increasing EXP + if (PKX.GetEXP(EncounterMatch.LevelMin, pkm.Species) == pkm.EXP && evs.Any(ev => ev > maxEV)) + AddLine(Severity.Invalid, string.Format(V418, maxEV), CheckIdentifier.EVs); + } // Only one of the following can be true: 0, 508, and x%6!=0 - if (sum == 0 && pkm.CurrentLevel - Math.Max(1, pkm.Met_Level) > 0) + if (sum == 0 && pkm.CurrentLevel != EncounterMatch.LevelMin) AddLine(Severity.Fishy, V23, CheckIdentifier.EVs); else if (sum == 508) AddLine(Severity.Fishy, V24, CheckIdentifier.EVs); @@ -600,31 +607,33 @@ private static IEnumerable VerifyVCEncounter(PKM pkm, int baseSpeci #endregion private void VerifyLevel() { - MysteryGift MatchedGift = EncounterMatch as MysteryGift; - if (MatchedGift != null && MatchedGift.Level != pkm.Met_Level) + if (EncounterMatch is MysteryGift gift) { - if (pkm.HasOriginalMetLocation && (!(MatchedGift is WC7) || ((WC7) MatchedGift).MetLevel != pkm.Met_Level)) + if (gift.Level != pkm.Met_Level) + if (pkm.HasOriginalMetLocation && (!(gift is WC7 wc7) || wc7.MetLevel != pkm.Met_Level)) { AddLine(new CheckResult(Severity.Invalid, V83, CheckIdentifier.Level)); return; } + if (gift.Level > pkm.CurrentLevel) + { + AddLine(new CheckResult(Severity.Invalid, V84, CheckIdentifier.Level)); + return; + } } - if (MatchedGift != null && MatchedGift.Level > pkm.CurrentLevel) + + if (pkm.IsEgg) { - AddLine(new CheckResult(Severity.Invalid, V84, CheckIdentifier.Level)); + int elvl = Legal.GetEggHatchLevel(pkm); + if (elvl != pkm.CurrentLevel) + AddLine(Severity.Invalid, string.Format(V52, elvl), CheckIdentifier.Level); return; } int lvl = pkm.CurrentLevel; - if (pkm.IsEgg) - { - int elvl = pkm.Format <= 3 ? 5 : 1; - if (elvl != lvl) - AddLine(Severity.Invalid, string.Format(V52, elvl), CheckIdentifier.Level); - } - else if (lvl < pkm.Met_Level) + if (lvl < pkm.Met_Level) AddLine(Severity.Invalid, V85, CheckIdentifier.Level); - else if (lvl > pkm.Met_Level && lvl > 1 && lvl != 100 && pkm.EXP == PKX.GetEXP(pkm.Stat_Level, pkm.Species)) + else if (EncounterMatch.LevelMin != lvl && lvl != 100 && pkm.EXP == PKX.GetEXP(lvl, pkm.Species)) AddLine(Severity.Fishy, V87, CheckIdentifier.Level); else AddLine(Severity.Valid, V88, CheckIdentifier.Level); diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 45e763260..71e089073 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -1831,7 +1831,7 @@ internal static int[] GetWildBalls(PKM pkm) return null; } } - + internal static int GetEggHatchLevel(PKM pkm) => pkm.Format <= 3 ? 5 : 1; internal static int[] GetSplitBreedGeneration(PKM pkm) { return GetSplitBreedGeneration(pkm.GenNumber); diff --git a/PKHeX.Core/Legality/LegalityCheckStrings.cs b/PKHeX.Core/Legality/LegalityCheckStrings.cs index 93b18d10a..258f5dbb2 100644 --- a/PKHeX.Core/Legality/LegalityCheckStrings.cs +++ b/PKHeX.Core/Legality/LegalityCheckStrings.cs @@ -411,6 +411,7 @@ public static class LegalityCheckStrings public static string V415 {get; set;} = "Eggs cannot have Pokéathlon stats."; // Invalid public static string V416 {get; set;} = "Mystery Gift cannot be received by this version."; // Invalid 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}."; #endregion } diff --git a/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt index eff677386..8a8baa428 100644 --- a/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX.Core/Resources/text/en/LegalityCheckStrings_en.txt @@ -309,7 +309,7 @@ V360 = Unable to match an event Egg encounter from origin game. V363 = Incompatible moves. Learned at the same level in Red/Blue and Yellow. V365 = Incompatible evolution moves. {0} Move learned at a lower level than other {1} moves. V366 = Incompatible evolution moves. {1} Move learned at a higher level than other {0} moves. -V367 = Individual EV for a level 100 encounter in Generation 4 cannot be greater than 100.public static string +V367 = Individual EV for a level 100 encounter in Generation 4 cannot be greater than 100. V368 = Eggs can not be infected with Pokérus. V369 = Invalid E-Reader Berry. V370 = Japanese E-Reader Berry in international savegame. @@ -348,3 +348,4 @@ V414 = Eggs cannot have Shiny Leaf/Crown. V415 = Eggs cannot have Pokéathlon stats. 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}. diff --git a/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt b/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt index 1d0079a86..25542b630 100644 --- a/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt +++ b/PKHeX.Core/Resources/text/ko/LegalityCheckStrings_ko.txt @@ -348,3 +348,4 @@ V414 = Eggs cannot have Shiny Leaf/Crown. V415 = Eggs cannot have Pokéathlon stats. 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}. diff --git a/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt b/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt index 3daa9ee11..9d0d30506 100644 --- a/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt +++ b/PKHeX.Core/Resources/text/zh/LegalityCheckStrings_zh.txt @@ -348,3 +348,4 @@ V414 = Eggs cannot have Shiny Leaf/Crown. V415 = Eggs cannot have Pokéathlon stats. 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}.