Add overload for Totem check, simplify some flow

This commit is contained in:
Kurt 2021-04-17 13:24:57 -07:00
parent 5635e8f345
commit f35a3ce03c
4 changed files with 15 additions and 7 deletions

View file

@ -12,6 +12,8 @@ namespace PKHeX.Core
public override int Generation => 7; public override int Generation => 7;
public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>(); public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>();
public bool IsTotem => FormInfo.IsTotemForm(Species, Form);
public EncounterStatic7(GameVersion game) : base(game) { } public EncounterStatic7(GameVersion game) : base(game) { }
protected override bool IsMatchLocation(PKM pkm) protected override bool IsMatchLocation(PKM pkm)
@ -26,7 +28,7 @@ namespace PKHeX.Core
if (SkipFormCheck) if (SkipFormCheck)
return true; return true;
if (FormInfo.IsTotemForm(Species, Form, 7)) if (IsTotem)
{ {
var expectForm = pkm.Format == 7 ? Form : FormInfo.GetTotemBaseForm(Species, Form); var expectForm = pkm.Format == 7 ? Form : FormInfo.GetTotemBaseForm(Species, Form);
return expectForm == evo.Form; return expectForm == evo.Form;

View file

@ -201,15 +201,21 @@ namespace PKHeX.Core
} }
/// <summary> /// <summary>
/// Chhecks if the <see cref="form"/> for the <see cref="species"/> is a Totem form. /// Checks if the <see cref="form"/> for the <see cref="species"/> is a Totem form.
/// </summary> /// </summary>
/// <param name="species">Entity species</param> /// <param name="species">Entity species</param>
/// <param name="form">Entity form</param> /// <param name="form">Entity form</param>
/// <param name="format">Current generation format</param> /// <param name="format">Current generation format</param>
public static bool IsTotemForm(int species, int form, int format) public static bool IsTotemForm(int species, int form, int format) => format == 7 && IsTotemForm(species, form);
/// <summary>
/// Checks if the <see cref="form"/> for the <see cref="species"/> is a Totem form.
/// </summary>
/// <remarks>Use <see cref="IsTotemForm(int,int,int)"/> if you aren't 100% sure the format is 7.</remarks>
/// <param name="species">Entity species</param>
/// <param name="form">Entity form</param>
public static bool IsTotemForm(int species, int form)
{ {
if (format != 7)
return false;
if (form == 0) if (form == 0)
return false; return false;
if (!Legal.Totem_USUM.Contains(species)) if (!Legal.Totem_USUM.Contains(species))

View file

@ -140,7 +140,7 @@ namespace PKHeX.Core
} }
else if (enc.Generation < 8 && pkm.Format >= 8) else if (enc.Generation < 8 && pkm.Format >= 8)
{ {
if (enc is EncounterStatic7 s && FormInfo.IsTotemForm(s.Species, s.Form, 7)) if (enc is EncounterStatic7 {IsTotem: true} s)
{ {
if (Legal.Totem_NoTransfer.Contains(s.Species)) if (Legal.Totem_NoTransfer.Contains(s.Species))
data.AddLine(GetInvalid(LTransferBad)); data.AddLine(GetInvalid(LTransferBad));

View file

@ -644,7 +644,7 @@ namespace PKHeX.Core
}; };
// Wipe Totem Forms // Wipe Totem Forms
if (FormInfo.IsTotemForm(Species, Form, 7)) if (FormInfo.IsTotemForm(Species, Form))
pk8.Form = FormInfo.GetTotemBaseForm(Species, Form); pk8.Form = FormInfo.GetTotemBaseForm(Species, Form);
// Fix PP and Stats // Fix PP and Stats