PKHeX/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5.cs
Kurt 5bcccc6d92
HOME 2.0.0: Handle conversion behavior & restrictions (#3506)
* Revises legality checks to account for traveling between the three game islands (PLA/BDSP/SWSH)
* Adds conversion mechanisms between the three formats, as well as flexible conversion options to backfill missing data (thanks GameFreak/ILCA for opting for lossy conversion instead of updating the games).
* Adds API abstractions for HOME data storage format (EKH/PKH format 1, aka EH1/PH1).
* Revises some APIs for better usage:
  - `PKM` now exposes a `Context` to indicate the isolation context for legality purposes.
  - Some method signatures have changed to accept `Context` or `GameVersion` instead of a vague `int` for Generation.
  - Evolution History is now tracked in the Legality parse for specific contexts, rather than only per generation.
2022-05-30 21:43:52 -07:00

56 lines
1.9 KiB
C#

using System.Linq;
namespace PKHeX.Core
{
/// <summary>
/// Generation 5 Static Encounter
/// </summary>
/// <inheritdoc cref="EncounterStatic"/>
public record EncounterStatic5(GameVersion Version) : EncounterStatic(Version)
{
public sealed override int Generation => 5;
public bool Roaming { get; init; }
public bool IsWildCorrelationPID => !Roaming && Shiny == Shiny.Random && Species != (int)Core.Species.Crustle;
protected sealed override bool IsMatchPartial(PKM pkm)
{
// BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil
if (Ability == AbilityPermission.OnlyHidden && pkm.AbilityNumber != 4 && pkm.Format <= 7)
return true;
return base.IsMatchPartial(pkm);
}
protected sealed override bool IsMatchLocation(PKM pk)
{
if (!Roaming)
return base.IsMatchLocation(pk);
return Roaming_MetLocation_BW.Contains(pk.Met_Location);
}
protected override bool IsMatchEggLocation(PKM pkm)
{
if (!EggEncounter)
return base.IsMatchEggLocation(pkm);
var eggloc = pkm.Egg_Location;
if (!pkm.IsEgg) // hatched
return eggloc == EggLocation || eggloc == Locations.LinkTrade5;
// Unhatched:
if (eggloc != EggLocation)
return false;
if (pkm.Met_Location is not (0 or Locations.LinkTrade5))
return false;
return true;
}
private static readonly int[] Roaming_MetLocation_BW =
{
25,26,27,28, // Route 12, 13, 14, 15 Night latter half
15,16,31, // Route 2, 3, 18 Morning
17,18,29, // Route 4, 5, 16 Daytime
19,20,21, // Route 6, 7, 8 Evening
22,23,24, // Route 9, 10, 11 Night former half
};
}
}