Minor tweaks

Move sociability
inline dictionaries
This commit is contained in:
Kurt 2022-04-09 00:08:24 -07:00
parent cc1c3e8d42
commit d3749bd4b6
2 changed files with 17 additions and 27 deletions

View file

@ -59,41 +59,31 @@ namespace PKHeX.Core
/// </summary> /// </summary>
/// <param name="value">GameCube (C/XD) language ID.</param> /// <param name="value">GameCube (C/XD) language ID.</param>
/// <returns>Main Series language ID.</returns> /// <returns>Main Series language ID.</returns>
public static byte GetMainLangIDfromGC(byte value) /// <remarks>If no conversion is possible or maps to the same value, the input <see cref="value"/> is returned.</remarks>
public static byte GetMainLangIDfromGC(byte value) => (LanguageGC)value switch
{ {
if (value is <= 2 or > 7) LanguageGC.German => (byte)German,
return value; LanguageGC.French => (byte)French,
return (byte) GCtoMainSeries[(LanguageGC)value]; LanguageGC.Italian => (byte)Italian,
} LanguageGC.Spanish => (byte)Spanish,
LanguageGC.UNUSED_6 => (byte)UNUSED_6,
_ => value,
};
/// <summary> /// <summary>
/// Gets the GameCube (C/XD) language ID from a Main Series language ID. /// Gets the GameCube (C/XD) language ID from a Main Series language ID.
/// </summary> /// </summary>
/// <param name="value">Main Series language ID.</param> /// <param name="value">Main Series language ID.</param>
/// <returns>GameCube (C/XD) language ID.</returns> /// <returns>GameCube (C/XD) language ID.</returns>
public static byte GetGCLangIDfromMain(byte value) /// <remarks>If no conversion is possible or maps to the same value, the input <see cref="value"/> is returned.</remarks>
public static byte GetGCLangIDfromMain(byte value) => (LanguageID)value switch
{ {
if (value is <= 2 or > 7) French => (byte)LanguageGC.French,
return value; Italian => (byte)LanguageGC.Italian,
return (byte) MainSeriesToGC[(LanguageID)value]; German => (byte)LanguageGC.German,
} UNUSED_6 => (byte)LanguageGC.UNUSED_6,
Spanish => (byte)LanguageGC.Spanish,
private static readonly Dictionary<LanguageID, LanguageGC> MainSeriesToGC = new() _ => value,
{
{German, LanguageGC.German},
{French, LanguageGC.French},
{Italian, LanguageGC.Italian},
{Spanish, LanguageGC.Spanish},
{UNUSED_6, LanguageGC.UNUSED_6},
};
private static readonly Dictionary<LanguageGC, LanguageID> GCtoMainSeries = new()
{
{LanguageGC.German, German},
{LanguageGC.French, French},
{LanguageGC.Italian, Italian},
{LanguageGC.Spanish, Spanish},
{LanguageGC.UNUSED_6, UNUSED_6},
}; };
} }
} }