moar is or

This commit is contained in:
Kurt 2020-12-25 12:30:26 -08:00
parent 4a8a495d04
commit ee5349ff98
80 changed files with 205 additions and 218 deletions

View file

@ -77,11 +77,12 @@ namespace PKHeX.Core
static int GetSimpleMarking(int val, int _) => val == 31 ? 1 : 0;
static int GetComplexMarking(int val, int _)
{
if (val == 31 || val == 1)
return 1;
if (val == 30 || val == 0)
return 2;
return 0;
return val switch
{
31 or 1 => 1,
30 or 0 => 2,
_ => 0,
};
}
}
}

View file

@ -639,17 +639,17 @@ namespace PKHeX.Core
switch (spec)
{
case (int)Core.Species.Basculin when form == "Blue-Striped":
case (int)Core.Species.Basculin when form is "Blue-Striped":
return "Blue";
case (int)Core.Species.Greninja when ability == 210:
return "Ash"; // Battle Bond
case (int)Core.Species.Vivillon when form == "Pokeball":
case (int)Core.Species.Vivillon when form is "Pokeball":
return "Poké Ball";
// Zygarde
case (int)Core.Species.Zygarde when form.Length == 0:
return ability == 211 ? "50%-C" : "50%";
case (int)Core.Species.Zygarde when form == "Complete":
case (int)Core.Species.Zygarde when form is "Complete":
return form;
case (int)Core.Species.Zygarde when ability == 211:
return "-C"; // Power Construct
@ -662,18 +662,18 @@ namespace PKHeX.Core
return $"C-{form}";
// Necrozma
case (int)Core.Species.Necrozma when form == "Dusk-Mane" || form == "Dusk Mane":
case (int)Core.Species.Necrozma when form is "Dusk-Mane" or "Dusk Mane":
return "Dusk";
case (int)Core.Species.Necrozma when form == "Dawn-Wings" || form == "Dawn Wings":
case (int)Core.Species.Necrozma when form is "Dawn-Wings" or "Dawn Wings":
return "Dawn";
// Toxtricity
case (int)Core.Species.Toxtricity when form == "Low-Key":
case (int)Core.Species.Toxtricity when form is "Low-Key":
return "Low Key";
// Darmanitan
case (int)Core.Species.Darmanitan:
if (form == "Galar-Zen")
if (form is "Galar-Zen")
return "Galar Zen";
return form;

View file

@ -45,7 +45,7 @@ namespace PKHeX.Core
return sav switch
{
SAV7b => source.SpeciesDataSource // LGPE: Kanto 151, Meltan/Melmetal
.Where(s => s.Value <= (int)Core.Species.Mew || s.Value == (int)Core.Species.Meltan || s.Value == (int)Core.Species.Melmetal),
.Where(s => s.Value <= (int)Core.Species.Mew || s.Value is (int)Core.Species.Meltan or (int)Core.Species.Melmetal),
_ => source.SpeciesDataSource.Where(s => s.Value <= sav.MaxSpeciesID)
};
}

View file

@ -257,7 +257,7 @@ namespace PKHeX.Core
SanitizeMetG7SM();
SanitizeMetG8SWSH();
if (lang == "es" || lang == "it")
if (lang is "es" or "it")
{
// Campeonato Mundial duplicates
for (int i = 27; i < 34; i++)

View file

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

View file

@ -225,9 +225,9 @@ namespace PKHeX.Core
// eggs/mystery gifts shouldn't share with wild encounters
var cenc = ca.Info.EncounterMatch;
bool eggMysteryCurrent = cenc is EncounterEgg || cenc is MysteryGift;
bool eggMysteryCurrent = cenc is EncounterEgg or MysteryGift;
var penc = pa.Info.EncounterMatch;
bool eggMysteryPrevious = penc is EncounterEgg || penc is MysteryGift;
bool eggMysteryPrevious = penc is EncounterEgg or MysteryGift;
if (eggMysteryCurrent != eggMysteryPrevious)
{
@ -254,9 +254,9 @@ namespace PKHeX.Core
// eggs/mystery gifts shouldn't share with wild encounters
var cenc = ca.Info.EncounterMatch;
bool eggMysteryCurrent = cenc is EncounterEgg || cenc is MysteryGift;
bool eggMysteryCurrent = cenc is EncounterEgg or MysteryGift;
var penc = pa.Info.EncounterMatch;
bool eggMysteryPrevious = penc is EncounterEgg || penc is MysteryGift;
bool eggMysteryPrevious = penc is EncounterEgg or MysteryGift;
if (eggMysteryCurrent != eggMysteryPrevious)
{

View file

@ -123,7 +123,7 @@ namespace PKHeX.Core
var slots = table.Slots;
var first = slots[0];
var extra = species
.Select(z => new EncounterSlot7b(table, z, (z == 006 || z >= 144) ? 03 : first.LevelMin, (z == 006 || z >= 144) ? 56 : first.LevelMax)).ToArray();
.Select(z => new EncounterSlot7b(table, z, (z is 006 or >= 144) ? 03 : first.LevelMin, (z is 006 or >= 144) ? 56 : first.LevelMax)).ToArray();
int count = slots.Length;
Array.Resize(ref slots, count + extra.Length);

View file

@ -21,6 +21,6 @@ namespace PKHeX.Core
/// Gets if the resulting <see cref="PKM"/> will still have a value depending on the current <see cref="format"/>.
/// </summary>
/// <remarks>Generation 6 no longer stores this value.</remarks>
public static bool HasTypeEncounter(this IEncounterTypeTile _, int format) => format == 4 || format == 5;
public static bool HasTypeEncounter(this IEncounterTypeTile _, int format) => format is 4 or 5;
}
}

View file

@ -58,7 +58,7 @@
// Amnesia Psyduck has different catch rates depending on language
if (Species == (int)Core.Species.Psyduck)
return catch_rate == (pk1.Japanese ? 167 : 168);
return catch_rate == 167 || catch_rate == 168;
return catch_rate is 167 or 168;
}
// Encounters can have different Catch Rates (RBG vs Y)

View file

@ -40,7 +40,7 @@ namespace PKHeX.Core
// Cosplay Pikachu is given from multiple locations
var loc = pkm.Met_Location;
return loc == 180 || loc == 186 || loc == 194;
return loc is 180 or 186 or 194;
}
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)

View file

@ -11,7 +11,7 @@ namespace PKHeX.Core
protected override bool IsMatchLocation(PKM pkm)
{
var loc = pkm.Met_Location;
return loc == SharedNest || loc == Watchtower;
return loc is SharedNest or Watchtower;
}
}
}

View file

@ -26,7 +26,7 @@ namespace PKHeX.Core
// Check downleveled (20-55)
if (lvl > Level)
return false;
if (lvl < 20 || lvl > 55)
if (lvl is < 20 or > 55)
return false;
return lvl % 5 == 0;
}

View file

@ -204,7 +204,7 @@ namespace PKHeX.Core
pkm.Language = (int)(pkm.Language == (int)LanguageID.German ? LanguageID.English : LanguageID.German);
break;
case 4 when Version == GameVersion.DPPt && (pkm.Version == (int)GameVersion.D || pkm.Version == (int)GameVersion.P):
case 4 when Version == GameVersion.DPPt && (pkm.Version is (int)GameVersion.D or (int)GameVersion.P):
// DP English origin are Japanese lang
pkm.Language = (int)LanguageID.Japanese;
break;

View file

