mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
Revise some method signatures
This commit is contained in:
parent
105e8b3818
commit
e34c8df044
|
|
@ -16,14 +16,14 @@ internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, int form,
|
|||
return Array.Empty<int>();
|
||||
|
||||
var r = new List<int>();
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, 1, form, version));
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, form, 1, version));
|
||||
|
||||
if (pkm.Format == 6 && pkm.Species != (int)Species.Meowstic)
|
||||
form = 0;
|
||||
|
||||
r.AddRange(MoveEgg.GetEggMoves(pkm, species, form, version));
|
||||
if (inheritlvlmoves)
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, 100, form, version));
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, form, 100, version));
|
||||
return r.Distinct();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
public static class MoveEgg
|
||||
{
|
||||
public static int[] GetEggMoves(PKM pkm, int species, int formnum, GameVersion version)
|
||||
public static int[] GetEggMoves(PKM pkm, int species, int form, GameVersion version)
|
||||
{
|
||||
int gen = pkm.Format <= 2 || pkm.VC ? 2 : pkm.Generation;
|
||||
if (!pkm.InhabitedGeneration(gen, species) || (pkm.PersonalInfo.Genderless && !FixedGenderFromBiGender.Contains(species)))
|
||||
|
|
@ -17,10 +17,10 @@ public static int[] GetEggMoves(PKM pkm, int species, int formnum, GameVersion v
|
|||
|
||||
if (version == GameVersion.Any)
|
||||
version = (GameVersion)pkm.Version;
|
||||
return GetEggMoves(gen, species, formnum, version);
|
||||
return GetEggMoves(gen, species, form, version);
|
||||
}
|
||||
|
||||
public static int[] GetEggMoves(int gen, int species, int formnum, GameVersion version)
|
||||
public static int[] GetEggMoves(int gen, int species, int form, GameVersion version)
|
||||
{
|
||||
switch (gen)
|
||||
{
|
||||
|
|
@ -49,15 +49,15 @@ public static int[] GetEggMoves(int gen, int species, int formnum, GameVersion v
|
|||
case 7: // entries per form if required
|
||||
return version switch
|
||||
{
|
||||
GameVersion.US => GetFormEggMoves(species, formnum, EggMovesUSUM),
|
||||
GameVersion.UM => GetFormEggMoves(species, formnum, EggMovesUSUM),
|
||||
_ => GetFormEggMoves(species, formnum, EggMovesSM)
|
||||
GameVersion.US => GetFormEggMoves(species, form, EggMovesUSUM),
|
||||
GameVersion.UM => GetFormEggMoves(species, form, EggMovesUSUM),
|
||||
_ => GetFormEggMoves(species, form, EggMovesSM)
|
||||
};
|
||||
|
||||
case 8:
|
||||
return version switch
|
||||
{
|
||||
_ => GetFormEggMoves(species, formnum, EggMovesSWSH)
|
||||
_ => GetFormEggMoves(species, form, EggMovesSWSH)
|
||||
};
|
||||
|
||||
default:
|
||||
|
|
@ -65,15 +65,15 @@ public static int[] GetEggMoves(int gen, int species, int formnum, GameVersion v
|
|||
}
|
||||
}
|
||||
|
||||
private static int[] GetFormEggMoves(int species, int formnum, IReadOnlyList<EggMoves7> table)
|
||||
private static int[] GetFormEggMoves(int species, int form, IReadOnlyList<EggMoves7> table)
|
||||
{
|
||||
var entry = table[species];
|
||||
if (formnum > 0 && entry.FormTableIndex > species)
|
||||
entry = table[entry.FormTableIndex + formnum - 1];
|
||||
if (form > 0 && entry.FormTableIndex > species)
|
||||
entry = table[entry.FormTableIndex + form - 1];
|
||||
return entry.Moves;
|
||||
}
|
||||
|
||||
internal static int[] GetRelearnLVLMoves(PKM pkm, int species, int lvl, int formnum, GameVersion version = GameVersion.Any)
|
||||
internal static int[] GetRelearnLVLMoves(PKM pkm, int species, int form, int lvl, GameVersion version = GameVersion.Any)
|
||||
{
|
||||
if (version == GameVersion.Any)
|
||||
version = (GameVersion)pkm.Version;
|
||||
|
|
@ -103,7 +103,7 @@ internal static int[] GetRelearnLVLMoves(PKM pkm, int species, int lvl, int form
|
|||
}
|
||||
return Array.Empty<int>();
|
||||
|
||||
int[] getMoves(IReadOnlyList<Learnset> moves, PersonalTable table) => moves[table.GetFormIndex(species, formnum)].GetMoves(lvl);
|
||||
int[] getMoves(IReadOnlyList<Learnset> moves, PersonalTable table) => moves[table.GetFormIndex(species, form)].GetMoves(lvl);
|
||||
}
|
||||
|
||||
public static bool GetIsSharedEggMove(PKM pkm, int gen, int move)
|
||||
|
|
|
|||
|
|
@ -335,6 +335,10 @@ public static ushort GetCHK3(byte[] data)
|
|||
return chk;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrypts the input <see cref="pkm"/> data into a new array if it is encrypted, and updates the reference.
|
||||
/// </summary>
|
||||
/// <remarks>Generation 3 Format encryption check which verifies the checksum</remarks>
|
||||
public static void DecryptIfEncrypted3(ref byte[] pkm)
|
||||
{
|
||||
ushort chk = GetCHK3(pkm);
|
||||
|
|
@ -342,18 +346,30 @@ public static void DecryptIfEncrypted3(ref byte[] pkm)
|
|||
pkm = DecryptArray3(pkm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrypts the input <see cref="pkm"/> data into a new array if it is encrypted, and updates the reference.
|
||||
/// </summary>
|
||||
/// <remarks>Generation 4 & 5 Format encryption check which checks for the unused bytes</remarks>
|
||||
public static void DecryptIfEncrypted45(ref byte[] pkm)
|
||||
{
|
||||
if (BitConverter.ToUInt32(pkm, 0x64) != 0)
|
||||
pkm = DecryptArray45(pkm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrypts the input <see cref="pkm"/> data into a new array if it is encrypted, and updates the reference.
|
||||
/// </summary>
|
||||
/// <remarks>Generation 6 & 7 Format encryption check</remarks>
|
||||
public static void DecryptIfEncrypted67(ref byte[] pkm)
|
||||
{
|
||||
if (BitConverter.ToUInt16(pkm, 0xC8) != 0 || BitConverter.ToUInt16(pkm, 0x58) != 0)
|
||||
pkm = DecryptArray6(pkm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decrypts the input <see cref="pkm"/> data into a new array if it is encrypted, and updates the reference.
|
||||
/// </summary>
|
||||
/// <remarks>Generation 8 Format encryption check</remarks>
|
||||
public static void DecryptIfEncrypted8(ref byte[] pkm)
|
||||
{
|
||||
if (BitConverter.ToUInt16(pkm, 0x70) != 0 || BitConverter.ToUInt16(pkm, 0xC0) != 0)
|
||||
|
|
|
|||
|
|
@ -652,13 +652,13 @@ protected override void SetDex(PKM pkm)
|
|||
else if (pkm.Species == (int)Species.Pichu && HGSS) // Pichu (HGSS Only)
|
||||
{
|
||||
int form = pkm.Form == 1 ? 2 : pkm.Gender;
|
||||
CheckInsertForm(ref forms, form);
|
||||
SetForms(pkm.Species, forms);
|
||||
if (TryInsertForm(forms, form))
|
||||
SetForms(pkm.Species, forms);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckInsertForm(ref forms, pkm.Form);
|
||||
SetForms(pkm.Species, forms);
|
||||
if (TryInsertForm(forms, pkm.Form))
|
||||
SetForms(pkm.Species, forms);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -844,24 +844,17 @@ private static uint SetDexFormValues(int[] Forms, int BitsPerForm, int readCt)
|
|||
return Value;
|
||||
}
|
||||
|
||||
private static bool CheckInsertForm(ref int[] Forms, int FormNum)
|
||||
private static bool TryInsertForm(int[] forms, int form)
|
||||
{
|
||||
if (Forms.Any(num => num == FormNum))
|
||||
{
|
||||
if (Array.IndexOf(forms, form) >= 0)
|
||||
return false; // already in list
|
||||
}
|
||||
if (Forms.All(num => num == -1))
|
||||
{
|
||||
Forms[0] = FormNum;
|
||||
return true; // none in list, insert at top
|
||||
}
|
||||
|
||||
// insert at first empty
|
||||
int n1 = Array.IndexOf(Forms, -1);
|
||||
if (n1 < 0)
|
||||
return false;
|
||||
var index = Array.IndexOf(forms, -1);
|
||||
if (index < 0)
|
||||
return false; // no free slots?
|
||||
|
||||
Forms[n1] = FormNum;
|
||||
forms[index] = form;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ public static class QR7
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
private static byte[] GetRawQR(int species, int formnum, bool shiny, int gender)
|
||||
private static byte[] GetRawQR(int species, int form, bool shiny, int gender)
|
||||
{
|
||||
var basedata = (byte[])BaseQR.Clone();
|
||||
BitConverter.GetBytes((ushort)species).CopyTo(basedata, 0x28);
|
||||
|
||||
var pi = PersonalTable.USUM.GetFormEntry(species, formnum);
|
||||
var pi = PersonalTable.USUM.GetFormEntry(species, form);
|
||||
bool biGender = false;
|
||||
if (pi.OnlyMale)
|
||||
gender = 0;
|
||||
|
|
@ -60,7 +60,7 @@ private static byte[] GetRawQR(int species, int formnum, bool shiny, int gender)
|
|||
else
|
||||
biGender = !GenderDifferences.Contains(species);
|
||||
|
||||
basedata[0x2A] = (byte)formnum;
|
||||
basedata[0x2A] = (byte)form;
|
||||
basedata[0x2B] = (byte)gender;
|
||||
basedata[0x2C] = shiny ? 1 : 0;
|
||||
basedata[0x2D] = biGender ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -446,13 +446,13 @@ private void LoadFavPKM()
|
|||
|
||||
private void SetAbilityList()
|
||||
{
|
||||
int newabil = Convert.ToInt16(MT_AbilNo.Text) >> 1;
|
||||
int abilityIndex = Convert.ToInt16(MT_AbilNo.Text) >> 1;
|
||||
int species = WinFormsUtil.GetIndex(CB_Species);
|
||||
int formnum = CB_Form.SelectedIndex;
|
||||
var abils = PersonalTable.AO.GetFormEntry(species, formnum).Abilities;
|
||||
int form = CB_Form.SelectedIndex;
|
||||
var abilities = PersonalTable.AO.GetFormEntry(species, form).Abilities;
|
||||
|
||||
CB_Ability.DataSource = GameInfo.FilteredSources.GetAbilityList(abils, 6);
|
||||
CB_Ability.SelectedIndex = newabil < 3 ? newabil : 0;
|
||||
CB_Ability.DataSource = GameInfo.FilteredSources.GetAbilityList(abilities, 6);
|
||||
CB_Ability.SelectedIndex = abilityIndex < 3 ? abilityIndex : 0;
|
||||
}
|
||||
|
||||
private void SetForms()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user