mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Relocate gen3 ereader berry logic
This commit is contained in:
parent
acd97c6287
commit
e4092e64df
5 changed files with 97 additions and 38 deletions
|
@ -390,11 +390,11 @@ namespace PKHeX.Core
|
||||||
case GameVersion.XD:
|
case GameVersion.XD:
|
||||||
return g3xditems;
|
return g3xditems;
|
||||||
default:
|
default:
|
||||||
if (Legal.EReaderBerryIsEnigma)
|
if (EReaderBerrySettings.IsEnigma)
|
||||||
return g3items;
|
return g3items;
|
||||||
|
|
||||||
var g3ItemsWithEBerry = (string[])g3items.Clone();
|
var g3ItemsWithEBerry = (string[])g3items.Clone();
|
||||||
g3ItemsWithEBerry[175] = Legal.EReaderBerryDisplayName;
|
g3ItemsWithEBerry[175] = EReaderBerrySettings.DisplayName;
|
||||||
return g3ItemsWithEBerry;
|
return g3ItemsWithEBerry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,6 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
public static partial class Legal
|
public static partial class Legal
|
||||||
{
|
{
|
||||||
/// <summary> e-Reader Berry is Enigma or special berry </summary>
|
|
||||||
public static bool EReaderBerryIsEnigma { get; set; } = true;
|
|
||||||
|
|
||||||
/// <summary> e-Reader Berry Name </summary>
|
|
||||||
public static string EReaderBerryName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
/// <summary> e-Reader Berry Name formatted in Title Case </summary>
|
|
||||||
public static string EReaderBerryDisplayName => string.Format(LegalityCheckStrings.L_XEnigmaBerry_0, Util.ToTitleCase(EReaderBerryName.ToLower()));
|
|
||||||
|
|
||||||
// Gen 1
|
// Gen 1
|
||||||
internal static readonly Learnset[] LevelUpRB = LearnsetReader.GetArray(Util.GetBinaryResource("lvlmove_rb.pkl"), MaxSpeciesID_1);
|
internal static readonly Learnset[] LevelUpRB = LearnsetReader.GetArray(Util.GetBinaryResource("lvlmove_rb.pkl"), MaxSpeciesID_1);
|
||||||
internal static readonly Learnset[] LevelUpY = LearnsetReader.GetArray(Util.GetBinaryResource("lvlmove_y.pkl"), MaxSpeciesID_1);
|
internal static readonly Learnset[] LevelUpY = LearnsetReader.GetArray(Util.GetBinaryResource("lvlmove_y.pkl"), MaxSpeciesID_1);
|
||||||
|
@ -220,7 +211,7 @@ namespace PKHeX.Core
|
||||||
return pkm.AltForm == 1;
|
return pkm.AltForm == 1;
|
||||||
if (pkm.Species == (int)Species.Lycanroc)
|
if (pkm.Species == (int)Species.Lycanroc)
|
||||||
return pkm.AltForm < 3;
|
return pkm.AltForm < 3;
|
||||||
return pkm.Species == 773;
|
return pkm.Species == (int)Species.Silvally;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsEvolutionValid(PKM pkm, int minSpecies = -1, int minLevel = -1)
|
internal static bool IsEvolutionValid(PKM pkm, int minSpecies = -1, int minLevel = -1)
|
||||||
|
|
|
@ -24,29 +24,22 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
private void VerifyEReaderBerry(LegalityAnalysis data)
|
private void VerifyEReaderBerry(LegalityAnalysis data)
|
||||||
{
|
{
|
||||||
if (Legal.EReaderBerryIsEnigma) // no E-Reader berry data provided, can't hold berry.
|
var status = EReaderBerrySettings.GetStatus();
|
||||||
|
var chk = GetEReaderCheckResult(status);
|
||||||
|
if (chk != null)
|
||||||
|
data.AddLine(chk);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CheckResult? GetEReaderCheckResult(EReaderBerryMatch status)
|
||||||
|
{
|
||||||
|
return status switch
|
||||||
{
|
{
|
||||||
data.AddLine(GetInvalid(LItemUnreleased));
|
EReaderBerryMatch.NoMatch => GetInvalid(LEReaderInvalid),
|
||||||
return;
|
EReaderBerryMatch.NoData => GetInvalid(LItemUnreleased),
|
||||||
}
|
EReaderBerryMatch.InvalidUSA => GetInvalid(LEReaderAmerica),
|
||||||
|
EReaderBerryMatch.InvalidJPN => GetInvalid(LEReaderJapan),
|
||||||
var matchUSA = Legal.EReaderBerriesNames_USA.Contains(Legal.EReaderBerryName);
|
_ => null
|
||||||
var matchJP = Legal.EReaderBerriesNames_JP.Contains(Legal.EReaderBerryName);
|
};
|
||||||
if (!matchJP && !matchUSA) // Does not match any released E-Reader berry
|
|
||||||
{
|
|
||||||
data.AddLine(GetInvalid(LEReaderInvalid));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ParseSettings.ActiveTrainer.Language <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool jp = ParseSettings.ActiveTrainer.Language == 1;
|
|
||||||
if (matchJP == jp)
|
|
||||||
return; // matches
|
|
||||||
|
|
||||||
// E-Reader is region locked
|
|
||||||
var msg = matchUSA ? LEReaderAmerica : LEReaderJapan;
|
|
||||||
data.AddLine(GetInvalid(msg));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
78
PKHeX.Core/Saves/Substructures/Gen3/EReaderBerrySettings.cs
Normal file
78
PKHeX.Core/Saves/Substructures/Gen3/EReaderBerrySettings.cs
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
using static PKHeX.Core.EReaderBerryMatch;
|
||||||
|
|
||||||
|
namespace PKHeX.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stores details about the Gen3 e-Reader Berry values.
|
||||||
|
/// </summary>
|
||||||
|
public static class EReaderBerrySettings
|
||||||
|
{
|
||||||
|
/// <summary> e-Reader Berry is Enigma or special berry (from e-Reader data)</summary>
|
||||||
|
public static bool IsEnigma { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary> e-Reader Berry Name </summary>
|
||||||
|
private static string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary> e-Reader Berry Name formatted in Title Case </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For use in validating the current e-Reader Berry settings.
|
||||||
|
/// </summary>
|
||||||
|
public enum EReaderBerryMatch : byte
|
||||||
|
{
|
||||||
|
/// <summary> Invalid: Doesn't match either language </summary>
|
||||||
|
NoMatch,
|
||||||
|
/// <summary> Invalid: No data provided from a save file </summary>
|
||||||
|
NoData,
|
||||||
|
/// <summary> Invalid: USA berry name on JPN save file </summary>
|
||||||
|
InvalidUSA,
|
||||||
|
/// <summary> Invalid: JPN berry name on USA save file</summary>
|
||||||
|
InvalidJPN,
|
||||||
|
|
||||||
|
/// <summary> Valid: Berry name matches either USA/JPN (Ambiguous Save File Language) </summary>
|
||||||
|
ValidAny,
|
||||||
|
/// <summary> Valid: Berry name matches a USA berry name </summary>
|
||||||
|
ValidUSA,
|
||||||
|
/// <summary> Valid: Berry name matches a JPN berry name </summary>
|
||||||
|
ValidJPN,
|
||||||
|
}
|
||||||
|
}
|
|
@ -707,10 +707,7 @@ namespace PKHeX.WinForms
|
||||||
private static void StoreLegalSaveGameData(SaveFile sav)
|
private static void StoreLegalSaveGameData(SaveFile sav)
|
||||||
{
|
{
|
||||||
if (sav is SAV3 sav3)
|
if (sav is SAV3 sav3)
|
||||||
{
|
EReaderBerrySettings.LoadFrom(sav3);
|
||||||
Legal.EReaderBerryIsEnigma = sav3.IsEBerryIsEnigma;
|
|
||||||
Legal.EReaderBerryName = sav3.EBerryName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OpenSAV(SaveFile sav, string path)
|
private bool OpenSAV(SaveFile sav, string path)
|
||||||
|
|
Loading…
Reference in a new issue