@ -119,7 +119,7 @@ namespace PKHeX.Core
private static bool IsHiddenAbilitySlot(this EncounterSlot slot)
{
return slot is EncounterSlot6AO {CanDexNav: true} || slot.Area.Type == SlotType.FriendSafari || slot.Area.Type == SlotType.Horde || slot.Area.Type == SlotType.SOS;
return slot is EncounterSlot6AO {CanDexNav: true} || slot.Area.Type is SlotType.FriendSafari or SlotType.Horde or SlotType.SOS;
}
internal static EncounterSlot? GetCaptureLocation(PKM pkm)

View file

@ -167,13 +167,13 @@ namespace PKHeX.Core
// Gigantamax Pikachu, Meowth-0, and Eevee are prevented from evolving.
// Raichu cannot be evolved to the Alolan variant at this time.
BanEvo((int)Species.Raichu, 0, pkm => pkm is IGigantamax {CanGigantamax: true});
BanEvo((int)Species.Raichu, 1, pkm => (pkm is IGigantamax {CanGigantamax: true}) || pkm.Version >= (int)GP || pkm.Version == (int)GO);
BanEvo((int)Species.Raichu, 1, pkm => (pkm is IGigantamax {CanGigantamax: true}) || pkm.Version is (int)GO or >= (int)GP);
BanEvo((int)Species.Persian, 0, pkm => pkm is IGigantamax {CanGigantamax: true});
BanEvo((int)Species.Persian, 1, pkm => pkm is IGigantamax {CanGigantamax: true});
BanEvo((int)Species.Perrserker, 0, pkm => pkm is IGigantamax {CanGigantamax: true});
BanEvo((int)Species.Exeggutor, 1, pkm => pkm.Version >= (int)GP || pkm.Version == (int)GO);
BanEvo((int)Species.Marowak, 1, pkm => pkm.Version >= (int)GP || pkm.Version == (int)GO);
BanEvo((int)Species.Exeggutor, 1, pkm => pkm.Version is (int)GO or >= (int)GP);
BanEvo((int)Species.Marowak, 1, pkm => pkm.Version is (int)GO or >= (int)GP);
BanEvo((int)Species.Weezing, 0, pkm => pkm.Version >= (int)SW);
BanEvo((int)Species.MrMime, 0, pkm => pkm.Version >= (int)SW);

View file

@ -58,7 +58,7 @@ namespace PKHeX.Core
public static class EvolutionTypeExtensions
{
public static bool IsTrade(this EvolutionType t) => t == Trade || t == TradeHeldItem || t == TradeSpecies;
public static bool IsTrade(this EvolutionType t) => t is Trade or TradeHeldItem or TradeSpecies;
public static bool IsLevelUpRequired(this EvolutionType t) => t.ToString().StartsWith("LevelUp"); // don't use this
}
}

View file

@ -62,7 +62,7 @@ namespace PKHeX.Core
yield return f;
// Generate frames for other slots after the regular slots
if (info.AllowLeads && (f.Lead == LeadRequired.CuteCharm || f.Lead == LeadRequired.None))
if (info.AllowLeads && (f.Lead is LeadRequired.CuteCharm or LeadRequired.None))
list.Add(f);
}
foreach (var f in list)

View file

@ -825,13 +825,13 @@ namespace PKHeX.Core
if (val == PIDType.CXDAnti && g.Shiny == Shiny.Never && g.Method == PIDType.CXD)
return true;
// forced shiny eggs, when hatched, can lose their detectable correlation.
return g.IsEgg && !pkm.IsEgg && val == PIDType.None && (g.Method == PIDType.BACD_R_S || g.Method == PIDType.BACD_U_S);
return g.IsEgg && !pkm.IsEgg && val == PIDType.None && (g.Method is PIDType.BACD_R_S or PIDType.BACD_U_S);
case EncounterStaticShadow:
return pkm.Version == (int)GameVersion.CXD && (val == PIDType.CXD || val == PIDType.CXDAnti);
return pkm.Version == (int)GameVersion.CXD && (val is PIDType.CXD or PIDType.CXDAnti);
case EncounterStatic3 s:
return pkm.Version switch
{
(int)GameVersion.CXD => val == PIDType.CXD || val == PIDType.CXD_ColoStarter || val == PIDType.CXDAnti,
(int)GameVersion.CXD => val is PIDType.CXD or PIDType.CXD_ColoStarter or PIDType.CXDAnti,
(int)GameVersion.E => val == PIDType.Method_1, // no roamer glitch
(int)GameVersion.FR or (int)GameVersion.LG => s.Roaming ? val.IsRoamerPIDIV(pkm) : val == PIDType.Method_1, // roamer glitch
_ => s.Roaming ? val.IsRoamerPIDIV(pkm) : MethodH14.Contains(val), // RS, roamer glitch && RSBox s/w emulation => method 4 available
@ -880,7 +880,7 @@ namespace PKHeX.Core
// 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 == GameVersion.D || ver == GameVersion.P || ver == GameVersion.Pt;
var IsDPPt = ver is GameVersion.D or GameVersion.P or GameVersion.Pt;
return pkm.IsShiny && IsDPPt && sl.TypeEncounter == EncounterType.TallGrass && !Locations.IsSafariZoneLocation4(sl.Location);
case PGT: // manaphy
return IsG4ManaphyPIDValid(val, pkm);
@ -915,7 +915,7 @@ namespace PKHeX.Core
private static bool IsCuteCharm4Valid(IEncounterable encounter, PKM pkm)
{
if (pkm.Species == (int)Species.Marill || pkm.Species == (int)Species.Azumarill)
if (pkm.Species is (int)Species.Marill or (int)Species.Azumarill)
{
return !IsCuteCharmAzurillMale(pkm.PID) // recognized as not Azurill
|| encounter.Species == (int)Species.Azurill; // encounter must be male Azurill

View file

@ -9,7 +9,7 @@ namespace PKHeX.Core
var rng = RNG.LCRNG;
var A = rng.Next(seed);
var B = rng.Next(A);
var skipBetweenPID = type == PIDType.Method_3 || type == PIDType.Method_3_Unown;
var skipBetweenPID = type is PIDType.Method_3 or PIDType.Method_3_Unown;
if (skipBetweenPID) // VBlank skip between PID rand() [RARE]
B = rng.Next(B);
@ -20,12 +20,12 @@ namespace PKHeX.Core
pk.PID = (B & 0xFFFF0000) | A >> 16;
var C = rng.Next(B);
var skipIV1Frame = type == PIDType.Method_2 || type == PIDType.Method_2_Unown;
var skipIV1Frame = type is PIDType.Method_2 or PIDType.Method_2_Unown;
if (skipIV1Frame) // VBlank skip after PID
C = rng.Next(C);
var D = rng.Next(C);
var skipIV2Frame = type == PIDType.Method_4 || type == PIDType.Method_4_Unown;
var skipIV2Frame = type is PIDType.Method_4 or PIDType.Method_4_Unown;
if (skipIV2Frame) // VBlank skip between IVs
D = rng.Next(D);
@ -43,7 +43,7 @@ namespace PKHeX.Core
private static void SetValuesFromSeedBACD(PKM pk, PIDType type, uint seed)
{
var rng = RNG.LCRNG;
bool shiny = type == PIDType.BACD_R_S || type == PIDType.BACD_U_S;
bool shiny = type is PIDType.BACD_R_S or PIDType.BACD_U_S;
uint X = shiny ? rng.Next(seed) : seed;
var A = rng.Next(X);
var B = rng.Next(A);
@ -58,7 +58,7 @@ namespace PKHeX.Core
pk.PID = PID;
}
else if (type == PIDType.BACD_R_AX || type == PIDType.BACD_U_AX)
else if (type is PIDType.BACD_R_AX or PIDType.BACD_U_AX)
{
uint low = B >> 16;
pk.PID = ((A & 0xFFFF0000) ^ (((uint)pk.TID ^ (uint)pk.SID ^ low) << 16)) | low;
@ -70,7 +70,7 @@ namespace PKHeX.Core
pk.IVs = MethodFinder.GetIVsInt32(C >> 16, D >> 16);
bool antishiny = type == PIDType.BACD_R_A || type == PIDType.BACD_U_A;
bool antishiny = type is PIDType.BACD_R_A or PIDType.BACD_U_A;
while (antishiny && pk.IsShiny)
pk.PID = unchecked(pk.PID + 1);
}
@ -232,7 +232,7 @@ namespace PKHeX.Core
// Ensure nature is set to required nature without affecting shininess
pid += nature - (pid % 25);
if (gr >= 0xFE || gr == 0) // non-dual gender
if (gr is 0 or >= 0xFE) // non-dual gender
return pid;
// Ensure Gender is set to required gender without affecting other properties

View file

@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace PKHeX.Core
namespace PKHeX.Core
{
/// <summary>
/// Provides information for <see cref="IRegionOrigin.ConsoleRegion"/> and <see cref="IRegionOrigin.Country"/> data.
@ -17,17 +15,14 @@ namespace PKHeX.Core
{
return consoleRegion switch
{
0 => (country == 1), // Japan
1 => ((8 <= country && country <= 52) || ExtendedAmericas.Contains(country)), // Americas
2 => ((64 <= country && country <= 127) || ExtendedEurope.Contains(country)), // Europe
4 => (country == 144 || country == 160), // China
5 => (country == 136), // Korea
6 => (country == 144 || country == 128), // Taiwan
0 => country is 1, // Japan
1 => (8 <= country && country <= 52) || (country is 153 or 156 or 168 or 174 or 186), // Americas
2 => (64 <= country && country <= 127) || (country is 169 or 184 or 185), // Europe
4 => country is 144 or 160, // China
5 => country is 136, // Korea
6 => country is 144 or 128, // Taiwan
_ => false
};
}
private static readonly HashSet<int> ExtendedAmericas = new() { 153, 156, 168, 174, 186 };
private static readonly HashSet<int> ExtendedEurope = new() { 169, 184, 185 };
}
}

View file

@ -220,7 +220,7 @@ namespace PKHeX.Core
if (!Legal.Totem_USUM.Contains(species))
return false;
if (species == (int)Mimikyu)
return form == 2 || form == 3;
return form is 2 or 3;
if (Legal.Totem_Alolan.Contains(species))
return form == 2;
return form == 1;

View file

@ -121,7 +121,7 @@
private const int SafariLocation_FRLG = 136;
private const int SafariLocation_HGSS = 202;
private const int MarshLocation_DPPt = 52;
public static bool IsSafariZoneLocation3(int loc) => loc == SafariLocation_RSE || loc == SafariLocation_FRLG;
public static bool IsSafariZoneLocation4(int loc) => loc == MarshLocation_DPPt || loc == SafariLocation_HGSS;
public static bool IsSafariZoneLocation3(int loc) => loc is SafariLocation_RSE or SafariLocation_FRLG;
public static bool IsSafariZoneLocation4(int loc) => loc is MarshLocation_DPPt or SafariLocation_HGSS;
}
}

