using static PKHeX.Core.EReaderBerryMatch;
namespace PKHeX.Core
{
///
/// Stores details about the Gen3 e-Reader Berry values.
///
public static class EReaderBerrySettings
{
/// e-Reader Berry is Enigma or special berry (from e-Reader data)
public static bool IsEnigma { get; set; } = true;
/// e-Reader Berry Name
private static string Name { get; set; } = string.Empty;
/// e-Reader Berry Name formatted in Title Case
public static string DisplayName => string.Format(LegalityCheckStrings.L_XEnigmaBerry_0, Util.ToTitleCase(Name));
private static int Language { get; set; }
public static EReaderBerryMatch GetStatus()
{
if (IsEnigma) // no e-Reader Berry data provided, can't hold berry.
return NoData;
var matchUSA = Legal.EReaderBerriesNames_USA.Contains(Name);
if (matchUSA)
{
if (Language <= 0)
return ValidAny;
if (Language != 1)
return ValidUSA;
return InvalidUSA;
}
var matchJP = Legal.EReaderBerriesNames_JP.Contains(Name);
if (matchJP)
{
if (Language <= 0)
return ValidAny;
if (Language == 1)
return ValidJPN;
return InvalidJPN;
}
return NoMatch;
}
public static void LoadFrom(SAV3 sav3)
{
IsEnigma = sav3.IsEBerryIsEnigma;
Name = sav3.EBerryName;
Language = sav3.Japanese ? (int)LanguageID.Japanese : (int)LanguageID.English;
}
}
///
/// For use in validating the current e-Reader Berry settings.
///
public enum EReaderBerryMatch : byte
{
/// Invalid: Doesn't match either language
NoMatch,
/// Invalid: No data provided from a save file
NoData,
/// Invalid: USA berry name on JPN save file
InvalidUSA,
/// Invalid: JPN berry name on USA save file
InvalidJPN,
/// Valid: Berry name matches either USA/JPN (Ambiguous Save File Language)
ValidAny,
/// Valid: Berry name matches a USA berry name
ValidUSA,
/// Valid: Berry name matches a JPN berry name
ValidJPN,
}
}