More pattern matching expressions

Shapes are fancy; nested pattern checks
This commit is contained in:
Kurt 2021-04-20 02:17:28 -07:00
parent 9dfa1077ee
commit 25565e6f07
5 changed files with 9 additions and 8 deletions

View file

@ -95,7 +95,7 @@ namespace PKHeX.Core
} }
var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.pkm); var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.pkm);
if (encounter is IRelearn r && r.Relearn.Count > 0) if (encounter is IRelearn {Relearn: {Count: > 0}} r)
return r.Relearn; return r.Relearn;
return m; return m;

View file

@ -76,12 +76,12 @@ namespace PKHeX.Core
var pi8 = (PersonalInfoSWSH)pt8[species]; var pi8 = (PersonalInfoSWSH)pt8[species];
if (pi8.IsPresentInGame) if (pi8.IsPresentInGame)
{ {
bool lgpe = (species <= 151 || species is 808 or 809) && (form == 0 || ptGG[species].HasForm(form)); bool lgpe = (species is (<= 151 or 808 or 809)) && (form == 0 || ptGG[species].HasForm(form));
return lgpe ? GameVersion.GG : GameVersion.SWSH; return lgpe ? GameVersion.GG : GameVersion.SWSH;
} }
if (species <= Legal.MaxSpeciesID_7_USUM) if (species <= Legal.MaxSpeciesID_7_USUM)
{ {
bool lgpe = species <= 151 && (form == 0 || ptGG[species].HasForm(form)); bool lgpe = species is <= 151 && (form == 0 || ptGG[species].HasForm(form));
return lgpe ? GameVersion.GG : GameVersion.USUM; return lgpe ? GameVersion.GG : GameVersion.USUM;
} }

View file

@ -470,7 +470,7 @@ namespace PKHeX
internal static bool IsTradedKadabraG1(PKM pkm) internal static bool IsTradedKadabraG1(PKM pkm)
{ {
if (pkm is not PK1 pk1 || pk1.Species != (int)Kadabra) if (pkm is not PK1 {Species: (int)Kadabra} pk1)
return false; return false;
if (pk1.TradebackStatus == TradebackType.WasTradeback) if (pk1.TradebackStatus == TradebackType.WasTradeback)
return true; return true;

View file

@ -440,9 +440,10 @@ namespace PKHeX.Core
if (pkm.Version == 15 && enc is EncounterStaticShadow s) if (pkm.Version == 15 && enc is EncounterStaticShadow s)
{ {
// only require national ribbon if no longer on origin game // only require national ribbon if no longer on origin game
eb[1] = s.Version == GameVersion.XD bool untraded = s.Version == GameVersion.XD
? pkm is not XK3 x || x.RibbonNational ? pkm is XK3 {RibbonNational: false}
: pkm is not CK3 c || c.RibbonNational; : pkm is CK3 {RibbonNational: false};
eb[1] = !untraded;
} }
} }

View file

@ -444,7 +444,7 @@ namespace PKHeX.Core
} }
for (int i = 8; i < 11; i++) // 3 PCD for (int i = 8; i < 11; i++) // 3 PCD
{ {
if (value[i] is PCD d && d.Gift.CardType != 0) if (value[i] is PCD {Gift: {CardType: not 0}})
return true; return true;
} }
return false; return false;