View file

@ -298,7 +298,7 @@ namespace PKHeX.Core
// hidden abilities
if (enc is EncounterSlot slot)
{
bool valid = slot is EncounterSlot6AO {CanDexNav: true} || slot.Area.Type == SlotType.FriendSafari || slot.Area.Type == SlotType.Horde;
bool valid = slot is EncounterSlot6AO {CanDexNav: true} || slot.Area.Type is SlotType.FriendSafari or SlotType.Horde;
if (!valid)
return GetInvalid(LAbilityMismatchHordeSafari);
}

View file

@ -209,7 +209,7 @@ namespace PKHeX.Core
{
if (!Legal.Inherit_Sport.Contains(species))
return GetInvalid(LBallSpecies);
if ((species == (int)Species.Volbeat || species == (int)Species.Illumise) && IsHiddenAndNotPossible(pkm)) // Volbeat/Illumise
if ((species is (int)Species.Volbeat or (int)Species.Illumise) && IsHiddenAndNotPossible(pkm)) // Volbeat/Illumise
return GetInvalid(LBallAbility);
return GetValid(LBallSpeciesPass);
}
@ -293,7 +293,7 @@ namespace PKHeX.Core
{
if (!Legal.Inherit_Sport.Contains(species))
return GetInvalid(LBallSpecies);
if ((species == (int)Species.Volbeat || species == (int)Species.Illumise) && IsHiddenAndNotPossible(pkm)) // Volbeat/Illumise
if ((species is (int)Species.Volbeat or (int)Species.Illumise) && IsHiddenAndNotPossible(pkm)) // Volbeat/Illumise
return GetInvalid(LBallAbility);
return GetValid(LBallSpeciesPass);
}

View file

@ -196,7 +196,7 @@ namespace PKHeX.Core
{
// We're okay here. There's also Alolan Meowth...
}
else if ((orig == (int) Species.MrMime || orig == (int)Species.MimeJr) && pkm.CurrentLevel > data.EncounterOriginal.LevelMin && Info.Generation >= 4)
else if ((orig is (int) Species.MrMime or (int)Species.MimeJr) && pkm.CurrentLevel > data.EncounterOriginal.LevelMin && Info.Generation >= 4)
{
// We're okay with a Mime Jr. that has evolved via level up.
}

View file

