diff --git a/PKHeX.Core/Game/GameUtil.cs b/PKHeX.Core/Game/GameUtil.cs
index 0ca4ebe76..f44ddcc2a 100644
--- a/PKHeX.Core/Game/GameUtil.cs
+++ b/PKHeX.Core/Game/GameUtil.cs
@@ -14,13 +14,13 @@ namespace PKHeX.Core
/// List of possible values a can have.
///
/// Ordered roughly by most recent games first.
- public static readonly IReadOnlyList GameVersions = ((GameVersion[])Enum.GetValues(typeof(GameVersion))).Where(z => z < RB && z > 0).Reverse().ToArray();
+ public static readonly IReadOnlyList GameVersions = ((GameVersion[])Enum.GetValues(typeof(GameVersion))).Where(IsValidSavedVersion).Reverse().ToArray();
///
/// Indicates if the value is a value used by the games or is an aggregate indicator.
///
/// Game to check
- public static bool IsValidSavedVersion(this GameVersion game) => 0 < game && game <= RB;
+ public static bool IsValidSavedVersion(this GameVersion game) => game is > 0 and <= HighestGameID;
///
/// Most recent game ID utilized by official games.
diff --git a/PKHeX.Core/Legality/Areas/EncounterArea1.cs b/PKHeX.Core/Legality/Areas/EncounterArea1.cs
index 609973342..0e54491db 100644
--- a/PKHeX.Core/Legality/Areas/EncounterArea1.cs
+++ b/PKHeX.Core/Legality/Areas/EncounterArea1.cs
@@ -41,7 +41,7 @@ namespace PKHeX.Core
public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyList chain)
{
- int rate = pkm is PK1 pk1 && pkm.Gen1_NotTradeback ? pk1.Catch_Rate : -1;
+ int rate = pkm is PK1 {Gen1_NotTradeback: true} pk1 ? pk1.Catch_Rate : -1;
foreach (var slot in Slots)
{
foreach (var evo in chain)
diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8.cs b/PKHeX.Core/Legality/Areas/EncounterArea8.cs
index 9184211ca..25ba7f25f 100644
--- a/PKHeX.Core/Legality/Areas/EncounterArea8.cs
+++ b/PKHeX.Core/Legality/Areas/EncounterArea8.cs
@@ -85,12 +85,12 @@ namespace PKHeX.Core
}
}
- public static bool IsWildArea(int loc) => IsWildArea8(loc) || IsWildArea8Armor(loc) || IsWildArea8Crown(loc);
- public static bool IsBoostedArea60(int loc) => IsWildArea(loc);
+ public static bool IsWildArea(int location) => IsWildArea8(location) || IsWildArea8Armor(location) || IsWildArea8Crown(location);
+ public static bool IsBoostedArea60(int location) => IsWildArea(location);
- private static bool IsWildArea8(int loc) => 122 <= loc && loc <= 154; // Rolling Fields -> Lake of Outrage
- private static bool IsWildArea8Armor(int loc) => 164 <= loc && loc <= 194; // Fields of Honor -> Honeycalm Island
- private static bool IsWildArea8Crown(int loc) => 204 <= loc && loc <= 234 && loc != 206; // Slippery Slope -> Dyna Tree Hill, skip Freezington
+ private static bool IsWildArea8(int location) => location is >= 122 and <= 154; // Rolling Fields -> Lake of Outrage
+ private static bool IsWildArea8Armor(int location) => location is >= 164 and <= 194; // Fields of Honor -> Honeycalm Island
+ private static bool IsWildArea8Crown(int location) => location is >= 204 and <= 234 and not 206; // Slippery Slope -> Dyna Tree Hill, skip Freezington
// Location, and areas that it can feed encounters to.
public static readonly IReadOnlyDictionary> ConnectingArea8 = new Dictionary>
diff --git a/PKHeX.Core/Legality/BulkAnalysis.cs b/PKHeX.Core/Legality/BulkAnalysis.cs
index f1bbbf877..9bdfb305f 100644
--- a/PKHeX.Core/Legality/BulkAnalysis.cs
+++ b/PKHeX.Core/Legality/BulkAnalysis.cs
@@ -160,7 +160,7 @@ namespace PKHeX.Core
continue; // already flagged
var cp = AllData[i];
var ca = AllAnalysis[i];
- bool g345 = 3 <= ca.Info.Generation && ca.Info.Generation <= 5;
+ bool g345 = ca.Info.Generation is 3 or 4 or 5;
var id = g345 ? cp.EncryptionConstant : cp.PID;
if (!dict.TryGetValue(id, out var pa))
@@ -210,7 +210,7 @@ namespace PKHeX.Core
{
const CheckIdentifier ident = PID;
int gen = pa.Info.Generation;
- bool gbaNDS = 3 <= gen && gen <= 5;
+ bool gbaNDS = gen is 3 or 4 or 5;
if (!gbaNDS)
{
@@ -245,7 +245,7 @@ namespace PKHeX.Core
return;
}
- bool gbaNDS = 3 <= gen && gen <= 5;
+ bool gbaNDS = gen is 3 or 4 or 5;
if (!gbaNDS)
{
AddLine(pa.pkm, ca.pkm, "PID sharing for 3DS-onward origin detected.", ident);
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs
index 0dad1773c..87295a394 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs
@@ -276,19 +276,6 @@ namespace PKHeX.Core
new() { Roaming = true, Species = 146, Level = 60, TypeEncounter = EncounterType.TallGrass | EncounterType.Surfing_Fishing, Version = Pt }, // Moltres
};
- internal static readonly EncounterStatic4 SpikyEaredPichu = new() // Spiky-Eared Pichu @ Ilex Forest
- {
- Species = 172,
- Level = 30,
- Gender = 1,
- Form = 1,
- Nature = Nature.Naughty,
- Location = 214,
- Moves = new[] { 344, 270, 207, 220 },
- TypeEncounter = EncounterType.Starter_Fossil_Gift_Pt_DPTrio,
- Shiny = Shiny.Never
- };
-
private static readonly EncounterStatic4[] Encounter_HGSS =
{
// Starters
@@ -344,7 +331,19 @@ namespace PKHeX.Core
new() { Species = 143, Level = 50, Location = 159, }, // Snorlax @ Route 11
new() { Species = 143, Level = 50, Location = 160, }, // Snorlax @ Route 12
new() { Species = 185, Level = 20, Location = 184, }, // Sudowoodo @ Route 36, Encounter does not have type
- SpikyEaredPichu,
+
+ new() // Spiky-Eared Pichu @ Ilex Forest
+ {
+ Species = 172,
+ Level = 30,
+ Gender = 1,
+ Form = 1,
+ Nature = Nature.Naughty,
+ Location = 214,
+ Moves = new[] { 344, 270, 207, 220 },
+ TypeEncounter = EncounterType.Starter_Fossil_Gift_Pt_DPTrio,
+ Shiny = Shiny.Never
+ },
// Stationary Legendary
new() { Species = 144, Level = 50, Location = 203, TypeEncounter = EncounterType.Cave_HallOfOrigin }, // Articuno @ Seafoam Islands
diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs
index dd1c2b018..335c5c0c3 100644
--- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs
+++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs
@@ -98,7 +98,7 @@ namespace PKHeX.Core
// Let it get picked up as regular EncounterEgg under other conditions.
if (pkm.Format > 2)
return false;
- if (pkm.Move1 != Dizzy && pkm.Move2 != Dizzy && pkm.Move3 != Dizzy && pkm.Move4 != Dizzy)
+ if (!pkm.HasMove(Dizzy))
return false;
if (pkm.IsEgg && pkm.EXP != 125)
return false;
diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs
index f3e9ce027..4378aafc8 100644
--- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs
+++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs
@@ -25,7 +25,7 @@ namespace PKHeX.Core
return false;
if (IVs.Count != 0 && !Legal.GetIsFixedIVSequenceValidNoRand(IVs, pkm))
return false;
- if (pkm.Format == 2 && pkm.Met_Location != 0 && pkm.Met_Location != 126)
+ if (pkm.Format == 2 && pkm.Met_Location is not 0 and not 126)
return false;
}
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs
index fab80b27d..d156af51e 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs
@@ -207,7 +207,7 @@ namespace PKHeX.Core
{
foreach (var z in GetValidStaticEncounter(pkm, chain))
{
- if (z.Gift && pkm.Ball != 4)
+ if (z.Gift && pkm.Ball != z.Ball)
deferIncompat.Enqueue(z);
else
yield return z;
@@ -269,7 +269,7 @@ namespace PKHeX.Core
{
foreach (var z in GetValidStaticEncounter(pkm, chain))
{
- if (z.Gift && pkm.Ball != 4)
+ if (z.Gift && pkm.Ball != z.Ball)
deferIncompat.Enqueue(z);
else
yield return z;
diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs
index 88376e15a..ce230916f 100644
--- a/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs
+++ b/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs
@@ -35,8 +35,6 @@ namespace PKHeX.Core
int species = pkm.Species;
if (info.EncounterMatch.Species == species)
return true;
- if (info.EncounterMatch.EggEncounter && species == (int)Species.Milotic && pkm.Format >= 5 && !pkm.IsUntraded) // Prism Scale
- return true;
if (species == (int)Species.Vespiquen && info.Generation < 6 && (pkm.PID & 0xFF) >= 0x1F) // Combee->Vespiquen Invalid Evolution
return false;
diff --git a/PKHeX.Core/Legality/RNG/MethodFinder.cs b/PKHeX.Core/Legality/RNG/MethodFinder.cs
index 81a671362..68f77d020 100644
--- a/PKHeX.Core/Legality/RNG/MethodFinder.cs
+++ b/PKHeX.Core/Legality/RNG/MethodFinder.cs
@@ -286,7 +286,7 @@ namespace PKHeX.Core
private static bool GetChannelMatch(uint top, uint bot, uint[] IVs, out PIDIV pidiv, PKM pk)
{
var ver = pk.Version;
- if (ver != (int) GameVersion.R && ver != (int) GameVersion.S)
+ if (ver is not (int) GameVersion.R and not (int) GameVersion.S)
return GetNonMatch(out pidiv);
var undo = top ^ 0x8000;
@@ -526,7 +526,7 @@ namespace PKHeX.Core
private static bool GetColoStarterMatch(PKM pk, uint top, uint bot, uint[] IVs, out PIDIV pidiv)
{
- if (pk.Version != 15 || (pk.Species != 196 && pk.Species != 197))
+ if (pk.Version != (int)GameVersion.CXD || pk.Species is not (int)Species.Espeon and not (int)Species.Umbreon)
return GetNonMatch(out pidiv);
var iv1 = GetIVChunk(IVs, 0);
@@ -862,11 +862,12 @@ namespace PKHeX.Core
{
switch (encounter)
{
- case EncounterStatic s:
- if (s == Encounters4.SpikyEaredPichu || (s.Location == Locations.PokeWalker4 && s.Gift)) // Pokewalker
- return val == PIDType.Pokewalker;
- if (s.Shiny == Shiny.Always)
+ case EncounterStatic4Pokewalker:
+ case EncounterStatic4 {Species: (int)Species.Pichu}:
+ return val == PIDType.Pokewalker;
+ case EncounterStatic4 {Shiny: Shiny.Always}:
return val == PIDType.ChainShiny;
+ case EncounterStatic4:
if (val == PIDType.CuteCharm && IsCuteCharm4Valid(encounter, pkm))
return true;
return val == PIDType.Method_1;
@@ -879,9 +880,7 @@ namespace PKHeX.Core
return false;
// Chain shiny with poke radar is only possible in DPPt in tall grass, safari zone do not allow pokeradar
// TypeEncounter TallGrass discard any cave or city
- var ver = (GameVersion)pkm.Version;
- var IsDPPt = ver is GameVersion.D or GameVersion.P or GameVersion.Pt;
- return pkm.IsShiny && IsDPPt && sl.TypeEncounter == EncounterType.TallGrass && !Locations.IsSafariZoneLocation4(sl.Location);
+ return pkm.IsShiny && !pkm.HGSS && sl.TypeEncounter == EncounterType.TallGrass && !Locations.IsSafariZoneLocation4(sl.Location);
case PGT: // manaphy
return IsG4ManaphyPIDValid(val, pkm);
case PCD d when d.Gift.PK.PID != 1:
@@ -924,7 +923,7 @@ namespace PKHeX.Core
return true;
}
- private static bool IsCuteCharmAzurillMale(uint pid) => pid >= 0xC8 && pid <= 0xE0;
+ private static bool IsCuteCharmAzurillMale(uint pid) => pid is >= 0xC8 and <= 0xE0;
private static void GetCuteCharmGenderSpecies(PKM pk, uint pid, out int genderValue, out int species)
{
diff --git a/PKHeX.Core/Legality/RNG/PIDGenerator.cs b/PKHeX.Core/Legality/RNG/PIDGenerator.cs
index d647fd42d..30faf91f2 100644
--- a/PKHeX.Core/Legality/RNG/PIDGenerator.cs
+++ b/PKHeX.Core/Legality/RNG/PIDGenerator.cs
@@ -13,7 +13,7 @@ namespace PKHeX.Core
if (skipBetweenPID) // VBlank skip between PID rand() [RARE]
B = rng.Next(B);
- var swappedPIDHalves = PIDType.Method_1_Unown <= type && type <= PIDType.Method_4_Unown;
+ var swappedPIDHalves = type is >= PIDType.Method_1_Unown and <= PIDType.Method_4_Unown;
if (swappedPIDHalves) // switched order of PID halves, "BA.."
pk.PID = (A & 0xFFFF0000) | B >> 16;
else
diff --git a/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs b/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs
index b59bc43ee..6b1ac4867 100644
--- a/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs
@@ -52,7 +52,7 @@ namespace PKHeX.Core
// Check AbilityNumber for transfers without unique abilities
int gen = data.Info.Generation;
- if (3 <= gen && gen <= 5 && num != 4)
+ if (gen is 3 or 4 or 5 && num != 4)
{
// To determine AbilityNumber [PK5->PK6], check if the first ability in Personal matches the ability.
// It is not possible to flip it to the other index as capsule requires unique abilities.
diff --git a/PKHeX.Core/Legality/Verifiers/CXDVerifier.cs b/PKHeX.Core/Legality/Verifiers/CXDVerifier.cs
index f8aee0e87..4a95ed6b0 100644
--- a/PKHeX.Core/Legality/Verifiers/CXDVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/CXDVerifier.cs
@@ -24,8 +24,8 @@ namespace PKHeX.Core
private static void VerifyCXDStarterCorrelation(LegalityAnalysis data)
{
var pidiv = data.Info.PIDIV;
- if (pidiv.Type != PIDType.CXD && pidiv.Type != PIDType.CXDAnti)
- return;
+ if (pidiv.Type is not PIDType.CXD and not PIDType.CXDAnti)
+ return; // already flagged as invalid
bool valid;
var EncounterMatch = data.EncounterMatch;
diff --git a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs
index c5e1896d5..714d6099e 100644
--- a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs
@@ -215,11 +215,11 @@ namespace PKHeX.Core
public static int GetArceusFormFromHeldItem(int item, int format)
{
- if (777 <= item && item <= 793)
+ if (item is >= 777 and <= 793)
return Array.IndexOf(Arceus_ZCrystal, (ushort)item) + 1;
int form = 0;
- if ((298 <= item && item <= 313) || item == 644)
+ if (item is >= 298 and <= 313 or 644)
form = Array.IndexOf(Arceus_PlateIDs, (ushort)item) + 1;
if (format == 4 && form >= 9)
return form + 1; // ??? type Form shifts everything by 1
diff --git a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs
index 11d924400..7bbf34e49 100644
--- a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs
@@ -75,7 +75,7 @@ namespace PKHeX.Core
data.AddLine(Get(msg, Severity.Fishy));
return true;
}
- if (pkm.Format <= 7 && StringConverter.HasEastAsianScriptCharacters(nickname) && !(pkm is PB7)) // East Asian Scripts
+ if (pkm.Format <= 7 && StringConverter.HasEastAsianScriptCharacters(nickname) && pkm is not PB7) // East Asian Scripts
{
data.AddLine(GetInvalid(LNickInvalidChar));
return true;
diff --git a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs
index de7c0b8af..26c56da68 100644
--- a/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/PIDVerifier.cs
@@ -42,7 +42,7 @@ namespace PKHeX.Core
// Underground Raids are originally anti-shiny on encounter.
// When selecting a prize at the end, the game rolls and force-shiny is applied to be XOR=1.
var xor = pkm.ShinyXor;
- if (xor <= 15 && xor != 1)
+ if (xor is <= 15 and not 1)
data.AddLine(GetInvalid(LEncStaticPIDShiny, CheckIdentifier.Shiny));
break;
}
diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifier.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifier.cs
index 9d559d774..85b28bc97 100644
--- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifier.cs
@@ -129,7 +129,7 @@ namespace PKHeX.Core
}
if (pkm is IRibbonSetCommon4 s4)
{
- bool inhabited4 = 3 <= gen && gen <= 4;
+ bool inhabited4 = gen is 3 or 4;
var iterate = GetInvalidRibbons4Any(pkm, s4, gen);
if (!inhabited4)
iterate = iterate.Concat(GetInvalidRibbonsNone(s4.RibbonBitsOnly(), s4.RibbonNamesOnly()));
@@ -138,7 +138,7 @@ namespace PKHeX.Core
}
if (pkm is IRibbonSetCommon6 s6)
{
- bool inhabited6 = 3 <= gen && gen <= 6;
+ bool inhabited6 = gen is >= 3 and <= 6;
var iterate = inhabited6
? GetInvalidRibbons6Any(pkm, s6, gen, enc)
diff --git a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs
index 24a615941..705511e0f 100644
--- a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs
@@ -181,7 +181,7 @@ namespace PKHeX.Core
{
if ('0' <= c)
return c <= '9';
- return c <= '9' && '0' <= c;
+ return c is >= '0' and <= '9';
}
return str.Count(IsNumber);
diff --git a/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs b/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs
index e370583fe..af3480133 100644
--- a/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/TransferVerifier.cs
@@ -59,11 +59,11 @@ namespace PKHeX.Core
return growth switch
{
0 => // MediumFast -- Can't be Brave, Adamant, Naughty, Bold, Docile, or Relaxed
- (nature < (int) Nature.Brave || nature > (int) Nature.Relaxed),
+ (nature is < (int) Nature.Brave or > (int) Nature.Relaxed),
4 => // Fast -- Can't be Gentle, Sassy, Careful, Quirky, Hardy, Lonely, Brave, Adamant, Naughty, or Bold
- (nature < (int) Nature.Gentle && nature > (int) Nature.Bold),
+ (nature is < (int) Nature.Gentle and > (int) Nature.Bold),
5 => // Slow -- Can't be Impish or Lax
- (nature != (int) Nature.Impish && nature != (int) Nature.Lax),
+ (nature is not (int) Nature.Impish and not (int) Nature.Lax),
_ => true
};
}
@@ -73,7 +73,7 @@ namespace PKHeX.Core
// Star, not square. Requires transferring a shiny and having the initially random PID to already be a Star shiny.
// (15:65536, ~1:4096) odds on a given shiny transfer!
var xor = data.pkm.ShinyXor;
- if (xor < 16 && xor != 0)
+ if (xor is <= 15 and not 0)
data.AddLine(Get(LEncStaticPIDShiny, ParseSettings.Gen7TransferStarPID, CheckIdentifier.PID));
}
@@ -103,11 +103,11 @@ namespace PKHeX.Core
switch (pkm.Species)
{
case (int)Species.Celebi:
- if (loc != Locations.Transfer4_CelebiUnused && loc != Locations.Transfer4_CelebiUsed)
+ if (loc is not Locations.Transfer4_CelebiUnused and not Locations.Transfer4_CelebiUsed)
data.AddLine(GetInvalid(LTransferMet));
break;
case (int)Species.Raikou or (int)Species.Entei or (int)Species.Suicune:
- if (loc != Locations.Transfer4_CrownUnused && loc != Locations.Transfer4_CrownUsed)
+ if (loc is not Locations.Transfer4_CrownUnused and not Locations.Transfer4_CrownUsed)
data.AddLine(GetInvalid(LTransferMet));
break;
default:
@@ -195,7 +195,7 @@ namespace PKHeX.Core
}
else if (pkm.Species == (int)Species.Unown)
{
- if (pkm.Form != 8 && pkm.Form != 21 && pkm.IsShiny) // impossibly form-shiny (not I or V)
+ if (pkm.Form is not 8 and not 21 && pkm.IsShiny) // impossibly form-shiny (not I or V)
yield return GetInvalid(LEncStaticPIDShiny, CheckIdentifier.PID);
}
}
diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs
index c77ccc8cb..d2f48067e 100644
--- a/PKHeX.Core/MysteryGifts/WC8.cs
+++ b/PKHeX.Core/MysteryGifts/WC8.cs
@@ -582,8 +582,7 @@ namespace PKHeX.Core
}
if (MetLevel != 0 && MetLevel != pkm.Met_Level) return false;
- if (Ball != 0 && Ball != pkm.Ball) return false;
- if (Ball == 0 && pkm.Ball != 4) return false;
+ if ((Ball == 0 ? 4 : Ball) != pkm.Ball) return false;
if (OTGender < 2 && OTGender != pkm.OT_Gender) return false;
if (Nature != -1 && pkm.Nature != Nature) return false;
if (Gender != 3 && Gender != pkm.Gender) return false;
diff --git a/PKHeX.Core/PKM/Searching/SearchUtil.cs b/PKHeX.Core/PKM/Searching/SearchUtil.cs
index a226c7987..bc0879cd9 100644
--- a/PKHeX.Core/PKM/Searching/SearchUtil.cs
+++ b/PKHeX.Core/PKM/Searching/SearchUtil.cs
@@ -62,7 +62,7 @@ namespace PKHeX.Core.Searching
{
1 => res.Where(pk => pk.EVTotal == 0), // None (0)
2 => res.Where(pk => pk.EVTotal < 128), // Some (127-0)
- 3 => res.Where(pk => pk.EVTotal >= 128 && pk.EVTotal < 508), // Half (128-507)
+ 3 => res.Where(pk => pk.EVTotal is >= 128 and < 508), // Half (128-507)
4 => res.Where(pk => pk.EVTotal >= 508), // Full (508+)
_ => res
};
@@ -73,9 +73,9 @@ namespace PKHeX.Core.Searching
return option switch
{
1 => res.Where(pk => pk.IVTotal <= 90), // <= 90
- 2 => res.Where(pk => pk.IVTotal > 90 && pk.IVTotal <= 120), // 91-120
- 3 => res.Where(pk => pk.IVTotal > 120 && pk.IVTotal <= 150), // 121-150
- 4 => res.Where(pk => pk.IVTotal > 150 && pk.IVTotal < 180), // 151-179
+ 2 => res.Where(pk => pk.IVTotal is > 90 and <= 120), // 91-120
+ 3 => res.Where(pk => pk.IVTotal is > 120 and <= 150), // 121-150
+ 4 => res.Where(pk => pk.IVTotal is > 150 and < 180), // 151-179
5 => res.Where(pk => pk.IVTotal >= 180), // 180+
6 => res.Where(pk => pk.IVTotal == 186), // == 186
_ => res
diff --git a/PKHeX.Core/PKM/Shared/G3PKM.cs b/PKHeX.Core/PKM/Shared/G3PKM.cs
index b6eb310de..be91f3b89 100644
--- a/PKHeX.Core/PKM/Shared/G3PKM.cs
+++ b/PKHeX.Core/PKM/Shared/G3PKM.cs
@@ -187,7 +187,7 @@
Unused4 = Unused4,
};
- if (pk is CK3 ck3 && ck3.ShadowID != 0)
+ if (pk is CK3 {ShadowID: not 0} ck3)
ck3.Purification = CK3.Purified; // purified
return pk;
}
diff --git a/PKHeX.Core/PKM/Strings/StringConverter.cs b/PKHeX.Core/PKM/Strings/StringConverter.cs
index 27be90152..3473a9c04 100644
--- a/PKHeX.Core/PKM/Strings/StringConverter.cs
+++ b/PKHeX.Core/PKM/Strings/StringConverter.cs
@@ -215,7 +215,7 @@ namespace PKHeX.Core
private const ushort Gen7_ZH_Ofs = 0xE800;
private const ushort SM_ZHCharTable_Size = 0x30F;
private const ushort USUM_CHS_Size = 0x4;
- private static bool GetisG7CHSChar(int idx) => idx < SM_ZHCharTable_Size || (SM_ZHCharTable_Size * 2 <= idx && idx < (SM_ZHCharTable_Size * 2) + USUM_CHS_Size);
+ private static bool GetisG7CHSChar(int idx) => idx is < SM_ZHCharTable_Size or >= SM_ZHCharTable_Size * 2 and < (SM_ZHCharTable_Size * 2) + USUM_CHS_Size;
private static readonly Dictionary G7_CHS = Gen7_ZH
.Select((value, index) => new { value, index })
@@ -277,7 +277,7 @@ namespace PKHeX.Core
var context = str.Except(FullToHalf);
bool fullwidth = context.Select(c => c >> 12) // select the group the char belongs to
- .Any(c => c != 0 /* Latin */ && c != 0xE /* Special Symbols */);
+ .Any(c => c is not 0 and not 0xE /* Latin, Special Symbols */);
if (fullwidth) // jp/ko/zh strings
return s; // keep as full width
@@ -289,6 +289,6 @@ namespace PKHeX.Core
private static readonly char[] FullToHalf = {'\u2640', '\u2642'}; // ♀♂
- public static bool HasEastAsianScriptCharacters(IEnumerable str) => str.Any(c => 0x4E00 <= c && c <= 0x9FFF);
+ public static bool HasEastAsianScriptCharacters(IEnumerable str) => str.Any(c => c is >= '\u4E00' and <= '\u9FFF');
}
}
diff --git a/PKHeX.Core/PKM/Strings/StringConverter12.cs b/PKHeX.Core/PKM/Strings/StringConverter12.cs
index f1a9df8ad..b629d07e3 100644
--- a/PKHeX.Core/PKM/Strings/StringConverter12.cs
+++ b/PKHeX.Core/PKM/Strings/StringConverter12.cs
@@ -53,7 +53,7 @@ namespace PKHeX.Core
///
/// Raw string bytes
/// Indication if the data is from a definitely-german string
- public static bool IsG12German(IEnumerable data) => data.Any(z => z >= 0xC0 && z <= 0xC6);
+ public static bool IsG12German(IEnumerable data) => data.Any(z => z is >= 0xC0 and <= 0xC6);
///
/// Checks if the input byte array is definitely of German origin (any ÄÖÜäöü)
diff --git a/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs b/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs
index d6bff8cce..8495569be 100644
--- a/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs
+++ b/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs
@@ -27,7 +27,7 @@ namespace PKHeX.Core
{
var val = data[offset + i];
var dict = val <= 0xB ? GSC2U_KOR[val] : RBY2U_U;
- if (val <= 0xB && val != 0)
+ if (val is <= 0xB and not 0)
val = data[offset + ++i];
if (!dict.TryGetValue(val, out var c)) // Take valid values
break;
diff --git a/PKHeX.Core/PKM/Util/PKMConverter.cs b/PKHeX.Core/PKM/Util/PKMConverter.cs
index 9394badd7..991d67d27 100644
--- a/PKHeX.Core/PKM/Util/PKMConverter.cs
+++ b/PKHeX.Core/PKM/Util/PKMConverter.cs
@@ -197,7 +197,7 @@ namespace PKHeX.Core
{
if (pk.Format >= 3 && pk.Format > format)
return false; // pk3->upward can't go backwards
- if (pk.Format <= 2 && format > 2 && format < 7)
+ if (pk.Format <= 2 && format is > 2 and < 7)
return false; // pk1/2->upward has to be 7 or greater
return true;
}
diff --git a/PKHeX.Core/PKM/Util/PKX.cs b/PKHeX.Core/PKM/Util/PKX.cs
index a576087e1..851caa2b4 100644
--- a/PKHeX.Core/PKM/Util/PKX.cs
+++ b/PKHeX.Core/PKM/Util/PKX.cs
@@ -247,7 +247,7 @@ namespace PKHeX.Core
/// Format hint that the file is.
public static int GetPKMFormatFromExtension(char last, int prefer)
{
- if ('1' <= last && last <= '9')
+ if (last is >= '1' and <= '9')
return last - '0';
return last == 'x' ? 6 : prefer;
}
diff --git a/PKHeX.Core/PKM/XK3.cs b/PKHeX.Core/PKM/XK3.cs
index f8d6b1b16..97203e10b 100644
--- a/PKHeX.Core/PKM/XK3.cs
+++ b/PKHeX.Core/PKM/XK3.cs
@@ -237,7 +237,7 @@ namespace PKHeX.Core
{
296 or 297 => metLevel != 30, // Makuhita 30 Colo 18 XD
175 or 176 => metLevel != 20, // Togepi 20 Colo 25 XD, also 20 as Togetic in Colo
- 179 or 180 or 181 => metLevel != 37 && metLevel != 30, // Mareep: 37 Colo 17 XD, Flaafy: 30 Colo
+ 179 or 180 or 181 => metLevel is not 37 and not 30, // Mareep: 37 Colo 17 XD, Flaafy: 30 Colo
219 => metLevel != 30, // Magcargo 30 Colo 38 XD (Slugma in Colo)
195 => metLevel != 30, // Quagsire 30 Colo // ** Wooper XD
334 => metLevel != 33, // Altaria 33 Colo // 36 XD (Swablu in Colo)
diff --git a/PKHeX.Core/PersonalInfo/PersonalTable.cs b/PKHeX.Core/PersonalInfo/PersonalTable.cs
index fb0aba0f6..bbd727e5b 100644
--- a/PKHeX.Core/PersonalInfo/PersonalTable.cs
+++ b/PKHeX.Core/PersonalInfo/PersonalTable.cs
@@ -224,13 +224,13 @@ namespace PKHeX.Core
{
get
{
- if (0 <= index && index < Table.Length)
- return Table[index];
- return Table[0];
+ if ((uint)index >= Table.Length)
+ return Table[0];
+ return Table[index];
}
set
{
- if (index < 0 || index >= Table.Length)
+ if ((uint)index >= Table.Length)
return;
Table[index] = value;
}
diff --git a/PKHeX.Core/Saves/MemeCrypto/MemeCrypto.cs b/PKHeX.Core/Saves/MemeCrypto/MemeCrypto.cs
index b6b932b55..7415282ea 100644
--- a/PKHeX.Core/Saves/MemeCrypto/MemeCrypto.cs
+++ b/PKHeX.Core/Saves/MemeCrypto/MemeCrypto.cs
@@ -141,7 +141,7 @@ namespace PKHeX.Core
/// The resigned save data. Invalid input returns null.
public static byte[] Resign7(byte[] sav7)
{
- if (sav7.Length != SaveUtil.SIZE_G7SM && sav7.Length != SaveUtil.SIZE_G7USUM)
+ if (sav7.Length is not SaveUtil.SIZE_G7SM and not SaveUtil.SIZE_G7USUM)
throw new ArgumentException("Should not be using this for unsupported saves.");
// Save Chunks are 0x200 bytes each; Memecrypto signature is 0x100 bytes into the 2nd to last chunk.
diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs
index 49ff16b03..5abab299b 100644
--- a/PKHeX.Core/Saves/SAV1.cs
+++ b/PKHeX.Core/Saves/SAV1.cs
@@ -23,7 +23,7 @@ namespace PKHeX.Core
public override IReadOnlyList PKMExtensions => PKM.Extensions.Where(f =>
{
int gen = f.Last() - 0x30;
- return 1 <= gen && gen <= 2;
+ return gen is 1 or 2;
}).ToArray();
public SAV1(GameVersion version = GameVersion.RBY, bool japanese = false) : base(SaveUtil.SIZE_G1RAW)
diff --git a/PKHeX.Core/Saves/SAV2.cs b/PKHeX.Core/Saves/SAV2.cs
index 3bdd555ff..016889c30 100644
--- a/PKHeX.Core/Saves/SAV2.cs
+++ b/PKHeX.Core/Saves/SAV2.cs
@@ -25,7 +25,7 @@ namespace PKHeX.Core
int gen = f.Last() - 0x30;
if (Korean)
return gen == 2;
- return 1 <= gen && gen <= 2;
+ return gen is 1 or 2;
}).ToArray();
public SAV2(GameVersion version = GameVersion.C, LanguageID lang = LanguageID.English) : base(SaveUtil.SIZE_G2RAW_J)
diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs
index 08a8d0ef9..bfa90e8a1 100644
--- a/PKHeX.Core/Saves/SAV4.cs
+++ b/PKHeX.Core/Saves/SAV4.cs
@@ -439,7 +439,7 @@ namespace PKHeX.Core
{
for (int i = 0; i < 8; i++) // 8 PGT
{
- if (value[i] is PGT g && g.CardType != 0)
+ if (value[i] is PGT {CardType: not 0})
return true;
}
for (int i = 8; i < 11; i++) // 3 PCD
diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs
index 3f5028c75..328801515 100644
--- a/PKHeX.Core/Saves/Util/SaveUtil.cs
+++ b/PKHeX.Core/Saves/Util/SaveUtil.cs
@@ -164,7 +164,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
internal static GameVersion GetIsG1SAV(byte[] data)
{
- if (data.Length != SIZE_G1RAW && data.Length != SIZE_G1BAT)
+ if (data.Length is not SIZE_G1RAW and not SIZE_G1BAT)
return Invalid;
// Check if it's not an american save or a japanese save
@@ -251,7 +251,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
internal static GameVersion GetIsG3SAV(byte[] data)
{
- if (data.Length != SIZE_G3RAW && data.Length != SIZE_G3RAWHALF)
+ if (data.Length is not SIZE_G3RAW and not SIZE_G3RAWHALF)
return Invalid;
// check the save file(s)
@@ -287,7 +287,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
internal static GameVersion GetIsG3BOXSAV(byte[] data)
{
- if (data.Length != SIZE_G3BOX && data.Length != SIZE_G3BOXGCI)
+ if (data.Length is not SIZE_G3BOX and not SIZE_G3BOXGCI)
return Invalid;
byte[] sav = data;
@@ -312,7 +312,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
internal static GameVersion GetIsG3COLOSAV(byte[] data)
{
- if (data.Length != SIZE_G3COLO && data.Length != SIZE_G3COLOGCI)
+ if (data.Length is not SIZE_G3COLO and not SIZE_G3COLOGCI)
return Invalid;
// Check the intro bytes for each save slot
@@ -331,7 +331,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
internal static GameVersion GetIsG3XDSAV(byte[] data)
{
- if (data.Length != SIZE_G3XD && data.Length != SIZE_G3XDGCI)
+ if (data.Length is not SIZE_G3XD and not SIZE_G3XDGCI)
return Invalid;
// Check the intro bytes for each save slot
@@ -416,7 +416,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
private static GameVersion GetIsG6SAV(byte[] data)
{
- if (data.Length != SIZE_G6XY && data.Length != SIZE_G6ORAS && data.Length != SIZE_G6ORASDEMO)
+ if (data.Length is not SIZE_G6XY and not SIZE_G6ORAS and not SIZE_G6ORASDEMO)
return Invalid;
if (BitConverter.ToUInt32(data, data.Length - 0x1F0) != BEEF)
@@ -434,7 +434,7 @@ namespace PKHeX.Core
/// Version Identifier or Invalid if type cannot be determined.
private static GameVersion GetIsG7SAV(byte[] data)
{
- if (data.Length != SIZE_G7SM && data.Length != SIZE_G7USUM)
+ if (data.Length is not SIZE_G7SM and not SIZE_G7USUM)
return Invalid;
if (BitConverter.ToUInt32(data, data.Length - 0x1F0) != BEEF)
diff --git a/PKHeX.Drawing/Sprites/SpriteBuilder.cs b/PKHeX.Drawing/Sprites/SpriteBuilder.cs
index 70c5fc570..08fdbac1f 100644
--- a/PKHeX.Drawing/Sprites/SpriteBuilder.cs
+++ b/PKHeX.Drawing/Sprites/SpriteBuilder.cs
@@ -123,11 +123,12 @@ namespace PKHeX.Drawing
private Image LayerOverImageItem(Image baseImage, int item, int generation)
{
- Image itemimg = (Image?)Resources.ResourceManager.GetObject(GetItemResourceName(item)) ?? UnknownItem;
- if (2 <= generation && generation <= 4 && 328 <= item && item <= 419) // gen2/3/4 TM
- itemimg = Resources.item_tm;
- else if (generation >= 8 && (1130 <= item && item <= 1229)) // Gen8 TR
- itemimg = Resources.bitem_tr;
+ Image itemimg = generation switch
+ {
+ <= 4 when item is >= 328 and <= 419 => Resources.item_tm, // gen2/3/4 TM
+ >= 8 when item is >= 1130 and <= 1229 => Resources.bitem_tr, // Gen8 TR
+ _ => (Image?)Resources.ResourceManager.GetObject(GetItemResourceName(item)) ?? UnknownItem,
+ };
// Redraw item in bottom right corner; since images are cropped, try to not have them at the edge
int x = ItemShiftX + ((ItemMaxSize - itemimg.Width) / 2);
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Pokedex5.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Pokedex5.cs
index 55fd02753..62ef97a80 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Pokedex5.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Pokedex5.cs
@@ -224,7 +224,7 @@ namespace PKHeX.WinForms
int gt = SAV.Personal[index].Gender;
CHK_P2.Checked = CHK_P4.Checked = gt != 254 && ModifierKeys != Keys.Control;
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{
@@ -305,7 +305,7 @@ namespace PKHeX.WinForms
if (mnuComplete == sender)
{
CHK_P2.Checked = CHK_P4.Checked = gt != 254; // not female only
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255; // not male only or genderless
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255; // not male only or genderless
}
else
{
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs
index fec21f0f0..66d35c490 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs
@@ -369,9 +369,10 @@ namespace PKHeX.WinForms
return;
}
- if (PKX.GetGenderFromString(CB_Form.Text) == 0 && Label_Gender.Text != gendersymbols[0])
+ var g = PKX.GetGenderFromString(CB_Form.Text);
+ if (g == 0 && Label_Gender.Text != gendersymbols[0])
CB_Form.SelectedIndex = 1;
- else if (PKX.GetGenderFromString(CB_Form.Text) == 1 && Label_Gender.Text != gendersymbols[1])
+ else if (g == 1 && Label_Gender.Text != gendersymbols[1])
CB_Form.SelectedIndex = 0;
if (species == (int)Species.Pyroar)
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexORAS.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexORAS.cs
index 46287cdbd..5fb01a224 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexORAS.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexORAS.cs
@@ -219,7 +219,7 @@ namespace PKHeX.WinForms
int gt = SAV.Personal[index].Gender;
CHK_P2.Checked = CHK_P4.Checked = gt != 254 && ModifierKeys != Keys.Control;
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{
@@ -318,7 +318,7 @@ namespace PKHeX.WinForms
if (mnuComplete == sender)
{
CHK_P2.Checked = CHK_P4.Checked = gt != 254; // not female only
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255; // not male only or genderless
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255; // not male only or genderless
}
else
{
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexXY.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexXY.cs
index 53e4d9529..0c3b85a82 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexXY.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_PokedexXY.cs
@@ -232,7 +232,7 @@ namespace PKHeX.WinForms
int gt = SAV.Personal[index].Gender;
CHK_P2.Checked = CHK_P4.Checked = gt != 254 && ModifierKeys != Keys.Control;
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{
@@ -310,7 +310,7 @@ namespace PKHeX.WinForms
if (mnuComplete == sender)
{
CHK_P2.Checked = CHK_P4.Checked = gt != 254; // not female only
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255; // not male only or genderless
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255; // not male only or genderless
}
else
{
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs
index 2b085bf23..a2c2191f6 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexGG.cs
@@ -217,7 +217,7 @@ namespace PKHeX.WinForms
int gt = Dex.GetBaseSpeciesGenderValue(LB_Species.SelectedIndex);
CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only
- CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless
+ CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt is not 0 and not 255; // Not Male-Only and Not Genderless
for (int i = 0; i < 4; i++)
CP[i + 1].Checked = Dex.GetSeen(currentSpecies, i);
@@ -339,7 +339,7 @@ namespace PKHeX.WinForms
int gt = Dex.GetBaseSpeciesGenderValue(LB_Species.SelectedIndex);
CHK_P2.Checked = CHK_P4.Checked = gt != 254 && ModifierKeys != Keys.Control;
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{
diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs
index f3a27a47b..cc1c72faa 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs
@@ -206,7 +206,7 @@ namespace PKHeX.WinForms
int gt = Dex.GetBaseSpeciesGenderValue(LB_Species.SelectedIndex);
CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = gt != 254; // Not Female-Only
- CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless
+ CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt is not 0 and not 255; // Not Male-Only and Not Genderless
for (int i = 0; i < 4; i++)
CP[i + 1].Checked = Dex.GetSeen(currentSpecies, i);
@@ -277,7 +277,7 @@ namespace PKHeX.WinForms
int gt = Dex.GetBaseSpeciesGenderValue(LB_Species.SelectedIndex);
CHK_P2.Checked = CHK_P4.Checked = gt != 254 && ModifierKeys != Keys.Control;
- CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
+ CHK_P3.Checked = CHK_P5.Checked = gt is not 0 and not 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{