mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +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)
68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using System;
|
|
using static PKHeX.Core.Species;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Personal Table storing <see cref="PersonalInfo6AO"/> used in Generation 6 games.
|
|
/// </summary>
|
|
public sealed class PersonalTable6AO : IPersonalTable, IPersonalTable<PersonalInfo6AO>
|
|
{
|
|
private readonly PersonalInfo6AO[] Table;
|
|
private const int SIZE = PersonalInfo6AO.SIZE;
|
|
private const int MaxSpecies = Legal.MaxSpeciesID_6;
|
|
public int MaxSpeciesID => MaxSpecies;
|
|
|
|
public PersonalTable6AO(ReadOnlySpan<byte> data)
|
|
{
|
|
Table = new PersonalInfo6AO[data.Length / SIZE];
|
|
var count = data.Length / SIZE;
|
|
for (int i = 0, ofs = 0; i < count; i++, ofs += SIZE)
|
|
{
|
|
var slice = data.Slice(ofs, SIZE).ToArray();
|
|
Table[i] = new PersonalInfo6AO(slice);
|
|
}
|
|
}
|
|
|
|
public PersonalInfo6AO this[int index] => Table[(uint)index < Table.Length ? index : 0];
|
|
public PersonalInfo6AO this[ushort species, byte form] => Table[GetFormIndex(species, form)];
|
|
public PersonalInfo6AO GetFormEntry(ushort species, byte form) => Table[GetFormIndex(species, form)];
|
|
|
|
public int GetFormIndex(ushort species, byte form)
|
|
{
|
|
if (species <= MaxSpeciesID)
|
|
return Table[species].FormIndex(species, form);
|
|
return 0;
|
|
}
|
|
|
|
public bool IsSpeciesInGame(ushort species) => species <= MaxSpecies;
|
|
public bool IsPresentInGame(ushort species, byte form)
|
|
{
|
|
if (!IsSpeciesInGame(species))
|
|
return false;
|
|
if (form == 0)
|
|
return true;
|
|
if (Table[species].HasForm(form))
|
|
return true;
|
|
return species switch
|
|
{
|
|
(int)Unown => form < 28,
|
|
(int)Burmy => form < 3,
|
|
(int)Mothim => form < 3,
|
|
(int)Shellos or (int)Gastrodon => form == 1,
|
|
(int)Arceus => form < 18,
|
|
(int)Deerling or (int)Sawsbuck => form < 4,
|
|
(int)Genesect => form < 5,
|
|
(int)Scatterbug or (int)Spewpa => form < 18,
|
|
(int)Vivillon => form <= 19,
|
|
(int)Flabébé or (int)Florges => form < 5,
|
|
(int)Floette => form <= 5,
|
|
(int)Xerneas => form == 1,
|
|
_ => false,
|
|
};
|
|
}
|
|
|
|
PersonalInfo IPersonalTable.this[int index] => this[index];
|
|
PersonalInfo IPersonalTable.this[ushort species, byte form] => this[species, form];
|
|
PersonalInfo IPersonalTable.GetFormEntry(ushort species, byte form) => GetFormEntry(species, form);
|
|
}
|