diff --git a/PKHeX.Core/Editing/Applicators/MarkingApplicator.cs b/PKHeX.Core/Editing/Applicators/MarkingApplicator.cs
index b03273681..4dc8881ce 100644
--- a/PKHeX.Core/Editing/Applicators/MarkingApplicator.cs
+++ b/PKHeX.Core/Editing/Applicators/MarkingApplicator.cs
@@ -75,15 +75,12 @@ public static int[] ToggleMarking(this PKM pk, int index, int[] markings)
return GetComplexMarking;
static int GetSimpleMarking(int val, int _) => val == 31 ? 1 : 0;
- static int GetComplexMarking(int val, int _)
+ static int GetComplexMarking(int val, int _) => val switch
{
- return val switch
- {
- 31 or 1 => 1,
- 30 or 0 => 2,
- _ => 0,
- };
- }
+ 31 or 1 => 1,
+ 30 or 0 => 2,
+ _ => 0,
+ };
}
}
-}
\ No newline at end of file
+}
diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs
index 1e1bcb5fe..d25b31cf3 100644
--- a/PKHeX.Core/Editing/CommonEdits.cs
+++ b/PKHeX.Core/Editing/CommonEdits.cs
@@ -279,20 +279,16 @@ public static void ApplyHeldItem(this PKM pk, int item, int format)
/// Pokémon to modify.
/// Index to set to
/// Value to set
- public static void SetEV(this PKM pk, int index, int value)
+ public static int SetEV(this PKM pk, int index, int value) => index switch
{
- switch (index)
- {
- case 0: pk.EV_HP = value; break;
- case 1: pk.EV_ATK = value; break;
- case 2: pk.EV_DEF = value; break;
- case 3: pk.EV_SPE = value; break;
- case 4: pk.EV_SPA = value; break;
- case 5: pk.EV_SPD = value; break;
- default:
- throw new ArgumentOutOfRangeException(nameof(index));
- }
- }
+ 0 => pk.EV_HP = value,
+ 1 => pk.EV_ATK = value,
+ 2 => pk.EV_DEF = value,
+ 3 => pk.EV_SPE = value,
+ 4 => pk.EV_SPA = value,
+ 5 => pk.EV_SPD = value,
+ _ => throw new ArgumentOutOfRangeException(nameof(index))
+ };
///
/// Sets one of the based on its index within the array.
@@ -300,20 +296,16 @@ public static void SetEV(this PKM pk, int index, int value)
/// Pokémon to modify.
/// Index to set to
/// Value to set
- public static void SetIV(this PKM pk, int index, int value)
+ public static int SetIV(this PKM pk, int index, int value) => index switch
{
- switch (index)
- {
- case 0: pk.IV_HP = value; break;
- case 1: pk.IV_ATK = value; break;
- case 2: pk.IV_DEF = value; break;
- case 3: pk.IV_SPE = value; break;
- case 4: pk.IV_SPA = value; break;
- case 5: pk.IV_SPD = value; break;
- default:
- throw new ArgumentOutOfRangeException(nameof(index));
- }
- }
+ 0 => pk.IV_HP = value,
+ 1 => pk.IV_ATK = value,
+ 2 => pk.IV_DEF = value,
+ 3 => pk.IV_SPE = value,
+ 4 => pk.IV_SPA = value,
+ 5 => pk.IV_SPD = value,
+ _ => throw new ArgumentOutOfRangeException(nameof(index))
+ };
///
/// Fetches the highest value the provided index can be while considering others.
diff --git a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs
index 41b28c396..17dac8da4 100644
--- a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs
+++ b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs
@@ -43,21 +43,18 @@ public static List GetExtraSlots(this SaveFile sav, bool all = fal
private static readonly List None = new();
- private static List GetExtraSlotsUnsafe(SaveFile sav, bool all)
+ private static List GetExtraSlotsUnsafe(SaveFile sav, bool all) => sav switch
{
- return sav switch
- {
- SAV2 sav2 => GetExtraSlots2(sav2),
- SAV3 sav3 => GetExtraSlots3(sav3),
- SAV4 sav4 => GetExtraSlots4(sav4),
- SAV5 sav5 => GetExtraSlots5(sav5),
- SAV6XY xy => GetExtraSlots6XY(xy),
- SAV6AO xy => GetExtraSlots6AO(xy),
- SAV7 sav7 => GetExtraSlots7(sav7, all),
- SAV8SWSH ss => GetExtraSlots8(ss),
- _ => None
- };
- }
+ SAV2 sav2 => GetExtraSlots2(sav2),
+ SAV3 sav3 => GetExtraSlots3(sav3),
+ SAV4 sav4 => GetExtraSlots4(sav4),
+ SAV5 sav5 => GetExtraSlots5(sav5),
+ SAV6XY xy => GetExtraSlots6XY(xy),
+ SAV6AO xy => GetExtraSlots6AO(xy),
+ SAV7 sav7 => GetExtraSlots7(sav7, all),
+ SAV8SWSH ss => GetExtraSlots8(ss),
+ _ => None
+ };
private static List GetExtraSlots2(SAV2 sav)
{
diff --git a/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs b/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs
index 4f0563d72..0f4db5bae 100644
--- a/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs
+++ b/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs
@@ -51,14 +51,11 @@ private void AddUndo(SlotReversion change)
RedoStack.Clear();
}
- private static SlotReversion GetReversion(ISlotInfo info, SaveFile sav)
+ private static SlotReversion GetReversion(ISlotInfo info, SaveFile sav) => info switch
{
- return info switch
- {
- SlotInfoParty p => new PartyReversion(p, sav),
- _ => new SingleSlotReversion(info, sav)
- };
- }
+ SlotInfoParty p => new PartyReversion(p, sav),
+ _ => new SingleSlotReversion(info, sav)
+ };
private abstract class SlotReversion
{
diff --git a/PKHeX.Core/Game/Enums/GCVersion.cs b/PKHeX.Core/Game/Enums/GCVersion.cs
index a1446f464..7de23c21e 100644
--- a/PKHeX.Core/Game/Enums/GCVersion.cs
+++ b/PKHeX.Core/Game/Enums/GCVersion.cs
@@ -23,37 +23,31 @@ public static class GCVersionExtensions
///
/// Version ID while present in the main-series games
/// Version ID while present in the GameCube games
- public static GCVersion GetCXDVersionID(this GameVersion gbaVersion)
+ public static GCVersion GetCXDVersionID(this GameVersion gbaVersion) => gbaVersion switch
{
- return gbaVersion switch
- {
- GameVersion.S => GCVersion.S,
- GameVersion.R => GCVersion.R,
- GameVersion.E => GCVersion.E,
- GameVersion.FR => GCVersion.FR,
- GameVersion.LG => GCVersion.LG,
- GameVersion.CXD => GCVersion.CXD,
- _ => GCVersion.None,
- };
- }
+ GameVersion.S => GCVersion.S,
+ GameVersion.R => GCVersion.R,
+ GameVersion.E => GCVersion.E,
+ GameVersion.FR => GCVersion.FR,
+ GameVersion.LG => GCVersion.LG,
+ GameVersion.CXD => GCVersion.CXD,
+ _ => GCVersion.None,
+ };
///
/// Translates a to the corresponding main-series value.
///
/// Version ID while present in the GameCube games
/// Version ID while present in the main-series games
- public static GameVersion GetG3VersionID(this GCVersion gcVersion)
+ public static GameVersion GetG3VersionID(this GCVersion gcVersion) => gcVersion switch
{
- return gcVersion switch
- {
- GCVersion.S => GameVersion.S,
- GCVersion.R => GameVersion.R,
- GCVersion.E => GameVersion.E,
- GCVersion.FR => GameVersion.FR,
- GCVersion.LG => GameVersion.LG,
- GCVersion.CXD => GameVersion.CXD,
- _ => GameVersion.Unknown
- };
- }
+ GCVersion.S => GameVersion.S,
+ GCVersion.R => GameVersion.R,
+ GCVersion.E => GameVersion.E,
+ GCVersion.FR => GameVersion.FR,
+ GCVersion.LG => GameVersion.LG,
+ GCVersion.CXD => GameVersion.CXD,
+ _ => GameVersion.Unknown
+ };
}
}
diff --git a/PKHeX.Core/Game/GameStrings/GameStrings.cs b/PKHeX.Core/Game/GameStrings/GameStrings.cs
index e9d5b58b4..4fa827fdd 100644
--- a/PKHeX.Core/Game/GameStrings/GameStrings.cs
+++ b/PKHeX.Core/Game/GameStrings/GameStrings.cs
@@ -487,96 +487,69 @@ public string GetLocationName(bool isEggLocation, int location, int format, int
/// BankID used to choose the text bank.
/// Version of origin
/// List of location names.
- public IReadOnlyList GetLocationNames(int gen, int bankID, GameVersion version)
+ public IReadOnlyList GetLocationNames(int gen, int bankID, GameVersion version) => gen switch
{
- switch (gen)
- {
- case 2: return metGSC_00000;
- case 3:
- return GameVersion.CXD.Contains(version) ? metCXD_00000 : metRSEFRLG_00000;
- case 4: return GetLocationNames4(bankID);
- case 5: return GetLocationNames5(bankID);
- case 6: return GetLocationNames6(bankID);
- case 7:
- if (GameVersion.Gen7b.Contains(version))
- return GetLocationNames7GG(bankID);
- return GetLocationNames7(bankID);
- case 8:
- return GetLocationNames8(bankID);
- default:
- return Array.Empty();
- }
- }
+ 2 => metGSC_00000,
+ 3 => GameVersion.CXD.Contains(version) ? metCXD_00000 : metRSEFRLG_00000,
+ 4 => GetLocationNames4(bankID),
+ 5 => GetLocationNames5(bankID),
+ 6 => GetLocationNames6(bankID),
+ 7 => GameVersion.Gen7b.Contains(version) ? GetLocationNames7GG(bankID) : GetLocationNames7(bankID),
+ 8 => GetLocationNames8(bankID),
+ _ => Array.Empty()
+ };
- private IReadOnlyList GetLocationNames4(int bankID)
+ private IReadOnlyList GetLocationNames4(int bankID) => bankID switch
{
- return bankID switch
- {
- 0 => metHGSS_00000,
- 2 => metHGSS_02000,
- 3 => metHGSS_03000,
- _ => Array.Empty()
- };
- }
+ 0 => metHGSS_00000,
+ 2 => metHGSS_02000,
+ 3 => metHGSS_03000,
+ _ => Array.Empty()
+ };
- public IReadOnlyList GetLocationNames5(int bankID)
+ public IReadOnlyList GetLocationNames5(int bankID) => bankID switch
{
- return bankID switch
- {
- 0 => metBW2_00000,
- 3 => metBW2_30000,
- 4 => metBW2_40000,
- 6 => metBW2_60000,
- _ => Array.Empty()
- };
- }
+ 0 => metBW2_00000,
+ 3 => metBW2_30000,
+ 4 => metBW2_40000,
+ 6 => metBW2_60000,
+ _ => Array.Empty()
+ };
- public IReadOnlyList GetLocationNames6(int bankID)
+ public IReadOnlyList GetLocationNames6(int bankID) => bankID switch
{
- return bankID switch
- {
- 0 => metXY_00000,
- 3 => metXY_30000,
- 4 => metXY_40000,
- 6 => metXY_60000,
- _ => Array.Empty()
- };
- }
+ 0 => metXY_00000,
+ 3 => metXY_30000,
+ 4 => metXY_40000,
+ 6 => metXY_60000,
+ _ => Array.Empty()
+ };
- public IReadOnlyList GetLocationNames7(int bankID)
+ public IReadOnlyList GetLocationNames7(int bankID) => bankID switch
{
- return bankID switch
- {
- 0 => metSM_00000,
- 3 => metSM_30000,
- 4 => metSM_40000,
- 6 => metSM_60000,
- _ => Array.Empty()
- };
- }
+ 0 => metSM_00000,
+ 3 => metSM_30000,
+ 4 => metSM_40000,
+ 6 => metSM_60000,
+ _ => Array.Empty()
+ };
- public IReadOnlyList GetLocationNames7GG(int bankID)
+ public IReadOnlyList GetLocationNames7GG(int bankID) => bankID switch
{
- return bankID switch
- {
- 0 => metGG_00000,
- 3 => metGG_30000,
- 4 => metGG_40000,
- 6 => metGG_60000,
- _ => Array.Empty()
- };
- }
+ 0 => metGG_00000,
+ 3 => metGG_30000,
+ 4 => metGG_40000,
+ 6 => metGG_60000,
+ _ => Array.Empty()
+ };
- public IReadOnlyList GetLocationNames8(int bankID)
+ public IReadOnlyList GetLocationNames8(int bankID) => bankID switch
{
- return bankID switch
- {
- 0 => metSWSH_00000,
- 3 => metSWSH_30000,
- 4 => metSWSH_40000,
- 6 => metSWSH_60000,
- _ => Array.Empty()
- };
- }
+ 0 => metSWSH_00000,
+ 3 => metSWSH_30000,
+ 4 => metSWSH_40000,
+ 6 => metSWSH_60000,
+ _ => Array.Empty()
+ };
}
}
diff --git a/PKHeX.Core/Game/GameStrings/MemoryStrings.cs b/PKHeX.Core/Game/GameStrings/MemoryStrings.cs
index 328738b44..88778a1ee 100644
--- a/PKHeX.Core/Game/GameStrings/MemoryStrings.cs
+++ b/PKHeX.Core/Game/GameStrings/MemoryStrings.cs
@@ -58,17 +58,14 @@ private List GetMemories()
public string[] GetMemoryQualities() => s.memories.Slice(2, 7);
public string[] GetMemoryFeelings(int format) => format >= 8 ? s.memories.Slice(9, 25) : s.memories.Slice(10, 24); // empty line for 0 in gen8+
- public List GetArgumentStrings(MemoryArgType memIndex)
+ public List GetArgumentStrings(MemoryArgType type) => type switch
{
- return memIndex switch
- {
- MemoryArgType.Species => Species,
- MemoryArgType.GeneralLocation => GeneralLocations,
- MemoryArgType.Item => Items,
- MemoryArgType.Move => Moves,
- MemoryArgType.SpecificLocation => SpecificLocations,
- _ => None
- };
- }
+ MemoryArgType.Species => Species,
+ MemoryArgType.GeneralLocation => GeneralLocations,
+ MemoryArgType.Item => Items,
+ MemoryArgType.Move => Moves,
+ MemoryArgType.SpecificLocation => SpecificLocations,
+ _ => None
+ };
}
}
diff --git a/PKHeX.Core/Game/GameUtil.cs b/PKHeX.Core/Game/GameUtil.cs
index f44ddcc2a..27558c63a 100644
--- a/PKHeX.Core/Game/GameUtil.cs
+++ b/PKHeX.Core/Game/GameUtil.cs
@@ -30,69 +30,63 @@ public static class GameUtil
/// Determines the Version Grouping of an input Version ID
/// Version of which to determine the group
/// Version Group Identifier or Invalid if type cannot be determined.
- public static GameVersion GetMetLocationVersionGroup(GameVersion version)
+ public static GameVersion GetMetLocationVersionGroup(GameVersion version) => version switch
{
- return version switch
- {
- // Side games
- CXD => CXD,
- GO => GO,
+ // Side games
+ CXD => CXD,
+ GO => GO,
- // VC Transfers
- RD or BU or YW or GN or GD or SV or C => USUM,
+ // VC Transfers
+ RD or BU or YW or GN or GD or SV or C => USUM,
- // Gen2 -- PK2
- GS or GSC => GSC,
+ // Gen2 -- PK2
+ GS or GSC => GSC,
- // Gen3
- R or S => RS,
- E => E,
- FR or LG => FR,
+ // Gen3
+ R or S => RS,
+ E => E,
+ FR or LG => FR,
- // Gen4
- D or P => DP,
- Pt => Pt,
- HG or SS => HGSS,
+ // Gen4
+ D or P => DP,
+ Pt => Pt,
+ HG or SS => HGSS,
- // Gen5
- B or W => BW,
- B2 or W2 => B2W2,
+ // Gen5
+ B or W => BW,
+ B2 or W2 => B2W2,
- // Gen6
- X or Y => XY,
- OR or AS => ORAS,
+ // Gen6
+ X or Y => XY,
+ OR or AS => ORAS,
- // Gen7
- SN or MN => SM,
- US or UM => USUM,
- GP or GE => GG,
+ // Gen7
+ SN or MN => SM,
+ US or UM => USUM,
+ GP or GE => GG,
- // Gen8
- SW or SH => SWSH,
- _ => Invalid,
- };
- }
+ // Gen8
+ SW or SH => SWSH,
+ _ => Invalid,
+ };
///
/// Gets a Version ID from the end of that Generation
///
/// Generation ID
/// Version ID from requested generation. If none, return .
- public static GameVersion GetVersion(int generation)
+ public static GameVersion GetVersion(int generation) => generation switch
{
- return generation switch
- {
- 1 => RBY,
- 2 => C,
- 3 => E,
- 4 => SS,
- 5 => W2,
- 6 => AS,
- 7 => UM,
- 8 => SH,
- _ => Invalid
- };
- }
+ 1 => RBY,
+ 2 => C,
+ 3 => E,
+ 4 => SS,
+ 5 => W2,
+ 6 => AS,
+ 7 => UM,
+ 8 => SH,
+ _ => Invalid
+ };
///
/// Gets the Generation the belongs to.
diff --git a/PKHeX.Core/Legality/Breeding.cs b/PKHeX.Core/Legality/Breeding.cs
index f7e13001d..ab6d2019f 100644
--- a/PKHeX.Core/Legality/Breeding.cs
+++ b/PKHeX.Core/Legality/Breeding.cs
@@ -76,15 +76,12 @@ internal static bool GetCanInheritMoves(int species)
(int)Chimecho,
};
- internal static ICollection GetSplitBreedGeneration(int generation)
+ internal static ICollection GetSplitBreedGeneration(int generation) => generation switch
{
- return generation switch
- {
- 3 => SplitBreed_3,
- 4 or 5 or 6 or 7 or 8 => SplitBreed,
- _ => Array.Empty(),
- };
- }
+ 3 => SplitBreed_3,
+ 4 or 5 or 6 or 7 or 8 => SplitBreed,
+ _ => Array.Empty(),
+ };
public static bool NoHatchFromEggForm(int species, int form, int generation)
{
diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs
index ebc29f247..116f8f2c4 100644
--- a/PKHeX.Core/Legality/Core.cs
+++ b/PKHeX.Core/Legality/Core.cs
@@ -60,37 +60,31 @@ public static IReadOnlyList GetPPTable(PKM pkm, int format)
return lgpe ? MovePP_GG : MovePP_SM;
}
- public static IReadOnlyList GetPPTable(int format)
+ public static IReadOnlyList GetPPTable(int format) => format switch
{
- return format switch
- {
- 1 => MovePP_RBY,
- 2 => MovePP_GSC,
- 3 => MovePP_RS,
- 4 => MovePP_DP,
- 5 => MovePP_BW,
- 6 => MovePP_XY,
- 7 => MovePP_SM,
- 8 => MovePP_SWSH,
- _ => Array.Empty()
- };
- }
+ 1 => MovePP_RBY,
+ 2 => MovePP_GSC,
+ 3 => MovePP_RS,
+ 4 => MovePP_DP,
+ 5 => MovePP_BW,
+ 6 => MovePP_XY,
+ 7 => MovePP_SM,
+ 8 => MovePP_SWSH,
+ _ => Array.Empty()
+ };
- internal static ICollection GetWildBalls(int gen, GameVersion game)
+ internal static ICollection GetWildBalls(int generation, GameVersion game) => generation switch
{
- return gen switch
- {
- 1 => WildPokeBalls1,
- 2 => WildPokeBalls2,
- 3 => WildPokeBalls3,
- 4 => GameVersion.HGSS.Contains(game) ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt,
- 5 => WildPokeBalls5,
- 6 => WildPokeballs6,
- 7 => GameVersion.Gen7b.Contains(game) ? WildPokeballs7b : WildPokeballs7,
- 8 => GameVersion.GO == game ? WildPokeballs8g : WildPokeballs8,
- _ => Array.Empty()
- };
- }
+ 1 => WildPokeBalls1,
+ 2 => WildPokeBalls2,
+ 3 => WildPokeBalls3,
+ 4 => GameVersion.HGSS.Contains(game) ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt,
+ 5 => WildPokeBalls5,
+ 6 => WildPokeballs6,
+ 7 => GameVersion.Gen7b.Contains(game) ? WildPokeballs7b : WildPokeballs7,
+ 8 => GameVersion.GO == game ? WildPokeballs8g : WildPokeballs8,
+ _ => Array.Empty()
+ };
internal static int GetMaxSpeciesOrigin(PKM pkm)
{
@@ -101,71 +95,54 @@ internal static int GetMaxSpeciesOrigin(PKM pkm)
return GetMaxSpeciesOrigin(pkm.Generation);
}
- internal static int GetMaxSpeciesOrigin(int generation)
+ internal static int GetMaxSpeciesOrigin(int generation) => generation switch
{
- return generation switch
- {
- 1 => MaxSpeciesID_1,
- 2 => MaxSpeciesID_2,
- 3 => MaxSpeciesID_3,
- 4 => MaxSpeciesID_4,
- 5 => MaxSpeciesID_5,
- 6 => MaxSpeciesID_6,
- 7 => MaxSpeciesID_7b,
- 8 => MaxSpeciesID_8,
- _ => -1
- };
- }
+ 1 => MaxSpeciesID_1,
+ 2 => MaxSpeciesID_2,
+ 3 => MaxSpeciesID_3,
+ 4 => MaxSpeciesID_4,
+ 5 => MaxSpeciesID_5,
+ 6 => MaxSpeciesID_6,
+ 7 => MaxSpeciesID_7b,
+ 8 => MaxSpeciesID_8,
+ _ => -1
+ };
- internal static ICollection GetFutureGenEvolutions(int generation)
+ internal static ICollection GetFutureGenEvolutions(int generation) => generation switch
{
- return generation switch
- {
- 1 => FutureEvolutionsGen1,
- 2 => FutureEvolutionsGen2,
- 3 => FutureEvolutionsGen3,
- 4 => FutureEvolutionsGen4,
- 5 => FutureEvolutionsGen5,
- _ => Array.Empty()
- };
- }
+ 1 => FutureEvolutionsGen1,
+ 2 => FutureEvolutionsGen2,
+ 3 => FutureEvolutionsGen3,
+ 4 => FutureEvolutionsGen4,
+ 5 => FutureEvolutionsGen5,
+ _ => Array.Empty()
+ };
- internal static int GetDebutGeneration(int species)
+ internal static int GetDebutGeneration(int species) => species switch
{
- if (species <= MaxSpeciesID_1)
- return 1;
- if (species <= MaxSpeciesID_2)
- return 2;
- if (species <= MaxSpeciesID_3)
- return 3;
- if (species <= MaxSpeciesID_4)
- return 4;
- if (species <= MaxSpeciesID_5)
- return 5;
- if (species <= MaxSpeciesID_6)
- return 6;
- if (species <= MaxSpeciesID_7b)
- return 7;
- if (species <= MaxSpeciesID_8)
- return 8;
- return -1;
- }
+ <= MaxSpeciesID_1 => 1,
+ <= MaxSpeciesID_2 => 2,
+ <= MaxSpeciesID_3 => 3,
+ <= MaxSpeciesID_4 => 4,
+ <= MaxSpeciesID_5 => 5,
+ <= MaxSpeciesID_6 => 6,
+ <= MaxSpeciesID_7b => 7,
+ <= MaxSpeciesID_8 => 8,
+ _ => -1
+ };
- internal static int GetMaxLanguageID(int generation)
+ internal static int GetMaxLanguageID(int generation) => generation switch
{
- return generation switch
- {
- 1 => (int) LanguageID.Spanish, // 1-7 except 6
- 3 => (int) LanguageID.Spanish, // 1-7 except 6
- 2 => (int) LanguageID.Korean,
- 4 => (int) LanguageID.Korean,
- 5 => (int) LanguageID.Korean,
- 6 => (int) LanguageID.Korean,
- 7 => (int) LanguageID.ChineseT,
- 8 => (int) LanguageID.ChineseT,
- _ => -1
- };
- }
+ 1 => (int) LanguageID.Spanish, // 1-7 except 6
+ 3 => (int) LanguageID.Spanish, // 1-7 except 6
+ 2 => (int) LanguageID.Korean,
+ 4 => (int) LanguageID.Korean,
+ 5 => (int) LanguageID.Korean,
+ 6 => (int) LanguageID.Korean,
+ 7 => (int) LanguageID.ChineseT,
+ 8 => (int) LanguageID.ChineseT,
+ _ => -1
+ };
internal static bool GetCanLearnMachineMove(PKM pkm, int move, int generation, GameVersion version = GameVersion.Any)
{
@@ -204,25 +181,19 @@ public static bool IsValidMissingLanguage(PKM pkm)
return pkm.Format == 5 && pkm.BW;
}
- public static int GetMaxLengthOT(int gen, LanguageID lang)
+ public static int GetMaxLengthOT(int generation, LanguageID language) => language switch
{
- return lang switch
- {
- LanguageID.ChineseS or LanguageID.ChineseT => 6,
- LanguageID.Japanese or LanguageID.Korean => gen >= 6 ? 6 : 5,
- _ => gen >= 6 ? 12 : 7
- };
- }
+ LanguageID.ChineseS or LanguageID.ChineseT => 6,
+ LanguageID.Japanese or LanguageID.Korean => generation >= 6 ? 6 : 5,
+ _ => generation >= 6 ? 12 : 7
+ };
- public static int GetMaxLengthNickname(int gen, LanguageID lang)
+ public static int GetMaxLengthNickname(int generation, LanguageID language) => language switch
{
- return lang switch
- {
- LanguageID.ChineseS or LanguageID.ChineseT => 6,
- LanguageID.Japanese or LanguageID.Korean => gen >= 6 ? 6 : 5,
- _ => gen >= 6 ? 12 : 10
- };
- }
+ LanguageID.ChineseS or LanguageID.ChineseT => 6,
+ LanguageID.Japanese or LanguageID.Korean => generation >= 6 ? 6 : 5,
+ _ => generation >= 6 ? 12 : 10
+ };
public static bool GetIsFixedIVSequenceValidSkipRand(IReadOnlyList IVs, PKM pkm, int max = 31)
{
diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs
index e68d9b899..1f1ea1a13 100644
--- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs
+++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using static PKHeX.Core.EncounterType;
namespace PKHeX.Core
{
@@ -15,7 +16,7 @@ public sealed record EncounterStatic4 : EncounterStatic, IEncounterTypeTile
public bool Roaming { get; init; }
/// values permitted for the encounter.
- public EncounterType TypeEncounter { get; init; } = EncounterType.None;
+ public EncounterType TypeEncounter { get; init; } = None;
protected override bool IsMatchLocation(PKM pkm)
{
@@ -100,16 +101,13 @@ protected override void SetMetData(PKM pk, int level, DateTime today)
pk.MetDate = today;
}
- private static int[] GetRoamLocations(int species, int type)
+ private static int[] GetRoamLocations(int species, int type) => species switch
{
- return species switch
- {
- 481 or 488 or 144 or 145 or 146 => 1 << type == (int)EncounterType.TallGrass ? Roaming_MetLocation_DPPt_Grass : Roaming_MetLocation_DPPt_Surf,
- 243 or 244 => 1 << type == (int)EncounterType.TallGrass ? Roaming_MetLocation_HGSS_Johto_Grass : Roaming_MetLocation_HGSS_Johto_Surf,
- 380 or 381 => 1 << type == (int)EncounterType.TallGrass ? Roaming_MetLocation_HGSS_Kanto_Grass : Roaming_MetLocation_HGSS_Kanto_Surf,
- _ => throw new IndexOutOfRangeException(nameof(species)),
- };
- }
+ 481 or 488 or 144 or 145 or 146 => 1 << type == (int)TallGrass ? Roaming_MetLocation_DPPt_Grass : Roaming_MetLocation_DPPt_Surf,
+ 243 or 244 => 1 << type == (int)TallGrass ? Roaming_MetLocation_HGSS_Johto_Grass : Roaming_MetLocation_HGSS_Johto_Surf,
+ 380 or 381 => 1 << type == (int)TallGrass ? Roaming_MetLocation_HGSS_Kanto_Grass : Roaming_MetLocation_HGSS_Kanto_Surf,
+ _ => throw new IndexOutOfRangeException(nameof(species)),
+ };
private static readonly int[] Roaming_MetLocation_DPPt_Grass =
{
diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs
index 64f42dc59..846307951 100644
--- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs
+++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs
@@ -61,21 +61,18 @@ public int TID7
public bool HasNickname => Nicknames.Count != 0 && IsNicknamed;
public bool HasTrainerName => TrainerNames.Count != 0;
- private static int GetDefaultMetLocation(int generation)
+ private static int GetDefaultMetLocation(int generation) => generation switch
{
- return generation switch
- {
- 1 => 0,
- 2 => Locations.LinkTrade2NPC,
- 3 => Locations.LinkTrade3NPC,
- 4 => Locations.LinkTrade4NPC,
- 5 => Locations.LinkTrade5NPC,
- 6 => Locations.LinkTrade6NPC,
- 7 => Locations.LinkTrade6NPC, // 7 is same as 6
- 8 => Locations.LinkTrade6NPC, // 8 is same as 6
- _ => throw new IndexOutOfRangeException(nameof(generation)),
- };
- }
+ 1 => 0,
+ 2 => Locations.LinkTrade2NPC,
+ 3 => Locations.LinkTrade3NPC,
+ 4 => Locations.LinkTrade4NPC,
+ 5 => Locations.LinkTrade5NPC,
+ 6 => Locations.LinkTrade6NPC,
+ 7 => Locations.LinkTrade6NPC, // 7 is same as 6
+ 8 => Locations.LinkTrade6NPC, // 8 is same as 6
+ _ => throw new IndexOutOfRangeException(nameof(generation)),
+ };
public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPKM(sav, EncounterCriteria.Unrestricted);
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs
index d156af51e..468ecb921 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs
@@ -24,18 +24,15 @@ public static class EncounterGenerator
///
/// The iterator lazily finds possible encounters. If no encounters are possible, the enumerable will be empty.
///
- public static IEnumerable GetEncounters(PKM pkm, LegalInfo info)
+ public static IEnumerable GetEncounters(PKM pkm, LegalInfo info) => info.Generation switch
{
- return info.Generation switch
- {
- 1 => EncounterGenerator12.GetEncounters12(pkm, info),
- 2 => EncounterGenerator12.GetEncounters12(pkm, info),
- 3 => GetEncounters3(pkm, info),
- 4 => GetEncounters4(pkm, info),
- 8 => GenerateRawEncounters8(pkm),
- _ => GenerateRawEncounters(pkm)
- };
- }
+ 1 => EncounterGenerator12.GetEncounters12(pkm, info),
+ 2 => EncounterGenerator12.GetEncounters12(pkm, info),
+ 3 => GetEncounters3(pkm, info),
+ 4 => GetEncounters4(pkm, info),
+ 8 => GenerateRawEncounters8(pkm),
+ _ => GenerateRawEncounters(pkm)
+ };
private static IEnumerable GetEncounters3(PKM pkm, LegalInfo info)
{
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs
index 22e00e6be..1364943af 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs
@@ -144,18 +144,15 @@ private static PeekEnumerator PickPreferredIterator(PKM pkm, Pee
return p1 > p2 ? g1i : g2i;
}
- private static GBEncounterPriority GetGBEncounterPriority(PKM pkm, IEncounterable Encounter)
+ private static GBEncounterPriority GetGBEncounterPriority(PKM pkm, IEncounterable enc) => enc switch
{
- return Encounter switch
- {
- EncounterTrade1 t1 when t1.IsMatchDeferred(pkm) => GBEncounterPriority.Least,
- EncounterTrade1 => GBEncounterPriority.TradeEncounterG1,
- EncounterTrade2 => GBEncounterPriority.TradeEncounterG2,
- EncounterStatic => GBEncounterPriority.StaticEncounter,
- EncounterSlot => GBEncounterPriority.WildEncounter,
- _ => GBEncounterPriority.EggEncounter
- };
- }
+ EncounterTrade1 t1 when t1.IsMatchDeferred(pkm) => GBEncounterPriority.Least,
+ EncounterTrade1 => GBEncounterPriority.TradeEncounterG1,
+ EncounterTrade2 => GBEncounterPriority.TradeEncounterG2,
+ EncounterStatic => GBEncounterPriority.StaticEncounter,
+ EncounterSlot => GBEncounterPriority.WildEncounter,
+ _ => GBEncounterPriority.EggEncounter
+ };
///
/// Generation 1/2 Encounter Data type, which serves as a 'best match' priority rating when returning from a list.
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs
index ab8b6e5f6..334faa4f1 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterSlotGenerator.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using static PKHeX.Core.Legal;
@@ -131,53 +132,47 @@ private static bool IsHiddenAbilitySlot(this EncounterSlot slot)
.FirstOrDefault();
}
- private static IEnumerable GetEncounterTable(PKM pkm, GameVersion gameSource = GameVersion.Any)
+ private static IEnumerable GetEncounterTable(PKM pkm, GameVersion game) => game switch
{
- if (gameSource == GameVersion.Any)
- gameSource = (GameVersion)pkm.Version;
+ RBY or RD or BU or GN or YW => SlotsRBY,
- return gameSource switch
- {
- RBY or RD or BU or GN or YW => SlotsRBY,
+ GSC or GD or SV or C => GetEncounterTableGSC(pkm),
- GSC or GD or SV or C => GetEncounterTableGSC(pkm),
+ R => SlotsR,
+ S => SlotsS,
+ E => SlotsE,
+ FR => SlotsFR,
+ LG => SlotsLG,
+ CXD => SlotsXD,
- R => SlotsR,
- S => SlotsS,
- E => SlotsE,
- FR => SlotsFR,
- LG => SlotsLG,
- CXD => SlotsXD,
+ D => SlotsD,
+ P => SlotsP,
+ Pt => SlotsPt,
+ HG => SlotsHG,
+ SS => SlotsSS,
- D => SlotsD,
- P => SlotsP,
- Pt => SlotsPt,
- HG => SlotsHG,
- SS => SlotsSS,
+ B => SlotsB,
+ W => SlotsW,
+ B2 => SlotsB2,
+ W2 => SlotsW2,
- B => SlotsB,
- W => SlotsW,
- B2 => SlotsB2,
- W2 => SlotsW2,
+ X => SlotsX,
+ Y => SlotsY,
+ AS => SlotsA,
+ OR => SlotsO,
- X => SlotsX,
- Y => SlotsY,
- AS => SlotsA,
- OR => SlotsO,
+ SN => SlotsSN,
+ MN => SlotsMN,
+ US => SlotsUS,
+ UM => SlotsUM,
+ GP => SlotsGP,
+ GE => SlotsGE,
- SN => SlotsSN,
- MN => SlotsMN,
- US => SlotsUS,
- UM => SlotsUM,
- GP => SlotsGP,
- GE => SlotsGE,
-
- GO => GetEncounterTableGO(pkm),
- SW => SlotsSW,
- SH => SlotsSH,
- _ => Enumerable.Empty()
- };
- }
+ GO => GetEncounterTableGO(pkm),
+ SW => SlotsSW,
+ SH => SlotsSH,
+ _ => Array.Empty()
+ };
private static IEnumerable GetEncounterTableGSC(PKM pkm)
{
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs
index 82d54a118..1e8c86623 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterStaticGenerator.cs
@@ -129,52 +129,46 @@ internal static EncounterStatic7 GetVCStaticTransferEncounter(PKM pkm, IEncounte
}
// Generation Specific Fetching
- private static IEnumerable GetEncounterStaticTable(PKM pkm, GameVersion gameSource = Any)
+ private static IEnumerable GetEncounterStaticTable(PKM pkm, GameVersion game) => game switch
{
- if (gameSource == Any)
- gameSource = (GameVersion)pkm.Version;
+ RBY or RD or BU or GN or YW => StaticRBY,
- return gameSource switch
- {
- RBY or RD or BU or GN or YW => StaticRBY,
+ GSC or GD or SV or C => GetEncounterStaticTableGSC(pkm),
- GSC or GD or SV or C => GetEncounterStaticTableGSC(pkm),
+ R => StaticR,
+ S => StaticS,
+ E => StaticE,
+ FR => StaticFR,
+ LG => StaticLG,
+ CXD => Encounter_CXD,
- R => StaticR,
- S => StaticS,
- E => StaticE,
- FR => StaticFR,
- LG => StaticLG,
- CXD => Encounter_CXD,
+ D => StaticD,
+ P => StaticP,
+ Pt => StaticPt,
+ HG => StaticHG,
+ SS => StaticSS,
- D => StaticD,
- P => StaticP,
- Pt => StaticPt,
- HG => StaticHG,
- SS => StaticSS,
+ B => StaticB,
+ W => StaticW,
+ B2 => StaticB2,
+ W2 => StaticW2,
- B => StaticB,
- W => StaticW,
- B2 => StaticB2,
- W2 => StaticW2,
+ X => StaticX,
+ Y => StaticY,
+ AS => StaticA,
+ OR => StaticO,
- X => StaticX,
- Y => StaticY,
- AS => StaticA,
- OR => StaticO,
+ SN => StaticSN,
+ MN => StaticMN,
+ US => StaticUS,
+ UM => StaticUM,
+ GP => StaticGP,
+ GE => StaticGE,
- SN => StaticSN,
- MN => StaticMN,
- US => StaticUS,
- UM => StaticUM,
- GP => StaticGP,
- GE => StaticGE,
-
- SW => StaticSW,
- SH => StaticSH,
- _ => Enumerable.Empty(),
- };
- }
+ SW => StaticSW,
+ SH => StaticSH,
+ _ => Array.Empty(),
+ };
private static IEnumerable GetEncounterStaticTableGSC(PKM pkm)
{
diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterTradeGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterTradeGenerator.cs
index 0fc5bee95..97019fd4a 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/EncounterTradeGenerator.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterTradeGenerator.cs
@@ -74,19 +74,16 @@ private static IEnumerable GetEncounterTradeTableVC(GameVersio
return Array.Empty();
}
- private static IEnumerable GetEncounterTradeTable(PKM pkm)
+ private static IEnumerable GetEncounterTradeTable(PKM pkm) => pkm.Generation switch
{
- return pkm.Generation switch
- {
- 3 => (pkm.FRLG ? Encounters3.TradeGift_FRLG : Encounters3.TradeGift_RSE),
- 4 => (pkm.HGSS ? Encounters4.TradeGift_HGSS : Encounters4.TradeGift_DPPt),
- 5 => (pkm.B2W2 ? Encounters5.TradeGift_B2W2 : Encounters5.TradeGift_BW),
- 6 => (pkm.XY ? Encounters6.TradeGift_XY : Encounters6.TradeGift_AO),
- 7 => (pkm.LGPE ? Encounters7b.TradeGift_GG : pkm.SM ? Encounters7.TradeGift_SM : Encounters7.TradeGift_USUM),
- 8 => Encounters8.TradeGift_SWSH,
- _ => Array.Empty(),
- };
- }
+ 3 => (pkm.FRLG ? Encounters3.TradeGift_FRLG : Encounters3.TradeGift_RSE),
+ 4 => (pkm.HGSS ? Encounters4.TradeGift_HGSS : Encounters4.TradeGift_DPPt),
+ 5 => (pkm.B2W2 ? Encounters5.TradeGift_B2W2 : Encounters5.TradeGift_BW),
+ 6 => (pkm.XY ? Encounters6.TradeGift_XY : Encounters6.TradeGift_AO),
+ 7 => (pkm.LGPE ? Encounters7b.TradeGift_GG : pkm.SM ? Encounters7.TradeGift_SM : Encounters7.TradeGift_USUM),
+ 8 => Encounters8.TradeGift_SWSH,
+ _ => Array.Empty(),
+ };
private static IEnumerable GetValidEncounterTradesVC(PKM pkm, IReadOnlyList chain, GameVersion gameSource)
{
diff --git a/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs
index 2f9d6d72c..d5ddd1344 100644
--- a/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs
+++ b/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs
@@ -32,19 +32,16 @@ public static IEnumerable GetValidGifts(PKM pkm, IReadOnlyList GetTable(int generation, PKM pkm)
+ private static IReadOnlyList GetTable(int generation, PKM pkm) => generation switch
{
- return generation switch
- {
- 3 => MGDB_G3,
- 4 => MGDB_G4,
- 5 => MGDB_G5,
- 6 => MGDB_G6,
- 7 => pkm.LGPE ? (IReadOnlyList)MGDB_G7GG : MGDB_G7,
- 8 => MGDB_G8,
- _ => Array.Empty()
- };
- }
+ 3 => MGDB_G3,
+ 4 => MGDB_G4,
+ 5 => MGDB_G5,
+ 6 => MGDB_G6,
+ 7 => pkm.LGPE ? MGDB_G7GG : MGDB_G7,
+ 8 => MGDB_G8,
+ _ => Array.Empty()
+ };
private static IEnumerable GetMatchingPCD(PKM pkm, IReadOnlyList DB, IReadOnlyList chain)
{
diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs
index 0e91f0793..b44e196df 100644
--- a/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs
+++ b/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs
@@ -53,16 +53,13 @@ public static int GetSuggestedEncounterEggLocationEgg(PKM pkm, bool traded = fal
return GetSuggestedEncounterEggLocationEgg(pkm.Generation, traded);
}
- public static int GetSuggestedEncounterEggLocationEgg(int generation, bool traded = false)
+ public static int GetSuggestedEncounterEggLocationEgg(int generation, bool traded = false) => generation switch
{
- return generation switch
- {
- 1 or 2 or 3 => 0,
- 4 => traded ? Locations.LinkTrade4 : Locations.Daycare4,
- 5 => traded ? Locations.LinkTrade5 : Locations.Daycare5,
- _ => traded ? Locations.LinkTrade6 : Locations.Daycare5,
- };
- }
+ 1 or 2 or 3 => 0,
+ 4 => traded ? Locations.LinkTrade4 : Locations.Daycare4,
+ 5 => traded ? Locations.LinkTrade5 : Locations.Daycare5,
+ _ => traded ? Locations.LinkTrade6 : Locations.Daycare5,
+ };
private static EncounterSuggestionData GetSuggestedEncounterWild(PKM pkm, EncounterSlot first, int loc = -1)
{
@@ -80,35 +77,31 @@ private static EncounterSuggestionData GetSuggestedEncounterStatic(PKM pkm, Enco
/// Gets a valid Egg hatch location for the origin game.
///
/// Pokémon data to suggest for
- public static int GetSuggestedEggMetLocation(PKM pkm)
+ public static int GetSuggestedEggMetLocation(PKM pkm) => (GameVersion)pkm.Version switch
{
- // Return one of legal hatch locations for game
- return ((GameVersion)pkm.Version) switch
+ R or S or E or FR or LG => pkm.Format switch
{
- R or S or E or FR or LG => pkm.Format switch
- {
- 3 => (pkm.FRLG ? Locations.HatchLocationFRLG : Locations.HatchLocationRSE),
- 4 => Locations.Transfer3, // Pal Park
- _ => Locations.Transfer4,
- },
+ 3 => (pkm.FRLG ? Locations.HatchLocationFRLG : Locations.HatchLocationRSE),
+ 4 => Locations.Transfer3, // Pal Park
+ _ => Locations.Transfer4,
+ },
- D or P or Pt => pkm.Format > 4 ? Locations.Transfer4 : Locations.HatchLocationDPPt,
- HG or SS => pkm.Format > 4 ? Locations.Transfer4 : Locations.HatchLocationHGSS,
+ D or P or Pt => pkm.Format > 4 ? Locations.Transfer4 : Locations.HatchLocationDPPt,
+ HG or SS => pkm.Format > 4 ? Locations.Transfer4 : Locations.HatchLocationHGSS,
- B or W or B2 or W2 => Locations.HatchLocation5,
+ B or W or B2 or W2 => Locations.HatchLocation5,
- X or Y => Locations.HatchLocation6XY,
- AS or OR => Locations.HatchLocation6AO,
+ X or Y => Locations.HatchLocation6XY,
+ AS or OR => Locations.HatchLocation6AO,
- SN or MN or US or UM => Locations.HatchLocation7,
- RD or BU or GN or Y => Locations.Transfer1,
- GD or SV or C => Locations.Transfer2,
- GSC or RBY => pkm.Met_Level == 0 ? 0 : Locations.HatchLocationC,
+ SN or MN or US or UM => Locations.HatchLocation7,
+ RD or BU or GN or Y => Locations.Transfer1,
+ GD or SV or C => Locations.Transfer2,
+ GSC or RBY => pkm.Met_Level == 0 ? 0 : Locations.HatchLocationC,
- SW or SH => Locations.HatchLocation8,
- _ => -1,
- };
- }
+ SW or SH => Locations.HatchLocation8,
+ _ => -1,
+ };
///
/// Gets the correct Transfer Met location for the origin game.
diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs
index d8ad72aad..05517992d 100644
--- a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs
+++ b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs
@@ -12,27 +12,21 @@ public static class EncounterVerifier
///
/// Source data to verify
/// Returns the verification method appropriate for the input PKM
- public static Func GetEncounterVerifierMethod(PKM pkm)
+ public static Func GetEncounterVerifierMethod(PKM pkm) => pkm.Generation switch
{
- return pkm.Generation switch
- {
- 1 or 2 => VerifyEncounterG12,
- _ => VerifyEncounter,
- };
- }
+ 1 or 2 => VerifyEncounterG12,
+ _ => VerifyEncounter,
+ };
- private static CheckResult VerifyEncounter(PKM pkm, LegalInfo info)
+ private static CheckResult VerifyEncounter(PKM pkm, LegalInfo info) => info.EncounterMatch switch
{
- return info.EncounterMatch switch
- {
- EncounterEgg e => VerifyEncounterEgg(pkm, e.Generation),
- EncounterTrade t => VerifyEncounterTrade(pkm, t),
- EncounterSlot w => VerifyEncounterWild(w),
- EncounterStatic s => VerifyEncounterStatic(pkm, s),
- MysteryGift g => VerifyEncounterEvent(pkm, g),
- _ => new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter)
- };
- }
+ EncounterEgg e => VerifyEncounterEgg(pkm, e.Generation),
+ EncounterTrade t => VerifyEncounterTrade(pkm, t),
+ EncounterSlot w => VerifyEncounterWild(w),
+ EncounterStatic s => VerifyEncounterStatic(pkm, s),
+ MysteryGift g => VerifyEncounterEvent(pkm, g),
+ _ => new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter)
+ };
private static CheckResult VerifyEncounterG12(PKM pkm, LegalInfo info)
{
diff --git a/PKHeX.Core/Legality/Enums/Severity.cs b/PKHeX.Core/Legality/Enums/Severity.cs
index 03671ba8f..35dfd0c24 100644
--- a/PKHeX.Core/Legality/Enums/Severity.cs
+++ b/PKHeX.Core/Legality/Enums/Severity.cs
@@ -38,16 +38,13 @@ public static partial class Extensions
///
/// value to convert to string.
/// Localized .
- public static string Description(this Severity s)
+ public static string Description(this Severity s) => s switch
{
- return s switch
- {
- Severity.Indeterminate => L_SIndeterminate,
- Severity.Invalid => L_SInvalid,
- Severity.Fishy => L_SFishy,
- Severity.Valid => L_SValid,
- _ => L_SNotImplemented
- };
- }
+ Severity.Indeterminate => L_SIndeterminate,
+ Severity.Invalid => L_SInvalid,
+ Severity.Fishy => L_SFishy,
+ Severity.Valid => L_SValid,
+ _ => L_SNotImplemented
+ };
}
}
diff --git a/PKHeX.Core/Legality/Enums/SlotType.cs b/PKHeX.Core/Legality/Enums/SlotType.cs
index 0fce95e03..04442662f 100644
--- a/PKHeX.Core/Legality/Enums/SlotType.cs
+++ b/PKHeX.Core/Legality/Enums/SlotType.cs
@@ -80,31 +80,25 @@ internal static bool IsFishingRodType(this SlotType t)
return t == SlotType.Old_Rod || t == SlotType.Good_Rod || t == SlotType.Super_Rod;
}
- internal static bool IsSweetScentType(this SlotType t)
+ internal static bool IsSweetScentType(this SlotType t) => t switch
{
- return t switch
- {
- SlotType.Grass => true,
- SlotType.Surf => true,
- SlotType.BugContest => true,
+ SlotType.Grass => true,
+ SlotType.Surf => true,
+ SlotType.BugContest => true,
- _ => false,
- };
- }
+ _ => false,
+ };
- public static Ball GetRequiredBallValueWild(this SlotType t, int gen, int loc)
+ public static Ball GetRequiredBallValueWild(this SlotType t, int generation, int location) => generation switch
{
- return gen switch
- {
- 3 when Locations.IsSafariZoneLocation3(loc) => Ball.Safari,
- 4 when Locations.IsSafariZoneLocation4(loc) => Ball.Safari,
- 4 when t == SlotType.BugContest => Ball.Sport,
+ 3 when Locations.IsSafariZoneLocation3(location) => Ball.Safari,
+ 4 when Locations.IsSafariZoneLocation4(location) => Ball.Safari,
+ 4 when t == SlotType.BugContest => Ball.Sport,
- // Poké Pelago
- 7 when loc == 30016 => Ball.Poke,
+ // Poké Pelago
+ 7 when location == 30016 => Ball.Poke,
- _ => Ball.None,
- };
- }
+ _ => Ball.None,
+ };
}
}
diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs
index 196607499..d8c2da778 100644
--- a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs
+++ b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs
@@ -34,35 +34,29 @@ static EvolutionTree()
Evolves8.FixEvoTreeSS();
}
- public static EvolutionTree GetEvolutionTree(int generation)
+ public static EvolutionTree GetEvolutionTree(int generation) => generation switch
{
- return generation switch
- {
- 1 => Evolves1,
- 2 => Evolves2,
- 3 => Evolves3,
- 4 => Evolves4,
- 5 => Evolves5,
- 6 => Evolves6,
- 7 => Evolves7,
- _ => Evolves8
- };
- }
+ 1 => Evolves1,
+ 2 => Evolves2,
+ 3 => Evolves3,
+ 4 => Evolves4,
+ 5 => Evolves5,
+ 6 => Evolves6,
+ 7 => Evolves7,
+ _ => Evolves8
+ };
- public static EvolutionTree GetEvolutionTree(PKM pkm, int generation)
+ public static EvolutionTree GetEvolutionTree(PKM pkm, int generation) => generation switch
{
- return generation switch
- {
- 1 => Evolves1,
- 2 => Evolves2,
- 3 => Evolves3,
- 4 => Evolves4,
- 5 => Evolves5,
- 6 => Evolves6,
- 7 => pkm.Version is (int)GO or (int)GP or (int)GE ? Evolves7b : Evolves7,
- _ => Evolves8
- };
- }
+ 1 => Evolves1,
+ 2 => Evolves2,
+ 3 => Evolves3,
+ 4 => Evolves4,
+ 5 => Evolves5,
+ 6 => Evolves6,
+ 7 => pkm.Version is (int)GO or (int)GP or (int)GE ? Evolves7b : Evolves7,
+ _ => Evolves8
+ };
private readonly IReadOnlyList Entries;
private readonly GameVersion Game;
@@ -78,7 +72,7 @@ private EvolutionTree(IReadOnlyList data, GameVersion game, PersonalTabl
Game = game;
Personal = personal;
MaxSpeciesTree = maxSpeciesTree;
- Entries = GetEntries(data);
+ Entries = GetEntries(data, game);
// Starting in Generation 7, forms have separate evolution data.
int format = Game - Gen1 + 1;
@@ -138,21 +132,18 @@ private EvolutionTree(IReadOnlyList data, GameVersion game, PersonalTabl
}
}
- private IReadOnlyList GetEntries(IReadOnlyList data)
+ private IReadOnlyList GetEntries(IReadOnlyList data, GameVersion game) => game switch
{
- return Game switch
- {
- Gen1 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree),
- Gen2 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree),
- Gen3 => EvolutionSet3.GetArray(data[0]),
- Gen4 => EvolutionSet4.GetArray(data[0]),
- Gen5 => EvolutionSet5.GetArray(data[0]),
- Gen6 => EvolutionSet6.GetArray(data),
- Gen7 => EvolutionSet7.GetArray(data),
- Gen8 => EvolutionSet7.GetArray(data),
- _ => throw new Exception()
- };
- }
+ Gen1 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree),
+ Gen2 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree),
+ Gen3 => EvolutionSet3.GetArray(data[0]),
+ Gen4 => EvolutionSet4.GetArray(data[0]),
+ Gen5 => EvolutionSet5.GetArray(data[0]),
+ Gen6 => EvolutionSet6.GetArray(data),
+ Gen7 => EvolutionSet7.GetArray(data),
+ Gen8 => EvolutionSet7.GetArray(data),
+ _ => throw new Exception()
+ };
private void FixEvoTreeSM()
{
diff --git a/PKHeX.Core/Legality/Moves/MoveEgg.cs b/PKHeX.Core/Legality/Moves/MoveEgg.cs
index d9d2530b9..d5091fb63 100644
--- a/PKHeX.Core/Legality/Moves/MoveEgg.cs
+++ b/PKHeX.Core/Legality/Moves/MoveEgg.cs
@@ -21,25 +21,22 @@ public static int[] GetEggMoves(PersonalInfo pi, int species, int form, GameVers
return GetEggMoves(generation, species, form, version);
}
- public static int[] GetEggMoves(int gen, int species, int form, GameVersion version)
+ public static int[] GetEggMoves(int generation, int species, int form, GameVersion version) => generation switch
{
- return gen switch
- {
- 1 or 2 => (version == C ? EggMovesC : EggMovesGS)[species].Moves,
- 3 => EggMovesRS[species].Moves,
- 4 when version is D or P or Pt => EggMovesDPPt[species].Moves,
- 4 when version is HG or SS => EggMovesHGSS[species].Moves,
- 5 => EggMovesBW[species].Moves,
+ 1 or 2 => (version == C ? EggMovesC : EggMovesGS)[species].Moves,
+ 3 => EggMovesRS[species].Moves,
+ 4 when version is D or P or Pt => EggMovesDPPt[species].Moves,
+ 4 when version is HG or SS => EggMovesHGSS[species].Moves,
+ 5 => EggMovesBW[species].Moves,
- 6 when version is X or Y => EggMovesXY[species].Moves,
- 6 when version is OR or AS => EggMovesAO[species].Moves,
+ 6 when version is X or Y => EggMovesXY[species].Moves,
+ 6 when version is OR or AS => EggMovesAO[species].Moves,
- 7 when version is SN or MN => GetFormEggMoves(species, form, EggMovesSM),
- 7 when version is US or UM => GetFormEggMoves(species, form, EggMovesUSUM),
- 8 => GetFormEggMoves(species, form, EggMovesSWSH),
- _ => Array.Empty(),
- };
- }
+ 7 when version is SN or MN => GetFormEggMoves(species, form, EggMovesSM),
+ 7 when version is US or UM => GetFormEggMoves(species, form, EggMovesUSUM),
+ 8 => GetFormEggMoves(species, form, EggMovesSWSH),
+ _ => Array.Empty(),
+ };
private static int[] GetFormEggMoves(int species, int form, IReadOnlyList table)
{
diff --git a/PKHeX.Core/Legality/Moves/MoveLevelUp.cs b/PKHeX.Core/Legality/Moves/MoveLevelUp.cs
index 0d5700058..402c04533 100644
--- a/PKHeX.Core/Legality/Moves/MoveLevelUp.cs
+++ b/PKHeX.Core/Legality/Moves/MoveLevelUp.cs
@@ -228,17 +228,14 @@ private static LearnVersion GetIsLevelUp3Deoxys(int form, int move, int lvl)
return LearnNONE;
}
- private static GameVersion GetDeoxysGameVersion3(int form)
+ private static GameVersion GetDeoxysGameVersion3(int form) => form switch
{
- return form switch
- {
- 0 => RS,
- 1 => FR,
- 2 => LG,
- 3 => E,
- _ => Invalid
- };
- }
+ 0 => RS,
+ 1 => FR,
+ 2 => LG,
+ 3 => E,
+ _ => Invalid
+ };
private static Learnset? GetDeoxysLearn3(int form, GameVersion ver = Any)
{
diff --git a/PKHeX.Core/Legality/RNG/Frame/FrameGenerator.cs b/PKHeX.Core/Legality/RNG/Frame/FrameGenerator.cs
index 5efe99489..8ac122a2c 100644
--- a/PKHeX.Core/Legality/RNG/Frame/FrameGenerator.cs
+++ b/PKHeX.Core/Legality/RNG/Frame/FrameGenerator.cs
@@ -86,16 +86,15 @@ public FrameGenerator(PKM pk)
/// Gender Ratio
/// Return Max (or Min)
/// Returns the maximum or minimum gender value that corresponds to the input gender ratio.
- private static int GetGenderMinMax(int gender, int ratio, bool max)
+ private static int GetGenderMinMax(int gender, int ratio, bool max) => ratio switch
{
- if (ratio is 0 or 254 or 255)
- return max ? 255 : 0;
- return gender switch
+ 0 or >254 => max ? 255 : 0,
+ _ => gender switch
{
- 0 => (max ? 255 : ratio), // male
- 1 => (max ? ratio - 1 : 0), // female
- _ => (max ? 255 : 0),
- };
- }
+ 0 => max ? 255 : ratio, // male
+ 1 => max ? ratio - 1 : 0, // female
+ _ => max ? 255 : 0,
+ }
+ };
}
}
diff --git a/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs b/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs
index 9aa9284e6..f32313c04 100644
--- a/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs
+++ b/PKHeX.Core/Legality/RNG/Frame/SlotRange.cs
@@ -15,16 +15,13 @@ public static class SlotRange
private static readonly Range[] K_BCC = GetRanges(5,5,5,5, 10,10,10,10, 20,20).Reverse().ToArray();
private static readonly Range[] K_Headbutt = GetRanges(50, 15, 15, 10, 5, 5);
- public static int GetSlot(SlotType type, uint rand, FrameType t)
+ public static int GetSlot(SlotType type, uint rand, FrameType t) => t switch
{
- return t switch
- {
- FrameType.MethodH => HSlot(type, rand),
- FrameType.MethodJ => JSlot(type, rand),
- FrameType.MethodK => KSlot(type, rand),
- _ => -1
- };
- }
+ FrameType.MethodH => HSlot(type, rand),
+ FrameType.MethodJ => JSlot(type, rand),
+ FrameType.MethodK => KSlot(type, rand),
+ _ => -1
+ };
private static int HSlot(SlotType type, uint rand)
{
diff --git a/PKHeX.Core/Legality/RNG/MethodFinder.cs b/PKHeX.Core/Legality/RNG/MethodFinder.cs
index 68f77d020..96e1bf2ce 100644
--- a/PKHeX.Core/Legality/RNG/MethodFinder.cs
+++ b/PKHeX.Core/Legality/RNG/MethodFinder.cs
@@ -804,16 +804,13 @@ public static bool IsPokeSpotActivation(int slot, uint seed, out uint s)
return true;
}
- private static bool IsPokeSpotSlotValid(int slot, uint esv)
+ private static bool IsPokeSpotSlotValid(int slot, uint esv) => slot switch
{
- return slot switch
- {
- 0 when esv < 50 => true,
- 1 when 50 <= esv && esv < 85 => true,
- 2 when 85 <= esv => true,
- _ => false
- };
- }
+ 0 when esv < 50 => true,
+ 1 when 50 <= esv && esv < 85 => true,
+ 2 when 85 <= esv => true,
+ _ => false
+ };
public static bool IsCompatible3(this PIDType val, IEncounterable encounter, PKM pkm)
{
diff --git a/PKHeX.Core/Legality/RNG/RNG.cs b/PKHeX.Core/Legality/RNG/RNG.cs
index 70c4e8e29..f07734b8e 100644
--- a/PKHeX.Core/Legality/RNG/RNG.cs
+++ b/PKHeX.Core/Legality/RNG/RNG.cs
@@ -275,15 +275,12 @@ public enum RNGType
public static class RNGTypeUtil
{
- public static RNG GetRNG(this RNGType type)
+ public static RNG GetRNG(this RNGType type) => type switch
{
- return type switch
- {
- RNGType.LCRNG => RNG.LCRNG,
- RNGType.XDRNG => RNG.XDRNG,
- RNGType.ARNG => RNG.ARNG,
- _ => throw new ArgumentException(nameof(type))
- };
- }
+ RNGType.LCRNG => RNG.LCRNG,
+ RNGType.XDRNG => RNG.XDRNG,
+ RNGType.ARNG => RNG.ARNG,
+ _ => throw new ArgumentException(nameof(type))
+ };
}
}
diff --git a/PKHeX.Core/Legality/RNG/RaidRNG.cs b/PKHeX.Core/Legality/RNG/RaidRNG.cs
index eb9f7dac6..edcbed221 100644
--- a/PKHeX.Core/Legality/RNG/RaidRNG.cs
+++ b/PKHeX.Core/Legality/RNG/RaidRNG.cs
@@ -25,15 +25,12 @@ public static class RaidRNG
ApplyDetailsTo(pk8, seed, IVs, raid.FlawlessIVCount, abil, ratio);
}
- private static int RemapAbilityToParam(int a)
+ private static int RemapAbilityToParam(int a) => a switch
{
- return a switch
- {
- -1 => 254,
- 0 => 255,
- _ => (a >> 1)
- };
- }
+ -1 => 254,
+ 0 => 255,
+ _ => (a >> 1)
+ };
private static int[] GetBlankIVTemplate() => new[] {-1, -1, -1, -1, -1, -1};
diff --git a/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs b/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs
index eb042a120..f5ddc9675 100644
--- a/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs
+++ b/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs
@@ -209,23 +209,20 @@ private static int GetRequiredMoveSlotsRegular(PKM pk, IReadOnlyList moves,
return IsMoveCountRequired3(species, pk.CurrentLevel, moves) ? 3 : 0; // no match
}
- private static bool IsMoveCountRequired3(int species, int level, IReadOnlyList moves)
+ private static bool IsMoveCountRequired3(int species, int level, IReadOnlyList moves) => species switch
{
// Species that evolve and learn the 4th move as evolved species at a greater level than base species
// The 4th move is included in the level up table set as a pre-evolution move,
// it should be removed from the used slots count if is not the learn move
- return species switch
- {
- (int)Species.Pidgeotto => level < 21 && !moves.Contains(018),// Whirlwind
- (int)Species.Sandslash => level < 27 && !moves.Contains(040),// Poison Sting
- (int)Species.Parasect => level < 30 && !moves.Contains(147),// Spore
- (int)Species.Golduck => level < 39 && !moves.Contains(093),// Confusion
- (int)Species.Dewgong => level < 44 && !moves.Contains(156),// Rest
- (int)Species.Haunter or (int)Species.Gengar => level < 29 && !moves.Contains(095),// Hypnosis
- (int)Species.Weezing => level < 39 && !moves.Contains(108),// Smoke Screen
- _ => false,
- };
- }
+ (int)Species.Pidgeotto => level < 21 && !moves.Contains(018), // Whirlwind
+ (int)Species.Sandslash => level < 27 && !moves.Contains(040), // Poison Sting
+ (int)Species.Parasect => level < 30 && !moves.Contains(147), // Spore
+ (int)Species.Golduck => level < 39 && !moves.Contains(093), // Confusion
+ (int)Species.Dewgong => level < 44 && !moves.Contains(156), // Rest
+ (int)Species.Weezing => level < 39 && !moves.Contains(108), // Smoke Screen
+ (int)Species.Haunter or (int) Species.Gengar => level < 29 && !moves.Contains(095), // Hypnosis
+ _ => false,
+ };
private static int GetRequiredMoveCountDecrement(PKM pk, IReadOnlyList moves, IReadOnlyList[] learn, IReadOnlyList initialmoves)
{
diff --git a/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs b/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs
index 41fd6a3c2..13eb081d3 100644
--- a/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs
+++ b/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs
@@ -32,26 +32,20 @@ public static bool IsHeldItemAllowed(int item, int generation)
{
if (item == 0)
return true;
- if (item < 0)
- return false;
-
var items = GetReleasedHeldItems(generation);
- return items.Count > item && items[item];
+ return (uint)item < items.Count && items[item];
}
- private static IReadOnlyList GetReleasedHeldItems(int generation)
+ private static IReadOnlyList GetReleasedHeldItems(int generation) => generation switch
{
- return generation switch
- {
- 2 => ReleasedHeldItems_2,
- 3 => ReleasedHeldItems_3,
- 4 => ReleasedHeldItems_4,
- 5 => ReleasedHeldItems_5,
- 6 => ReleasedHeldItems_6,
- 7 => ReleasedHeldItems_7,
- 8 => ReleasedHeldItems_8,
- _ => Array.Empty()
- };
- }
+ 2 => ReleasedHeldItems_2,
+ 3 => ReleasedHeldItems_3,
+ 4 => ReleasedHeldItems_4,
+ 5 => ReleasedHeldItems_5,
+ 6 => ReleasedHeldItems_6,
+ 7 => ReleasedHeldItems_7,
+ 8 => ReleasedHeldItems_8,
+ _ => Array.Empty()
+ };
}
}
diff --git a/PKHeX.Core/Legality/Restrictions/Locale3DS.cs b/PKHeX.Core/Legality/Restrictions/Locale3DS.cs
index 7df84ecc3..9b3fb6fc3 100644
--- a/PKHeX.Core/Legality/Restrictions/Locale3DS.cs
+++ b/PKHeX.Core/Legality/Restrictions/Locale3DS.cs
@@ -13,19 +13,16 @@ public static class Locale3DS
/// Console region.
/// Country of nationality
/// Country is within Console Region
- public static bool IsConsoleRegionCountryValid(int consoleRegion, int country)
+ public static bool IsConsoleRegionCountryValid(int consoleRegion, int country) => consoleRegion switch
{
- return consoleRegion switch
- {
- 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
- };
- }
+ 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
+ };
///
/// Compares the and language ID to determine if the language is available within that region.
diff --git a/PKHeX.Core/Legality/Restrictions/Memories.cs b/PKHeX.Core/Legality/Restrictions/Memories.cs
index 09630d483..c79caf0c0 100644
--- a/PKHeX.Core/Legality/Restrictions/Memories.cs
+++ b/PKHeX.Core/Legality/Restrictions/Memories.cs
@@ -218,15 +218,12 @@ private MemoryVariableSet(string handler, int m, int v, int i, int f)
Feeling = f;
}
- public static MemoryVariableSet Read(ITrainerMemories pkm, int handler)
+ public static MemoryVariableSet Read(ITrainerMemories pkm, int handler) => handler switch
{
- return handler switch
- {
- 0 => new MemoryVariableSet(LegalityCheckStrings.L_XOT, pkm.OT_Memory, pkm.OT_TextVar, pkm.OT_Intensity, pkm.OT_Feeling), // OT
- 1 => new MemoryVariableSet(LegalityCheckStrings.L_XOT, pkm.HT_Memory, pkm.HT_TextVar, pkm.HT_Intensity, pkm.HT_Feeling), // HT
- _ => new MemoryVariableSet(LegalityCheckStrings.L_XOT, 0, 0, 0, 0)
- };
- }
+ 0 => new MemoryVariableSet(LegalityCheckStrings.L_XOT, pkm.OT_Memory, pkm.OT_TextVar, pkm.OT_Intensity, pkm.OT_Feeling), // OT
+ 1 => new MemoryVariableSet(LegalityCheckStrings.L_XOT, pkm.HT_Memory, pkm.HT_TextVar, pkm.HT_Intensity, pkm.HT_Feeling), // HT
+ _ => new MemoryVariableSet(LegalityCheckStrings.L_XOT, 0, 0, 0, 0)
+ };
public bool Equals(MemoryVariableSet v) => v.Handler == Handler
&& v.MemoryID == MemoryID
diff --git a/PKHeX.Core/Legality/Structures/Shiny.cs b/PKHeX.Core/Legality/Structures/Shiny.cs
index 1c8270c41..939c894bb 100644
--- a/PKHeX.Core/Legality/Structures/Shiny.cs
+++ b/PKHeX.Core/Legality/Structures/Shiny.cs
@@ -38,16 +38,13 @@ public enum Shiny : byte
public static partial class Extensions
{
- public static bool IsValid(this Shiny s, PKM pkm)
+ public static bool IsValid(this Shiny s, PKM pkm) => s switch
{
- return s switch
- {
- Shiny.Always => pkm.IsShiny,
- Shiny.Never => !pkm.IsShiny,
- Shiny.AlwaysSquare => pkm.ShinyXor == 0,
- Shiny.AlwaysStar => pkm.ShinyXor == 1,
- _ => true
- };
- }
+ Shiny.Always => pkm.IsShiny,
+ Shiny.Never => !pkm.IsShiny,
+ Shiny.AlwaysSquare => pkm.ShinyXor == 0,
+ Shiny.AlwaysStar => pkm.ShinyXor == 1,
+ _ => true
+ };
}
}
diff --git a/PKHeX.Core/Legality/Tables/FormInfo.cs b/PKHeX.Core/Legality/Tables/FormInfo.cs
index fc8ee5b13..9f76fd5fa 100644
--- a/PKHeX.Core/Legality/Tables/FormInfo.cs
+++ b/PKHeX.Core/Legality/Tables/FormInfo.cs
@@ -44,16 +44,13 @@ public static bool IsBattleOnlyForm(int species, int form, int format)
/// Entity form
/// Current generation format
/// Suggested alt form value.
- public static int GetOutOfBattleForm(int species, int form, int format)
+ public static int GetOutOfBattleForm(int species, int form, int format) => species switch
{
- return species switch
- {
- (int)Darmanitan => form & 2,
- (int)Zygarde when format > 6 => 3,
- (int)Minior => form + 7,
- _ => 0
- };
- }
+ (int)Darmanitan => form & 2,
+ (int)Zygarde when format > 6 => 3,
+ (int)Minior => form + 7,
+ _ => 0
+ };
///
/// Checks if the is a fused form, which indicates it cannot be traded away.
@@ -62,16 +59,13 @@ public static int GetOutOfBattleForm(int species, int form, int format)
/// Entity form
/// Current generation format
/// True if it is a fused species-form, false if it is not fused.
- public static bool IsFusedForm(int species, int form, int format)
+ public static bool IsFusedForm(int species, int form, int format) => species switch
{
- return species switch
- {
- (int)Kyurem when form != 0 && format >= 5 => true,
- (int)Necrozma when form != 0 && format >= 7 => true,
- (int)Calyrex when form != 0 && format >= 8 => true,
- _ => false
- };
- }
+ (int)Kyurem when form != 0 && format >= 5 => true,
+ (int)Necrozma when form != 0 && format >= 7 => true,
+ (int)Calyrex when form != 0 && format >= 8 => true,
+ _ => false
+ };
/// Checks if the form may be different than the original encounter detail.
/// Original species
@@ -246,19 +240,16 @@ public static int GetTotemBaseForm(int species, int form)
/// Entity form
/// Current generation format
///
- public static bool IsValidOutOfBoundsForm(int species, int form, int format)
+ public static bool IsValidOutOfBoundsForm(int species, int form, int format) => (Species) species switch
{
- return (Species) species switch
- {
- Unown => form < (format == 2 ? 26 : 28), // A-Z : A-Z?!
- Mothim => form < 3, // Burmy base form is kept
+ Unown => form < (format == 2 ? 26 : 28), // A-Z : A-Z?!
+ Mothim => form < 3, // Burmy base form is kept
- Scatterbug => form < 18, // Vivillon Pre-evolutions
- Spewpa => form < 18, // Vivillon Pre-evolutions
+ Scatterbug => form < 18, // Vivillon Pre-evolutions
+ Spewpa => form < 18, // Vivillon Pre-evolutions
- _ => false
- };
- }
+ _ => false
+ };
///
/// Checks if the data should have a drop-down selection visible for the value.
diff --git a/PKHeX.Core/Legality/Tables/Locations.cs b/PKHeX.Core/Legality/Tables/Locations.cs
index 4cf7d8381..bda9e0809 100644
--- a/PKHeX.Core/Legality/Tables/Locations.cs
+++ b/PKHeX.Core/Legality/Tables/Locations.cs
@@ -90,28 +90,22 @@ public static class Locations
public const int BugCatchingContest4 = 207;
- public static int TradedEggLocationNPC(int gen)
+ public static int TradedEggLocationNPC(int generation) => generation switch
{
- return gen switch
- {
- 1 => LinkTrade2NPC,
- 2 => LinkTrade2NPC,
- 3 => LinkTrade3NPC,
- 4 => LinkTrade4NPC,
- 5 => LinkTrade5NPC,
- _ => LinkTrade6NPC
- };
- }
+ 1 => LinkTrade2NPC,
+ 2 => LinkTrade2NPC,
+ 3 => LinkTrade3NPC,
+ 4 => LinkTrade4NPC,
+ 5 => LinkTrade5NPC,
+ _ => LinkTrade6NPC
+ };
- public static int TradedEggLocation(int gen)
+ public static int TradedEggLocation(int generation) => generation switch
{
- return gen switch
- {
- 4 => LinkTrade4,
- 5 => LinkTrade5,
- _ => LinkTrade6
- };
- }
+ 4 => LinkTrade4,
+ 5 => LinkTrade5,
+ _ => LinkTrade6
+ };
public static bool IsPtHGSSLocation(int location) => 111 < location && location < 2000;
public static bool IsPtHGSSLocationEgg(int location) => 2010 < location && location < 3000;
diff --git a/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs b/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs
index 0b229364a..85aad651d 100644
--- a/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs
@@ -424,14 +424,11 @@ public static bool CanAbilityPatch(int format, IReadOnlyList abilities, int
};
}
- private static int GetEncounterFixedAbilityNumber(IEncounterable enc)
+ private static int GetEncounterFixedAbilityNumber(IEncounterable enc) => enc switch
{
- return enc switch
- {
- EncounterStatic s => s.Ability,
- EncounterTrade t => t.Ability,
- _ => -1
- };
- }
+ EncounterStatic s => s.Ability,
+ EncounterTrade t => t.Ability,
+ _ => -1
+ };
}
}
diff --git a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs
index 157052c25..93299637a 100644
--- a/PKHeX.Core/Legality/Verifiers/BallVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/BallVerifier.cs
@@ -100,16 +100,13 @@ private CheckResult VerifyBallEgg(LegalityAnalysis data)
};
}
- private CheckResult VerifyBallInherited(LegalityAnalysis data)
+ private CheckResult VerifyBallInherited(LegalityAnalysis data) => data.Info.Generation switch
{
- return data.Info.Generation switch
- {
- 6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
- 7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
- 8 => VerifyBallEggGen8(data),
- _ => NONE
- };
- }
+ 6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
+ 7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
+ 8 => VerifyBallEggGen8(data),
+ _ => NONE
+ };
private CheckResult VerifyBallEggGen6(LegalityAnalysis data)
{
diff --git a/PKHeX.Core/Legality/Verifiers/ContestStatVerifier.cs b/PKHeX.Core/Legality/Verifiers/ContestStatVerifier.cs
index c835312b6..3e57bcf7e 100644
--- a/PKHeX.Core/Legality/Verifiers/ContestStatVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/ContestStatVerifier.cs
@@ -18,19 +18,15 @@ public override void Verify(LegalityAnalysis data)
// some encounters have contest stats built in. they're already checked by the initial encounter match.
}
- private static bool CanHaveContestStats(PKM pkm, int origin)
+ private static bool CanHaveContestStats(PKM pkm, int generation) => generation switch
{
- return origin switch
- {
- 1 => false,
- 2 => false,
- 3 => true,
- 4 => true,
- 5 => (pkm.Format >= 6), // ORAS Contests
- 6 => (!pkm.IsUntraded || pkm.AO),
- 7 => false,
- _ => false
- };
- }
+ 1 => false,
+ 2 => false,
+ 3 => true,
+ 4 => true,
+ 5 => (pkm.Format >= 6), // ORAS Contests
+ 6 => (!pkm.IsUntraded || pkm.AO),
+ _ => false,
+ };
}
}
diff --git a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs
index c3c7c118d..c03e4a7cb 100644
--- a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs
@@ -36,17 +36,17 @@ private CheckResult VerifyForm(LegalityAnalysis data)
return VALID; // no forms to check
var species = pkm.Species;
- var EncounterMatch = data.EncounterMatch;
+ var enc = data.EncounterMatch;
var Info = data.Info;
if (!PersonalInfo.IsFormWithinRange(form) && !FormInfo.IsValidOutOfBoundsForm(species, form, Info.Generation))
return GetInvalid(string.Format(LFormInvalidRange, count - 1, form));
- if (EncounterMatch is EncounterSlot w && w.Area.Type == SlotType.FriendSafari)
+ if (enc is EncounterSlot w && w.Area.Type == SlotType.FriendSafari)
{
VerifyFormFriendSafari(data);
}
- else if (EncounterMatch is EncounterEgg)
+ else if (enc is EncounterEgg)
{
if (FormInfo.IsTotemForm(species, form, data.Info.Generation))
return GetInvalid(LFormInvalidGame);
@@ -55,26 +55,23 @@ private CheckResult VerifyForm(LegalityAnalysis data)
switch (species)
{
case (int)Species.Pikachu when Info.Generation == 6: // Cosplay
- bool isStatic = EncounterMatch is EncounterStatic;
+ bool isStatic = enc is EncounterStatic;
if (isStatic != (form != 0))
return GetInvalid(isStatic ? LFormPikachuCosplayInvalid : LFormPikachuCosplay);
break;
case (int)Species.Pikachu when Info.Generation >= 7: // Cap
- bool IsValidPikachuCap()
+ bool validCap = enc switch
{
- return EncounterMatch switch
- {
- WC7 wc7 => (wc7.Form == form),
- WC8 wc => (wc.Form == form),
- EncounterStatic s => (s.Form == form),
- _ => (form == 0)
- };
- }
+ WC7 wc7 => wc7.Form == form,
+ WC8 wc => wc.Form == form,
+ EncounterStatic s => s.Form == form,
+ _ => form == 0
+ };
- if (!IsValidPikachuCap())
+ if (!validCap)
{
- bool gift = EncounterMatch is MysteryGift g && g.Form != form;
+ bool gift = enc is MysteryGift g && g.Form != form;
var msg = gift ? LFormPikachuEventInvalid : LFormInvalidGame;
return GetInvalid(msg);
}
@@ -109,7 +106,7 @@ bool IsValidPikachuCap()
case (int)Species.Greninja:
if (form > 1) // Ash Battle Bond active
return GetInvalid(LFormBattle);
- if (form != 0 && EncounterMatch is not MysteryGift) // Formes are not breedable, MysteryGift already checked
+ if (form != 0 && enc is not MysteryGift) // Formes are not breedable, MysteryGift already checked
return GetInvalid(string.Format(LFormInvalidRange, 0, form));
break;
@@ -124,7 +121,7 @@ bool IsValidPikachuCap()
case (int)Species.Vivillon:
if (form > 17) // Fancy & Pokéball
{
- if (EncounterMatch is not MysteryGift)
+ if (enc is not MysteryGift)
return GetInvalid(LFormVivillonInvalid);
return GetValid(LFormVivillon);
}
@@ -135,7 +132,7 @@ bool IsValidPikachuCap()
break;
case (int)Species.Floette when form == 5: // Floette Eternal Flower -- Never Released
- if (EncounterMatch is not MysteryGift)
+ if (enc is not MysteryGift)
return GetInvalid(LFormEternalInvalid);
return GetValid(LFormEternal);
case (int)Species.Meowstic when form != pkm.Gender:
@@ -200,7 +197,7 @@ bool IsValidPikachuCap()
{
// We're okay with a Mime Jr. that has evolved via level up.
}
- else if (EncounterMatch.Version != GameVersion.GO)
+ else if (enc.Version != GameVersion.GO)
{
return GetInvalid(LFormInvalidGame);
}
diff --git a/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs b/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs
index 83e39220a..ec8825154 100644
--- a/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs
@@ -74,16 +74,15 @@ private static bool IsValidFixedGenderFromBiGender(PKM pkm, int original)
return gender == current;
}
- private static bool IsValidGenderMismatch(PKM pkm)
+ private static bool IsValidGenderMismatch(PKM pkm) => pkm.Species switch
{
- return pkm.Species switch
- {
- // Shedinja evolution gender glitch, should match original Gender
- (int) Species.Shedinja when pkm.Format == 4 => pkm.Gender == PKX.GetGenderFromPIDAndRatio(pkm.EncryptionConstant, 0x7F), // 50M-50F
- // Evolved from Azurill after transferring to keep gender
- (int) Species.Marill or (int) Species.Azumarill when pkm.Format >= 6 => pkm.Gender == 1 && (pkm.EncryptionConstant & 0xFF) > 0x3F,
- _ => false
- };
- }
+ // Shedinja evolution gender glitch, should match original Gender
+ (int) Species.Shedinja when pkm.Format == 4 => pkm.Gender == PKX.GetGenderFromPIDAndRatio(pkm.EncryptionConstant, 0x7F), // 50M-50F
+
+ // Evolved from Azurill after transferring to keep gender
+ (int) Species.Marill or (int) Species.Azumarill when pkm.Format >= 6 => pkm.Gender == 1 && (pkm.EncryptionConstant & 0xFF) > 0x3F,
+
+ _ => false
+ };
}
}
diff --git a/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs b/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs
index f8f14a99d..711601b48 100644
--- a/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs
@@ -172,34 +172,26 @@ private void VerifyGeoLocationData(LegalityAnalysis data, IGeoTrack t, PKM pkm)
// ORAS contests mistakenly apply 20 affection to the OT instead of the current handler's value
private static bool IsInvalidContestAffection(IAffection pkm) => pkm.OT_Affection != 255 && pkm.OT_Affection % 20 != 0;
- public static bool GetCanOTHandle(IEncounterable enc, PKM pkm, int gen)
+ public static bool GetCanOTHandle(IEncounterable enc, PKM pkm, int generation) => generation < 6 || enc switch
{
- if (gen < 6)
- return true;
- return enc switch
- {
- EncounterTrade => false,
- EncounterSlot8GO => false,
- WC6 wc6 when wc6.OT_Name.Length > 0 => false,
- WC7 wc7 when wc7.OT_Name.Length > 0 && wc7.TID != 18075 => false, // Ash Pikachu QR Gift doesn't set Current Handler
- WC8 wc8 when wc8.GetHasOT(pkm.Language) => false,
- WC8 { IsHOMEGift: true } => false,
- _ => true
- };
- }
+ EncounterTrade => false,
+ EncounterSlot8GO => false,
+ WC6 wc6 when wc6.OT_Name.Length > 0 => false,
+ WC7 wc7 when wc7.OT_Name.Length > 0 && wc7.TID != 18075 => false, // Ash Pikachu QR Gift doesn't set Current Handler
+ WC8 wc8 when wc8.GetHasOT(pkm.Language) => false,
+ WC8 {IsHOMEGift: true} => false,
+ _ => true
+ };
- private static int GetBaseFriendship(int gen, int species, int form)
+ private static int GetBaseFriendship(int generation, int species, int form) => generation switch
{
- return gen switch
- {
- 1 => PersonalTable.USUM[species].BaseFriendship,
- 2 => PersonalTable.USUM[species].BaseFriendship,
+ 1 => PersonalTable.USUM[species].BaseFriendship,
+ 2 => PersonalTable.USUM[species].BaseFriendship,
- 6 => PersonalTable.AO[species].BaseFriendship,
- 7 => PersonalTable.USUM[species].BaseFriendship,
- 8 => PersonalTable.SWSH.GetFormEntry(species, form).BaseFriendship,
- _ => throw new IndexOutOfRangeException(),
- };
- }
+ 6 => PersonalTable.AO[species].BaseFriendship,
+ 7 => PersonalTable.USUM[species].BaseFriendship,
+ 8 => PersonalTable.SWSH.GetFormEntry(species, form).BaseFriendship,
+ _ => throw new IndexOutOfRangeException(),
+ };
}
}
diff --git a/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs b/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs
index e16ff58a6..de4577235 100644
--- a/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/ItemVerifier.cs
@@ -30,16 +30,13 @@ private void VerifyEReaderBerry(LegalityAnalysis data)
data.AddLine(chk);
}
- private CheckResult? GetEReaderCheckResult(EReaderBerryMatch status)
+ private CheckResult? GetEReaderCheckResult(EReaderBerryMatch status) => status switch
{
- return status switch
- {
- EReaderBerryMatch.NoMatch => GetInvalid(LEReaderInvalid),
- EReaderBerryMatch.NoData => GetInvalid(LItemUnreleased),
- EReaderBerryMatch.InvalidUSA => GetInvalid(LEReaderAmerica),
- EReaderBerryMatch.InvalidJPN => GetInvalid(LEReaderJapan),
- _ => null
- };
- }
+ EReaderBerryMatch.NoMatch => GetInvalid(LEReaderInvalid),
+ EReaderBerryMatch.NoData => GetInvalid(LItemUnreleased),
+ EReaderBerryMatch.InvalidUSA => GetInvalid(LEReaderAmerica),
+ EReaderBerryMatch.InvalidJPN => GetInvalid(LEReaderJapan),
+ _ => null
+ };
}
}
diff --git a/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs b/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs
index 8f692fcec..0376a9442 100644
--- a/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs
+++ b/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs
@@ -63,37 +63,22 @@ public static bool IsMarkValid(RibbonIndex mark, PKM pk, IEncounterable enc)
return IsMarkAllowedAny(enc) && IsMarkAllowedSpecific(mark, pk, enc);
}
- public static bool IsMarkAllowedSpecific(RibbonIndex mark, PKM pk, IEncounterable _)
+ public static bool IsMarkAllowedSpecific(RibbonIndex mark, PKM pk, IEncounterable _) => mark switch
{
- return mark switch
- {
- RibbonIndex.MarkCurry when !IsMarkAllowedCurry(pk) => false,
- RibbonIndex.MarkDestiny => false,
- _ => true
- };
- }
+ RibbonIndex.MarkCurry when !IsMarkAllowedCurry(pk) => false,
+ RibbonIndex.MarkDestiny => false,
+ _ => true
+ };
- public static bool IsMarkAllowedAny(IEncounterable enc)
+ public static bool IsMarkAllowedAny(IEncounterable enc) => enc.Generation == 8 && enc switch
{
- if (enc.Generation != 8)
- return false;
-
- switch (enc)
- {
- case WC8:
- case EncounterEgg:
- case EncounterTrade:
- case EncounterStatic8U:
- case EncounterStatic8N:
- case EncounterStatic8ND:
- case EncounterStatic8NC:
- case EncounterStatic8 { Gift: true }:
- case EncounterStatic8 { ScriptedNoMarks: true }:
- return false;
- }
-
- return true;
- }
+ WC8 or EncounterEgg or EncounterTrade
+ or EncounterStatic8U or EncounterStatic8N or EncounterStatic8ND or EncounterStatic8NC
+ or EncounterStatic8 {Gift: true}
+ or EncounterStatic8 {ScriptedNoMarks: true}
+ => false,
+ _ => true,
+ };
public static bool IsMarkAllowedCurry(ILocation enc, int ball = (int)Ball.Poke) => IsMarkAllowedCurry(enc.Location, ball);
public static bool IsMarkAllowedCurry(PKM pkm) => IsMarkAllowedCurry(pkm.Met_Location, pkm.Ball);
diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs
index 386198e6c..92953855a 100644
--- a/PKHeX.Core/MysteryGifts/MysteryGift.cs
+++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs
@@ -60,48 +60,42 @@ public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, ILocatio
/// Extension of the file from which the was retrieved.
/// An instance of representing the given data, or null if or is invalid.
/// This overload differs from by checking the / combo for validity. If either is invalid, a null reference is returned.
- public static DataMysteryGift? GetMysteryGift(byte[] data, string ext)
+ public static DataMysteryGift? GetMysteryGift(byte[] data, string ext) => data.Length switch
{
- return data.Length switch
- {
- PGT.Size when ext == ".pgt" => new PGT(data),
- PCD.Size when ext is ".pcd" or ".wc4" => new PCD(data),
- PGF.Size when ext == ".pgf" => new PGF(data),
- WC6.Size when ext == ".wc6" => new WC6(data),
- WC7.Size when ext == ".wc7" => new WC7(data),
- WB7.Size when ext == ".wb7" => new WB7(data),
- WR7.Size when ext == ".wr7" => new WR7(data),
- WC8.Size when ext is ".wc8" or ".wc8full" => new WC8(data),
+ PGT.Size when ext == ".pgt" => new PGT(data),
+ PCD.Size when ext is ".pcd" or ".wc4" => new PCD(data),
+ PGF.Size when ext == ".pgf" => new PGF(data),
+ WC6.Size when ext == ".wc6" => new WC6(data),
+ WC7.Size when ext == ".wc7" => new WC7(data),
+ WB7.Size when ext == ".wb7" => new WB7(data),
+ WR7.Size when ext == ".wr7" => new WR7(data),
+ WC8.Size when ext is ".wc8" or ".wc8full" => new WC8(data),
- WB7.SizeFull when ext == ".wb7full" => new WB7(data),
- WC6Full.Size when ext == ".wc6full" => new WC6Full(data).Gift,
- WC7Full.Size when ext == ".wc7full" => new WC7Full(data).Gift,
- _ => null
- };
- }
+ WB7.SizeFull when ext == ".wb7full" => new WB7(data),
+ WC6Full.Size when ext == ".wc6full" => new WC6Full(data).Gift,
+ WC7Full.Size when ext == ".wc7full" => new WC7Full(data).Gift,
+ _ => null
+ };
///
/// Converts the given data to a .
///
/// Raw data of the mystery gift.
/// An instance of representing the given data, or null if is invalid.
- public static DataMysteryGift? GetMysteryGift(byte[] data)
+ public static DataMysteryGift? GetMysteryGift(byte[] data) => data.Length switch
{
- return data.Length switch
- {
- PGT.Size => new PGT(data),
- PCD.Size => new PCD(data),
- PGF.Size => new PGF(data),
- WR7.Size => new WR7(data),
- WC8.Size => new WC8(data),
+ PGT.Size => new PGT(data),
+ PCD.Size => new PCD(data),
+ PGF.Size => new PGF(data),
+ WR7.Size => new WR7(data),
+ WC8.Size => new WC8(data),
- // WC6/WC7: Check year
- WC6.Size => BitConverter.ToUInt32(data, 0x4C) / 10000 < 2000 ? new WC7(data) : new WC6(data),
- // WC6Full/WC7Full: 0x205 has 3 * 0x46 for gen6, now only 2.
- WC6Full.Size => data[0x205] == 0 ? new WC7Full(data).Gift : new WC6Full(data).Gift,
- _ => null
- };
- }
+ // WC6/WC7: Check year
+ WC6.Size => BitConverter.ToUInt32(data, 0x4C) / 10000 < 2000 ? new WC7(data) : new WC6(data),
+ // WC6Full/WC7Full: 0x205 has 3 * 0x46 for gen6, now only 2.
+ WC6Full.Size => data[0x205] == 0 ? new WC7Full(data).Gift : new WC6Full(data).Gift,
+ _ => null
+ };
public string Extension => GetType().Name.ToLower();
public string FileName => $"{CardHeader}.{Extension}";
diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs
index 91621488c..f37aae9bf 100644
--- a/PKHeX.Core/MysteryGifts/PGF.cs
+++ b/PKHeX.Core/MysteryGifts/PGF.cs
@@ -280,15 +280,12 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria)
SetIVs(pk);
}
- private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi)
+ private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi) => AbilityType switch
{
- return AbilityType switch
- {
- 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
- 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi),// 0/1 or 0/1/H
- _ => throw new ArgumentException(nameof(AbilityType)),
- };
- }
+ 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
+ 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi), // 0/1 or 0/1/H
+ _ => throw new ArgumentException(nameof(AbilityType)),
+ };
private void SetPID(PKM pk, int av)
{
diff --git a/PKHeX.Core/MysteryGifts/WB7.cs b/PKHeX.Core/MysteryGifts/WB7.cs
index ad01c621a..81c2a59bf 100644
--- a/PKHeX.Core/MysteryGifts/WB7.cs
+++ b/PKHeX.Core/MysteryGifts/WB7.cs
@@ -397,15 +397,12 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria)
SetIVs(pk);
}
- private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi)
+ private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi) => AbilityType switch
{
- return AbilityType switch
- {
- 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
- 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi),// 0/1 or 0/1/H
- _ => throw new ArgumentException(nameof(AbilityType)),
- };
- }
+ 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
+ 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi), // 0/1 or 0/1/H
+ _ => throw new ArgumentException(nameof(AbilityType)),
+ };
private void SetPID(PKM pk)
{
diff --git a/PKHeX.Core/MysteryGifts/WC3.cs b/PKHeX.Core/MysteryGifts/WC3.cs
index 9ca2a05d5..0542ff2d5 100644
--- a/PKHeX.Core/MysteryGifts/WC3.cs
+++ b/PKHeX.Core/MysteryGifts/WC3.cs
@@ -174,15 +174,12 @@ private void SetPINGA(PK3 pk, EncounterCriteria criteria)
PIDGenerator.SetValuesFromSeed(pk, Method, seed);
}
- private uint GetSaneSeed(uint seed)
+ private uint GetSaneSeed(uint seed) => Method switch
{
- return Method switch
- {
- PIDType.BACD_R => (seed & 0x0000FFFF),
- PIDType.BACD_R_S => (seed & 0x000000FF),
- _ => seed
- };
- }
+ PIDType.BACD_R => seed & 0x0000FFFF, // u16
+ PIDType.BACD_R_S => seed & 0x000000FF, // u8
+ _ => seed
+ };
private LanguageID GetSafeLanguage(LanguageID hatchLang)
{
@@ -205,13 +202,11 @@ private static GameVersion GetRandomVersion(GameVersion version)
if (version <= GameVersion.CXD && version > GameVersion.Unknown) // single game
return version;
- int rand = Util.Rand.Next(2); // 0 or 1
return version switch
{
- GameVersion.FRLG => GameVersion.FR + rand, // or LG
- GameVersion.RS or GameVersion.RSE => GameVersion.S + rand, // or R
- GameVersion.COLO => GameVersion.CXD,
- GameVersion.XD => GameVersion.CXD,
+ GameVersion.FRLG => GameVersion.FR + Util.Rand.Next(2), // or LG
+ GameVersion.RS or GameVersion.RSE => GameVersion.S + Util.Rand.Next(2), // or R
+ GameVersion.COLO or GameVersion.XD => GameVersion.CXD,
_ => throw new Exception($"Unknown GameVersion: {version}")
};
}
diff --git a/PKHeX.Core/MysteryGifts/WC6.cs b/PKHeX.Core/MysteryGifts/WC6.cs
index d726fbe77..b2056be53 100644
--- a/PKHeX.Core/MysteryGifts/WC6.cs
+++ b/PKHeX.Core/MysteryGifts/WC6.cs
@@ -408,15 +408,12 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria)
SetIVs(pk);
}
- private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi)
+ private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi) => AbilityType switch
{
- return AbilityType switch
- {
- 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
- 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi),// 0/1 or 0/1/H
- _ => throw new ArgumentException(nameof(AbilityType)),
- };
- }
+ 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
+ 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi), // 0/1 or 0/1/H
+ _ => throw new ArgumentException(nameof(AbilityType)),
+ };
private void SetPID(PKM pk)
{
diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs
index 0de311aa2..e5d31d589 100644
--- a/PKHeX.Core/MysteryGifts/WC7.cs
+++ b/PKHeX.Core/MysteryGifts/WC7.cs
@@ -439,15 +439,12 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria)
SetIVs(pk);
}
- private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi)
+ private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi) => AbilityType switch
{
- return AbilityType switch
- {
- 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
- 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi),// 0/1 or 0/1/H
- _ => throw new ArgumentException(nameof(AbilityType)),
- };
- }
+ 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
+ 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi), // 0/1 or 0/1/H
+ _ => throw new ArgumentException(nameof(AbilityType)),
+ };
private void SetPID(PKM pk)
{
diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs
index acaaa5d4e..9c2da7cb8 100644
--- a/PKHeX.Core/MysteryGifts/WC8.cs
+++ b/PKHeX.Core/MysteryGifts/WC8.cs
@@ -168,21 +168,15 @@ public override int HeldItem
public int Nature { get => (sbyte)Data[CardStart + 0x246]; set => Data[CardStart + 0x246] = (byte)value; }
public override int AbilityType { get => Data[CardStart + 0x247]; set => Data[CardStart + 0x247] = (byte)value; }
- public Shiny PIDType
+ public Shiny PIDType => Data[CardStart + 0x248] switch
{
- get
- {
- return Data[CardStart + 0x248] switch
- {
- 0 => Shiny.Never,
- 1 => Shiny.Random,
- 2 => Shiny.AlwaysStar,
- 3 => Shiny.AlwaysSquare,
- 4 => Shiny.FixedValue,
- _ => throw new ArgumentException()
- };
- }
- }
+ 0 => Shiny.Never,
+ 1 => Shiny.Random,
+ 2 => Shiny.AlwaysStar,
+ 3 => Shiny.AlwaysSquare,
+ 4 => Shiny.FixedValue,
+ _ => throw new ArgumentException()
+ };
public int MetLevel { get => Data[CardStart + 0x249]; set => Data[CardStart + 0x249] = (byte)value; }
public byte DynamaxLevel { get => Data[CardStart + 0x24A]; set => Data[CardStart + 0x24A] = value; }
@@ -453,15 +447,12 @@ private void SetPINGA(PKM pk, EncounterCriteria criteria)
SetIVs(pk);
}
- private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi)
+ private int GetAbilityIndex(EncounterCriteria criteria, PersonalInfo pi) => AbilityType switch
{
- return AbilityType switch
- {
- 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
- 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi),// 0/1 or 0/1/H
- _ => throw new ArgumentException(nameof(AbilityType)),
- };
- }
+ 00 or 01 or 02 => AbilityType, // Fixed 0/1/2
+ 03 or 04 => criteria.GetAbilityFromType(AbilityType, pi), // 0/1 or 0/1/H
+ _ => throw new ArgumentException(nameof(AbilityType)),
+ };
private uint GetPID(ITrainerID tr, byte type)
{
diff --git a/PKHeX.Core/PKM/PB7.cs b/PKHeX.Core/PKM/PB7.cs
index 7ca962be3..adfced0fb 100644
--- a/PKHeX.Core/PKM/PB7.cs
+++ b/PKHeX.Core/PKM/PB7.cs
@@ -393,15 +393,12 @@ private static int GetStat(int baseStat, int iv, int level, int nature, int stat
return AmplifyStat(nature, statIndex, initial);
}
- private static int AmplifyStat(int nature, int index, int initial)
+ private static int AmplifyStat(int nature, int index, int initial) => GetNatureAmp(nature, index) switch
{
- return GetNatureAmp(nature, index) switch
- {
- 1 => (110 * initial / 100), // 110%
- -1 => (90 * initial / 100), // 90%
- _ => initial
- };
- }
+ 1 => 110 * initial / 100, // 110%
+ -1 => 90 * initial / 100, // 90%
+ _ => initial,
+ };
private static sbyte GetNatureAmp(int nature, int index)
{
diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs
index 0caebbbf9..53493c646 100644
--- a/PKHeX.Core/PKM/PKM.cs
+++ b/PKHeX.Core/PKM/PKM.cs
@@ -1065,38 +1065,23 @@ public void TransferPropertiesWithReflection(PKM Destination)
public int GetMoveIndex(int move) => Move1 == move ? 0 : Move2 == move ? 1 : Move3 == move ? 2 : Move4 == move ? 3 : -1;
- public int GetMove(int index)
+ public int GetMove(int index) => index switch
{
- return index switch
- {
- 0 => Move1,
- 1 => Move2,
- 2 => Move3,
- 3 => Move4,
- _ => throw new IndexOutOfRangeException(nameof(index)),
- };
- }
+ 0 => Move1,
+ 1 => Move2,
+ 2 => Move3,
+ 3 => Move4,
+ _ => throw new IndexOutOfRangeException(nameof(index)),
+ };
- public void SetMove(int index, int value)
+ public int SetMove(int index, int value) => index switch
{
- switch (index)
- {
- case 0:
- Move1 = value;
- return;
- case 1:
- Move2 = value;
- return;
- case 2:
- Move3 = value;
- return;
- case 3:
- Move4 = value;
- return;
- default:
- throw new IndexOutOfRangeException(nameof(index));
- }
- }
+ 0 => Move1 = value,
+ 1 => Move2 = value,
+ 2 => Move3 = value,
+ 3 => Move4 = value,
+ _ => throw new IndexOutOfRangeException(nameof(index))
+ };
///
/// Clears moves that a may have, possibly from a future generation.
@@ -1129,36 +1114,30 @@ public void ClearInvalidMoves()
/// Gets one of the based on its index within the array.
///
/// Index to get
- public int GetEV(int index)
+ public int GetEV(int index) => index switch
{
- return index switch
- {
- 0 => EV_HP,
- 1 => EV_ATK,
- 2 => EV_DEF,
- 3 => EV_SPE,
- 4 => EV_SPA,
- 5 => EV_SPD,
- _ => throw new ArgumentOutOfRangeException(nameof(index))
- };
- }
+ 0 => EV_HP,
+ 1 => EV_ATK,
+ 2 => EV_DEF,
+ 3 => EV_SPE,
+ 4 => EV_SPA,
+ 5 => EV_SPD,
+ _ => throw new ArgumentOutOfRangeException(nameof(index))
+ };
///
/// Gets one of the based on its index within the array.
///
/// Index to get
- public int GetIV(int index)
+ public int GetIV(int index) => index switch
{
- return index switch
- {
- 0 => IV_HP,
- 1 => IV_ATK,
- 2 => IV_DEF,
- 3 => IV_SPE,
- 4 => IV_SPA,
- 5 => IV_SPD,
- _ => throw new ArgumentOutOfRangeException(nameof(index))
- };
- }
+ 0 => IV_HP,
+ 1 => IV_ATK,
+ 2 => IV_DEF,
+ 3 => IV_SPE,
+ 4 => IV_SPA,
+ 5 => IV_SPD,
+ _ => throw new ArgumentOutOfRangeException(nameof(index))
+ };
}
}
diff --git a/PKHeX.Core/PKM/Searching/SearchUtil.cs b/PKHeX.Core/PKM/Searching/SearchUtil.cs
index bc0879cd9..72a98ad1b 100644
--- a/PKHeX.Core/PKM/Searching/SearchUtil.cs
+++ b/PKHeX.Core/PKM/Searching/SearchUtil.cs
@@ -32,15 +32,12 @@ public static IEnumerable FilterByFormat(IEnumerable res, int format,
return res;
}
- public static IEnumerable FilterByGeneration(IEnumerable res, int generation)
+ public static IEnumerable FilterByGeneration(IEnumerable res, int generation) => generation switch
{
- return generation switch
- {
- 1 => res.Where(pk => pk.VC || pk.Format < 3),
- 2 => res.Where(pk => pk.VC || pk.Format < 3),
- _ => res.Where(pk => pk.Generation == generation)
- };
- }
+ 1 => res.Where(pk => pk.VC || pk.Format < 3),
+ 2 => res.Where(pk => pk.VC || pk.Format < 3),
+ _ => res.Where(pk => pk.Generation == generation)
+ };
public static IEnumerable FilterByLevel(IEnumerable res, SearchComparison option, int level)
{
@@ -56,31 +53,25 @@ public static IEnumerable FilterByLevel(IEnumerable res, SearchCompari
};
}
- public static IEnumerable FilterByEVs(IEnumerable res, int option)
+ public static IEnumerable FilterByEVs(IEnumerable res, int option) => option switch
{
- return option switch
- {
- 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 is >= 128 and < 508), // Half (128-507)
- 4 => res.Where(pk => pk.EVTotal >= 508), // Full (508+)
- _ => res
- };
- }
+ 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 is >= 128 and < 508), // Half (128-507)
+ 4 => res.Where(pk => pk.EVTotal >= 508), // Full (508+)
+ _ => res
+ };
- public static IEnumerable FilterByIVs(IEnumerable res, int option)
+ public static IEnumerable FilterByIVs(IEnumerable res, int option) => option switch
{
- return option switch
- {
- 1 => res.Where(pk => pk.IVTotal <= 90), // <= 90
- 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
- };
- }
+ 1 => res.Where(pk => pk.IVTotal <= 90), // <= 90
+ 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
+ };
public static IEnumerable FilterByMoves(IEnumerable res, IEnumerable requiredMoves)
{
@@ -103,34 +94,25 @@ public static IEnumerable FilterByBatchInstruction(IEnumerable res, IL
return res.Where(pkm => BatchEditing.IsFilterMatch(filters, pkm)); // Compare across all filters
}
- public static Func GetCloneDetectMethod(CloneDetectionMethod method)
+ public static Func GetCloneDetectMethod(CloneDetectionMethod method) => method switch
{
- return method switch
- {
- CloneDetectionMethod.HashPID => HashByPID,
- _ => HashByDetails,
- };
- }
+ CloneDetectionMethod.HashPID => HashByPID,
+ _ => HashByDetails,
+ };
- public static string HashByDetails(PKM pk)
+ public static string HashByDetails(PKM pk) => pk.Format switch
{
- return pk.Format switch
- {
- 1 => $"{pk.Species:000}{((PK1) pk).DV16:X4}",
- 2 => $"{pk.Species:000}{((PK2) pk).DV16:X4}",
- _ => $"{pk.Species:000}{pk.PID:X8}{string.Join(" ", pk.IVs)}{pk.Form:00}"
- };
- }
+ 1 => $"{pk.Species:000}{((PK1) pk).DV16:X4}",
+ 2 => $"{pk.Species:000}{((PK2) pk).DV16:X4}",
+ _ => $"{pk.Species:000}{pk.PID:X8}{string.Join(" ", pk.IVs)}{pk.Form:00}"
+ };
- public static string HashByPID(PKM pk)
+ public static string HashByPID(PKM pk) => pk.Format switch
{
- return pk.Format switch
- {
- 1 => $"{((PK1) pk).DV16:X4}",
- 2 => $"{((PK2) pk).DV16:X4}",
- _ => $"{pk.PID:X8}"
- };
- }
+ 1 => $"{((PK1) pk).DV16:X4}",
+ 2 => $"{((PK2) pk).DV16:X4}",
+ _ => $"{pk.PID:X8}"
+ };
public static IEnumerable GetClones(IEnumerable res, CloneDetectionMethod type = CloneDetectionMethod.HashDetails)
{
diff --git a/PKHeX.Core/PKM/Shared/IAwakened.cs b/PKHeX.Core/PKM/Shared/IAwakened.cs
index 4dd48878c..8cca85132 100644
--- a/PKHeX.Core/PKM/Shared/IAwakened.cs
+++ b/PKHeX.Core/PKM/Shared/IAwakened.cs
@@ -80,39 +80,32 @@ public static bool AwakeningAllValid(this IAwakened pk)
/// Pokémon to modify.
/// Index to set to
/// Value to set
- public static void SetAV(this IAwakened pk, int index, int value)
+ public static int SetAV(this IAwakened pk, int index, int value) => index switch
{
- switch (index)
- {
- case 0: pk.AV_HP = value; break;
- case 1: pk.AV_ATK = value; break;
- case 2: pk.AV_DEF = value; break;
- case 3: pk.AV_SPE = value; break;
- case 4: pk.AV_SPA = value; break;
- case 5: pk.AV_SPD = value; break;
- default:
- throw new ArgumentOutOfRangeException(nameof(index));
- }
- }
+ 0 => pk.AV_HP = value,
+ 1 => pk.AV_ATK = value,
+ 2 => pk.AV_DEF = value,
+ 3 => pk.AV_SPE = value,
+ 4 => pk.AV_SPA = value,
+ 5 => pk.AV_SPD = value,
+ _ => throw new ArgumentOutOfRangeException(nameof(index))
+ };
///
/// Sets one of the values based on its index within the array.
///
/// Pokémon to check.
/// Index to get
- public static int GetAV(this IAwakened pk, int index)
+ public static int GetAV(this IAwakened pk, int index) => index switch
{
- return index switch
- {
- 0 => pk.AV_HP,
- 1 => pk.AV_ATK,
- 2 => pk.AV_DEF,
- 3 => pk.AV_SPE,
- 4 => pk.AV_SPA,
- 5 => pk.AV_SPD,
- _ => throw new ArgumentOutOfRangeException(nameof(index))
- };
- }
+ 0 => pk.AV_HP,
+ 1 => pk.AV_ATK,
+ 2 => pk.AV_DEF,
+ 3 => pk.AV_SPE,
+ 4 => pk.AV_SPA,
+ 5 => pk.AV_SPD,
+ _ => throw new ArgumentOutOfRangeException(nameof(index))
+ };
///
/// Sets the values based on the current .
diff --git a/PKHeX.Core/PKM/Shared/PokeSize.cs b/PKHeX.Core/PKM/Shared/PokeSize.cs
index 77a65beab..eb866c29c 100644
--- a/PKHeX.Core/PKM/Shared/PokeSize.cs
+++ b/PKHeX.Core/PKM/Shared/PokeSize.cs
@@ -16,31 +16,24 @@ public static class PokeSizeUtil
///
/// Sizing scalar (0-255)
/// 0-4 rating
- public static PokeSize GetSizeRating(int scalar)
+ public static PokeSize GetSizeRating(int scalar) => scalar switch
{
- if (scalar < 0x10)
- return PokeSize.XS; // 1/16 = XS
- if (scalar < 0x30u)
- return PokeSize.S; // 2/16 = S
- if (scalar < 0xD0u)
- return PokeSize.AV; // average (10/16)
- if (scalar < 0xF0u)
- return PokeSize.L; // 2/16 = L
- return PokeSize.XL; // 1/16 = XL
- }
+ < 0x10 => PokeSize.XS, // 1/16 = XS
+ < 0x30 => PokeSize.S, // 2/16 = S
+ < 0xD0 => PokeSize.AV, // average (10/16)
+ < 0xF0 => PokeSize.L, // 2/16 = L
+ _ => PokeSize.XL, // 1/16 = XL
+ };
- public static int GetRandomScalar(this PokeSize size)
+ public static int GetRandomScalar(this PokeSize size) => size switch
{
- return size switch
- {
- PokeSize.XS => (Util.Rand.Next(0x10) + 0x00),
- PokeSize.S => (Util.Rand.Next(0x20) + 0x10),
- PokeSize.AV => (Util.Rand.Next(0xA0) + 0x30),
- PokeSize.L => (Util.Rand.Next(0x20) + 0xD0),
- PokeSize.XL => (Util.Rand.Next(0x10) + 0xF0),
- _ => GetRandomScalar()
- };
- }
+ PokeSize.XS => Util.Rand.Next(0x10),
+ PokeSize.S => Util.Rand.Next(0x20) + 0x10,
+ PokeSize.AV => Util.Rand.Next(0xA0) + 0x30,
+ PokeSize.L => Util.Rand.Next(0x20) + 0xD0,
+ PokeSize.XL => Util.Rand.Next(0x10) + 0xF0,
+ _ => GetRandomScalar()
+ };
///
/// Gets a random size scalar with a triangular distribution (copying official implementation).
diff --git a/PKHeX.Core/PKM/Util/ItemConverter.cs b/PKHeX.Core/PKM/Util/ItemConverter.cs
index 78d1ebbd4..7f11b0d29 100644
--- a/PKHeX.Core/PKM/Util/ItemConverter.cs
+++ b/PKHeX.Core/PKM/Util/ItemConverter.cs
@@ -208,15 +208,12 @@ internal static int GetItemForFormat(int srcItem, int srcFormat, int destFormat)
/// Item ID
/// Generation the exists in
/// True if is an HM
- internal static bool IsItemHM(ushort item, int generation)
+ internal static bool IsItemHM(ushort item, int generation) => generation switch
{
- return generation switch
- {
- 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,
- };
- }
+ 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,
+ };
}
}
diff --git a/PKHeX.Core/PKM/Util/Language.cs b/PKHeX.Core/PKM/Util/Language.cs
index c1711377b..f1593bf58 100644
--- a/PKHeX.Core/PKM/Util/Language.cs
+++ b/PKHeX.Core/PKM/Util/Language.cs
@@ -41,20 +41,17 @@ public static class Language
_ => Languages_7 .Contains((int)prefer) ? prefer : SafeLanguage,
};
- public static string GetLanguage2CharName(this LanguageID lang)
+ public static string GetLanguage2CharName(this LanguageID language) => language switch
{
- return lang switch
- {
- Japanese => "ja",
- French => "fr",
- Italian => "it",
- German => "de",
- Spanish => "es",
- Korean => "ko",
- ChineseS or ChineseT => "zh",
- _ => GameLanguage.DefaultLanguage,
- };
- }
+ Japanese => "ja",
+ French => "fr",
+ Italian => "it",
+ German => "de",
+ Spanish => "es",
+ Korean => "ko",
+ ChineseS or ChineseT => "zh",
+ _ => GameLanguage.DefaultLanguage,
+ };
///
/// Gets the Main Series language ID from a GameCube (C/XD) language ID.
diff --git a/PKHeX.Core/PKM/Util/PKX.cs b/PKHeX.Core/PKM/Util/PKX.cs
index 851caa2b4..bc2852039 100644
--- a/PKHeX.Core/PKM/Util/PKX.cs
+++ b/PKHeX.Core/PKM/Util/PKX.cs
@@ -69,7 +69,7 @@ public static int GetGenderFromString(string s)
{
if (s.Length != 1)
return 2;
- return (s[0]) switch
+ return s[0] switch
{
'♂' or 'M' => 0,
'♀' or 'F' => 1,
@@ -190,16 +190,13 @@ public static int GetGenderFromPID(int species, uint pid)
return GetGenderFromPIDAndRatio(pid, gt);
}
- public static int GetGenderFromPIDAndRatio(uint pid, int gr)
+ public static int GetGenderFromPIDAndRatio(uint pid, int gr) => gr switch
{
- return gr switch
- {
- 255 => 2,
- 254 => 1,
- 0 => 0,
- _ => ((pid & 0xFF) < gr ? 1 : 0)
- };
- }
+ 255 => 2,
+ 254 => 1,
+ 0 => 0,
+ _ => (pid & 0xFF) < gr ? 1 : 0
+ };
///
/// Gets an array of valid file extensions.
diff --git a/PKHeX.Core/PKM/XK3.cs b/PKHeX.Core/PKM/XK3.cs
index 872de68c3..ed1e002e3 100644
--- a/PKHeX.Core/PKM/XK3.cs
+++ b/PKHeX.Core/PKM/XK3.cs
@@ -231,33 +231,30 @@ private bool IsOriginXD()
return IsOriginXD(Species, Met_Level);
}
- private static bool IsOriginXD(int species, int metLevel)
+ private static bool IsOriginXD(int species, int metLevel) => species switch
{
- return species switch
- {
- 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 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)
- 167 => metLevel != 40, // Ledian 40 Colo // 10 Ledyba XD
- 207 => metLevel != 43, // Gligar 43 Colo // ** Gligar XD
- 221 => metLevel != 43, // Piloswine 43 Colo // 22 Swinub XD
- 205 => metLevel != 43, // Forretress 43 Colo // 20 Pineco XD
- 168 => metLevel != 43, // Ariados 43 Colo // 14 Spinarak XD
- 229 => metLevel != 48, // Houndoom 48 Colo // 17 Houndour XD
- 217 => metLevel != 45, // Ursaring 45 Colo // 11 Teddiursa XD
- 212 => metLevel != 50, // Scizor 50 Colo // 40 Scyther XD
- 196 => metLevel != 25, // Espeon
- 197 => metLevel != 26, // Umbreon
+ 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 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)
+ 167 => metLevel != 40, // Ledian 40 Colo // 10 Ledyba XD
+ 207 => metLevel != 43, // Gligar 43 Colo // ** Gligar XD
+ 221 => metLevel != 43, // Piloswine 43 Colo // 22 Swinub XD
+ 205 => metLevel != 43, // Forretress 43 Colo // 20 Pineco XD
+ 168 => metLevel != 43, // Ariados 43 Colo // 14 Spinarak XD
+ 229 => metLevel != 48, // Houndoom 48 Colo // 17 Houndour XD
+ 217 => metLevel != 45, // Ursaring 45 Colo // 11 Teddiursa XD
+ 212 => metLevel != 50, // Scizor 50 Colo // 40 Scyther XD
+ 196 => metLevel != 25, // Espeon
+ 197 => metLevel != 26, // Umbreon
- // Shuckle, Elekid, Larvitar, Meditite
- 213 or 239 or 240 or 246 or 247 or 248 or 307 or 308 => metLevel == 20,
+ // Shuckle, Elekid, Larvitar, Meditite
+ 213 or 239 or 240 or 246 or 247 or 248 or 307 or 308 => metLevel == 20,
- // all other cases handled, if not in Colo's table it's from XD.
- _ => !Legal.ValidSpecies_Colo.Contains(species),
- };
- }
+ // all other cases handled, if not in Colo's table it's from XD.
+ _ => !Legal.ValidSpecies_Colo.Contains(species),
+ };
}
}
diff --git a/PKHeX.Core/PersonalInfo/PersonalTable.cs b/PKHeX.Core/PersonalInfo/PersonalTable.cs
index d18c1a4c1..40cae1272 100644
--- a/PKHeX.Core/PersonalInfo/PersonalTable.cs
+++ b/PKHeX.Core/PersonalInfo/PersonalTable.cs
@@ -112,41 +112,35 @@ private static PersonalTable GetTable(string game, GameVersion format)
return new(Util.GetBinaryResource($"personal_{game}"), format);
}
- private static Func GetConstructor(GameVersion format)
+ private static Func GetConstructor(GameVersion format) => format switch
{
- return format switch
- {
- GameVersion.RB or GameVersion.YW => z => new PersonalInfoG1(z),
- GameVersion.GS or GameVersion.C => z => new PersonalInfoG2(z),
- GameVersion.RS or GameVersion.E or GameVersion.FR or GameVersion.LG => z => new PersonalInfoG3(z),
- GameVersion.DP or GameVersion.Pt or GameVersion.HGSS => z => new PersonalInfoG4(z),
- GameVersion.BW => z => new PersonalInfoBW(z),
- GameVersion.B2W2 => z => new PersonalInfoB2W2(z),
- GameVersion.XY => z => new PersonalInfoXY(z),
- GameVersion.ORAS => z => new PersonalInfoORAS(z),
- GameVersion.SM or GameVersion.USUM => z => new PersonalInfoSM(z),
- GameVersion.GG => z => new PersonalInfoGG(z),
- _ => z => new PersonalInfoSWSH(z),
- };
- }
+ GameVersion.RB or GameVersion.YW => z => new PersonalInfoG1(z),
+ GameVersion.GS or GameVersion.C => z => new PersonalInfoG2(z),
+ GameVersion.RS or GameVersion.E or GameVersion.FR or GameVersion.LG => z => new PersonalInfoG3(z),
+ GameVersion.DP or GameVersion.Pt or GameVersion.HGSS => z => new PersonalInfoG4(z),
+ GameVersion.BW => z => new PersonalInfoBW(z),
+ GameVersion.B2W2 => z => new PersonalInfoB2W2(z),
+ GameVersion.XY => z => new PersonalInfoXY(z),
+ GameVersion.ORAS => z => new PersonalInfoORAS(z),
+ GameVersion.SM or GameVersion.USUM => z => new PersonalInfoSM(z),
+ GameVersion.GG => z => new PersonalInfoGG(z),
+ _ => z => new PersonalInfoSWSH(z),
+ };
- private static int GetEntrySize(GameVersion format)
+ private static int GetEntrySize(GameVersion format) => format switch
{
- return format switch
- {
- GameVersion.RB or GameVersion.YW => PersonalInfoG1.SIZE,
- GameVersion.GS or GameVersion.C => PersonalInfoG2.SIZE,
- GameVersion.RS or GameVersion.E or GameVersion.FR or GameVersion.LG => PersonalInfoG3.SIZE,
- GameVersion.DP or GameVersion.Pt or GameVersion.HGSS => PersonalInfoG4.SIZE,
- GameVersion.BW => PersonalInfoBW.SIZE,
- GameVersion.B2W2 => PersonalInfoB2W2.SIZE,
- GameVersion.XY => PersonalInfoXY.SIZE,
- GameVersion.ORAS => PersonalInfoORAS.SIZE,
- GameVersion.SM or GameVersion.USUM or GameVersion.GG => PersonalInfoSM.SIZE,
- GameVersion.SWSH => PersonalInfoSWSH.SIZE,
- _ => -1,
- };
- }
+ GameVersion.RB or GameVersion.YW => PersonalInfoG1.SIZE,
+ GameVersion.GS or GameVersion.C => PersonalInfoG2.SIZE,
+ GameVersion.RS or GameVersion.E or GameVersion.FR or GameVersion.LG => PersonalInfoG3.SIZE,
+ GameVersion.DP or GameVersion.Pt or GameVersion.HGSS => PersonalInfoG4.SIZE,
+ GameVersion.BW => PersonalInfoBW.SIZE,
+ GameVersion.B2W2 => PersonalInfoB2W2.SIZE,
+ GameVersion.XY => PersonalInfoXY.SIZE,
+ GameVersion.ORAS => PersonalInfoORAS.SIZE,
+ GameVersion.SM or GameVersion.USUM or GameVersion.GG => PersonalInfoSM.SIZE,
+ GameVersion.SWSH => PersonalInfoSWSH.SIZE,
+ _ => -1,
+ };
static PersonalTable() // Finish Setup
{
diff --git a/PKHeX.Core/Saves/MemeCrypto/MemeKey.cs b/PKHeX.Core/Saves/MemeCrypto/MemeKey.cs
index c548f5209..9e234418f 100644
--- a/PKHeX.Core/Saves/MemeCrypto/MemeKey.cs
+++ b/PKHeX.Core/Saves/MemeCrypto/MemeKey.cs
@@ -232,28 +232,25 @@ private byte[] Exponentiate(BigInteger M, BigInteger Power)
return outSig;
}
- private static byte[] GetMemeData(MemeKeyIndex key)
+ private static byte[] GetMemeData(MemeKeyIndex key) => key switch
{
- return key switch
- {
- MemeKeyIndex.LocalWireless => DER_LW,
- MemeKeyIndex.FriendlyCompetition => DER_0,
- MemeKeyIndex.LiveCompetition => DER_1,
- MemeKeyIndex.RentalTeam => DER_2,
- MemeKeyIndex.PokedexAndSaveFile => DER_3,
- MemeKeyIndex.GaOle => DER_4,
- MemeKeyIndex.MagearnaEvent => DER_5,
- MemeKeyIndex.MoncolleGet => DER_6,
- MemeKeyIndex.IslandScanEventSpecial => DER_7,
- MemeKeyIndex.TvTokyoDataBroadcasting => DER_8,
- MemeKeyIndex.CapPikachuEvent => DER_9,
- MemeKeyIndex.Unknown10 => DER_A,
- MemeKeyIndex.Unknown11 => DER_B,
- MemeKeyIndex.Unknown12 => DER_C,
- MemeKeyIndex.Unknown13 => DER_D,
- _ => throw new ArgumentOutOfRangeException(nameof(key), key, null)
- };
- }
+ MemeKeyIndex.LocalWireless => DER_LW,
+ MemeKeyIndex.FriendlyCompetition => DER_0,
+ MemeKeyIndex.LiveCompetition => DER_1,
+ MemeKeyIndex.RentalTeam => DER_2,
+ MemeKeyIndex.PokedexAndSaveFile => DER_3,
+ MemeKeyIndex.GaOle => DER_4,
+ MemeKeyIndex.MagearnaEvent => DER_5,
+ MemeKeyIndex.MoncolleGet => DER_6,
+ MemeKeyIndex.IslandScanEventSpecial => DER_7,
+ MemeKeyIndex.TvTokyoDataBroadcasting => DER_8,
+ MemeKeyIndex.CapPikachuEvent => DER_9,
+ MemeKeyIndex.Unknown10 => DER_A,
+ MemeKeyIndex.Unknown11 => DER_B,
+ MemeKeyIndex.Unknown12 => DER_C,
+ MemeKeyIndex.Unknown13 => DER_D,
+ _ => throw new ArgumentOutOfRangeException(nameof(key), key, null)
+ };
// Helper Method to perform AES ECB Encryption
private static byte[] AesEcbEncrypt(byte[] key, byte[] data)
diff --git a/PKHeX.Core/Saves/MemeCrypto/SCBlockMetadata.cs b/PKHeX.Core/Saves/MemeCrypto/SCBlockMetadata.cs
index 30661d6a1..7058342fd 100644
--- a/PKHeX.Core/Saves/MemeCrypto/SCBlockMetadata.cs
+++ b/PKHeX.Core/Saves/MemeCrypto/SCBlockMetadata.cs
@@ -107,26 +107,23 @@ private string GetBlockHint(SCBlock z, int i)
/// Returns an object that wraps the block with a Value property to get/set via a PropertyGrid/etc control.
///
/// Returns null if no wrapping is supported.
- public static object? GetEditableBlockObject(SCBlock block)
+ public static object? GetEditableBlockObject(SCBlock block) => block.Type switch
{
- return block.Type switch
- {
- SCTypeCode.Byte => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.UInt16 => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.UInt32 => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.UInt64 => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.Byte => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.UInt16 => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.UInt32 => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.UInt64 => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.SByte => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.Int16 => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.Int32 => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.Int64 => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.SByte => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.Int16 => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.Int32 => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.Int64 => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.Single => new WrappedValueView(block, block.GetValue()),
- SCTypeCode.Double => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.Single => new WrappedValueView(block, block.GetValue()),
+ SCTypeCode.Double => new WrappedValueView(block, block.GetValue()),
- _ => null,
- };
- }
+ _ => null,
+ };
private sealed class WrappedValueView where T : struct
{
diff --git a/PKHeX.Core/Saves/MemeCrypto/SCTypeCode.cs b/PKHeX.Core/Saves/MemeCrypto/SCTypeCode.cs
index a9f8dd781..08216553c 100644
--- a/PKHeX.Core/Saves/MemeCrypto/SCTypeCode.cs
+++ b/PKHeX.Core/Saves/MemeCrypto/SCTypeCode.cs
@@ -34,49 +34,43 @@ public static class SCTypeCodeExtensions
{
public static bool IsBoolean(this SCTypeCode type) => (byte)type - 1 < 3;
- public static int GetTypeSize(this SCTypeCode type)
+ public static int GetTypeSize(this SCTypeCode type) => type switch
{
- return type switch
- {
- SCTypeCode.Bool3 => sizeof(bool),
+ SCTypeCode.Bool3 => sizeof(bool),
- SCTypeCode.Byte => sizeof(byte),
- SCTypeCode.UInt16 => sizeof(ushort),
- SCTypeCode.UInt32 => sizeof(uint),
- SCTypeCode.UInt64 => sizeof(ulong),
+ SCTypeCode.Byte => sizeof(byte),
+ SCTypeCode.UInt16 => sizeof(ushort),
+ SCTypeCode.UInt32 => sizeof(uint),
+ SCTypeCode.UInt64 => sizeof(ulong),
- SCTypeCode.SByte => sizeof(sbyte),
- SCTypeCode.Int16 => sizeof(short),
- SCTypeCode.Int32 => sizeof(int),
- SCTypeCode.Int64 => sizeof(long),
+ SCTypeCode.SByte => sizeof(sbyte),
+ SCTypeCode.Int16 => sizeof(short),
+ SCTypeCode.Int32 => sizeof(int),
+ SCTypeCode.Int64 => sizeof(long),
- SCTypeCode.Single => sizeof(float),
- SCTypeCode.Double => sizeof(double),
+ SCTypeCode.Single => sizeof(float),
+ SCTypeCode.Double => sizeof(double),
- _ => throw new ArgumentException(type.ToString(), nameof(type))
- };
- }
+ _ => throw new ArgumentException(type.ToString(), nameof(type))
+ };
- public static Type GetType(this SCTypeCode type)
+ public static Type GetType(this SCTypeCode type) => type switch
{
- return type switch
- {
- SCTypeCode.Byte => typeof(byte),
- SCTypeCode.UInt16 => typeof(ushort),
- SCTypeCode.UInt32 => typeof(uint),
- SCTypeCode.UInt64 => typeof(ulong),
+ SCTypeCode.Byte => typeof(byte),
+ SCTypeCode.UInt16 => typeof(ushort),
+ SCTypeCode.UInt32 => typeof(uint),
+ SCTypeCode.UInt64 => typeof(ulong),
- SCTypeCode.SByte => typeof(sbyte),
- SCTypeCode.Int16 => typeof(short),
- SCTypeCode.Int32 => typeof(int),
- SCTypeCode.Int64 => typeof(long),
+ SCTypeCode.SByte => typeof(sbyte),
+ SCTypeCode.Int16 => typeof(short),
+ SCTypeCode.Int32 => typeof(int),
+ SCTypeCode.Int64 => typeof(long),
- SCTypeCode.Single => typeof(float),
- SCTypeCode.Double => typeof(double),
+ SCTypeCode.Single => typeof(float),
+ SCTypeCode.Double => typeof(double),
- _ => throw new ArgumentException(type.ToString(), nameof(type))
- };
- }
+ _ => throw new ArgumentException(type.ToString(), nameof(type))
+ };
public static object GetValue(this SCTypeCode type, byte[] data)
{
@@ -119,4 +113,4 @@ public static void SetValue(this SCTypeCode type, byte[] data, object value)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs
index 1c4a23f20..f7b1c8b11 100644
--- a/PKHeX.Core/Saves/SAV3.cs
+++ b/PKHeX.Core/Saves/SAV3.cs
@@ -404,18 +404,12 @@ public override string ChecksumInfo
// Trainer Info
public override GameVersion Version { get; protected set; }
- public uint SecurityKey
+ public uint SecurityKey => Version switch
{
- get
- {
- return Version switch
- {
- GameVersion.E => BitConverter.ToUInt32(Data, BlockOfs[0] + 0xAC),
- GameVersion.FRLG => BitConverter.ToUInt32(Data, BlockOfs[0] + 0xF20),
- _ => 0u
- };
- }
- }
+ GameVersion.E => BitConverter.ToUInt32(Data, BlockOfs[0] + 0xAC),
+ GameVersion.FRLG => BitConverter.ToUInt32(Data, BlockOfs[0] + 0xF20),
+ _ => 0u
+ };
public override string OT
{
diff --git a/PKHeX.Core/Saves/SAV6AO.cs b/PKHeX.Core/Saves/SAV6AO.cs
index bd9415c01..9af342de5 100644
--- a/PKHeX.Core/Saves/SAV6AO.cs
+++ b/PKHeX.Core/Saves/SAV6AO.cs
@@ -90,18 +90,12 @@ private void Initialize()
public Zukan6AO Zukan => Blocks.Zukan;
#endregion
- public override GameVersion Version
+ public override GameVersion Version => Game switch
{
- get
- {
- return Game switch
- {
- (int)GameVersion.AS => GameVersion.AS,
- (int)GameVersion.OR => GameVersion.OR,
- _ => GameVersion.Invalid
- };
- }
- }
+ (int) GameVersion.AS => GameVersion.AS,
+ (int) GameVersion.OR => GameVersion.OR,
+ _ => GameVersion.Invalid
+ };
public override bool GetCaught(int species) => Blocks.Zukan.GetCaught(species);
public override bool GetSeen(int species) => Blocks.Zukan.GetSeen(species);
diff --git a/PKHeX.Core/Saves/SAV6AODemo.cs b/PKHeX.Core/Saves/SAV6AODemo.cs
index d62a8bebd..281cb4463 100644
--- a/PKHeX.Core/Saves/SAV6AODemo.cs
+++ b/PKHeX.Core/Saves/SAV6AODemo.cs
@@ -36,18 +36,12 @@ private void Initialize()
EventFlag = EventConst + 0x2FC;
}
- public override GameVersion Version
+ public override GameVersion Version => Game switch
{
- get
- {
- return Game switch
- {
- (int) GameVersion.AS => GameVersion.AS,
- (int) GameVersion.OR => GameVersion.OR,
- _ => GameVersion.Invalid
- };
- }
- }
+ (int) GameVersion.AS => GameVersion.AS,
+ (int) GameVersion.OR => GameVersion.OR,
+ _ => GameVersion.Invalid
+ };
public override uint Money { get => Blocks.Misc.Money; set => Blocks.Misc.Money = value; }
public override int Vivillon { get => Blocks.Misc.Vivillon; set => Blocks.Misc.Vivillon = value; } // unused
diff --git a/PKHeX.Core/Saves/SAV6XY.cs b/PKHeX.Core/Saves/SAV6XY.cs
index a15e8abe5..fe9670976 100644
--- a/PKHeX.Core/Saves/SAV6XY.cs
+++ b/PKHeX.Core/Saves/SAV6XY.cs
@@ -136,18 +136,12 @@ public void UnlockAllFriendSafariSlots()
State.Edited = true;
}
- public override GameVersion Version
+ public override GameVersion Version => Game switch
{
- get
- {
- return Game switch
- {
- (int)GameVersion.X => GameVersion.X,
- (int)GameVersion.Y => GameVersion.Y,
- _ => GameVersion.Invalid
- };
- }
- }
+ (int) GameVersion.X => GameVersion.X,
+ (int) GameVersion.Y => GameVersion.Y,
+ _ => GameVersion.Invalid
+ };
protected override bool[] MysteryGiftReceivedFlags { get => Blocks.MysteryGift.GetReceivedFlags(); set => Blocks.MysteryGift.SetReceivedFlags(value); }
protected override DataMysteryGift[] MysteryGiftCards { get => Blocks.MysteryGift.GetGifts(); set => Blocks.MysteryGift.SetGifts(value); }
diff --git a/PKHeX.Core/Saves/SAV7.cs b/PKHeX.Core/Saves/SAV7.cs
index d5fbc87aa..edfc0a2ed 100644
--- a/PKHeX.Core/Saves/SAV7.cs
+++ b/PKHeX.Core/Saves/SAV7.cs
@@ -109,20 +109,14 @@ protected override byte[] GetFinalData()
public int HoF { get; protected set; }
- public override GameVersion Version
+ public override GameVersion Version => Game switch
{
- get
- {
- return Game switch
- {
- 30 => GameVersion.SN,
- 31 => GameVersion.MN,
- 32 => GameVersion.US,
- 33 => GameVersion.UM,
- _ => GameVersion.Invalid
- };
- }
- }
+ (int)GameVersion.SN => GameVersion.SN,
+ (int)GameVersion.MN => GameVersion.MN,
+ (int)GameVersion.US => GameVersion.US,
+ (int)GameVersion.UM => GameVersion.UM,
+ _ => GameVersion.Invalid
+ };
public override string GetString(byte[] data, int offset, int length) => StringConverter.GetString7(data, offset, length);
diff --git a/PKHeX.Core/Saves/SAV7b.cs b/PKHeX.Core/Saves/SAV7b.cs
index cfa71c2f0..823d82f8f 100644
--- a/PKHeX.Core/Saves/SAV7b.cs
+++ b/PKHeX.Core/Saves/SAV7b.cs
@@ -127,18 +127,12 @@ public override byte[] SetString(string value, int maxLength, int PadToSize = 0,
return StringConverter.SetString7b(value, maxLength, Language, PadToSize, PadWith);
}
- public override GameVersion Version
+ public override GameVersion Version => Game switch
{
- get
- {
- return Game switch
- {
- (int)GameVersion.GP => GameVersion.GP,
- (int)GameVersion.GE => GameVersion.GE,
- _ => GameVersion.Invalid
- };
- }
- }
+ (int)GameVersion.GP => GameVersion.GP,
+ (int)GameVersion.GE => GameVersion.GE,
+ _ => GameVersion.Invalid
+ };
// Player Information
public override int TID { get => Blocks.Status.TID; set => Blocks.Status.TID = value; }
diff --git a/PKHeX.Core/Saves/SAV8.cs b/PKHeX.Core/Saves/SAV8.cs
index e41a97616..947036c8f 100644
--- a/PKHeX.Core/Saves/SAV8.cs
+++ b/PKHeX.Core/Saves/SAV8.cs
@@ -60,18 +60,12 @@ public abstract class SAV8 : SaveFile, ISaveBlock8Main
public abstract TeamIndexes8 TeamIndexes { get; }
#endregion
- public override GameVersion Version
+ public override GameVersion Version => Game switch
{
- get
- {
- var game = (GameVersion)Game;
- return game switch
- {
- GameVersion.SW or GameVersion.SH => game,
- _ => GameVersion.Invalid
- };
- }
- }
+ (int)GameVersion.SW => GameVersion.SW,
+ (int)GameVersion.SH => GameVersion.SH,
+ _ => GameVersion.Invalid
+ };
public override string GetString(byte[] data, int offset, int length) => StringConverter.GetString7(data, offset, length);
diff --git a/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs b/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs
index cd285a6b1..d8aa0ef85 100644
--- a/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs
+++ b/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs
@@ -39,16 +39,13 @@ public static uint GetKey(SAV3 sav)
return sav.SecurityKey;
}
- private static Type GetEnumType(GameVersion ver)
+ private static Type GetEnumType(GameVersion ver) => ver switch
{
- return ver switch
- {
- GameVersion.RS => typeof(RecID3RuSa),
- GameVersion.FRLG => typeof(RecID3FRLG),
- GameVersion.E => typeof(RecID3Emerald),
- _ => throw new ArgumentException(nameof(ver))
- };
- }
+ GameVersion.RS => typeof(RecID3RuSa),
+ GameVersion.FRLG => typeof(RecID3FRLG),
+ GameVersion.E => typeof(RecID3Emerald),
+ _ => throw new ArgumentException(nameof(ver))
+ };
public static int[] GetEnumValues(GameVersion ver) => (int[])Enum.GetValues(GetEnumType(ver));
public static string[] GetEnumNames(GameVersion ver) => Enum.GetNames(GetEnumType(ver));
diff --git a/PKHeX.Core/Saves/Substructures/Gen5/EntreeForest.cs b/PKHeX.Core/Saves/Substructures/Gen5/EntreeForest.cs
index ddadb0066..93f55b733 100644
--- a/PKHeX.Core/Saves/Substructures/Gen5/EntreeForest.cs
+++ b/PKHeX.Core/Saves/Substructures/Gen5/EntreeForest.cs
@@ -111,15 +111,12 @@ private static EntreeForestArea GetSlotArea(int index)
return (EntreeForestArea)((int)EntreeForestArea.First << area) | GetSlotPosition(index / Count18);
}
- private static EntreeForestArea GetSlotPosition(int index)
+ private static EntreeForestArea GetSlotPosition(int index) => index switch
{
- return index switch
- {
- 0 => EntreeForestArea.Center,
- 1 => EntreeForestArea.Left,
- 2 => EntreeForestArea.Right,
- _ => throw new ArgumentOutOfRangeException()
- };
- }
+ 0 => EntreeForestArea.Center,
+ 1 => EntreeForestArea.Left,
+ 2 => EntreeForestArea.Right,
+ _ => throw new ArgumentOutOfRangeException()
+ };
}
}
diff --git a/PKHeX.Core/Saves/Substructures/Gen7/EventWork7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/EventWork7b.cs
index 70fa7c0ef..fd7431d9c 100644
--- a/PKHeX.Core/Saves/Substructures/Gen7/EventWork7b.cs
+++ b/PKHeX.Core/Saves/Substructures/Gen7/EventWork7b.cs
@@ -131,52 +131,40 @@ public EventVarType GetWorkType(int index, out int subIndex)
throw new ArgumentException(nameof(index));
}
- private int GetFlagStart(EventVarType type)
+ private static int GetFlagStart(EventVarType type) => type switch
{
- return type switch
- {
- EventVarType.Zone => ZoneFlagStart,
- EventVarType.System => SystemFlagStart,
- EventVarType.Vanish => VanishFlagStart,
- EventVarType.Event => EventFlagStart,
- _ => throw new ArgumentException(nameof(type))
- };
- }
+ EventVarType.Zone => ZoneFlagStart,
+ EventVarType.System => SystemFlagStart,
+ EventVarType.Vanish => VanishFlagStart,
+ EventVarType.Event => EventFlagStart,
+ _ => throw new ArgumentException(nameof(type))
+ };
- private int GetWorkStart(EventVarType type)
+ private static int GetWorkStart(EventVarType type) => type switch
{
- return type switch
- {
- EventVarType.Zone => ZoneWorkStart,
- EventVarType.System => SystemWorkStart,
- EventVarType.Scene => SceneWorkStart,
- EventVarType.Event => EventWorkStart,
- _ => throw new ArgumentException(nameof(type))
- };
- }
+ EventVarType.Zone => ZoneWorkStart,
+ EventVarType.System => SystemWorkStart,
+ EventVarType.Scene => SceneWorkStart,
+ EventVarType.Event => EventWorkStart,
+ _ => throw new ArgumentException(nameof(type))
+ };
- private int GetFlagCount(EventVarType type)
+ private static int GetFlagCount(EventVarType type) => type switch
{
- return type switch
- {
- EventVarType.Zone => ZoneFlagCount,
- EventVarType.System => SystemFlagCount,
- EventVarType.Vanish => VanishFlagCount,
- EventVarType.Event => EventFlagCount,
- _ => throw new ArgumentException(nameof(type))
- };
- }
+ EventVarType.Zone => ZoneFlagCount,
+ EventVarType.System => SystemFlagCount,
+ EventVarType.Vanish => VanishFlagCount,
+ EventVarType.Event => EventFlagCount,
+ _ => throw new ArgumentException(nameof(type))
+ };
- private int GetWorkCount(EventVarType type)
+ private static int GetWorkCount(EventVarType type) => type switch
{
- return type switch
- {
- EventVarType.Zone => ZoneWorkCount,
- EventVarType.System => SystemWorkCount,
- EventVarType.Scene => SceneWorkCount,
- EventVarType.Event => EventWorkCount,
- _ => throw new ArgumentException(nameof(type))
- };
- }
+ EventVarType.Zone => ZoneWorkCount,
+ EventVarType.System => SystemWorkCount,
+ EventVarType.Scene => SceneWorkCount,
+ EventVarType.Event => EventWorkCount,
+ _ => throw new ArgumentException(nameof(type))
+ };
}
}
\ No newline at end of file
diff --git a/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs b/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs
index 8ee44fa28..139518251 100644
--- a/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs
+++ b/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs
@@ -37,28 +37,22 @@ public FestaFacility(SAV7 sav, int index)
public byte[] TrainerFesID { get => Data.Slice(0x34, 0xC); set => value.CopyTo(Data, 0x34); }
public int ExchangeLeftCount { get => Data[0x40]; set => Data[0x40] = (byte)value; } // used when Type=Exchange
- public int GetMessage(int index)
+ public int GetMessage(int index) => index switch
{
- return index switch
- {
- 0 => MessageMeet,
- 1 => MessagePart,
- 2 => MessageMoved,
- 3 => MessageDisappointed,
- _ => 0
- };
- }
+ 0 => MessageMeet,
+ 1 => MessagePart,
+ 2 => MessageMoved,
+ 3 => MessageDisappointed,
+ _ => 0
+ };
- public void SetMessage(int index, ushort value)
+ public int SetMessage(int index, ushort value) => index switch
{
- switch (index)
- {
- case 0: MessageMeet = value; break;
- case 1: MessagePart = value; break;
- case 2: MessageMoved = value; break;
- case 3: MessageDisappointed = value; break;
- default: return;
- }
- }
+ 0 => MessageMeet = value,
+ 1 => MessagePart = value,
+ 2 => MessageMoved = value,
+ 3 => MessageDisappointed = value,
+ _ => -1,
+ };
}
}
diff --git a/PKHeX.Core/Saves/Substructures/Gen8/Daycare8.cs b/PKHeX.Core/Saves/Substructures/Gen8/Daycare8.cs
index 0193828ca..fb30961bc 100644
--- a/PKHeX.Core/Saves/Substructures/Gen8/Daycare8.cs
+++ b/PKHeX.Core/Saves/Substructures/Gen8/Daycare8.cs
@@ -72,25 +72,19 @@ public static int GetDaycare2StructOffset(int slot)
return DAYCARE_SIZE + (slot * STRUCT_SIZE);
}
- public static int GetDaycareSlotOffset(int daycare, int slot)
+ public static int GetDaycareSlotOffset(int daycare, int slot) => daycare switch
{
- return daycare switch
- {
- 0 => (1 + GetDaycare1StructOffset(slot)),
- 1 => (1 + GetDaycare2StructOffset(slot)),
- _ => throw new IndexOutOfRangeException(nameof(daycare))
- };
- }
+ 0 => (1 + GetDaycare1StructOffset(slot)),
+ 1 => (1 + GetDaycare2StructOffset(slot)),
+ _ => throw new IndexOutOfRangeException(nameof(daycare))
+ };
- public static int GetDaycareMetadataOffset(int daycare)
+ public static int GetDaycareMetadataOffset(int daycare) => daycare switch
{
- return daycare switch
- {
- 0 => META_1,
- 1 => META_2,
- _ => throw new IndexOutOfRangeException(nameof(daycare))
- };
- }
+ 0 => META_1,
+ 1 => META_2,
+ _ => throw new IndexOutOfRangeException(nameof(daycare))
+ };
public ulong GetDaycareSeed(int daycare) => BitConverter.ToUInt64(Data, GetDaycareMetadataOffset(daycare) + 6);
public void SetDaycareSeed(int daycare, ulong value) => SAV.SetData(Data, BitConverter.GetBytes(value), GetDaycareMetadataOffset(daycare) + 6);
diff --git a/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8.cs b/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8.cs
index 5f99021e8..fcb3feff1 100644
--- a/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8.cs
+++ b/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8.cs
@@ -85,14 +85,11 @@ internal void SanitizeCounts()
item.Count = GetSuggestedCount(Type, item.Index, item.Count);
}
- public static int GetSuggestedCount(InventoryType t, int item, int requestVal)
+ public static int GetSuggestedCount(InventoryType t, int item, int requestVal) => t switch
{
- return t switch
- {
- // TMs are clamped to 1, let TRs be whatever
- InventoryType.TMHMs => 1130 <= item && item <= 1229 ? requestVal : 1,
- _ => requestVal
- };
- }
+ // TMs are clamped to 1, let TRs be whatever
+ InventoryType.TMHMs => 1130 <= item && item <= 1229 ? requestVal : 1,
+ _ => requestVal
+ };
}
}
diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs
index 894a3642f..bc76cb52f 100644
--- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs
+++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan8.cs
@@ -29,16 +29,13 @@ public int GetRevision()
return 2;
}
- private byte[] GetDexBlock(Zukan8Type infoDexType)
+ private byte[] GetDexBlock(Zukan8Type infoDexType) => infoDexType switch
{
- return infoDexType switch
- {
- Zukan8Type.Galar => Galar.Data,
- Zukan8Type.Armor => Rigel1.Data,
- Zukan8Type.Crown => Rigel2.Data,
- _ => throw new ArgumentOutOfRangeException(nameof(infoDexType), infoDexType, null)
- };
- }
+ Zukan8Type.Galar => Galar.Data,
+ Zukan8Type.Armor => Rigel1.Data,
+ Zukan8Type.Crown => Rigel2.Data,
+ _ => throw new ArgumentOutOfRangeException(nameof(infoDexType), infoDexType, null)
+ };
private static bool GetFlag(byte[] data, int offset, int bitIndex) => FlagUtil.GetFlag(data, offset + (bitIndex >> 3), bitIndex);
private static void SetFlag(byte[] data, int offset, int bitIndex, bool value = true) => FlagUtil.SetFlag(data, offset + (bitIndex >> 3), bitIndex, value);
diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs
index 328801515..ace4228e0 100644
--- a/PKHeX.Core/Saves/Util/SaveUtil.cs
+++ b/PKHeX.Core/Saves/Util/SaveUtil.cs
@@ -633,47 +633,44 @@ public static SaveFile GetBlankSAV(GameVersion game, string trainerName, Languag
/// Version to create the save file for.
/// Save file language to initialize for
/// Blank save file from the requested game, null if no game exists for that .
- private static SaveFile GetBlankSAV(GameVersion game, LanguageID language)
+ private static SaveFile GetBlankSAV(GameVersion game, LanguageID language) => game switch
{
- return game switch
- {
- RD or BU or GN or YW or RBY => new SAV1(version: game),
- StadiumJ => new SAV1StadiumJ(),
- Stadium => new SAV1Stadium(language == LanguageID.Japanese),
+ RD or BU or GN or YW or RBY => new SAV1(version: game),
+ StadiumJ => new SAV1StadiumJ(),
+ Stadium => new SAV1Stadium(language == LanguageID.Japanese),
- GD or SV or GS => new SAV2(version: GS, lang: language),
- C or GSC => new SAV2(version: C, lang: language),
- Stadium2 => new SAV2Stadium(language == LanguageID.Japanese),
+ GD or SV or GS => new SAV2(version: GS, lang: language),
+ C or GSC => new SAV2(version: C, lang: language),
+ Stadium2 => new SAV2Stadium(language == LanguageID.Japanese),
- R or S or E or FR or LG => new SAV3(version: game, language == LanguageID.Japanese),
- RS => new SAV3(version: R, language == LanguageID.Japanese),
- RSE => new SAV3(version: E, language == LanguageID.Japanese),
- FRLG => new SAV3(version: FR, language == LanguageID.Japanese),
+ R or S or E or FR or LG => new SAV3(version: game, language == LanguageID.Japanese),
+ RS => new SAV3(version: R, language == LanguageID.Japanese),
+ RSE => new SAV3(version: E, language == LanguageID.Japanese),
+ FRLG => new SAV3(version: FR, language == LanguageID.Japanese),
- CXD or COLO => new SAV3Colosseum(),
- XD => new SAV3XD(),
- RSBOX => new SAV3RSBox(),
+ CXD or COLO => new SAV3Colosseum(),
+ XD => new SAV3XD(),
+ RSBOX => new SAV3RSBox(),
- D or P or DP => new SAV4DP(),
- Pt or DPPt => new SAV4Pt(),
- HG or SS or HGSS => new SAV4HGSS(),
+ D or P or DP => new SAV4DP(),
+ Pt or DPPt => new SAV4Pt(),
+ HG or SS or HGSS => new SAV4HGSS(),
- B or W or BW => new SAV5BW(),
- B2 or W2 or B2W2 => new SAV5B2W2(),
+ B or W or BW => new SAV5BW(),
+ B2 or W2 or B2W2 => new SAV5B2W2(),
- X or Y or XY => new SAV6XY(),
- ORASDEMO => new SAV6AODemo(),
- OR or AS or ORAS => new SAV6AO(),
+ X or Y or XY => new SAV6XY(),
+ ORASDEMO => new SAV6AODemo(),
+ OR or AS or ORAS => new SAV6AO(),
- SN or MN or SM => new SAV7SM(),
- US or UM or USUM => new SAV7USUM(),
- GP or GE or GG or GO => new SAV7b(),
+ SN or MN or SM => new SAV7SM(),
+ US or UM or USUM => new SAV7USUM(),
+ GP or GE or GG or GO => new SAV7b(),
- SW or SH or SWSH => new SAV8SWSH(),
+ SW or SH or SWSH => new SAV8SWSH(),
- _ => throw new ArgumentException(nameof(game)),
- };
- }
+ _ => throw new ArgumentException(nameof(game)),
+ };
///
/// Creates an instance of a SaveFile with a blank base.
@@ -785,9 +782,7 @@ private static void CheckHeaderFooter(ref byte[] input, out byte[] header, out b
private static bool GetHasFooterDSV(byte[] input)
{
var signature = FOOTER_DSV;
- if (!GetHasSignature(input, signature, input.Length - signature.Length))
- return false;
- return true;
+ return GetHasSignature(input, signature, input.Length - signature.Length);
}
private static bool GetHasSignature(byte[] input, byte[] signature, int start)
@@ -806,39 +801,33 @@ private static bool GetHasSignature(byte[] input, byte[] signature, int start)
/// SaveFile data to force
/// Version to retrieve for
/// New object.
- public static SAV3 GetG3SaveOverride(SaveFile sav, GameVersion ver)
+ public static SAV3 GetG3SaveOverride(SaveFile sav, GameVersion ver) => ver switch // Reset save file info
{
- return ver switch // Reset save file info
- {
- R => new SAV3(sav.State.BAK, RS),
- S => new SAV3(sav.State.BAK, RS),
- RS => new SAV3(sav.State.BAK, RS),
- E => new SAV3(sav.State.BAK, E),
- FRLG => new SAV3(sav.State.BAK, FRLG),
- FR => new SAV3(sav.State.BAK, FRLG),
- LG => new SAV3(sav.State.BAK, FRLG),
- _ => throw new ArgumentException(nameof(ver))
- };
- }
+ R => new SAV3(sav.State.BAK, RS),
+ S => new SAV3(sav.State.BAK, RS),
+ RS => new SAV3(sav.State.BAK, RS),
+ E => new SAV3(sav.State.BAK, E),
+ FRLG => new SAV3(sav.State.BAK, FRLG),
+ FR => new SAV3(sav.State.BAK, FRLG),
+ LG => new SAV3(sav.State.BAK, FRLG),
+ _ => throw new ArgumentException(nameof(ver))
+ };
///
/// Gets the for a Gen3 save file.
///
/// Version to retrieve for
/// Reference to the .
- public static PersonalTable GetG3Personal(GameVersion ver)
+ public static PersonalTable GetG3Personal(GameVersion ver) => ver switch
{
- return ver switch
- {
- RS => PersonalTable.RS,
- E => PersonalTable.E,
- FRLG => PersonalTable.FR,
- FR => PersonalTable.FR,
- LG => PersonalTable.LG,
- R => PersonalTable.RS,
- S => PersonalTable.RS,
- _ => throw new ArgumentException(nameof(ver))
- };
- }
+ RS => PersonalTable.RS,
+ E => PersonalTable.E,
+ FRLG => PersonalTable.FR,
+ FR => PersonalTable.FR,
+ LG => PersonalTable.LG,
+ R => PersonalTable.RS,
+ S => PersonalTable.RS,
+ _ => throw new ArgumentException(nameof(ver))
+ };
}
}
diff --git a/PKHeX.Drawing/Names/BoxWallpaper.cs b/PKHeX.Drawing/Names/BoxWallpaper.cs
index 2ff9dc2a6..b6fd1d9bb 100644
--- a/PKHeX.Drawing/Names/BoxWallpaper.cs
+++ b/PKHeX.Drawing/Names/BoxWallpaper.cs
@@ -16,25 +16,22 @@ public static string GetWallpaperResourceName(GameVersion version, int index)
return $"box_wp{index:00}{suffix}";
}
- private static string GetResourceSuffix(GameVersion version, int index)
+ private static string GetResourceSuffix(GameVersion version, int index) => version.GetGeneration() switch
{
- return version.GetGeneration() switch
- {
- 3 when version == E => "e",
- 3 when FRLG.Contains(version) && index > 12 => "frlg",
- 3 => "rs",
+ 3 when version == E => "e",
+ 3 when FRLG.Contains(version) && index > 12 => "frlg",
+ 3 => "rs",
- 4 when index < 16 => "dp",
- 4 when version == Pt => "pt",
- 4 when HGSS.Contains(version) => "hgss",
+ 4 when index < 16 => "dp",
+ 4 when version == Pt => "pt",
+ 4 when HGSS.Contains(version) => "hgss",
- 5 => B2W2.Contains(version) && index > 16 ? "b2w2" : "bw",
- 6 => ORAS.Contains(version) && index > 16 ? "ao" : "xy",
- 7 when !GG.Contains(version) => "xy",
- 8 => "swsh",
- _ => string.Empty
- };
- }
+ 5 => B2W2.Contains(version) && index > 16 ? "b2w2" : "bw",
+ 6 => ORAS.Contains(version) && index > 16 ? "ao" : "xy",
+ 7 when !GG.Contains(version) => "xy",
+ 8 => "swsh",
+ _ => string.Empty
+ };
public static bool IsWallpaperRed(GameVersion version, int wallpaperID)
{
diff --git a/PKHeX.Drawing/QR/QRDecode.cs b/PKHeX.Drawing/QR/QRDecode.cs
index 8cb7ef476..faf2d0afc 100644
--- a/PKHeX.Drawing/QR/QRDecode.cs
+++ b/PKHeX.Drawing/QR/QRDecode.cs
@@ -82,18 +82,15 @@ private static byte[] DecodeQRJson(string data)
return Convert.FromBase64String(pkstr);
}
- public static string ConvertMsg(this QRDecodeResult result)
+ public static string ConvertMsg(this QRDecodeResult result) => result switch
{
- return result switch
- {
- QRDecodeResult.Success => string.Empty,
- QRDecodeResult.BadPath => MessageStrings.MsgQRUrlFailPath,
- QRDecodeResult.BadImage => MessageStrings.MsgQRUrlFailImage,
- QRDecodeResult.BadType => MessageStrings.MsgQRUrlFailType,
- QRDecodeResult.BadConnection => MessageStrings.MsgQRUrlFailConnection,
- QRDecodeResult.BadConversion => MessageStrings.MsgQRUrlFailConvert,
- _ => throw new ArgumentOutOfRangeException(nameof(result), result, null)
- };
- }
+ QRDecodeResult.Success => string.Empty,
+ QRDecodeResult.BadPath => MessageStrings.MsgQRUrlFailPath,
+ QRDecodeResult.BadImage => MessageStrings.MsgQRUrlFailImage,
+ QRDecodeResult.BadType => MessageStrings.MsgQRUrlFailType,
+ QRDecodeResult.BadConnection => MessageStrings.MsgQRUrlFailConnection,
+ QRDecodeResult.BadConversion => MessageStrings.MsgQRUrlFailConvert,
+ _ => throw new ArgumentOutOfRangeException(nameof(result), result, null)
+ };
}
}
diff --git a/PKHeX.Drawing/Sprites/SpriteBuilder.cs b/PKHeX.Drawing/Sprites/SpriteBuilder.cs
index 08fdbac1f..748195cd8 100644
--- a/PKHeX.Drawing/Sprites/SpriteBuilder.cs
+++ b/PKHeX.Drawing/Sprites/SpriteBuilder.cs
@@ -48,16 +48,13 @@ public void Initialize(SaveFile sav)
private GameVersion Game;
- private static int GetDeoxysForm(GameVersion game)
+ private static int GetDeoxysForm(GameVersion game) => game switch
{
- return game switch
- {
- GameVersion.FR => 1, // Attack
- GameVersion.LG => 2, // Defense
- GameVersion.E => 3, // Speed
- _ => 0
- };
- }
+ GameVersion.FR => 1, // Attack
+ GameVersion.LG => 2, // Defense
+ GameVersion.E => 3, // Speed
+ _ => 0
+ };
public Image GetSprite(int species, int form, int gender, uint formarg, int heldItem, bool isEgg, bool isShiny, int generation = -1, bool isBoxBGRed = false, bool isAltShiny = false)
{
diff --git a/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs b/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs
index 548a93f5b..4a3c5d75f 100644
--- a/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs
+++ b/PKHeX.WinForms/Controls/PKM Editor/DrawConfig.cs
@@ -72,15 +72,12 @@ public sealed class DrawConfig : IDisposable
public DrawConfig() => LoadBrushes();
- public Color GetGenderColor(int gender)
+ public Color GetGenderColor(int gender) => gender switch
{
- return gender switch
- {
- 0 => Male,
- 1 => Female,
- _ => TextColor
- };
- }
+ 0 => Male,
+ 1 => Female,
+ _ => TextColor
+ };
public bool GetMarkingColor(int markval, out Color c)
{
diff --git a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
index 2de1f0277..135bea685 100644
--- a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
+++ b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs
@@ -536,17 +536,14 @@ private void B_OpenBoxLayout_Click(object sender, EventArgs e)
UpdateBoxViewers(all: true); // update subviewers
}
- private static Form GetTrainerEditor(SaveFile sav)
+ private static Form GetTrainerEditor(SaveFile sav) => sav switch
{
- return sav switch
- {
- SAV6 s6 => new SAV_Trainer(s6),
- SAV7 s7 => new SAV_Trainer7(s7),
- SAV7b b7 => new SAV_Trainer7GG(b7),
- SAV8SWSH swsh => new SAV_Trainer8(swsh),
- _ => new SAV_SimpleTrainer(sav)
- };
- }
+ SAV6 s6 => new SAV_Trainer(s6),
+ SAV7 s7 => new SAV_Trainer7(s7),
+ SAV7b b7 => new SAV_Trainer7GG(b7),
+ SAV8SWSH swsh => new SAV_Trainer8(swsh),
+ _ => new SAV_SimpleTrainer(sav)
+ };
private void B_OpenRaids_Click(object sender, EventArgs e)
{
@@ -584,21 +581,18 @@ private void B_Blocks_Click(object sender, EventArgs e)
form.Dispose();
}
- private static Form GetAccessorForm(SaveFile sav)
+ private static Form GetAccessorForm(SaveFile sav) => sav switch
{
- return sav switch
- {
- SAV5BW s => new SAV_Accessor(s.Blocks),
- SAV5B2W2 s => new SAV_Accessor(s.Blocks),
- SAV6XY s => new SAV_Accessor(s.Blocks),
- SAV6AO s => new SAV_Accessor(s.Blocks),
- SAV6AODemo s => new SAV_Accessor(s.Blocks),
- SAV7SM s => new SAV_Accessor(s.Blocks),
- SAV7USUM s => new SAV_Accessor(s.Blocks),
- SAV8SWSH s => new SAV_BlockDump8(s),
- _ => GetPropertyForm(sav),
- };
- }
+ SAV5BW s => new SAV_Accessor(s.Blocks),
+ SAV5B2W2 s => new SAV_Accessor(s.Blocks),
+ SAV6XY s => new SAV_Accessor(s.Blocks),
+ SAV6AO s => new SAV_Accessor(s.Blocks),
+ SAV6AODemo s => new SAV_Accessor(s.Blocks),
+ SAV7SM s => new SAV_Accessor(s.Blocks),
+ SAV7USUM s => new SAV_Accessor(s.Blocks),
+ SAV8SWSH s => new SAV_BlockDump8(s),
+ _ => GetPropertyForm(sav),
+ };
private static Form GetPropertyForm(object sav)
{
diff --git a/PKHeX.WinForms/Controls/Slots/SlotUtil.cs b/PKHeX.WinForms/Controls/Slots/SlotUtil.cs
index 852711c4b..281fde329 100644
--- a/PKHeX.WinForms/Controls/Slots/SlotUtil.cs
+++ b/PKHeX.WinForms/Controls/Slots/SlotUtil.cs
@@ -14,31 +14,25 @@ public static class SlotUtil
///
/// Gets the background image for a slot based on the provided .
///
- public static Image GetTouchTypeBackground(SlotTouchType type)
+ public static Image GetTouchTypeBackground(SlotTouchType type) => type switch
{
- return type switch
- {
- SlotTouchType.None => SpriteUtil.Spriter.Transparent,
- SlotTouchType.Get => SpriteUtil.Spriter.View,
- SlotTouchType.Set => SpriteUtil.Spriter.Set,
- SlotTouchType.Delete => SpriteUtil.Spriter.Delete,
- SlotTouchType.Swap => SpriteUtil.Spriter.Set,
- _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
- };
- }
+ SlotTouchType.None => SpriteUtil.Spriter.Transparent,
+ SlotTouchType.Get => SpriteUtil.Spriter.View,
+ SlotTouchType.Set => SpriteUtil.Spriter.Set,
+ SlotTouchType.Delete => SpriteUtil.Spriter.Delete,
+ SlotTouchType.Swap => SpriteUtil.Spriter.Set,
+ _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
+ };
///
/// Gets the type of action that should be performed for a Drag & Drop request.
///
- public static DropModifier GetDropModifier()
+ public static DropModifier GetDropModifier() => Control.ModifierKeys switch
{
- return Control.ModifierKeys switch
- {
- Keys.Shift => DropModifier.Clone,
- Keys.Alt => DropModifier.Overwrite,
- _ => DropModifier.None
- };
- }
+ Keys.Shift => DropModifier.Clone,
+ Keys.Alt => DropModifier.Overwrite,
+ _ => DropModifier.None
+ };
///
/// Refreshes a with the appropriate display content.
diff --git a/PKHeX.WinForms/Subforms/KChart.cs b/PKHeX.WinForms/Subforms/KChart.cs
index 6104ff021..d0936eddd 100644
--- a/PKHeX.WinForms/Subforms/KChart.cs
+++ b/PKHeX.WinForms/Subforms/KChart.cs
@@ -85,14 +85,11 @@ private string GetAbility(IReadOnlyList abilityIDs, int index)
return abilities[abilityIDs[index]];
}
- private static bool GetIsNative(PersonalInfo personalInfo, int s)
+ private static bool GetIsNative(PersonalInfo personalInfo, int s) => personalInfo switch
{
- return personalInfo switch
- {
- PersonalInfoSM => s > 721 || Legal.PastGenAlolanNatives.Contains(s),
- PersonalInfoSWSH ss => ss.IsInDex,
- _ => true,
- };
- }
+ PersonalInfoSM => s > 721 || Legal.PastGenAlolanNatives.Contains(s),
+ PersonalInfoSWSH ss => ss.IsInDex,
+ _ => true,
+ };
}
}
diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs
index 3457363b4..6be9ab0c9 100644
--- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs
+++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs
@@ -372,18 +372,15 @@ public TextMarkup(string[] args)
if (!string.IsNullOrWhiteSpace(args[9])) Location = args[9] + ":";
}
- public string GetMemoryCategory(MemoryArgType type, int format)
+ public string GetMemoryCategory(MemoryArgType type, int format) => type switch
{
- return type switch
- {
- MemoryArgType.GeneralLocation => Area,
- MemoryArgType.SpecificLocation when format == 6 => Location,
- MemoryArgType.Species => Species,
- MemoryArgType.Move => Move,
- MemoryArgType.Item => Item,
- _ => string.Empty
- };
- }
+ MemoryArgType.GeneralLocation => Area,
+ MemoryArgType.SpecificLocation when format == 6 => Location,
+ MemoryArgType.Species => Species,
+ MemoryArgType.Move => Move,
+ MemoryArgType.Item => Item,
+ _ => string.Empty
+ };
}
}
}
\ No newline at end of file
diff --git a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs
index a6914e901..f0bf74051 100644
--- a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs
+++ b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs
@@ -189,15 +189,12 @@ private static NumericUpDown GetNUD(int min, int max, bool hex) => new()
Margin = new Padding(0),
};
- private static ushort[] GetChars(int generation)
+ private static ushort[] GetChars(int generation) => generation switch
{
- return generation switch
- {
- 6 => chars67,
- 7 => chars67,
- _ => Array.Empty()
- };
- }
+ 6 => chars67,
+ 7 => chars67,
+ _ => Array.Empty(), // Undocumented
+ };
private static readonly ushort[] chars67 =
{
diff --git a/PKHeX.WinForms/Subforms/SAV_Encounters.cs b/PKHeX.WinForms/Subforms/SAV_Encounters.cs
index cc45b821a..1db2ef7cc 100644
--- a/PKHeX.WinForms/Subforms/SAV_Encounters.cs
+++ b/PKHeX.WinForms/Subforms/SAV_Encounters.cs
@@ -302,8 +302,7 @@ private void FillPKXBoxes(int start)
for (int i = 0; i < end; i++)
{
var enc = Results[i + begin];
- var form = GetForm(enc);
- PKXBOXES[i].Image = SpriteUtil.GetSprite(enc.Species, form, 0, 0, 0, enc.EggEncounter, false, enc.Generation);
+ PKXBOXES[i].Image = SpriteUtil.GetSprite(enc.Species, enc.Form, 0, 0, 0, enc.EggEncounter, false, enc.Generation);
}
for (int i = end; i < RES_MAX; i++)
PKXBOXES[i].Image = null;
@@ -314,18 +313,6 @@ private void FillPKXBoxes(int start)
PKXBOXES[slotSelected - begin].BackgroundImage = slotColor ?? SpriteUtil.Spriter.View;
}
- private static int GetForm(IEncounterable enc)
- {
- return enc switch
- {
- EncounterSlot s => s.Form,
- EncounterStatic s => s.Form,
- MysteryGift m => m.Form,
- EncounterTrade t => t.Form,
- _ => 0
- };
- }
-
private void Menu_SearchAdvanced_Click(object sender, EventArgs e)
{
// todo
diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
index 5bf64a1d0..0f0e1f4f7 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventFlags.cs
@@ -6,6 +6,7 @@
using System.Windows.Forms;
using PKHeX.Core;
using static PKHeX.Core.MessageStrings;
+using static PKHeX.Core.GameVersion;
namespace PKHeX.WinForms
{
@@ -104,27 +105,24 @@ private string[] GetStringList(string type)
return GameLanguage.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type);
}
- private static string GetResourceSuffix(GameVersion ver)
+ private static string GetResourceSuffix(GameVersion ver) => ver switch
{
- return ver switch
- {
- GameVersion.X or GameVersion.Y or GameVersion.XY => "xy",
- GameVersion.OR or GameVersion.AS or GameVersion.ORAS => "oras",
- GameVersion.SN or GameVersion.MN or GameVersion.SM => "sm",
- GameVersion.US or GameVersion.UM or GameVersion.USUM => "usum",
- GameVersion.D or GameVersion.P or GameVersion.DP => "dp",
- GameVersion.Pt or GameVersion.DPPt => "pt",
- GameVersion.HG or GameVersion.SS or GameVersion.HGSS => "hgss",
- GameVersion.B or GameVersion.W or GameVersion.BW => "bw",
- GameVersion.B2 or GameVersion.W2 or GameVersion.B2W2 => "b2w2",
- GameVersion.R or GameVersion.S or GameVersion.RS => "rs",
- GameVersion.E => "e",
- GameVersion.FR or GameVersion.LG or GameVersion.FRLG => "frlg",
- GameVersion.C => "c",
- GameVersion.GD or GameVersion.SV or GameVersion.GS => "gs",
- _ => throw new ArgumentException(nameof(GameVersion))
- };
- }
+ X or Y or XY => "xy",
+ OR or AS or ORAS => "oras",
+ SN or MN or SM => "sm",
+ US or UM or USUM => "usum",
+ D or P or DP => "dp",
+ Pt or DPPt => "pt",
+ HG or SS or HGSS => "hgss",
+ B or W or BW => "bw",
+ B2 or W2 or B2W2 => "b2w2",
+ R or S or RS => "rs",
+ E => "e",
+ FR or LG or FRLG => "frlg",
+ C => "c",
+ GD or SV or GS => "gs",
+ _ => throw new ArgumentException(nameof(GameVersion))
+ };
private void AddFlagList(string[] list)
{
diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventWork.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventWork.cs
index 6248402ef..53b4fa194 100644
--- a/PKHeX.WinForms/Subforms/Save Editors/SAV_EventWork.cs
+++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_EventWork.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Windows.Forms;
using PKHeX.Core;
+using static PKHeX.Core.GameVersion;
namespace PKHeX.WinForms
{
@@ -245,28 +246,25 @@ private static string[] GetStringList(GameVersion game, string type)
return GameLanguage.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type);
}
- private static string GetGameFilePrefix(GameVersion game)
+ private static string GetGameFilePrefix(GameVersion game) => game switch
{
- return game switch
- {
- GameVersion.SW or GameVersion.SH or GameVersion.SWSH => "swsh",
- GameVersion.GP or GameVersion.GE or GameVersion.GG => "gg",
- GameVersion.X or GameVersion.Y => "xy",
- GameVersion.OR or GameVersion.AS => "oras",
- GameVersion.SN or GameVersion.MN => "sm",
- GameVersion.US or GameVersion.UM => "usum",
- GameVersion.DP => "dp",
- GameVersion.Pt => "pt",
- GameVersion.HGSS => "hgss",
- GameVersion.BW => "bw",
- GameVersion.B2W2 => "b2w2",
- GameVersion.E => "e",
- GameVersion.C => "c",
- GameVersion.R or GameVersion.S or GameVersion.RS => "rs",
- GameVersion.FR or GameVersion.LG or GameVersion.FRLG => "frlg",
- _ => throw new IndexOutOfRangeException(nameof(game))
- };
- }
+ SW or SH or SWSH => "swsh",
+ GP or GE or GG => "gg",
+ X or Y => "xy",
+ OR or AS => "oras",
+ SN or MN => "sm",
+ US or UM => "usum",
+ DP => "dp",
+ Pt => "pt",
+ HGSS => "hgss",
+ BW => "bw",
+ B2W2 => "b2w2",
+ E => "e",
+ C => "c",
+ R or S or RS => "rs",
+ FR or LG or FRLG => "frlg",
+ _ => throw new IndexOutOfRangeException(nameof(game))
+ };
private void DiffSaves()
{
diff --git a/PKHeX.WinForms/Subforms/SettingsEditor.cs b/PKHeX.WinForms/Subforms/SettingsEditor.cs
index 5121e2491..41c01f920 100644
--- a/PKHeX.WinForms/Subforms/SettingsEditor.cs
+++ b/PKHeX.WinForms/Subforms/SettingsEditor.cs
@@ -83,14 +83,11 @@ private static CheckBox GetCheckBox(string name, bool state) => new()
AutoSize = true,
};
- private static object GetValue(IDisposable control)
+ private static object GetValue(IDisposable control) => control switch
{
- return control switch
- {
- CheckBox cb => cb.Checked,
- _ => throw new Exception(nameof(control)),
- };
- }
+ CheckBox cb => cb.Checked,
+ _ => throw new Exception(nameof(control)),
+ };
private void SettingsEditor_KeyDown(object sender, KeyEventArgs e)
{
diff --git a/PKHeX.WinForms/Util/WinFormsUtil.cs b/PKHeX.WinForms/Util/WinFormsUtil.cs
index 3fc227be8..0ff0dbe2a 100644
--- a/PKHeX.WinForms/Util/WinFormsUtil.cs
+++ b/PKHeX.WinForms/Util/WinFormsUtil.cs
@@ -424,19 +424,17 @@ public static bool ExportMGDialog(DataMysteryGift gift, GameVersion origin)
///
/// Format specifier for the
/// Game the format originated from/to
- public static string GetMysterGiftFilter(int format, GameVersion origin)
+ public static string GetMysterGiftFilter(int format, GameVersion origin) => format switch
{
- const string all = "|All Files|*.*";
- return format switch
- {
- 4 => ("Gen4 Mystery Gift|*.pgt;*.pcd;*.wc4" + all),
- 5 => ("Gen5 Mystery Gift|*.pgf" + all),
- 6 => ("Gen6 Mystery Gift|*.wc6;*.wc6full" + all),
- 7 => (GameVersion.GG.Contains(origin)
- ? "Beluga Gift Record|*.wr7" + all
- : "Gen7 Mystery Gift|*.wc7;*.wc7full" + all),
- _ => string.Empty
- };
- }
+ 4 => "Gen4 Mystery Gift|*.pgt;*.pcd;*.wc4" + all,
+ 5 => "Gen5 Mystery Gift|*.pgf" + all,
+ 6 => "Gen6 Mystery Gift|*.wc6;*.wc6full" + all,
+ 7 => GameVersion.GG.Contains(origin)
+ ? "Beluga Gift Record|*.wr7" + all
+ : "Gen7 Mystery Gift|*.wc7;*.wc7full" + all,
+ _ => string.Empty,
+ };
+
+ private const string all = "|All Files|*.*";
}
}