mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Use more expression return style
Reduces indentation & bracketing, a bit more concise
This commit is contained in:
parent
1d22b74970
commit
09089da14e
94 changed files with 1249 additions and 1753 deletions
|
@ -75,15 +75,12 @@ namespace PKHeX.Core
|
|||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,20 +279,16 @@ namespace PKHeX.Core
|
|||
/// <param name="pk">Pokémon to modify.</param>
|
||||
/// <param name="index">Index to set to</param>
|
||||
/// <param name="value">Value to set</param>
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Sets one of the <see cref="PKM.IVs"/> based on its index within the array.
|
||||
|
@ -300,20 +296,16 @@ namespace PKHeX.Core
|
|||
/// <param name="pk">Pokémon to modify.</param>
|
||||
/// <param name="index">Index to set to</param>
|
||||
/// <param name="value">Value to set</param>
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the highest value the provided <see cref="PKM.EVs"/> index can be while considering others.
|
||||
|
|
|
@ -43,21 +43,18 @@ namespace PKHeX.Core
|
|||
|
||||
private static readonly List<SlotInfoMisc> None = new();
|
||||
|
||||
private static List<SlotInfoMisc> GetExtraSlotsUnsafe(SaveFile sav, bool all)
|
||||
private static List<SlotInfoMisc> 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<SlotInfoMisc> GetExtraSlots2(SAV2 sav)
|
||||
{
|
||||
|
|
|
@ -51,14 +51,11 @@ namespace PKHeX.Core
|
|||
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
|
||||
{
|
||||
|
|
|
@ -23,37 +23,31 @@
|
|||
/// </summary>
|
||||
/// <param name="gbaVersion">Version ID while present in the main-series games</param>
|
||||
/// <returns>Version ID while present in the GameCube games</returns>
|
||||
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,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Translates a <see cref="GCVersion"/> to the corresponding main-series <see cref="GameVersion"/> value.
|
||||
/// </summary>
|
||||
/// <param name="gcVersion">Version ID while present in the GameCube games</param>
|
||||
/// <returns>Version ID while present in the main-series games</returns>
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -487,96 +487,69 @@ namespace PKHeX.Core
|
|||
/// <param name="bankID">BankID used to choose the text bank.</param>
|
||||
/// <param name="version">Version of origin</param>
|
||||
/// <returns>List of location names.</returns>
|
||||
public IReadOnlyList<string> GetLocationNames(int gen, int bankID, GameVersion version)
|
||||
public IReadOnlyList<string> 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<string>();
|
||||
}
|
||||
}
|
||||
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<string>()
|
||||
};
|
||||
|
||||
private IReadOnlyList<string> GetLocationNames4(int bankID)
|
||||
private IReadOnlyList<string> GetLocationNames4(int bankID) => bankID switch
|
||||
{
|
||||
return bankID switch
|
||||
{
|
||||
0 => metHGSS_00000,
|
||||
2 => metHGSS_02000,
|
||||
3 => metHGSS_03000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
0 => metHGSS_00000,
|
||||
2 => metHGSS_02000,
|
||||
3 => metHGSS_03000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> GetLocationNames5(int bankID)
|
||||
public IReadOnlyList<string> GetLocationNames5(int bankID) => bankID switch
|
||||
{
|
||||
return bankID switch
|
||||
{
|
||||
0 => metBW2_00000,
|
||||
3 => metBW2_30000,
|
||||
4 => metBW2_40000,
|
||||
6 => metBW2_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
0 => metBW2_00000,
|
||||
3 => metBW2_30000,
|
||||
4 => metBW2_40000,
|
||||
6 => metBW2_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> GetLocationNames6(int bankID)
|
||||
public IReadOnlyList<string> GetLocationNames6(int bankID) => bankID switch
|
||||
{
|
||||
return bankID switch
|
||||
{
|
||||
0 => metXY_00000,
|
||||
3 => metXY_30000,
|
||||
4 => metXY_40000,
|
||||
6 => metXY_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
0 => metXY_00000,
|
||||
3 => metXY_30000,
|
||||
4 => metXY_40000,
|
||||
6 => metXY_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> GetLocationNames7(int bankID)
|
||||
public IReadOnlyList<string> GetLocationNames7(int bankID) => bankID switch
|
||||
{
|
||||
return bankID switch
|
||||
{
|
||||
0 => metSM_00000,
|
||||
3 => metSM_30000,
|
||||
4 => metSM_40000,
|
||||
6 => metSM_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
0 => metSM_00000,
|
||||
3 => metSM_30000,
|
||||
4 => metSM_40000,
|
||||
6 => metSM_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> GetLocationNames7GG(int bankID)
|
||||
public IReadOnlyList<string> GetLocationNames7GG(int bankID) => bankID switch
|
||||
{
|
||||
return bankID switch
|
||||
{
|
||||
0 => metGG_00000,
|
||||
3 => metGG_30000,
|
||||
4 => metGG_40000,
|
||||
6 => metGG_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
0 => metGG_00000,
|
||||
3 => metGG_30000,
|
||||
4 => metGG_40000,
|
||||
6 => metGG_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
|
||||
public IReadOnlyList<string> GetLocationNames8(int bankID)
|
||||
public IReadOnlyList<string> GetLocationNames8(int bankID) => bankID switch
|
||||
{
|
||||
return bankID switch
|
||||
{
|
||||
0 => metSWSH_00000,
|
||||
3 => metSWSH_30000,
|
||||
4 => metSWSH_40000,
|
||||
6 => metSWSH_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
0 => metSWSH_00000,
|
||||
3 => metSWSH_30000,
|
||||
4 => metSWSH_40000,
|
||||
6 => metSWSH_60000,
|
||||
_ => Array.Empty<string>()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,17 +58,14 @@ namespace PKHeX.Core
|
|||
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<ComboItem> GetArgumentStrings(MemoryArgType memIndex)
|
||||
public List<ComboItem> 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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,69 +30,63 @@ namespace PKHeX.Core
|
|||
/// <summary>Determines the Version Grouping of an input Version ID</summary>
|
||||
/// <param name="version">Version of which to determine the group</param>
|
||||
/// <returns>Version Group Identifier or Invalid if type cannot be determined.</returns>
|
||||
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,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Version ID from the end of that Generation
|
||||
/// </summary>
|
||||
/// <param name="generation">Generation ID</param>
|
||||
/// <returns>Version ID from requested generation. If none, return <see cref="Invalid"/>.</returns>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Generation the <see cref="GameVersion"/> belongs to.
|
||||
|
|
|
@ -76,15 +76,12 @@ namespace PKHeX.Core
|
|||
(int)Chimecho,
|
||||
};
|
||||
|
||||
internal static ICollection<int> GetSplitBreedGeneration(int generation)
|
||||
internal static ICollection<int> GetSplitBreedGeneration(int generation) => generation switch
|
||||
{
|
||||
return generation switch
|
||||
{
|
||||
3 => SplitBreed_3,
|
||||
4 or 5 or 6 or 7 or 8 => SplitBreed,
|
||||
_ => Array.Empty<int>(),
|
||||
};
|
||||
}
|
||||
3 => SplitBreed_3,
|
||||
4 or 5 or 6 or 7 or 8 => SplitBreed,
|
||||
_ => Array.Empty<int>(),
|
||||
};
|
||||
|
||||
public static bool NoHatchFromEggForm(int species, int form, int generation)
|
||||
{
|
||||
|
|
|
@ -60,37 +60,31 @@ namespace PKHeX.Core
|
|||
return lgpe ? MovePP_GG : MovePP_SM;
|
||||
}
|
||||
|
||||
public static IReadOnlyList<byte> GetPPTable(int format)
|
||||
public static IReadOnlyList<byte> 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<byte>()
|
||||
};
|
||||
}
|
||||
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<byte>()
|
||||
};
|
||||
|
||||
internal static ICollection<int> GetWildBalls(int gen, GameVersion game)
|
||||
internal static ICollection<int> 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<int>()
|
||||
};
|
||||
}
|
||||
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<int>()
|
||||
};
|
||||
|
||||
internal static int GetMaxSpeciesOrigin(PKM pkm)
|
||||
{
|
||||
|
@ -101,71 +95,54 @@ namespace PKHeX.Core
|
|||
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<int> GetFutureGenEvolutions(int generation)
|
||||
internal static ICollection<int> GetFutureGenEvolutions(int generation) => generation switch
|
||||
{
|
||||
return generation switch
|
||||
{
|
||||
1 => FutureEvolutionsGen1,
|
||||
2 => FutureEvolutionsGen2,
|
||||
3 => FutureEvolutionsGen3,
|
||||
4 => FutureEvolutionsGen4,
|
||||
5 => FutureEvolutionsGen5,
|
||||
_ => Array.Empty<int>()
|
||||
};
|
||||
}
|
||||
1 => FutureEvolutionsGen1,
|
||||
2 => FutureEvolutionsGen2,
|
||||
3 => FutureEvolutionsGen3,
|
||||
4 => FutureEvolutionsGen4,
|
||||
5 => FutureEvolutionsGen5,
|
||||
_ => Array.Empty<int>()
|
||||
};
|
||||
|
||||
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 @@ namespace PKHeX.Core
|
|||
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<int> IVs, PKM pkm, int max = 31)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.EncounterType;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -15,7 +16,7 @@ namespace PKHeX.Core
|
|||
public bool Roaming { get; init; }
|
||||
|
||||
/// <summary> <see cref="PK4.EncounterType"/> values permitted for the encounter. </summary>
|
||||
public EncounterType TypeEncounter { get; init; } = EncounterType.None;
|
||||
public EncounterType TypeEncounter { get; init; } = None;
|
||||
|
||||
protected override bool IsMatchLocation(PKM pkm)
|
||||
{
|
||||
|
@ -100,16 +101,13 @@ namespace PKHeX.Core
|
|||
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 =
|
||||
{
|
||||
|
|
|
@ -61,21 +61,18 @@ namespace PKHeX.Core
|
|||
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);
|
||||
|
||||
|
|
|
@ -24,18 +24,15 @@ namespace PKHeX.Core
|
|||
/// <remarks>
|
||||
/// The iterator lazily finds possible encounters. If no encounters are possible, the enumerable will be empty.
|
||||
/// </remarks>
|
||||
public static IEnumerable<IEncounterable> GetEncounters(PKM pkm, LegalInfo info)
|
||||
public static IEnumerable<IEncounterable> 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<IEncounterable> GetEncounters3(PKM pkm, LegalInfo info)
|
||||
{
|
||||
|
|
|
@ -144,18 +144,15 @@ namespace PKHeX.Core
|
|||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Generation 1/2 Encounter Data type, which serves as a 'best match' priority rating when returning from a list.
|
||||
|
|
|
@ -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 @@ namespace PKHeX.Core
|
|||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
private static IEnumerable<EncounterArea> GetEncounterTable(PKM pkm, GameVersion gameSource = GameVersion.Any)
|
||||
private static IEnumerable<EncounterArea> 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<EncounterArea>()
|
||||
};
|
||||
}
|
||||
GO => GetEncounterTableGO(pkm),
|
||||
SW => SlotsSW,
|
||||
SH => SlotsSH,
|
||||
_ => Array.Empty<EncounterArea>()
|
||||
};
|
||||
|
||||
private static IEnumerable<EncounterArea> GetEncounterTableGSC(PKM pkm)
|
||||
{
|
||||
|
|
|
@ -129,52 +129,46 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
// Generation Specific Fetching
|
||||
private static IEnumerable<EncounterStatic> GetEncounterStaticTable(PKM pkm, GameVersion gameSource = Any)
|
||||
private static IEnumerable<EncounterStatic> 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<EncounterStatic>(),
|
||||
};
|
||||
}
|
||||
SW => StaticSW,
|
||||
SH => StaticSH,
|
||||
_ => Array.Empty<EncounterStatic>(),
|
||||
};
|
||||
|
||||
private static IEnumerable<EncounterStatic> GetEncounterStaticTableGSC(PKM pkm)
|
||||
{
|
||||
|
|
|
@ -74,19 +74,16 @@ namespace PKHeX.Core
|
|||
return Array.Empty<EncounterTradeGB>();
|
||||
}
|
||||
|
||||
private static IEnumerable<EncounterTrade> GetEncounterTradeTable(PKM pkm)
|
||||
private static IEnumerable<EncounterTrade> 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<EncounterTrade>(),
|
||||
};
|
||||
}
|
||||
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<EncounterTrade>(),
|
||||
};
|
||||
|
||||
private static IEnumerable<EncounterTradeGB> GetValidEncounterTradesVC(PKM pkm, IReadOnlyList<DexLevel> chain, GameVersion gameSource)
|
||||
{
|
||||
|
|
|
@ -32,19 +32,16 @@ namespace PKHeX.Core
|
|||
return GetMatchingGifts(pkm, table, chain);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<MysteryGift> GetTable(int generation, PKM pkm)
|
||||
private static IReadOnlyList<MysteryGift> 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<MysteryGift>)MGDB_G7GG : MGDB_G7,
|
||||
8 => MGDB_G8,
|
||||
_ => Array.Empty<MysteryGift>()
|
||||
};
|
||||
}
|
||||
3 => MGDB_G3,
|
||||
4 => MGDB_G4,
|
||||
5 => MGDB_G5,
|
||||
6 => MGDB_G6,
|
||||
7 => pkm.LGPE ? MGDB_G7GG : MGDB_G7,
|
||||
8 => MGDB_G8,
|
||||
_ => Array.Empty<MysteryGift>()
|
||||
};
|
||||
|
||||
private static IEnumerable<MysteryGift> GetMatchingPCD(PKM pkm, IReadOnlyList<PCD> DB, IReadOnlyList<DexLevel> chain)
|
||||
{
|
||||
|
|
|
@ -53,16 +53,13 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
/// Gets a valid Egg hatch location for the origin game.
|
||||
/// </summary>
|
||||
/// <param name="pkm">Pokémon data to suggest for</param>
|
||||
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,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the correct Transfer Met location for the origin game.
|
||||
|
|
|
@ -12,27 +12,21 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="pkm">Source data to verify</param>
|
||||
/// <returns>Returns the verification method appropriate for the input PKM</returns>
|
||||
public static Func<PKM, LegalInfo, CheckResult> GetEncounterVerifierMethod(PKM pkm)
|
||||
public static Func<PKM, LegalInfo, CheckResult> 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)
|
||||
{
|
||||
|
|
|
@ -38,16 +38,13 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="s"><see cref="Severity"/> value to convert to string.</param>
|
||||
/// <returns>Localized <see cref="string"/>.</returns>
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,31 +80,25 @@ namespace PKHeX.Core
|
|||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,35 +34,29 @@ namespace PKHeX.Core
|
|||
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<EvolutionMethod[]> Entries;
|
||||
private readonly GameVersion Game;
|
||||
|
@ -78,7 +72,7 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<EvolutionMethod[]> GetEntries(IReadOnlyList<byte[]> data)
|
||||
private IReadOnlyList<EvolutionMethod[]> GetEntries(IReadOnlyList<byte[]> 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()
|
||||
{
|
||||
|
|
|
@ -21,25 +21,22 @@ namespace PKHeX.Core
|
|||
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<int>(),
|
||||
};
|
||||
}
|
||||
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<int>(),
|
||||
};
|
||||
|
||||
private static int[] GetFormEggMoves(int species, int form, IReadOnlyList<EggMoves7> table)
|
||||
{
|
||||
|
|
|
@ -228,17 +228,14 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -86,16 +86,15 @@ namespace PKHeX.Core
|
|||
/// <param name="ratio">Gender Ratio</param>
|
||||
/// <param name="max">Return Max (or Min)</param>
|
||||
/// <returns>Returns the maximum or minimum gender value that corresponds to the input gender ratio.</returns>
|
||||
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,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,16 +15,13 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -804,16 +804,13 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -275,15 +275,12 @@ namespace PKHeX.Core
|
|||
|
||||
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))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,15 +25,12 @@ namespace PKHeX.Core
|
|||
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};
|
||||
|
||||
|
|
|
@ -209,23 +209,20 @@ namespace PKHeX
|
|||
return IsMoveCountRequired3(species, pk.CurrentLevel, moves) ? 3 : 0; // no match
|
||||
}
|
||||
|
||||
private static bool IsMoveCountRequired3(int species, int level, IReadOnlyList<int> moves)
|
||||
private static bool IsMoveCountRequired3(int species, int level, IReadOnlyList<int> 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<int> moves, IReadOnlyList<int>[] learn, IReadOnlyList<int> initialmoves)
|
||||
{
|
||||
|
|
|
@ -32,26 +32,20 @@ namespace PKHeX.Core
|
|||
{
|
||||
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<bool> GetReleasedHeldItems(int generation)
|
||||
private static IReadOnlyList<bool> 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<bool>()
|
||||
};
|
||||
}
|
||||
2 => ReleasedHeldItems_2,
|
||||
3 => ReleasedHeldItems_3,
|
||||
4 => ReleasedHeldItems_4,
|
||||
5 => ReleasedHeldItems_5,
|
||||
6 => ReleasedHeldItems_6,
|
||||
7 => ReleasedHeldItems_7,
|
||||
8 => ReleasedHeldItems_8,
|
||||
_ => Array.Empty<bool>()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,19 +13,16 @@ namespace PKHeX.Core
|
|||
/// <param name="consoleRegion">Console region.</param>
|
||||
/// <param name="country">Country of nationality</param>
|
||||
/// <returns>Country is within Console Region</returns>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Compares the <see cref="IRegionOrigin.ConsoleRegion"/> and language ID to determine if the language is available within that region.
|
||||
|
|
|
@ -218,15 +218,12 @@ namespace PKHeX.Core
|
|||
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
|
||||
|
|
|
@ -38,16 +38,13 @@
|
|||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,16 +44,13 @@ namespace PKHeX.Core
|
|||
/// <param name="form">Entity form</param>
|
||||
/// <param name="format">Current generation format</param>
|
||||
/// <returns>Suggested alt form value.</returns>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="form"/> is a fused form, which indicates it cannot be traded away.
|
||||
|
@ -62,16 +59,13 @@ namespace PKHeX.Core
|
|||
/// <param name="form">Entity form</param>
|
||||
/// <param name="format">Current generation format</param>
|
||||
/// <returns>True if it is a fused species-form, false if it is not fused.</returns>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>Checks if the form may be different than the original encounter detail.</summary>
|
||||
/// <param name="species">Original species</param>
|
||||
|
@ -246,19 +240,16 @@ namespace PKHeX.Core
|
|||
/// <param name="form">Entity form</param>
|
||||
/// <param name="format">Current generation format</param>
|
||||
/// <seealso cref="HasFormValuesNotIndicatedByPersonal"/>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PKM"/> data should have a drop-down selection visible for the <see cref="PKM.Form"/> value.
|
||||
|
|
|
@ -90,28 +90,22 @@
|
|||
|
||||
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;
|
||||
|
|
|
@ -424,14 +424,11 @@ namespace PKHeX.Core
|
|||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,16 +100,13 @@ namespace PKHeX.Core
|
|||
};
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -18,19 +18,15 @@
|
|||
// 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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,17 +36,17 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
{
|
||||
// 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);
|
||||
}
|
||||
|
|
|
@ -74,16 +74,15 @@ namespace PKHeX.Core
|
|||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,34 +172,26 @@ namespace PKHeX.Core
|
|||
// 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(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,16 +30,13 @@ namespace PKHeX.Core
|
|||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,37 +63,22 @@ namespace PKHeX.Core
|
|||
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);
|
||||
|
|
|
@ -60,48 +60,42 @@ namespace PKHeX.Core
|
|||
/// <param name="ext">Extension of the file from which the <paramref name="data"/> was retrieved.</param>
|
||||
/// <returns>An instance of <see cref="MysteryGift"/> representing the given data, or null if <paramref name="data"/> or <paramref name="ext"/> is invalid.</returns>
|
||||
/// <remarks>This overload differs from <see cref="GetMysteryGift(byte[])"/> by checking the <paramref name="data"/>/<paramref name="ext"/> combo for validity. If either is invalid, a null reference is returned.</remarks>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converts the given data to a <see cref="MysteryGift"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">Raw data of the mystery gift.</param>
|
||||
/// <returns>An instance of <see cref="MysteryGift"/> representing the given data, or null if <paramref name="data"/> is invalid.</returns>
|
||||
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}";
|
||||
|
|
|
@ -280,15 +280,12 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -397,15 +397,12 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -174,15 +174,12 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
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}")
|
||||
};
|
||||
}
|
||||
|
|
|
@ -408,15 +408,12 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -439,15 +439,12 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -168,21 +168,15 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -393,15 +393,12 @@ namespace PKHeX.Core
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -1065,38 +1065,23 @@ namespace PKHeX.Core
|
|||
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Clears moves that a <see cref="PKM"/> may have, possibly from a future generation.
|
||||
|
@ -1129,36 +1114,30 @@ namespace PKHeX.Core
|
|||
/// Gets one of the <see cref="EVs"/> based on its index within the array.
|
||||
/// </summary>
|
||||
/// <param name="index">Index to get</param>
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets one of the <see cref="IVs"/> based on its index within the array.
|
||||
/// </summary>
|
||||
/// <param name="index">Index to get</param>
|
||||
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))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,12 @@ namespace PKHeX.Core.Searching
|
|||
return res;
|
||||
}
|
||||
|
||||
public static IEnumerable<PKM> FilterByGeneration(IEnumerable<PKM> res, int generation)
|
||||
public static IEnumerable<PKM> FilterByGeneration(IEnumerable<PKM> 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<PKM> FilterByLevel(IEnumerable<PKM> res, SearchComparison option, int level)
|
||||
{
|
||||
|
@ -56,31 +53,25 @@ namespace PKHeX.Core.Searching
|
|||
};
|
||||
}
|
||||
|
||||
public static IEnumerable<PKM> FilterByEVs(IEnumerable<PKM> res, int option)
|
||||
public static IEnumerable<PKM> FilterByEVs(IEnumerable<PKM> 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<PKM> FilterByIVs(IEnumerable<PKM> res, int option)
|
||||
public static IEnumerable<PKM> FilterByIVs(IEnumerable<PKM> 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<PKM> FilterByMoves(IEnumerable<PKM> res, IEnumerable<int> requiredMoves)
|
||||
{
|
||||
|
@ -103,34 +94,25 @@ namespace PKHeX.Core.Searching
|
|||
return res.Where(pkm => BatchEditing.IsFilterMatch(filters, pkm)); // Compare across all filters
|
||||
}
|
||||
|
||||
public static Func<PKM, string> GetCloneDetectMethod(CloneDetectionMethod method)
|
||||
public static Func<PKM, string> 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<PKM> GetClones(IEnumerable<PKM> res, CloneDetectionMethod type = CloneDetectionMethod.HashDetails)
|
||||
{
|
||||
|
|
|
@ -80,39 +80,32 @@ namespace PKHeX.Core
|
|||
/// <param name="pk">Pokémon to modify.</param>
|
||||
/// <param name="index">Index to set to</param>
|
||||
/// <param name="value">Value to set</param>
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Sets one of the <see cref="IAwakened"/> values based on its index within the array.
|
||||
/// </summary>
|
||||
/// <param name="pk">Pokémon to check.</param>
|
||||
/// <param name="index">Index to get</param>
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Sets the values based on the current <see cref="PKM.IVs"/>.
|
||||
|
|
|
@ -16,31 +16,24 @@
|
|||
/// </summary>
|
||||
/// <param name="scalar">Sizing scalar (0-255)</param>
|
||||
/// <returns>0-4 rating</returns>
|
||||
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()
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random size scalar with a triangular distribution (copying official implementation).
|
||||
|
|
|
@ -208,15 +208,12 @@ namespace PKHeX.Core
|
|||
/// <param name="item">Item ID</param>
|
||||
/// <param name="generation">Generation the <see cref="item"/> exists in</param>
|
||||
/// <returns>True if is an HM</returns>
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,20 +41,17 @@ namespace PKHeX.Core
|
|||
_ => 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,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Main Series language ID from a GameCube (C/XD) language ID.
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (s.Length != 1)
|
||||
return 2;
|
||||
return (s[0]) switch
|
||||
return s[0] switch
|
||||
{
|
||||
'♂' or 'M' => 0,
|
||||
'♀' or 'F' => 1,
|
||||
|
@ -190,16 +190,13 @@ namespace PKHeX.Core
|
|||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of valid <see cref="PKM"/> file extensions.
|
||||
|
|
|
@ -231,33 +231,30 @@ namespace PKHeX.Core
|
|||
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),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,41 +112,35 @@ namespace PKHeX.Core
|
|||
return new(Util.GetBinaryResource($"personal_{game}"), format);
|
||||
}
|
||||
|
||||
private static Func<byte[], PersonalInfo> GetConstructor(GameVersion format)
|
||||
private static Func<byte[], PersonalInfo> 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
|
||||
{
|
||||
|
|
|
@ -232,28 +232,25 @@ namespace PKHeX.Core
|
|||
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)
|
||||
|
|
|
@ -107,26 +107,23 @@ namespace PKHeX.Core
|
|||
/// Returns an object that wraps the block with a Value property to get/set via a PropertyGrid/etc control.
|
||||
/// </summary>
|
||||
/// <returns>Returns null if no wrapping is supported.</returns>
|
||||
public static object? GetEditableBlockObject(SCBlock block)
|
||||
public static object? GetEditableBlockObject(SCBlock block) => block.Type switch
|
||||
{
|
||||
return block.Type switch
|
||||
{
|
||||
SCTypeCode.Byte => new WrappedValueView<byte>(block, block.GetValue()),
|
||||
SCTypeCode.UInt16 => new WrappedValueView<ushort>(block, block.GetValue()),
|
||||
SCTypeCode.UInt32 => new WrappedValueView<uint>(block, block.GetValue()),
|
||||
SCTypeCode.UInt64 => new WrappedValueView<ulong>(block, block.GetValue()),
|
||||
SCTypeCode.Byte => new WrappedValueView<byte>(block, block.GetValue()),
|
||||
SCTypeCode.UInt16 => new WrappedValueView<ushort>(block, block.GetValue()),
|
||||
SCTypeCode.UInt32 => new WrappedValueView<uint>(block, block.GetValue()),
|
||||
SCTypeCode.UInt64 => new WrappedValueView<ulong>(block, block.GetValue()),
|
||||
|
||||
SCTypeCode.SByte => new WrappedValueView<sbyte>(block, block.GetValue()),
|
||||
SCTypeCode.Int16 => new WrappedValueView<short>(block, block.GetValue()),
|
||||
SCTypeCode.Int32 => new WrappedValueView<int>(block, block.GetValue()),
|
||||
SCTypeCode.Int64 => new WrappedValueView<long>(block, block.GetValue()),
|
||||
SCTypeCode.SByte => new WrappedValueView<sbyte>(block, block.GetValue()),
|
||||
SCTypeCode.Int16 => new WrappedValueView<short>(block, block.GetValue()),
|
||||
SCTypeCode.Int32 => new WrappedValueView<int>(block, block.GetValue()),
|
||||
SCTypeCode.Int64 => new WrappedValueView<long>(block, block.GetValue()),
|
||||
|
||||
SCTypeCode.Single => new WrappedValueView<float>(block, block.GetValue()),
|
||||
SCTypeCode.Double => new WrappedValueView<double>(block, block.GetValue()),
|
||||
SCTypeCode.Single => new WrappedValueView<float>(block, block.GetValue()),
|
||||
SCTypeCode.Double => new WrappedValueView<double>(block, block.GetValue()),
|
||||
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
_ => null,
|
||||
};
|
||||
|
||||
private sealed class WrappedValueView<T> where T : struct
|
||||
{
|
||||
|
|
|
@ -34,49 +34,43 @@ namespace PKHeX.Core
|
|||
{
|
||||
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 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,18 +404,12 @@ namespace PKHeX.Core
|
|||
// 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
|
||||
{
|
||||
|
|
|
@ -90,18 +90,12 @@ namespace PKHeX.Core
|
|||
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);
|
||||
|
|
|
@ -36,18 +36,12 @@ namespace PKHeX.Core
|
|||
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
|
||||
|
|
|
@ -136,18 +136,12 @@ namespace PKHeX.Core
|
|||
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); }
|
||||
|
|
|
@ -109,20 +109,14 @@ namespace PKHeX.Core
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -127,18 +127,12 @@ namespace PKHeX.Core
|
|||
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; }
|
||||
|
|
|
@ -60,18 +60,12 @@ namespace PKHeX.Core
|
|||
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);
|
||||
|
||||
|
|
|
@ -39,16 +39,13 @@ namespace PKHeX.Core
|
|||
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));
|
||||
|
|
|
@ -111,15 +111,12 @@ namespace PKHeX.Core
|
|||
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()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,52 +131,40 @@ namespace PKHeX.Core
|
|||
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))
|
||||
};
|
||||
}
|
||||
}
|
|
@ -37,28 +37,22 @@ namespace PKHeX.Core
|
|||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,25 +72,19 @@ namespace PKHeX.Core
|
|||
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);
|
||||
|
|
|
@ -85,14 +85,11 @@ namespace PKHeX.Core
|
|||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,16 +29,13 @@ namespace PKHeX.Core
|
|||
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);
|
||||
|
|
|
@ -633,47 +633,44 @@ namespace PKHeX.Core
|
|||
/// <param name="game">Version to create the save file for.</param>
|
||||
/// <param name="language">Save file language to initialize for</param>
|
||||
/// <returns>Blank save file from the requested game, null if no game exists for that <see cref="GameVersion"/>.</returns>
|
||||
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)),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of a SaveFile with a blank base.
|
||||
|
@ -785,9 +782,7 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
/// <param name="sav">SaveFile data to force</param>
|
||||
/// <param name="ver">Version to retrieve for</param>
|
||||
/// <returns>New <see cref="SaveFile"/> object.</returns>
|
||||
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))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PersonalTable"/> for a Gen3 save file.
|
||||
/// </summary>
|
||||
/// <param name="ver">Version to retrieve for</param>
|
||||
/// <returns>Reference to the <see cref="PersonalTable"/>.</returns>
|
||||
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))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,25 +16,22 @@ namespace PKHeX.Drawing
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -82,18 +82,15 @@ namespace PKHeX.Drawing
|
|||
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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,16 +48,13 @@ namespace PKHeX.Drawing
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -72,15 +72,12 @@ namespace PKHeX.WinForms
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -536,17 +536,14 @@ namespace PKHeX.WinForms.Controls
|
|||
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 @@ namespace PKHeX.WinForms.Controls
|
|||
form.Dispose();
|
||||
}
|
||||
|
||||
private static Form GetAccessorForm(SaveFile sav)
|
||||
private static Form GetAccessorForm(SaveFile sav) => sav switch
|
||||
{
|
||||
return sav switch
|
||||
{
|
||||
SAV5BW s => new SAV_Accessor<SaveBlockAccessor5BW>(s.Blocks),
|
||||
SAV5B2W2 s => new SAV_Accessor<SaveBlockAccessor5B2W2>(s.Blocks),
|
||||
SAV6XY s => new SAV_Accessor<SaveBlockAccessor6XY>(s.Blocks),
|
||||
SAV6AO s => new SAV_Accessor<SaveBlockAccessor6AO>(s.Blocks),
|
||||
SAV6AODemo s => new SAV_Accessor<SaveBlockAccessor6AODemo>(s.Blocks),
|
||||
SAV7SM s => new SAV_Accessor<SaveBlockAccessor7SM>(s.Blocks),
|
||||
SAV7USUM s => new SAV_Accessor<SaveBlockAccessor7USUM>(s.Blocks),
|
||||
SAV8SWSH s => new SAV_BlockDump8(s),
|
||||
_ => GetPropertyForm(sav),
|
||||
};
|
||||
}
|
||||
SAV5BW s => new SAV_Accessor<SaveBlockAccessor5BW>(s.Blocks),
|
||||
SAV5B2W2 s => new SAV_Accessor<SaveBlockAccessor5B2W2>(s.Blocks),
|
||||
SAV6XY s => new SAV_Accessor<SaveBlockAccessor6XY>(s.Blocks),
|
||||
SAV6AO s => new SAV_Accessor<SaveBlockAccessor6AO>(s.Blocks),
|
||||
SAV6AODemo s => new SAV_Accessor<SaveBlockAccessor6AODemo>(s.Blocks),
|
||||
SAV7SM s => new SAV_Accessor<SaveBlockAccessor7SM>(s.Blocks),
|
||||
SAV7USUM s => new SAV_Accessor<SaveBlockAccessor7USUM>(s.Blocks),
|
||||
SAV8SWSH s => new SAV_BlockDump8(s),
|
||||
_ => GetPropertyForm(sav),
|
||||
};
|
||||
|
||||
private static Form GetPropertyForm(object sav)
|
||||
{
|
||||
|
|
|
@ -14,31 +14,25 @@ namespace PKHeX.WinForms.Controls
|
|||
/// <summary>
|
||||
/// Gets the background image for a slot based on the provided <see cref="type"/>.
|
||||
/// </summary>
|
||||
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)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of action that should be performed for a Drag & Drop request.
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes a <see cref="PictureBox"/> with the appropriate display content.
|
||||
|
|
|
@ -85,14 +85,11 @@ namespace PKHeX.WinForms
|
|||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,18 +372,15 @@ namespace PKHeX.WinForms
|
|||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -189,15 +189,12 @@ namespace PKHeX.WinForms
|
|||
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<ushort>()
|
||||
};
|
||||
}
|
||||
6 => chars67,
|
||||
7 => chars67,
|
||||
_ => Array.Empty<ushort>(), // Undocumented
|
||||
};
|
||||
|
||||
private static readonly ushort[] chars67 =
|
||||
{
|
||||
|
|
|
@ -302,8 +302,7 @@ namespace PKHeX.WinForms
|
|||
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 @@ namespace PKHeX.WinForms
|
|||
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
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Windows.Forms;
|
||||
using PKHeX.Core;
|
||||
using static PKHeX.Core.MessageStrings;
|
||||
using static PKHeX.Core.GameVersion;
|
||||
|
||||
namespace PKHeX.WinForms
|
||||
{
|
||||
|
@ -104,27 +105,24 @@ namespace PKHeX.WinForms
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using PKHeX.Core;
|
||||
using static PKHeX.Core.GameVersion;
|
||||
|
||||
namespace PKHeX.WinForms
|
||||
{
|
||||
|
@ -245,28 +246,25 @@ namespace PKHeX.WinForms
|
|||
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()
|
||||
{
|
||||
|
|
|
@ -83,14 +83,11 @@ namespace PKHeX.WinForms
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -424,19 +424,17 @@ namespace PKHeX.WinForms
|
|||
/// </summary>
|
||||
/// <param name="format">Format specifier for the </param>
|
||||
/// <param name="origin">Game the format originated from/to</param>
|
||||
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|*.*";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue