mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +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)
83 lines
2.1 KiB
C#
83 lines
2.1 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Exposes details about base stat values.
|
|
/// </summary>
|
|
public interface IBaseStat
|
|
{
|
|
/// <summary>
|
|
/// Base HP
|
|
/// </summary>
|
|
int HP { get; set; }
|
|
|
|
/// <summary>
|
|
/// Base Attack
|
|
/// </summary>
|
|
int ATK { get; set; }
|
|
|
|
/// <summary>
|
|
/// Base Defense
|
|
/// </summary>
|
|
int DEF { get; set; }
|
|
|
|
/// <summary>
|
|
/// Base Special Attack
|
|
/// </summary>
|
|
int SPA { get; set; }
|
|
|
|
/// <summary>
|
|
/// Base Special Defense
|
|
/// </summary>
|
|
int SPD { get; set; }
|
|
|
|
/// <summary>
|
|
/// Base Speed
|
|
/// </summary>
|
|
int SPE { get; set; }
|
|
}
|
|
|
|
public static class BaseStatExtensions
|
|
{
|
|
/// <summary>
|
|
/// Base Stat Total sum of all stats.
|
|
/// </summary>
|
|
public static int GetBaseStatTotal(this IBaseStat stats) => stats.HP + stats.ATK + stats.DEF + stats.SPA + stats.SPD + stats.SPE;
|
|
|
|
/// <summary>
|
|
/// Gets the requested Base Stat value with the requested <see cref="index"/>.
|
|
/// </summary>
|
|
public static int GetBaseStatValue(this IBaseStat stats, int index) => index switch
|
|
{
|
|
0 => stats.HP,
|
|
1 => stats.ATK,
|
|
2 => stats.DEF,
|
|
3 => stats.SPE,
|
|
4 => stats.SPA,
|
|
5 => stats.SPD,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
|
};
|
|
|
|
/// <summary>
|
|
/// Gathers the base stat values into the <see cref="span"/> then sorts (by value) lowest to highest.
|
|
/// </summary>
|
|
/// <param name="pi">Stat implementation to load from</param>
|
|
/// <param name="span">Result storage</param>
|
|
public static void GetSortedStatIndexes(this IBaseStat pi, Span<(int Index, int Stat)> span)
|
|
{
|
|
for (int i = 0; i < span.Length; i++)
|
|
span[i] = (i, pi.GetBaseStatValue(i));
|
|
|
|
// Bubble sort based off Stat value
|
|
// Higher stat values go to lower indexes in the span.
|
|
for (int i = 0; i < span.Length - 1; i++)
|
|
{
|
|
for (int j = 0; j < span.Length - 1 - i; j++)
|
|
{
|
|
if (span[j].Stat < span[j + 1].Stat)
|
|
(span[j], span[j + 1]) = (span[j + 1], span[j]);
|
|
}
|
|
}
|
|
}
|
|
}
|