mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-23 10:53:10 +00:00
3c232505e5
In this pull request I've changed a ton of method signatures to reflect the more-narrow types of Species, Move# and Form; additionally, I've narrowed other large collections that stored lists of species / permitted values, and reworked them to be more performant with the latest API spaghetti that PKHeX provides. Roamer met locations, usually in a range of [max-min]<64, can be quickly checked using a bitflag operation on a UInt64. Other collections (like "Is this from Colosseum or XD") were eliminated -- shadow state is not transferred COLO<->XD, so having a Shadow ID or matching the met location from a gift/wild encounter is a sufficient check for "originated in XD".
69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Generation 3 Static Encounter
|
|
/// </summary>
|
|
/// <inheritdoc cref="EncounterStatic"/>
|
|
public sealed record EncounterStatic3 : EncounterStatic
|
|
{
|
|
public override int Generation => 3;
|
|
public override EntityContext Context => EntityContext.Gen3;
|
|
public bool Roaming { get; init; }
|
|
|
|
public EncounterStatic3(ushort species, byte level, GameVersion game) : base(game)
|
|
{
|
|
Species = species;
|
|
Level = level;
|
|
}
|
|
|
|
protected override bool IsMatchEggLocation(PKM pk)
|
|
{
|
|
if (pk.Format == 3)
|
|
return !pk.IsEgg || EggLocation == 0 || EggLocation == pk.Met_Location;
|
|
return base.IsMatchEggLocation(pk);
|
|
}
|
|
|
|
protected override bool IsMatchLevel(PKM pk, EvoCriteria evo)
|
|
{
|
|
if (pk.Format != 3) // Met Level lost on PK3=>PK4
|
|
return Level <= evo.LevelMax;
|
|
|
|
if (EggEncounter)
|
|
return pk.Met_Level == 0 && pk.CurrentLevel >= 5; // met level 0, origin level 5
|
|
|
|
return pk.Met_Level == Level;
|
|
}
|
|
|
|
protected override bool IsMatchLocation(PKM pk)
|
|
{
|
|
if (EggEncounter)
|
|
return true;
|
|
if (pk.Format != 3)
|
|
return true; // transfer location verified later
|
|
|
|
var met = pk.Met_Location;
|
|
if (!Roaming)
|
|
return Location == met;
|
|
|
|
// Route 101-138
|
|
if (Version <= GameVersion.E)
|
|
return met is >= 16 and <= 49;
|
|
// Route 1-25 encounter is possible either in grass or on water
|
|
return met is >= 101 and <= 125;
|
|
}
|
|
|
|
protected override bool IsMatchPartial(PKM pk)
|
|
{
|
|
if (Gift && pk.Ball != Ball)
|
|
return true;
|
|
return base.IsMatchPartial(pk);
|
|
}
|
|
|
|
protected override void SetMetData(PKM pk, int level, DateTime today)
|
|
{
|
|
pk.Met_Level = level;
|
|
pk.Met_Location = !Roaming ? Location : (Version <= GameVersion.E ? 16 : 101);
|
|
}
|
|
}
|