From 4bb9e01ff9af385e2b8953b87f6af80c381e7dea Mon Sep 17 00:00:00 2001 From: javierhimura Date: Mon, 27 Mar 2017 01:36:08 +0200 Subject: [PATCH] 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; } }