@ -24,7 +24,7 @@ namespace PKHeX.Core
// Korean Gen4 games can not trade with other Gen4 languages, but can use Pal Park with any Gen3 game/language.
if (pkm.Format == 4 && pkm.Gen4 && !IsValidG4Korean(currentLanguage)
&& !(data.EncounterMatch is EncounterTrade x && (x.Species == (int)Species.Pikachu || x.Species == (int)Species.Magikarp)) // ger magikarp / eng pikachu
&& !(data.EncounterMatch is EncounterTrade4 {Species: (int)Species.Pikachu or (int)Species.Magikarp}) // ger magikarp / eng pikachu
)
{
bool kor = currentLanguage == (int)LanguageID.Korean;

View file

@ -38,7 +38,7 @@ namespace PKHeX.Core
return;
}
if (Info.Generation >= 7 || Info.Generation <= 2)
if (Info.Generation is >= 7 or <= 2)
{
// Can't have any super training data if it never visited Gen6.
if (TrainCount > 0)

View file

@ -109,7 +109,7 @@ namespace PKHeX.Core
var Type_B_Match = Type_B == pi.Type2;
var first = Type_A_Match ? GetValid(LG1TypeMatch1) : GetInvalid(LG1Type1Fail);
var second = Type_B_Match || (ParseSettings.AllowGBCartEra && ((species == (int)Species.Magnemite || species == (int)Species.Magneton) && Type_B == 9)) // Steel Magnemite via Stadium2
var second = Type_B_Match || (ParseSettings.AllowGBCartEra && ((species is (int)Species.Magnemite or (int)Species.Magneton) && Type_B == 9)) // Steel Magnemite via Stadium2
? GetValid(LG1TypeMatch2) : GetInvalid(LG1Type2Fail);
data.AddLine(first);
data.AddLine(second);

View file

@ -251,7 +251,7 @@ namespace PKHeX.Core
break;
default:
if (lang == 1 && (pkm.Version == (int)GameVersion.D || pkm.Version == (int)GameVersion.P))
if (lang == 1 && (pkm.Version is (int)GameVersion.D or (int)GameVersion.P))
{
// DP English origin are Japanese lang
if (pkm.OT_Name != t.GetOT(1)) // not japanese
@ -333,7 +333,7 @@ namespace PKHeX.Core
}
else // B2W2
{
if (t.TID == Encounters5.YancyTID || t.TID == Encounters5.CurtisTID)
if (t.TID is Encounters5.YancyTID or Encounters5.CurtisTID)
VerifyTradeOTOnly(data, t);
else
VerifyTrade(data, t, lang);

View file

@ -123,7 +123,7 @@ namespace PKHeX.Core
var c4 = u4.RibbonBitsContest4();
var c4n = u4.RibbonNamesContest4();
var iter4 = (gen == 3 || gen == 4) && IsAllowedInContest4(pkm.Species) ? GetMissingContestRibbons(c4, c4n) : GetInvalidRibbonsNone(c4, c4n);
var iter4 = (gen is 3 or 4) && IsAllowedInContest4(pkm.Species) ? GetMissingContestRibbons(c4, c4n) : GetInvalidRibbonsNone(c4, c4n);
foreach (var z in iter4)
yield return z;
}
@ -207,8 +207,8 @@ namespace PKHeX.Core
if (s4.RibbonFootprint && !CanHaveFootprintRibbon(pkm, gen))
yield return new RibbonResult(nameof(s4.RibbonFootprint));
bool gen34 = gen == 3 || gen == 4;
bool not6 = pkm.Format < 6 || gen > 6 || gen < 3;
bool gen34 = gen is 3 or 4;
bool not6 = pkm.Format < 6 || gen is > 6 or < 3;
bool noDaily = !gen34 && not6;
bool noCosmetic = !gen34 && (not6 || (pkm.XY && pkm.IsUntraded));
@ -504,7 +504,7 @@ namespace PKHeX.Core
if (enc.LevelMin <= 50)
return true;
return !(enc is EncounterStaticShadow || enc is WC3);
return !(enc is EncounterStaticShadow or WC3);
}
private static bool CanHaveRibbonVictory(PKM pkm, int gen)

View file

@ -135,7 +135,7 @@ namespace PKHeX.Core
if (g is WC6 && g.CardID == 2048 && g.ItemID == 726) // Eon Ticket (OR/AS)
{
if (!(sav is SAV6AO))
if (sav is not SAV6AO)
{
message = MsgMysteryGiftSlotSpecialReject;
return false;

View file

@ -254,7 +254,7 @@ namespace PKHeX.Core
{
var egg = pkm.Egg_Location;
if (!pkm.IsEgg) // Link Trade Egg or Ranger
return egg == Locations.LinkTrade4 || egg == Locations.Ranger4;
return egg is Locations.LinkTrade4 or Locations.Ranger4;
if (egg != Locations.Ranger4)
return false;
@ -262,7 +262,7 @@ namespace PKHeX.Core
return false;
var met = pkm.Met_Location;
return met == Locations.LinkTrade4 || met == 0;
return met is Locations.LinkTrade4 or 0;
}
protected override bool IsMatchExact(PKM pkm, DexLevel evo) => false;

View file

@ -239,7 +239,7 @@ namespace PKHeX.Core
private static int GetLanguageIndex(int language)
{
var lang = (LanguageID) language;
if (lang < LanguageID.Japanese || lang == LanguageID.UNUSED_6 || lang > LanguageID.ChineseT)
if (lang is < LanguageID.Japanese or LanguageID.UNUSED_6 or > LanguageID.ChineseT)
return (int) LanguageID.English; // fallback
return lang < LanguageID.UNUSED_6 ? language - 1 : language - 2;
}

View file

@ -90,7 +90,7 @@ namespace PKHeX.Core
get
{
var type = PIDType;
if (type == Shiny.AlwaysStar || type == Shiny.AlwaysSquare)
if (type is Shiny.AlwaysStar or Shiny.AlwaysSquare)
return true;
if (type != Shiny.FixedValue)
return false;
@ -260,7 +260,7 @@ namespace PKHeX.Core
private static int GetLanguageIndex(int language)
{
var lang = (LanguageID) language;
if (lang < LanguageID.Japanese || lang == LanguageID.UNUSED_6 || lang > LanguageID.ChineseT)
if (lang is < LanguageID.Japanese or LanguageID.UNUSED_6 or > LanguageID.ChineseT)
return (int) LanguageID.English; // fallback
return lang < LanguageID.UNUSED_6 ? language - 1 : language - 2;
}

View file

@ -170,7 +170,7 @@ namespace PKHeX.Core
pk7.OT_Friendship = pk7.HT_Friendship = PersonalTable.SM[Species].BaseFriendship;
// IVs
var special = Species == 151 || Species == 251;
var special = Species is 151 or 251;
var new_ivs = new int[6];
int flawless = special ? 5 : 3;
var rnd = Util.Rand;

View file

@ -236,7 +236,7 @@ namespace PKHeX.Core
if (!IsNicknamed)
{
int lang = SpeciesName.GetSpeciesNameLanguage(Species, Language, value, 7);
if (lang == (int)LanguageID.ChineseS || lang == (int)LanguageID.ChineseT)
if (lang is (int)LanguageID.ChineseS or (int)LanguageID.ChineseT)
{
StringConverter.SetString7(value, 12, lang, chinese: true).CopyTo(Data, 0x40);
return;

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static PKHeX.Core.GameVersion;
namespace PKHeX.Core
{
@ -282,34 +283,34 @@ namespace PKHeX.Core
}
public bool E => Version == (int)GameVersion.E;
public bool FRLG => Version == (int)GameVersion.FR || Version == (int)GameVersion.LG;
public bool FRLG => Version is (int)FR or (int)LG;
public bool Pt => (int)GameVersion.Pt == Version;
public bool HGSS => Version == (int)GameVersion.HG || Version == (int)GameVersion.SS;
public bool BW => Version == (int)GameVersion.B || Version == (int)GameVersion.W;
public bool B2W2 => Version == (int)GameVersion.B2 || Version == (int)GameVersion.W2;
public bool XY => Version == (int)GameVersion.X || Version == (int)GameVersion.Y;
public bool AO => Version == (int)GameVersion.AS || Version == (int)GameVersion.OR;
public bool SM => Version == (int)GameVersion.SN || Version == (int)GameVersion.MN;
public bool USUM => Version == (int)GameVersion.US || Version == (int)GameVersion.UM;
public bool GO => Version == (int)GameVersion.GO;
public bool VC1 => Version >= (int)GameVersion.RD && Version <= (int)GameVersion.YW;
public bool VC2 => Version >= (int)GameVersion.GD && Version <= (int)GameVersion.C;
public bool LGPE => Version == (int)GameVersion.GP || Version == (int)GameVersion.GE;
public bool SWSH => Version == (int)GameVersion.SW || Version == (int)GameVersion.SH;
public bool HGSS => Version is (int)HG or (int)SS;
public bool BW => Version is (int)B or (int)W;
public bool B2W2 => Version is (int)B2 or (int)W2;
public bool XY => Version is (int)X or (int)Y;
public bool AO => Version is (int)AS or (int)OR;
public bool SM => Version is (int)SN or (int)MN;
public bool USUM => Version is (int)US or (int)UM;
public bool GO => Version is (int)GameVersion.GO;
public bool VC1 => Version is >= (int)RD and <= (int)YW;
public bool VC2 => Version is >= (int)GD and <= (int)C;
public bool LGPE => Version is (int)GP or (int)GE;
public bool SWSH => Version is (int)SW or (int)SH;
protected bool PtHGSS => Pt || HGSS;
public bool GO_LGPE => GO && Met_Location == Locations.GO7;
public bool GO_HOME => GO && Met_Location == Locations.GO8;
public bool VC => VC1 || VC2;
public bool GG => LGPE || GO_LGPE;
public bool Gen8 => (Version >= 44 && Version <= 45) || GO_HOME;
public bool Gen7 => (Version >= 30 && Version <= 33) || GG;
public bool Gen6 => Version >= 24 && Version <= 29;
public bool Gen5 => Version >= 20 && Version <= 23;
public bool Gen4 => Version >= 7 && Version <= 12 && Version != 9;
public bool Gen3 => (Version >= 1 && Version <= 5) || Version == 15;
public bool Gen2 => Version == (int)GameVersion.GSC;
public bool Gen1 => Version == (int)GameVersion.RBY;
public bool Gen8 => Version is >= 44 and <= 45 || GO_HOME;
public bool Gen7 => Version is >= 30 and <= 33 || GG;
public bool Gen6 => Version is >= 24 and <= 29;
public bool Gen5 => Version is >= 20 and <= 23;
public bool Gen4 => Version is >= 7 and <= 12 and not 9;
public bool Gen3 => Version is >= 1 and <= 5 or 15;
public bool Gen2 => Version == (int)GSC; // Fixed value set by the Gen2 PKM classes
public bool Gen1 => Version == (int)RBY; // Fixed value set by the Gen1 PKM classes
public bool GenU => Generation <= 0;
public int Generation
@ -454,7 +455,7 @@ namespace PKHeX.Core
if (Generation > 5 || Format > 5)
return -1;
if (Version == (int) GameVersion.CXD)
if (Version == (int) CXD)
return PersonalInfo.GetAbilityIndex(Ability); // Can mismatch; not tied to PID
return (int)((Gen5 ? PID >> 16 : PID) & 1);
}
@ -614,14 +615,14 @@ namespace PKHeX.Core
int gen = Generation;
return generation switch
{
1 => (Format == 1 || VC), // species compat checked via sanity above
2 => (Format == 2 || VC),
1 => Format == 1 || VC, // species compat checked via sanity above
2 => Format == 2 || VC,
3 => Gen3,
4 => (3 <= gen && gen <= 4),
5 => (3 <= gen && gen <= 5),
6 => (3 <= gen && gen <= 6),
7 => ((3 <= gen && gen <= 7) || VC),
8 => ((3 <= gen && gen <= 8) || VC),
4 => gen is >= 3 and <= 4,
5 => gen is >= 3 and <= 5,
6 => gen is >= 3 and <= 6,
7 => gen is >= 3 and <= 7 || VC,
8 => gen is >= 3 and <= 8 || VC,
_ => false
};
}
@ -648,7 +649,7 @@ namespace PKHeX.Core
return gender == 0;
int gen = Generation;
if (gen <= 2 || gen >= 6)
if (gen is <= 2 or >= 6) // not 3-5
return gender == (gender & 1);
return gender == PKX.GetGenderFromPIDAndRatio(PID, gv);
@ -1030,7 +1031,7 @@ namespace PKHeX.Core
return 2;
}
if (VC)
return Species == (int)Core.Species.Mew || Species == (int)Core.Species.Celebi ? 5 : 3;
return Species is (int)Core.Species.Mew or (int)Core.Species.Celebi ? 5 : 3;
return 0;
}

View file

@ -49,7 +49,7 @@
public sealed override int AbilityNumber { get => 1 << PIDAbility; set { } }
// Legality Extensions
public sealed override bool WasEvent => (Met_Location >= 3000 && Met_Location <= 3076) || FatefulEncounter;
public sealed override bool WasEvent => (Met_Location is >= 3000 and <= 3076) || FatefulEncounter;
public sealed override bool WasEventEgg => WasEgg && Species == (int)Core.Species.Manaphy; // Manaphy was the only generation 4 released event egg
public abstract int ShinyLeaf { get; set; }

View file

@ -178,7 +178,7 @@ namespace PKHeX.Core
int lang = Language;
if (lang > 0)
return lang;
if (fallback == (int)LanguageID.French || fallback == (int)LanguageID.German) // only other permitted besides English
if (fallback is (int)LanguageID.French or (int)LanguageID.German) // only other permitted besides English
return fallback;
return (int)LanguageID.English;
}

