2022-08-21 08:39:16 +00:00
|
|
|
namespace PKHeX.Core;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2022-08-21 08:39:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Exposes details about an encounter with a specific location ID required.
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
public interface ILocation
|
2018-01-02 20:00:41 +00:00
|
|
|
{
|
2022-08-21 08:39:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Met Location ID the encounter is found at.
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
int Location { get; }
|
2022-08-21 08:39:16 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Egg Location ID the encounter is obtained with.
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
int EggLocation { get; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public static partial class Extensions
|
|
|
|
{
|
2022-08-21 08:39:16 +00:00
|
|
|
public static int GetLocation(this ILocation enc)
|
2018-01-02 20:00:41 +00:00
|
|
|
{
|
2022-08-21 08:39:16 +00:00
|
|
|
return enc.Location != 0
|
|
|
|
? enc.Location
|
|
|
|
: enc.EggLocation;
|
2018-01-02 20:00:41 +00:00
|
|
|
}
|
|
|
|
|
2022-08-21 08:39:16 +00:00
|
|
|
public static string? GetEncounterLocation(this ILocation enc, int gen, int version = -1)
|
2018-01-02 20:00:41 +00:00
|
|
|
{
|
2022-08-21 08:39:16 +00:00
|
|
|
int loc = enc.GetLocation();
|
2022-06-18 18:04:24 +00:00
|
|
|
if (loc < 0)
|
|
|
|
return null;
|
2018-01-31 04:24:45 +00:00
|
|
|
|
2022-08-21 08:39:16 +00:00
|
|
|
bool egg = loc != enc.Location;
|
2022-06-18 18:04:24 +00:00
|
|
|
return GameInfo.GetLocationName(egg, loc, gen, gen, (GameVersion)version);
|
2018-01-02 20:00:41 +00:00
|
|
|
}
|
|
|
|
}
|