2023-09-16 23:53:06 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Logic for determining if a <see cref="IHomeTrack.Tracker"/> value is required for a given encounter.
|
|
|
|
/// </summary>
|
|
|
|
public static class HomeTrackerUtil
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Indicates if a <see cref="IHomeTrack.Tracker"/> value is required for the given encounter.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="enc">Encounter source</param>
|
|
|
|
/// <param name="pk">Entity to check</param>
|
|
|
|
/// <returns>True if the encounter must have a <see cref="IHomeTrack.Tracker"/> value</returns>
|
2023-09-26 16:32:49 +00:00
|
|
|
public static bool IsRequired(IEncounterTemplate enc, PKM pk) => IsRequired(enc, pk.Context);
|
2023-09-16 23:53:06 +00:00
|
|
|
|
2023-09-26 16:32:49 +00:00
|
|
|
/// <inheritdoc cref="IsRequired(IEncounterTemplate,PKM)"/>
|
|
|
|
public static bool IsRequired(IEncounterTemplate enc, EntityContext current)
|
2023-09-16 23:53:06 +00:00
|
|
|
{
|
|
|
|
if (IsRequired(current, enc.Context))
|
|
|
|
return true;
|
|
|
|
if (IsRequired(enc))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-09-26 16:32:49 +00:00
|
|
|
/// <inheritdoc cref="IsRequired(IEncounterTemplate,PKM)"/>
|
|
|
|
public static bool IsRequired(EntityContext current, EntityContext origin) => origin != current;
|
2023-09-16 23:53:06 +00:00
|
|
|
|
2023-09-26 16:32:49 +00:00
|
|
|
/// <inheritdoc cref="IsRequired(IEncounterTemplate,PKM)"/>
|
2023-09-16 23:53:06 +00:00
|
|
|
/// <remarks>
|
|
|
|
/// Encounters that originate in HOME -> transfer to save data
|
|
|
|
/// </remarks>
|
|
|
|
public static bool IsRequired(IEncounterTemplate enc) => enc switch
|
|
|
|
{
|
|
|
|
EncounterSlot8GO => true,
|
|
|
|
WC8 { IsHOMEGift: true } => true,
|
|
|
|
WB8 { IsHOMEGift: true } => true,
|
|
|
|
WA8 { IsHOMEGift: true } => true,
|
|
|
|
WC9 { IsHOMEGift: true } => true,
|
|
|
|
_ => enc.Generation < 8,
|
|
|
|
};
|
|
|
|
}
|