View file

@ -26,7 +26,7 @@ namespace PKHeX.Core
/// <returns>True if either species can toggle Gigantamax potential</returns>
public static bool CanToggleGigantamax(this IGigantamax _, int currentSpecies, int currentForm, int originSpecies, int originForm)
{
if (currentSpecies == (int)Species.Meowth || currentSpecies == (int)Species.Pikachu)
if (currentSpecies is (int)Species.Meowth or (int)Species.Pikachu)
return currentForm == 0;
var soup = CanEatMaxSoup;
@ -42,7 +42,7 @@ namespace PKHeX.Core
/// <returns>True if the species can toggle Gigantamax potential</returns>
public static bool CanToggleGigantamax(this IGigantamax _, int currentSpecies, int currentForm)
{
if (currentSpecies == (int)Species.Meowth || currentSpecies == (int)Species.Pikachu)
if (currentSpecies is (int)Species.Meowth or (int)Species.Pikachu)
return currentForm == 0;
var soup = CanEatMaxSoup;
return soup.Contains(currentSpecies);

View file

@ -80,7 +80,7 @@ namespace PKHeX.Core
private static int GetStringLength(bool jp) => jp ? GBPKML.STRLEN_J : GBPKML.STRLEN_U;
protected bool IsFormatParty => IsCapacityPartyFormat((PokeListType)Capacity);
protected static bool IsCapacityPartyFormat(PokeListType Capacity) => Capacity == PokeListType.Single || Capacity == PokeListType.Party;
protected static bool IsCapacityPartyFormat(PokeListType Capacity) => Capacity is PokeListType.Single or PokeListType.Party;
protected static int GetDataSize(PokeListType c, bool jp, int entrySize)
{

View file

@ -45,7 +45,7 @@ namespace PKHeX.Core
}
// this is a hack; depends on currently loaded SaveFile's Game ID
private static bool IsGG() => PKMConverter.Game == (int)GameVersion.GP || PKMConverter.Game == (int)GameVersion.GE;
private static bool IsGG() => PKMConverter.Game is (int)GameVersion.GP or (int)GameVersion.GE;
private static readonly string[] EMPTY = { string.Empty };
private const string Starter = nameof(Starter);

View file

@ -212,10 +212,10 @@ namespace PKHeX.Core
{
return generation switch
{
1 => (196 <= item && item <= 200), // HMs
2 => (item >= 243), // HMs
3 => (339 <= item && item <= 346),
_ => ((420 <= item && item <= 427) || item == 737)
1 => item is >= 196 and <= 200, // HMs
2 => item is >= 243, // HMs
3 => item is >= 339 and <= 346,
_ => item is >= 420 and <= 427 or 737,
};
}
}

View file

@ -63,7 +63,7 @@ namespace PKHeX.Core
/// <returns>Main Series language ID.</returns>
public static byte GetMainLangIDfromGC(byte value)
{
if (value <= 2 || value > 7)
if (value is <= 2 or > 7)
return value;
return (byte) GCtoMainSeries[(LanguageGC)value];
}
@ -75,7 +75,7 @@ namespace PKHeX.Core
/// <returns>GameCube (C/XD) language ID.</returns>
public static byte GetGCLangIDfromMain(byte value)
{
if (value <= 2 || value > 7)
if (value is <= 2 or > 7)
return value;
return (byte) MainSeriesToGC[(LanguageID)value];
}

View file

@ -129,7 +129,7 @@ namespace PKHeX.Core
uint abilBitVal = g34 ? oldPID & 0x0000_0001 : oldPID & 0x0001_0000;
bool g3unown = origin <= 5 && species == (int)Species.Unown;
bool singleGender = gt == 255 || gt == 254 || gt == 0; // skip gender check
bool singleGender = gt is 0 or 254 or 255; // single gender, skip gender check
while (true) // Loop until we find a suitable PID
{
uint pid = Util.Rand32(rnd);
@ -209,7 +209,7 @@ namespace PKHeX.Core
public static string[] GetPKMExtensions(int maxGeneration = Generation)
{
var result = new List<string>();
int min = maxGeneration <= 2 || maxGeneration >= 7 ? 1 : 3;
int min = maxGeneration is <= 2 or >= 7 ? 1 : 3;
for (int i = min; i <= maxGeneration; i++)
result.Add($"pk{i}");

View file

@ -254,7 +254,7 @@ namespace PKHeX.Core
/// <returns>Decrypted data.</returns>
public static byte[] DecryptArray3(byte[] ekm)
{
Debug.Assert(ekm.Length == SIZE_3PARTY || ekm.Length == SIZE_3STORED);
Debug.Assert(ekm.Length is SIZE_3PARTY or SIZE_3STORED);
uint PID = BitConverter.ToUInt32(ekm, 0);
uint OID = BitConverter.ToUInt32(ekm, 4);
@ -296,7 +296,7 @@ namespace PKHeX.Core
/// <returns>Encrypted data.</returns>
public static byte[] EncryptArray3(byte[] pkm)
{
Debug.Assert(pkm.Length == SIZE_3PARTY || pkm.Length == SIZE_3STORED);
Debug.Assert(pkm.Length is SIZE_3PARTY or SIZE_3STORED);
uint PID = BitConverter.ToUInt32(pkm, 0);
uint OID = BitConverter.ToUInt32(pkm, 4);

View file

@ -69,7 +69,7 @@ namespace PKHeX.Core
if (x1.Data.Length == 0)
continue;
if (x1.Type == SCTypeCode.Object || x1.Type == SCTypeCode.Array)
if (x1.Type is SCTypeCode.Object or SCTypeCode.Array)
{
if (!x1.Data.SequenceEqual(x2.Data))
ValueChanged.Add($"{name} - Bytes Changed");

View file

@ -73,7 +73,7 @@ namespace PKHeX.Core
if (blockName != null)
return $"*{type} {blockName}";
var result = $"{z.Key:X8} - {i:0000} {type}";
if (z.Type == SCTypeCode.Object || z.Type == SCTypeCode.Array)
if (z.Type is SCTypeCode.Object or SCTypeCode.Array)
result += $" 0x{z.Data.Length:X3}";
else if (!isBool)
result += $" {z.GetValue()}";

View file

@ -78,12 +78,12 @@ namespace PKHeX.Core
public SAV3(GameVersion version = GameVersion.FRLG, bool japanese = false) : base(SaveUtil.SIZE_G3RAW)
{
if (version == GameVersion.FR || version == GameVersion.LG)
Version = GameVersion.FRLG;
else if (version == GameVersion.R || version == GameVersion.S)
Version = GameVersion.RS;
else
Version = version;
Version = version switch
{
GameVersion.FR or GameVersion.LG => GameVersion.FRLG,
GameVersion.R or GameVersion.S => GameVersion.RS,
_ => version
};
_personal = SaveUtil.GetG3Personal(Version);
Japanese = japanese;

View file

@ -159,7 +159,7 @@ namespace PKHeX.Core
box /= 2;
int offset = Box + 0x1EC38 + (9 * box);
if (Data[offset] == 0 || Data[offset] == 0xFF)
if (Data[offset] is 0 or 0xFF)
boxName += $"BOX {box + 1}";
boxName += GetString(offset, 9);

View file

@ -65,9 +65,11 @@ namespace PKHeX.Core
get
{
var game = (GameVersion)Game;
if (game == GameVersion.SW || game == GameVersion.SH)
return game;
return GameVersion.Invalid;
return game switch
{
GameVersion.SW or GameVersion.SH => game,
_ => GameVersion.Invalid
};
}
}

View file

@ -293,7 +293,7 @@ namespace PKHeX.Core
}
set
{
if (value.Count == 0 || value.Count > 6)
if (value.Count is 0 or > 6)
throw new ArgumentException($"Expected 1-6, got {value.Count}");
if (value.Any(pk => PKMType != pk.GetType()))
throw new ArgumentException($"Not {PKMType} array.");

View file

@ -117,7 +117,7 @@ namespace PKHeX.Core
if (fn != null)
return Path.GetExtension(fn);
if ((sav.Generation == 4 || sav.Generation == 5) && sav.Metadata.HasFooter)
if ((sav.Generation is 4 or 5) && sav.Metadata.HasFooter)
return ".dsv";
return sav.Extension;
}

View file

@ -45,7 +45,7 @@ namespace PKHeX.Core
public sealed override int MaxGameID => blank.MaxGameID;
public sealed override int OTLength => blank.OTLength;
public sealed override int NickLength => blank.NickLength;
public bool IsBigEndian => blank is BK4 || blank is XK3 || blank is CK3;
public bool IsBigEndian => blank is BK4 or XK3 or CK3;
private readonly Func<byte[], int, bool> GetIsPKMPresent;
public sealed override bool IsPKMPresent(byte[] data, int offset) => GetIsPKMPresent(data, offset);

View file

@ -169,9 +169,10 @@ namespace PKHeX.Core
private static int ValToIndex(int val)
{
if ((val & 0x3FF) < 0xA0 || (val & 0x3FF) > 0x280)
var trunc = (val & 0x3FF);
if (trunc is < 0xA0 or > 0x280)
return (val & 0x5C00) | 0xFF;
return ((val % 0x20) + (17 * (((val & 0x3FF) - 0xA0) / 0x20))) | (val & 0x5C00);
return ((val % 0x20) + (17 * ((trunc - 0xA0) / 0x20))) | (val & 0x5C00);
}
private static byte Convert8to5(int colorval)

View file

@ -20,14 +20,14 @@ namespace PKHeX.Core
public ulong? GetSeed()
{
if (!(SAV is SAV5B2W2))
if (SAV is not SAV5B2W2)
return null;
return BitConverter.ToUInt64(Data, Offset + 0x1CC);
}
public void SetSeed(string value)
{
if (!(SAV is SAV5B2W2))
if (SAV is not SAV5B2W2)
return;
var data = Util.GetBytesFromHexString(value);
SAV.SetData(data, Offset + 0x1CC);

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core
public ushort GetPWTRecord(PWTRecordID id)
{
if (id < PWTRecordID.Normal || id > PWTRecordID.MixMaster)
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
throw new ArgumentException(nameof(id));
int ofs = Offset + 0x5C + ((int)id * 2);
return BitConverter.ToUInt16(Data, ofs);
@ -20,7 +20,7 @@ namespace PKHeX.Core
public void SetPWTRecord(PWTRecordID id, ushort value)
{
if (id < PWTRecordID.Normal || id > PWTRecordID.MixMaster)
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
throw new ArgumentException(nameof(id));
int ofs = Offset + 0x5C + ((int)id * 2);
SAV.SetData(BitConverter.GetBytes(value), ofs);

View file

@ -37,7 +37,7 @@ namespace PKHeX.Core
{
if (species <= (int)Species.Mew)
return species - 1;
if (species == (int)Species.Meltan || species == (int)Species.Melmetal)
if (species is (int)Species.Meltan or (int)Species.Melmetal)
return species - 657; // 151, 152
return -1;
}

View file

@ -30,7 +30,7 @@ namespace PKHeX.Core
}
set
{
if (value < 1 || value > WormholeSlotMax)
if (value is < 1 or > WormholeSlotMax)
return;
for (int i = 1; i <= WormholeSlotMax; i++)
{
@ -129,7 +129,7 @@ namespace PKHeX.Core
public static int WormholeSlotToPokemon(int mapid, int slot)
{
if (slot < 1 || slot > WormholeSlotMax)
if (slot is < 1 or > WormholeSlotMax)
return -1;
return mapid switch

View file

@ -126,7 +126,7 @@ namespace PKHeX.Core
[Category(Derived), Description("Rare encounter details used instead of Common details.")]
public bool IsRare
{
get => DenType == RaidType.Rare || DenType == RaidType.RareWish;
get => DenType is RaidType.Rare or RaidType.RareWish;
set
{
if (value)
@ -143,7 +143,7 @@ namespace PKHeX.Core
[Category(Derived), Description("Wishing Piece was used for Raid encounter.")]
public bool IsWishingPiece
{
get => DenType == RaidType.CommonWish || DenType == RaidType.RareWish;
get => DenType is RaidType.CommonWish or RaidType.RareWish;
set
{
if (value)

View file

@ -54,15 +54,13 @@ namespace PKHeX.Core
public override int AppearPKM { get => Data[0x2D]; set => Data[0x2D] = (byte)value; }
public override int MailType { get => Data[0x2E]; set => Data[0x2E] = (byte)value; }
public override bool? IsEmpty
public override bool? IsEmpty => MailType switch
{
get
{
if (MailType == 0) return true;
else if (MailType == 0x9E || (MailType >= 0xB5 && MailType <= 0xBD)) return false;
else return null;
}
}
0 => true,
0x9E => false,
>= 0xB5 and <= 0xBD => false,
_ => null
};
public override void SetBlank() => (new byte[0x2F]).CopyTo(Data, 0);
}

View file

@ -116,7 +116,7 @@ namespace PKHeX.Core
{
if (SAV.Version == GameVersion.Invalid) // sanity
return;
if (pkm.Species == 0 || pkm.Species > SAV.MaxSpeciesID) // out of range
if ((uint)(pkm.Species - 1) >= (uint)SAV.MaxSpeciesID) // out of range
return;
if (pkm.IsEgg) // do not add
return;

View file

@ -126,16 +126,14 @@ namespace PKHeX.Core
return true;
}
protected sealed override int GetDexLangFlag(int lang)
protected sealed override int GetDexLangFlag(int lang) => lang switch
{
if (lang > 10 || lang == 6 || lang <= 0)
return -1; // invalid language
if (lang >= 7) // skip over langID 6 (unused)
lang--;
lang--; // skip over langID 0 (unused) => [0-8]
return lang;
}
> 10 or 6 or <= 0 => -1, // invalid language
// skip over langID 0 (unused) => [0-8]
// skip over langID 6 (unused)
>= 7 => lang - 2,
_ => lang - 1,
};
protected sealed override void SetSpindaDexData(PKM pkm, bool alreadySeen)
{

View file

@ -112,16 +112,14 @@ namespace PKHeX.Core
return result;
}
private static int GetDexLangFlag(int lang)
private static int GetDexLangFlag(int lang) => lang switch
{
if (lang > 10 || lang == 6 || lang <= 0)
return -1; // invalid language
if (lang >= 7) // skip over langID 6 (unused)
lang--;
lang--; // skip over langID 0 (unused) => [0-8]
return lang;
}
> 10 or 6 or <= 0 => -1, // invalid language
// skip over langID 0 (unused) => [0-8]
// skip over langID 6 (unused)
>= 7 => lang - 2,
_ => lang - 1,
};
public IList<string> GetEntryNames(IReadOnlyList<string> speciesNames)
{

View file

@ -364,7 +364,7 @@ namespace PKHeX.Core
const int DATE_INT = 0x20060623;
const int DATE_KO = 0x20070903;
return sdk == DATE_INT || sdk == DATE_KO;
return sdk is DATE_INT or DATE_KO;
}
// Check the other save -- first save is done to the latter half of the binary.

View file

@ -350,7 +350,7 @@ namespace PKHeX.WinForms.Controls
private static void CheckTransferPIDValid(PKM pk)
{
var ver = pk.Version;
if (ver >= (int)GameVersion.X || ver == 0)
if (ver is 0 or >= (int)GameVersion.X) // Gen6+ ignored
return;
uint EC = pk.EncryptionConstant;

View file

@ -1075,15 +1075,15 @@ namespace PKHeX.WinForms.Controls
B_CGearSkin.Enabled = sav.Generation == 5;
B_OpenPokeBeans.Enabled = B_CellsStickers.Enabled = B_FestivalPlaza.Enabled = sav is SAV7;
B_OtherSlots.Enabled = sav is SAV1StadiumJ || sav is SAV1Stadium || sav is SAV2Stadium;
B_OpenTrainerInfo.Enabled = B_OpenItemPouch.Enabled = (sav.HasParty && !(SAV is SAV4BR)) || SAV is SAV7b; // Box RS & Battle Revolution
B_OpenMiscEditor.Enabled = sav is SAV3 || sav is SAV4 || sav is SAV5;
B_OtherSlots.Enabled = sav is SAV1StadiumJ or SAV1Stadium or SAV2Stadium;
B_OpenTrainerInfo.Enabled = B_OpenItemPouch.Enabled = (sav.HasParty && SAV is not SAV4BR) || SAV is SAV7b; // Box RS & Battle Revolution
B_OpenMiscEditor.Enabled = sav is SAV3 or SAV4 or SAV5;
B_Roamer.Enabled = sav is SAV3;
B_OpenHoneyTreeEditor.Enabled = B_OpenUGSEditor.Enabled = sav is SAV4Sinnoh;
B_OpenApricorn.Enabled = sav is SAV4HGSS;
B_OpenRTCEditor.Enabled = sav.Generation == 2 || (sav is SAV3 s3 && (s3.RS || s3.E));
B_MailBox.Enabled = sav is SAV2 || sav is SAV3 || sav is SAV4 || sav is SAV5;
B_MailBox.Enabled = sav is SAV2 or SAV3 or SAV4 or SAV5;
B_Raids.Enabled = sav is SAV8SWSH;
B_RaidArmor.Enabled = sav is SAV8SWSH {SaveRevision: >= 1};

View file

@ -1108,7 +1108,7 @@ namespace PKHeX.WinForms
private void Dragout_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && (ModifierKeys == Keys.Alt || ModifierKeys == Keys.Shift))
if (e.Button == MouseButtons.Left && (ModifierKeys is Keys.Alt or Keys.Shift))
ClickQR(sender, e);
if (e.Button == MouseButtons.Right)
return;

View file

@ -298,7 +298,7 @@ namespace PKHeX.WinForms
}
int ColorCount = BrightCount.Count(v => v > 0);
if (ColorCount > 4 || ColorCount == 0)
if (ColorCount is 0 or > 4)
return;
int errmin = int.MaxValue;
byte[] LCT = new byte[4];

View file

@ -298,7 +298,7 @@ namespace PKHeX.WinForms
private void ModifyAll(object sender, EventArgs e)
{
int lang = SAV.Language - 1;
if (lang > 5 || lang < 0) // KOR or Invalid
if (lang is < 0 or > 5) // KOR or Invalid
lang = 0;
bool seenA = sender == mnuSeenAll || sender == mnuCaughtAll || sender == mnuComplete;

View file

@ -735,18 +735,9 @@ namespace PKHeX.WinForms
}
else
{
if (swSuperCheck == 0x10 || swSuperCheck == 0x30 || swSuperCheck == 0x50)
{
CHK_SuperSingle.Checked = true;
}
if (swSuperCheck == 0x20 || swSuperCheck == 0x30 || swSuperCheck == 0x60)
{
CHK_SuperDouble.Checked = true;
}
if (swSuperCheck == 0x40 || swSuperCheck == 0x50 || swSuperCheck == 0x60)
{
CHK_SuperMulti.Checked = true;
}
if (swSuperCheck is 0x10 or 0x30 or 0x50) CHK_SuperSingle.Checked = true;
if (swSuperCheck is 0x20 or 0x30 or 0x60) CHK_SuperDouble.Checked = true;
if (swSuperCheck is 0x40 or 0x50 or 0x60) CHK_SuperMulti.Checked = true;
}
// Normal

View file

@ -325,7 +325,8 @@ namespace PKHeX.WinForms
private void SetForms()
{
int species = WinFormsUtil.GetIndex(CB_Species);
bool hasForms = PersonalTable.AO[species].HasForms || new[] { 664, 665, 414 }.Contains(species);
var pi = PersonalTable.AO[species];
bool hasForms = FormInfo.HasFormSelection(pi, species, 6);
CB_Form.Enabled = CB_Form.Visible = hasForms;
CB_Form.InitializeBinding();

View file

@ -46,7 +46,7 @@ namespace PKHeX.WinForms
PB_Sprite.Visible = CHK_MegaRayquazaUnlocked.Visible = SAV is SAV6AO;
L_Style.Visible = TB_Style.Visible = SAV is SAV6XY;
if (!(SAV is SAV6XY))
if (SAV is not SAV6XY)
TC_Editor.TabPages.Remove(Tab_Appearance);
if (SAV is SAV6AODemo)

View file

@ -412,7 +412,7 @@ namespace PKHeX.WinForms
if (sender != mnuSeenAll)
SetRecords();
if (spec == 25 || spec == 133)
if (spec is (int)Species.Pikachu or (int)Species.Eevee)
continue; // ignore starter (setdex doesn't set buddy bit; totem raticate is not emitted below).
// Set forme flags

View file

@ -71,7 +71,7 @@ namespace PKHeX.WinForms
CB_Vivillon.InitializeBinding();
CB_Vivillon.DataSource = FormConverter.GetFormList((int)Species.Vivillon, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation);
if (!(SAV is SAV7USUM))
if (SAV is not SAV7USUM)
BattleStyles.RemoveAt(BattleStyles.Count - 1); // remove Nihilist
foreach (string t in BattleStyles)
{
@ -241,7 +241,7 @@ namespace PKHeX.WinForms
188,-1,-1,
198,202,110,204,//Beach
};
if (SAV.Version == GameVersion.UM || SAV.Version == GameVersion.MN)
if (SAV.Version is GameVersion.UM or GameVersion.MN)
{
FlyDestNameIndex[28] = 142;
FlyDestNameIndex[36] = 178;
@ -409,7 +409,7 @@ namespace PKHeX.WinForms
if (CB_BallThrowType.SelectedIndex >= 0)
SAV.MyStatus.BallThrowType = CB_BallThrowType.SelectedIndex;
if (!(SAV is SAV7SM)) // unlock flags are in flag editor instead
if (SAV is not SAV7SM) // unlock flags are in flag editor instead
return;
const int unlockStart = 292;

View file

@ -93,7 +93,7 @@ namespace PKHeX.WinForms
}
NUD_Collected.Value += added;
if (!(SAV is SAV7USUM))
if (SAV is not SAV7USUM)
NUD_Cells.Value += added;
System.Media.SystemSounds.Asterisk.Play();

View file

@ -26,7 +26,7 @@ namespace PKHeX.WinForms
itemlist[i] = $"(Item #{i:000})";
}
HasFreeSpace = SAV.Generation >= 7 && !(SAV is SAV7b);
HasFreeSpace = SAV.Generation >= 7 && SAV is not SAV7b;
HasNew = CHK_NEW.Visible = SAV.Generation >= 7;
Pouches = SAV.Inventory;
CreateBagViews();

View file

@ -35,9 +35,9 @@ namespace PKHeX.WinForms
NUD_BoxSize.Visible = L_BoxSize.Visible = Gen == 2;
GB_MessageTB.Visible = Gen == 2;
GB_MessageNUD.Visible = Gen != 2;
Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen == 4 || Gen == 5;
Messages[0][3].Visible = Messages[1][3].Visible = Messages[2][3].Visible = Gen is 4 or 5;
NUD_AuthorSID.Visible = Gen != 2;
Label_OTGender.Visible = CB_AuthorLang.Visible = CB_AuthorVersion.Visible = Gen == 4 || Gen == 5;
Label_OTGender.Visible = CB_AuthorLang.Visible = CB_AuthorVersion.Visible = Gen is 4 or 5;
L_AppearPKM.Visible = AppearPKMs[0].Visible = Gen != 5;
AppearPKMs[1].Visible = AppearPKMs[2].Visible = Gen == 4;
NUD_MessageEnding.Visible = Gen == 5;
@ -112,13 +112,13 @@ namespace PKHeX.WinForms
MakePartyList();
MakePCList();
if (Gen == 2 || Gen == 3)
if (Gen is 2 or 3)
{
CB_AppearPKM1.Items.Clear();
CB_AppearPKM1.InitializeBinding();
CB_AppearPKM1.DataSource = new BindingSource(GameInfo.FilteredSources.Species.ToList(), null);
}
else if (Gen == 4 || Gen == 5)
else if (Gen is 4 or 5)
{
var species = GameInfo.FilteredSources.Species.ToList();
foreach (ComboBox a in AppearPKMs)
@ -351,7 +351,7 @@ namespace PKHeX.WinForms
heldMailIDs[i] = h;
if (ItemIsMail(p[i].HeldItem))
{
if (h < 0 || h > 5) //A
if (h is < 0 or > 5) //A
ret.Add($"Party#{i + 1} MailID mismatch");
else if (m[h].IsEmpty == true) //B
ret.Add($"Party#{i + 1} MailID mismatch");
@ -373,7 +373,7 @@ namespace PKHeX.WinForms
// Gen2, Gen4
// P: held item is mail, but mail is empty(invalid mail type. g2:not 181 to 189, g4:12 to 255). it should be not empty or held not mail.
// Q: held item is not mail, but mail is not empty. it should be empty or held mail.
else if (Gen == 2 || Gen == 4)
else if (Gen is 2 or 4)
{
for (int i = 0; i < p.Count; i++)
{

View file

@ -102,7 +102,7 @@ namespace PKHeX.WinForms
CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
}
if (SAV is SAV3Colosseum || SAV is SAV3XD)
if (SAV is SAV3Colosseum or SAV3XD)
{
GB_Map.Visible = false;
GB_Badges.Visible = false;

View file

@ -109,7 +109,8 @@ namespace PKHeX.WinForms
private void SetCardID(int cardID)
{
if (cardID <= 0 || cardID >= 0x100 * 8) return;
if (cardID is <= 0 or >= 0x100 * 8)
return;
string card = cardID.ToString("0000");
if (!LB_Received.Items.Contains(card))