PKHeX/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs
Kurt 88830e0d00
Update from .NET Framework 4.6 to .NET 7 (#3729)
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now.

Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes.

Adds functionality for Batch Editor commands to `>`, `<` and <=/>=

TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants.

Main window has a new layout to account for DPI scaling (8 point grid)

Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects
Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724)
Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720)
Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714)
Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691)
Added: Properties for ribbon/mark count (closes #3659)
Fixed: Traded SV eggs are now checked correctly (closes #3692)
2023-01-21 20:02:33 -08:00

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 is { Met_Level: 0, 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);
}
}