Enable editing gen1/2 hidden power type

This commit is contained in:
Kurt 2018-07-14 10:56:11 -07:00
parent 625a77589b
commit baac632218
3 changed files with 10 additions and 5 deletions

View file

@ -484,7 +484,7 @@ namespace PKHeX.Core
InvalidLines.Add($"Invalid IVs for Hidden Power Type: {type}");
}
else if (hpVal >= 0)
IVs = PKX.SetHPIVs(hpVal, IVs); // Get IVs
IVs = PKX.SetHPIVs(hpVal, IVs, Format); // Get IVs
else
InvalidLines.Add($"Invalid Hidden Power Type: {type}");
}

View file

@ -634,9 +634,16 @@ namespace PKHeX.Core
/// <summary>Calculate the Hidden Power Type of the entered IVs.</summary>
/// <param name="type">Hidden Power Type</param>
/// <param name="ivs">Individual Values (H/A/B/S/C/D)</param>
/// <param name="format">Generation specific format</param>
/// <returns>Hidden Power Type</returns>
public static int[] SetHPIVs(int type, int[] ivs)
public static int[] SetHPIVs(int type, int[] ivs, int format = Generation)
{
if (format <= 2)
{
ivs[1] = (ivs[1] & ~3) | (type >> 2);
ivs[2] = (ivs[2] & ~3) | (type & 3);
return ivs;
}
for (int i = 0; i < 6; i++)
ivs[i] = (ivs[i] & 0x1E) + hpivs[type, i];
return ivs;

View file

@ -186,7 +186,7 @@ namespace PKHeX.WinForms.Controls
// Change IVs to match the new Hidden Power
int hpower = WinFormsUtil.GetIndex(CB_HPType);
int[] newIVs = PKX.SetHPIVs(hpower, pkm.IVs);
int[] newIVs = PKX.SetHPIVs(hpower, pkm.IVs, pkm.Format);
LoadIVs(newIVs);
}
private void ClickStatLabel(object sender, MouseEventArgs e)
@ -378,8 +378,6 @@ namespace PKHeX.WinForms.Controls
{
FLP_StatsTotal.Visible = gen >= 3;
FLP_Characteristic.Visible = gen >= 3;
CB_HPType.Enabled = gen >= 3;
FLP_HPType.Visible = gen >= 2;
switch (gen)
{