mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-23 02:43:13 +00:00
88830e0d00
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)
63 lines
2 KiB
C#
63 lines
2 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Interface that exposes a <see cref="BattleVersion"/> for allowing a Pokémon into ranked battles if it originated from a prior game.
|
|
/// </summary>
|
|
public interface IBattleVersion
|
|
{
|
|
/// <summary>
|
|
/// Indicates which <see cref="GameVersion"/> the Pokémon's moves were reset on.
|
|
/// </summary>
|
|
byte BattleVersion { get; set; }
|
|
}
|
|
|
|
public static class BattleVersionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Checks if the applied Battle Version value is valid based on visitation.
|
|
/// </summary>
|
|
public static bool IsBattleVersionValid<T>(this T pk, EvolutionHistory h) where T : PKM, IBattleVersion => pk.BattleVersion switch
|
|
{
|
|
0 => true,
|
|
(int)GameVersion.SW or (int)GameVersion.SH => h.HasVisitedSWSH && !(pk.SWSH || pk.BDSP || pk.LA),
|
|
_ => false,
|
|
};
|
|
|
|
/// <summary>
|
|
/// Resets the <see cref="PKM"/>'s moves and sets the requested version.
|
|
/// </summary>
|
|
/// <param name="v">Reference to the object to set the <see cref="version"/></param>
|
|
/// <param name="pk">Reference to the same object that gets moves reset</param>
|
|
/// <param name="version">Version to apply</param>
|
|
public static void AdaptToBattleVersion(this IBattleVersion v, PKM pk, GameVersion version)
|
|
{
|
|
var empty = new Moveset();
|
|
pk.SetMoves(empty);
|
|
pk.SetRelearnMoves(empty);
|
|
|
|
Span<ushort> moves = stackalloc ushort[4];
|
|
MoveLevelUp.GetEncounterMoves(moves, pk, pk.CurrentLevel, version);
|
|
pk.SetMoves(moves);
|
|
pk.FixMoves();
|
|
v.BattleVersion = (byte)version;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the minimum Generation ID that it was last reset in.
|
|
/// </summary>
|
|
public static int GetMinGeneration(this IBattleVersion v)
|
|
{
|
|
var ver = v.BattleVersion;
|
|
if (ver == 0)
|
|
return 1;
|
|
var game = (GameVersion) ver;
|
|
if (!game.IsValidSavedVersion())
|
|
return -1;
|
|
var gen = game.GetGeneration();
|
|
if (gen >= 8)
|
|
return gen;
|
|
return -1;
|
|
}
|
|
}
|