From c704fe5625094c3243d5646ca58dbeb544870ebb Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 00:11:09 +0200 Subject: [PATCH 01/13] If pokemon is transfer from gen 3 to 4 or latter and it can be from an egg (pokeball 4, level and met level above 5, etc) check always for an egg encounter first, if does not match egg encounter then check other encounters When verify moves for this pokemon it here is a non egg possible encounter first check moves from that encounter and if does not match check egg encounters Also for gen 2 unhatched eggs ignore gen 1 encounters --- PKHeX/Legality/Checks.cs | 25 +++++++++++++++++++++++-- PKHeX/Legality/Core.cs | 11 +++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 2d60aa058..d57b774db 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -738,8 +738,19 @@ private CheckResult verifyEncounter() EncounterMatch = null; // Reset Encounter Object, test for remaining encounters } - - if (pkm.WasEgg) + + if(pkm.Gen3 && !pkm.HasOriginalMetLocation) + { + bool WasEgg = Legal.getWasEgg23(pkm) && !Legal.NoHatchFromEgg.Contains(pkm.Species); + if(WasEgg) + { + pkm.WasEgg = true; + var v = verifyEncounterEgg(); + if (v.Valid) + return v; + } + } + else if (pkm.WasEgg) return verifyEncounterEgg(); if (null != (EncounterMatch = Legal.getValidFriendSafari(pkm))) @@ -2202,6 +2213,16 @@ private CheckResult[] verifyMovesWasEggPreRelearn(int[] Moves, List[] valid { CheckResult[] res = new CheckResult[4]; + if(pkm.GenNumber == 3 && !pkm.HasOriginalMetLocation && EncounterMatch !=null) + { + if (EventGiftMatch?.Count > 1) // Multiple possible Mystery Gifts matched, get the best match too + res = parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor); + else // Everything else + res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, new int[0], GameVersion.Any); + if (res.All(r => r.Valid)) // moves is satisfactory + return res; + } + // Some games can have different egg movepools. Have to check all situations. GameVersion[] Games = { }; switch (pkm.GenNumber) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 4594a099b..a28585106 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -1090,7 +1090,7 @@ private static EncounterTrade getValidEncounterTradeVC1(PKM pkm, DexLevel[] p, E } internal static Tuple getEncounter12(PKM pkm, bool gen2) { - var g1 = getEncounter12(pkm, GameVersion.RBY); + var g1 = pkm.IsEgg ? null :getEncounter12(pkm, GameVersion.RBY); var g2 = gen2 ? getEncounter12(pkm, GameVersion.GSC) : null; if (g1 == null || g2 == null) @@ -1139,15 +1139,22 @@ internal static EncounterSlot[] getValidFriendSafari(PKM pkm) return slots.Any() ? slots.ToArray() : null; } - private static bool getWasEgg23(PKM pkm) + internal static bool getWasEgg23(PKM pkm) { + if (pkm.IsEgg) + return true; if (pkm.Format > 2 && pkm.Ball != 4) return false; + if (pkm.Format == 3) + return pkm.WasEgg; int lvl = pkm.CurrentLevel; if (lvl < 5) return false; + if(pkm.Format > 3 && pkm.Met_Level <5) + return false; + return getEvolutionValid(pkm); } From 7f21973038c40d2c3bfd7a61a810848ccf70422a Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 00:37:56 +0200 Subject: [PATCH 02/13] verifyEncounterG3Transfer function For gen 3 transfer pokemon it checks the non egg possible encounter and if the pokemon could have been hatched egg encounter Return the result from one of the two encounters that is valid, with non egg preference but marking WasEgg a True if it can be from an egg In verify moves both possible encounters are considered, there is no way to discart one or another --- PKHeX/Legality/Checks.cs | 66 ++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index d57b774db..474e205b5 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -729,7 +729,12 @@ private CheckResult verifyEncounter() if (result != null) return result; } - + + if (pkm.Gen3 && !pkm.HasOriginalMetLocation) + { + return verifyEncounterG3Transfer(); + } + if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) { var result = verifyEncounterStatic(); @@ -739,18 +744,7 @@ private CheckResult verifyEncounter() EncounterMatch = null; // Reset Encounter Object, test for remaining encounters } - if(pkm.Gen3 && !pkm.HasOriginalMetLocation) - { - bool WasEgg = Legal.getWasEgg23(pkm) && !Legal.NoHatchFromEgg.Contains(pkm.Species); - if(WasEgg) - { - pkm.WasEgg = true; - var v = verifyEncounterEgg(); - if (v.Valid) - return v; - } - } - else if (pkm.WasEgg) + if (pkm.WasEgg) return verifyEncounterEgg(); if (null != (EncounterMatch = Legal.getValidFriendSafari(pkm))) @@ -766,6 +760,52 @@ private CheckResult verifyEncounter() ? new CheckResult(Severity.Invalid, V78, CheckIdentifier.Encounter) : new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter); } + + private CheckResult verifyEncounterG3Transfer() + { + CheckResult EggResult = null; + CheckResult NonEggResult = null; + bool WasEgg = Legal.getWasEgg23(pkm) && !Legal.NoHatchFromEgg.Contains(pkm.Species); + if (WasEgg) + { + pkm.WasEgg = true; + EggResult = verifyEncounterEgg3Transfer(); + } + + if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) + { + NonEggResult = verifyEncounterStatic(); + } + + if (NonEggResult !=null) + { + EncounterMatch = null; // Reset Encounter Object, test for remaining encounters + if (null != (EncounterMatch = Legal.getValidWildEncounters(pkm))) + NonEggResult = verifyEncounterWild(); + + if (null != (EncounterMatch = Legal.getValidIngameTrade(pkm))) + NonEggResult = verifyEncounterTrade(); + } + + // Even if EggResult is not returned WasEgg is keep true to check in verifymoves first the + // non egg encounter moves and after that egg encounter moves, because there is no way to tell + // what of the two encounters was the real origin + if (EggResult != null && NonEggResult!=null) + { + // Return the valid result of both, with non egg preference, + // there is more data in the pkm for non egg encounters + if (NonEggResult.Valid) + return NonEggResult; + if (EggResult.Valid) + return EggResult; + // if both are invalid returns non egg information, because + // there is more data in the pokemon to found normal encounter + return NonEggResult; + } + + return NonEggResult ?? EggResult; + + } private CheckResult verifyVCEncounter(int baseSpecies) { // Sanitize Species to non-future species# From 6d8d6b775821c88db209909698d7d8ae8d835aba Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 00:48:50 +0200 Subject: [PATCH 03/13] Ignore NonEgg Encounter for gen 3 illegal transfer unhatched eggs --- PKHeX/Legality/Checks.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 474e205b5..9cafc3f91 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -722,6 +722,11 @@ private CheckResult verifyEncounter() if (pkm.WasLink) return verifyEncounterLink(); + if (pkm.Gen3 && !pkm.HasOriginalMetLocation) + { + return verifyEncounterG3Transfer(); + } + bool wasEvent = pkm.WasEvent || pkm.WasEventEgg; if (wasEvent) { @@ -730,11 +735,6 @@ private CheckResult verifyEncounter() return result; } - if (pkm.Gen3 && !pkm.HasOriginalMetLocation) - { - return verifyEncounterG3Transfer(); - } - if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) { var result = verifyEncounterStatic(); @@ -770,8 +770,11 @@ private CheckResult verifyEncounterG3Transfer() { pkm.WasEgg = true; EggResult = verifyEncounterEgg3Transfer(); + if (pkm.IsEgg) + return EggResult; } + // TODO: Include also gen 3 events if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) { NonEggResult = verifyEncounterStatic(); From 25180a32c5f1ae2d807134b1edffeec1cfc704c1 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:00:52 +0200 Subject: [PATCH 04/13] Include check of invalid transfer to gen 4/5 --- PKHeX/Legality/Checks.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 9cafc3f91..9d1fbcb44 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -763,6 +763,7 @@ private CheckResult verifyEncounter() private CheckResult verifyEncounterG3Transfer() { + CheckResult InvalidTransferResult = null; CheckResult EggResult = null; CheckResult NonEggResult = null; bool WasEgg = Legal.getWasEgg23(pkm) && !Legal.NoHatchFromEgg.Contains(pkm.Species); @@ -773,11 +774,16 @@ private CheckResult verifyEncounterG3Transfer() if (pkm.IsEgg) return EggResult; } + + if (pkm.Format == 4 && pkm.Met_Location != 0x37) // Pal Park + InvalidTransferResult = new CheckResult(Severity.Invalid, V60, CheckIdentifier.Encounter); + if (pkm.Format != 4 && pkm.Met_Location != 30001) + InvalidTransferResult = new CheckResult(Severity.Invalid, V61, CheckIdentifier.Encounter); // TODO: Include also gen 3 events if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) { - NonEggResult = verifyEncounterStatic(); + NonEggResult = new CheckResult(Severity.Valid, V75, CheckIdentifier.Encounter); } if (NonEggResult !=null) @@ -790,13 +796,16 @@ private CheckResult verifyEncounterG3Transfer() NonEggResult = verifyEncounterTrade(); } + // InvalidTransferResult have preference, because is invalid that from the current generation + if (InvalidTransferResult != null) + return InvalidTransferResult; + // Even if EggResult is not returned WasEgg is keep true to check in verifymoves first the // non egg encounter moves and after that egg encounter moves, because there is no way to tell // what of the two encounters was the real origin if (EggResult != null && NonEggResult!=null) { - // Return the valid result of both, with non egg preference, - // there is more data in the pkm for non egg encounters + // InvalidTransferResult have preference, because is invalid data from the current generation if (NonEggResult.Valid) return NonEggResult; if (EggResult.Valid) @@ -806,8 +815,13 @@ private CheckResult verifyEncounterG3Transfer() return NonEggResult; } - return NonEggResult ?? EggResult; + // No egg result then it can be from egg, no non egg result then return there is no valid encounter found + if (EggResult == null && NonEggResult == null) + { + return new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter); + } + return NonEggResult ?? InvalidTransferResult; } private CheckResult verifyVCEncounter(int baseSpecies) { From 8729ddf17a5bfddcdcd397a6d8289e4117a7cc00 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:15:24 +0200 Subject: [PATCH 05/13] Add verifyEncounterG4Transfer, is similar to gen3transfer but more simple, it just add an invalid transfer to gen 5 validation and return that if is wrong and there is no other wrong encounter result --- PKHeX/Legality/Checks.cs | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 9d1fbcb44..1a73c2aba 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -727,6 +727,11 @@ private CheckResult verifyEncounter() return verifyEncounterG3Transfer(); } + if (pkm.Gen4 && !pkm.HasOriginalMetLocation) + { + return verifyEncounterG3Transfer(); + } + bool wasEvent = pkm.WasEvent || pkm.WasEventEgg; if (wasEvent) { @@ -823,6 +828,57 @@ private CheckResult verifyEncounterG3Transfer() return NonEggResult ?? InvalidTransferResult; } + private CheckResult verifyEncounterG4Transfer() + { + CheckResult Gen4Result = null; + CheckResult InvalidTransferResult = null; + + var CrownLocation = -1; + var AllowCrownLocation = pkm.Gen4 && pkm.FatefulEncounter && Legal.CrownBeasts.Contains(pkm.Species); + if (AllowCrownLocation) + CrownLocation = pkm.Species == 251 ? 30010 : 30012; // Celebi : Beast + + if (pkm.Met_Location != 30001 && (!AllowCrownLocation || pkm.Met_Location != CrownLocation)) + InvalidTransferResult = new CheckResult(Severity.Invalid, V61, CheckIdentifier.Encounter); + + bool wasEvent = pkm.WasEvent || pkm.WasEventEgg; + if (wasEvent) + { + var result = verifyEncounterEvent(); + if (result != null) + Gen4Result = result; + } + + if (Gen4Result == null && null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) + { + var result = verifyEncounterStatic(); + if (result != null) + return result.Valid && InvalidTransferResult != null ? InvalidTransferResult : result; + + EncounterMatch = null; // Reset Encounter Object, test for remaining encounters + } + + if (pkm.WasEgg) // Invalid transfer is already checked in encounter egg + return verifyEncounterEgg(); + + if (Gen4Result == null && null != (EncounterMatch = Legal.getValidFriendSafari(pkm))) + Gen4Result = verifyEncounterSafari(); + + if (Gen4Result == null && null != (EncounterMatch = Legal.getValidWildEncounters(pkm))) + Gen4Result = verifyEncounterWild(); + + if (Gen4Result == null && null != (EncounterMatch = Legal.getValidIngameTrade(pkm))) + Gen4Result = verifyEncounterTrade(); + + if (Gen4Result != null && InvalidTransferResult != null) + return Gen4Result.Valid ? InvalidTransferResult : Gen4Result; + if (Gen4Result != null || InvalidTransferResult != null) + return Gen4Result ?? InvalidTransferResult; + + return wasEvent + ? new CheckResult(Severity.Invalid, V78, CheckIdentifier.Encounter) + : new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter); + } private CheckResult verifyVCEncounter(int baseSpecies) { // Sanitize Species to non-future species# From bff867ce31fc181bb1cece888bf593c8fc9db627 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:18:26 +0200 Subject: [PATCH 06/13] Add transporter or crown location text error --- PKHeX/Legality/Checks.cs | 4 ++-- PKHeX/Legality/LegalityCheckStrings.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 1a73c2aba..f3a08e7cd 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -729,7 +729,7 @@ private CheckResult verifyEncounter() if (pkm.Gen4 && !pkm.HasOriginalMetLocation) { - return verifyEncounterG3Transfer(); + return verifyEncounterG4Transfer(); } bool wasEvent = pkm.WasEvent || pkm.WasEventEgg; @@ -839,7 +839,7 @@ private CheckResult verifyEncounterG4Transfer() CrownLocation = pkm.Species == 251 ? 30010 : 30012; // Celebi : Beast if (pkm.Met_Location != 30001 && (!AllowCrownLocation || pkm.Met_Location != CrownLocation)) - InvalidTransferResult = new CheckResult(Severity.Invalid, V61, CheckIdentifier.Encounter); + InvalidTransferResult = new CheckResult(Severity.Invalid, AllowCrownLocation ? V351 : V61, CheckIdentifier.Encounter); bool wasEvent = pkm.WasEvent || pkm.WasEventEgg; if (wasEvent) diff --git a/PKHeX/Legality/LegalityCheckStrings.cs b/PKHeX/Legality/LegalityCheckStrings.cs index ecee05022..fd20169bc 100644 --- a/PKHeX/Legality/LegalityCheckStrings.cs +++ b/PKHeX/Legality/LegalityCheckStrings.cs @@ -336,7 +336,8 @@ public static class LegalityCheckStrings public static string V347 {get; set;} = "Inherited move learned by Level-up.Not expected in an event egg."; public static string V348 {get; set;} = "Inherited tutor move. Not expected in an event egg."; public static string V350 {get; set;} = "Inherited TM/HM move. Not expected in an event egg."; + public static string V351 {get; set;} = "Invalid Met Location, expected Transporter or Crown."; // Invalid #endregion - } + } } From ed681fa626c17807a07b164c1e0ad425de972b71 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:27:10 +0200 Subject: [PATCH 07/13] Crown error text --- PKHeX/Resources/text/en/LegalityCheckStrings_en.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt index d706d8f3e..7ffc3fb82 100644 --- a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt @@ -270,4 +270,5 @@ V342 = Event egg move missing. V343 = Expected the following Moves: {0} V347 = Inherited move learned by Level-up. Not expected in an event egg. V348 = Inherited tutor move. Not expected in an event egg. -V350 = Inherited TM/HM move. Not expected in an event egg. \ No newline at end of file +V350 = Inherited TM/HM move. Not expected in an event egg. +V351 = Invalid Met Location, expected Transporter or Crown. \ No newline at end of file From c93acf47674a6c62e3703313ba4aa65c77a16a92 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:28:34 +0200 Subject: [PATCH 08/13] In PK6 and PK7 defer to base properties when GenNumber < 5 for WasEgg, WasTradedEgg and WasIngameTrade --- PKHeX/PKM/PK6.cs | 6 +++--- PKHeX/PKM/PK7.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PKHeX/PKM/PK6.cs b/PKHeX/PKM/PK6.cs index 6872d60f5..898398b96 100644 --- a/PKHeX/PKM/PK6.cs +++ b/PKHeX/PKM/PK6.cs @@ -584,11 +584,11 @@ public void TradeMemory(bool Bank) // Legality Properties public override bool WasLink => Met_Location == 30011; - public override bool WasEgg => Legal.EggLocations.Contains(Egg_Location); + public override bool WasEgg => GenNumber < 5 ? base.WasEgg : Legal.EggLocations.Contains(Egg_Location); public override bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter && Species != 386; public override bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; - public override bool WasTradedEgg => Egg_Location == 30002; - public override bool WasIngameTrade => Met_Location == 30001; + public override bool WasTradedEgg => GenNumber < 5 ? base.WasEgg : Egg_Location == 30002; + public override bool WasIngameTrade => GenNumber < 5 ? base.WasEgg : Met_Location == 30001; public PK7 convertToPK7() { diff --git a/PKHeX/PKM/PK7.cs b/PKHeX/PKM/PK7.cs index 2e66ca784..500030f43 100644 --- a/PKHeX/PKM/PK7.cs +++ b/PKHeX/PKM/PK7.cs @@ -621,10 +621,10 @@ public void TradeMemory(bool Bank) // Legality Properties public override bool WasLink => Met_Location == 30011; - public override bool WasEgg => Legal.EggLocations.Contains(Egg_Location); + public override bool WasEgg => GenNumber < 5 ? base.WasEgg : Legal.EggLocations.Contains(Egg_Location); public override bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter && Species != 386; public override bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; - public override bool WasTradedEgg => Egg_Location == 30002; - public override bool WasIngameTrade => Met_Location == 30001; + public override bool WasTradedEgg => GenNumber < 5 ? base.WasEgg : Egg_Location == 30002; + public override bool WasIngameTrade => GenNumber < 5 ? base.WasEgg : Met_Location == 30001; } } From 4bb9e01ff9af385e2b8953b87f6af80c381e7dea Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:36:08 +0200 Subject: [PATCH 09/13] Better approach of WasEgg functions Private variable _WasEgg is only needed for pokemon from gen 2 and 3, for gen 4 return WasEgg if EggLocation > 0 A gen4 Legal.EggLocations array should be created in the future --- PKHeX/PKM/PK4.cs | 4 +++- PKHeX/PKM/PK5.cs | 5 ++++- PKHeX/PKM/PK6.cs | 6 +++--- PKHeX/PKM/PK7.cs | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/PKHeX/PKM/PK4.cs b/PKHeX/PKM/PK4.cs index 12429b38c..89d182a28 100644 --- a/PKHeX/PKM/PK4.cs +++ b/PKHeX/PKM/PK4.cs @@ -383,7 +383,9 @@ public override int Characteristic return pm6stat * 5 + maxIV % 5; } } - + // Legality Extensions + public override bool WasEgg => GenNumber < 4 ? base.WasEgg : Egg_Location > 0; + // Methods public override byte[] Encrypt() { diff --git a/PKHeX/PKM/PK5.cs b/PKHeX/PKM/PK5.cs index e14917bac..3b928f2fb 100644 --- a/PKHeX/PKM/PK5.cs +++ b/PKHeX/PKM/PK5.cs @@ -299,7 +299,10 @@ public override int Characteristic return pm6stat * 5 + maxIV % 5; } } - + + // Legality Extensions + public override bool WasEgg => GenNumber < 4 ? base.WasEgg : GenNumber == 4 ? Egg_Location > 0 : Legal.EggLocations.Contains(Egg_Location); + // Methods public override byte[] Encrypt() { diff --git a/PKHeX/PKM/PK6.cs b/PKHeX/PKM/PK6.cs index 898398b96..bee8a0071 100644 --- a/PKHeX/PKM/PK6.cs +++ b/PKHeX/PKM/PK6.cs @@ -584,11 +584,11 @@ public void TradeMemory(bool Bank) // Legality Properties public override bool WasLink => Met_Location == 30011; - public override bool WasEgg => GenNumber < 5 ? base.WasEgg : Legal.EggLocations.Contains(Egg_Location); + public override bool WasEgg => GenNumber < 4 ? base.WasEgg : GenNumber == 4 ? Egg_Location > 0 : Legal.EggLocations.Contains(Egg_Location); public override bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter && Species != 386; public override bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; - public override bool WasTradedEgg => GenNumber < 5 ? base.WasEgg : Egg_Location == 30002; - public override bool WasIngameTrade => GenNumber < 5 ? base.WasEgg : Met_Location == 30001; + public override bool WasTradedEgg => Egg_Location == 30002 || GenNumber == 4 && Egg_Location == 2002; + public override bool WasIngameTrade => Met_Location == 30001 || GenNumber == 4 && Egg_Location == 2001; public PK7 convertToPK7() { diff --git a/PKHeX/PKM/PK7.cs b/PKHeX/PKM/PK7.cs index 500030f43..9a576865f 100644 --- a/PKHeX/PKM/PK7.cs +++ b/PKHeX/PKM/PK7.cs @@ -621,10 +621,10 @@ public void TradeMemory(bool Bank) // Legality Properties public override bool WasLink => Met_Location == 30011; - public override bool WasEgg => GenNumber < 5 ? base.WasEgg : Legal.EggLocations.Contains(Egg_Location); + public override bool WasEgg => GenNumber < 4 ? base.WasEgg : GenNumber == 4 ? Egg_Location > 0 : Legal.EggLocations.Contains(Egg_Location); public override bool WasEvent => Met_Location > 40000 && Met_Location < 50000 || FatefulEncounter && Species != 386; public override bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1; - public override bool WasTradedEgg => GenNumber < 5 ? base.WasEgg : Egg_Location == 30002; - public override bool WasIngameTrade => GenNumber < 5 ? base.WasEgg : Met_Location == 30001; + public override bool WasTradedEgg => Egg_Location == 30002 || GenNumber == 4 && Egg_Location == 2002; + public override bool WasIngameTrade => Met_Location == 30001 || GenNumber == 4 && Egg_Location == 2001; } } From f1d4bccb09749379054fce061f228ecd4af83b70 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:38:31 +0200 Subject: [PATCH 10/13] WasEvent included in PK4 --- PKHeX/PKM/PK4.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX/PKM/PK4.cs b/PKHeX/PKM/PK4.cs index 89d182a28..0b75e248d 100644 --- a/PKHeX/PKM/PK4.cs +++ b/PKHeX/PKM/PK4.cs @@ -385,7 +385,7 @@ public override int Characteristic } // Legality Extensions public override bool WasEgg => GenNumber < 4 ? base.WasEgg : Egg_Location > 0; - + public override bool WasEvent => Met_Location >= 3000 && Met_Location <= 3076 || FatefulEncounter && Species != 386; // Methods public override byte[] Encrypt() { From a66f106aeffca9342d9af1d0ad415755fd5a5015 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:51:19 +0200 Subject: [PATCH 11/13] Detect English faraway island mew and hall of origin arceus as invalid, they are unreleased events --- PKHeX/Legality/Checks.cs | 9 +++++++++ PKHeX/Legality/LegalityCheckStrings.cs | 2 ++ PKHeX/Legality/Tables3.cs | 2 +- PKHeX/Legality/Tables4.cs | 2 +- PKHeX/Resources/text/en/LegalityCheckStrings_en.txt | 4 +++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index f3a08e7cd..7818f0cd0 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -659,6 +659,15 @@ private CheckResult verifyEncounterStatic() { var s = (EncounterStatic)EncounterMatch; + if (pkm.GenNumber == 4 && pkm.Species == 493 && s.Location == 086) + { + return new CheckResult(Severity.Invalid, V352, CheckIdentifier.Encounter); + } + if (pkm.GenNumber == 3 && pkm.Species == 151 && s.Location == 201 && pkm.Language != 1) + { + return new CheckResult(Severity.Invalid, V353, CheckIdentifier.Encounter); + } + // Re-parse relearn moves if (s.EggLocation != 60002 || vRelearn.Any(rl => !rl.Valid)) { diff --git a/PKHeX/Legality/LegalityCheckStrings.cs b/PKHeX/Legality/LegalityCheckStrings.cs index fd20169bc..d1501df74 100644 --- a/PKHeX/Legality/LegalityCheckStrings.cs +++ b/PKHeX/Legality/LegalityCheckStrings.cs @@ -337,6 +337,8 @@ public static class LegalityCheckStrings public static string V348 {get; set;} = "Inherited tutor move. Not expected in an event egg."; public static string V350 {get; set;} = "Inherited TM/HM move. Not expected in an event egg."; public static string V351 {get; set;} = "Invalid Met Location, expected Transporter or Crown."; // Invalid + public static string V352 {get; set;} = "Arceus from Hall of Origin. Unreleased event."; + public static string V353 {get; set;} = "Non japanese Mew from Faraway Island. Unreleased event."; #endregion } diff --git a/PKHeX/Legality/Tables3.cs b/PKHeX/Legality/Tables3.cs index 1c6a35ceb..7e8cca95c 100644 --- a/PKHeX/Legality/Tables3.cs +++ b/PKHeX/Legality/Tables3.cs @@ -265,7 +265,7 @@ public static partial class Legal new EncounterStatic { Species = 384, Level = 70, Location = 085, }, // Rayquaza @ Sky Pillar // Event - new EncounterStatic { Species = 151, Level = 30, Location = 201, Version = GameVersion.E, Fateful = true }, // Mew @ Faraway Island + new EncounterStatic { Species = 151, Level = 30, Location = 201, Version = GameVersion.E, Fateful = true }, // Mew @ Faraway Island (Unreleased outside of Japan) new EncounterStatic { Species = 249, Level = 70, Location = 211, Version = GameVersion.E, }, // Lugia @ Navel Rock new EncounterStatic { Species = 250, Level = 70, Location = 211, Version = GameVersion.E, }, // Ho-Oh @ Navel Rock new EncounterStatic { Species = 386, Level = 30, Location = 200, Version = GameVersion.E, Form = 3, Fateful = true }, // Deoxys @ Birth Island diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index 8c6cf3c6e..ef6589dd4 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -442,7 +442,7 @@ public static partial class Legal new EncounterStatic { Species = 491, Level = 40, Location = 079, Version = GameVersion.DP,}, //Darkrai @ Newmoon Island new EncounterStatic { Species = 491, Level = 50, Location = 079, Version = GameVersion.Pt,}, //Darkrai @ Newmoon Island new EncounterStatic { Species = 492, Form = 0, Level = 30, Location = 063, Fateful = true,}, //Shaymin @ Flower Paradise - //new EncounterStatic { Species = 493, Level = 80, Location = 086,}, //Arceus @ Hall of Origin + new EncounterStatic { Species = 493, Form = 0, Level = 80, Location = 086,}, //Arceus @ Hall of Origin (Unreleased) }; internal static readonly EncounterStatic[] Encounter_DPPt = Encounter_DPPt_Roam.SelectMany(e => e.Clone(Roaming_MetLocation_DPPt)).Concat(Encounter_DPPt_Regular).ToArray(); diff --git a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt index 7ffc3fb82..85e0c0b12 100644 --- a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt @@ -271,4 +271,6 @@ V343 = Expected the following Moves: {0} V347 = Inherited move learned by Level-up. Not expected in an event egg. V348 = Inherited tutor move. Not expected in an event egg. V350 = Inherited TM/HM move. Not expected in an event egg. -V351 = Invalid Met Location, expected Transporter or Crown. \ No newline at end of file +V351 = Invalid Met Location, expected Transporter or Crown. +V352 = Arceus from Hall of Origin. Unreleased event. +V353 = Non japanese Mew from Faraway Island. Unreleased event. \ No newline at end of file From 22e0b0f8735d61c06a42a9d479b930b3a80f4c66 Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:56:38 +0200 Subject: [PATCH 12/13] Unreleased Shaymin from Diamond and Pearl --- PKHeX/Legality/Checks.cs | 10 +++++++--- PKHeX/Legality/LegalityCheckStrings.cs | 1 + PKHeX/Legality/Tables4.cs | 2 +- PKHeX/Resources/text/en/LegalityCheckStrings_en.txt | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 7818f0cd0..419dad49e 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -659,13 +659,17 @@ private CheckResult verifyEncounterStatic() { var s = (EncounterStatic)EncounterMatch; + if (pkm.GenNumber == 3 && pkm.Species == 151 && s.Location == 201 && pkm.Language != 1) + { + return new CheckResult(Severity.Invalid, V353, CheckIdentifier.Encounter); + } if (pkm.GenNumber == 4 && pkm.Species == 493 && s.Location == 086) { return new CheckResult(Severity.Invalid, V352, CheckIdentifier.Encounter); } - if (pkm.GenNumber == 3 && pkm.Species == 151 && s.Location == 201 && pkm.Language != 1) + if (pkm.GenNumber == 4 && pkm.Species == 492 && s.Location == 063 && pkm.Version != (int)GameVersion.Pt) { - return new CheckResult(Severity.Invalid, V353, CheckIdentifier.Encounter); + return new CheckResult(Severity.Invalid, V354, CheckIdentifier.Encounter); } // Re-parse relearn moves @@ -797,7 +801,7 @@ private CheckResult verifyEncounterG3Transfer() // TODO: Include also gen 3 events if (null != (EncounterMatch = Legal.getValidStaticEncounter(pkm))) { - NonEggResult = new CheckResult(Severity.Valid, V75, CheckIdentifier.Encounter); + NonEggResult = verifyEncounterStatic(); } if (NonEggResult !=null) diff --git a/PKHeX/Legality/LegalityCheckStrings.cs b/PKHeX/Legality/LegalityCheckStrings.cs index d1501df74..7cd14a948 100644 --- a/PKHeX/Legality/LegalityCheckStrings.cs +++ b/PKHeX/Legality/LegalityCheckStrings.cs @@ -339,6 +339,7 @@ public static class LegalityCheckStrings public static string V351 {get; set;} = "Invalid Met Location, expected Transporter or Crown."; // Invalid public static string V352 {get; set;} = "Arceus from Hall of Origin. Unreleased event."; public static string V353 {get; set;} = "Non japanese Mew from Faraway Island. Unreleased event."; + public static string V354 {get; set;} = "Non Platinum Shaymin from Flower Paradise. Unreleased event."; #endregion } diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index ef6589dd4..f89b46f45 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -441,7 +441,7 @@ public static partial class Legal new EncounterStatic { Species = 490, Level = 01, EggLocation = 3001, Fateful = true, Gift = true }, //Manaphy from Pokemon Ranger new EncounterStatic { Species = 491, Level = 40, Location = 079, Version = GameVersion.DP,}, //Darkrai @ Newmoon Island new EncounterStatic { Species = 491, Level = 50, Location = 079, Version = GameVersion.Pt,}, //Darkrai @ Newmoon Island - new EncounterStatic { Species = 492, Form = 0, Level = 30, Location = 063, Fateful = true,}, //Shaymin @ Flower Paradise + new EncounterStatic { Species = 492, Form = 0, Level = 30, Location = 063, Fateful = true,}, //Shaymin @ Flower Paradise (Unreleased in Diamond and Pearl) new EncounterStatic { Species = 493, Form = 0, Level = 80, Location = 086,}, //Arceus @ Hall of Origin (Unreleased) }; internal static readonly EncounterStatic[] Encounter_DPPt = Encounter_DPPt_Roam.SelectMany(e => e.Clone(Roaming_MetLocation_DPPt)).Concat(Encounter_DPPt_Regular).ToArray(); diff --git a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt index 85e0c0b12..c9842eade 100644 --- a/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt +++ b/PKHeX/Resources/text/en/LegalityCheckStrings_en.txt @@ -273,4 +273,5 @@ V348 = Inherited tutor move. Not expected in an event egg. V350 = Inherited TM/HM move. Not expected in an event egg. V351 = Invalid Met Location, expected Transporter or Crown. V352 = Arceus from Hall of Origin. Unreleased event. -V353 = Non japanese Mew from Faraway Island. Unreleased event. \ No newline at end of file +V353 = Non japanese Mew from Faraway Island. Unreleased event. +V354 = Non Platinum Shaymin from Flower Paradise. Unreleased event. \ No newline at end of file From 8511c2a36d65b20ff1879c3c0653341c66141e3b Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 02:56:25 +0200 Subject: [PATCH 13/13] verifyEncounterEgg Fix for Manaphy egg from gen4 --- PKHeX/Legality/Checks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 419dad49e..fbec56178 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -494,7 +494,7 @@ private CheckResult verifyEncounterEvent() private CheckResult verifyEncounterEgg() { // Check Species - if (Legal.NoHatchFromEgg.Contains(pkm.Species)) + if (Legal.NoHatchFromEgg.Contains(pkm.Species) && (pkm.GenNumber != 4 || pkm.Species == 490)) return new CheckResult(Severity.Invalid, V50, CheckIdentifier.Encounter); switch (pkm.GenNumber)