mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 12:06:47 -05:00
Minor tweaks
add method to randomize AVs from interface extension method revise stat presence check to check ATK since HP is stored in gen1 format
This commit is contained in:
@@ -24,21 +24,35 @@ public static partial class Extensions
|
||||
/// Clears all values.
|
||||
/// </summary>
|
||||
/// <param name="pk">Data to clear from</param>
|
||||
public static void AwakeningClear(this IAwakened pk) => pk.AV_HP = pk.AV_ATK = pk.AV_DEF = pk.AV_SPE = pk.AV_SPA = pk.AV_SPD = 0;
|
||||
public static void AwakeningClear(this IAwakened pk) => pk.AwakeningSetAllTo(0);
|
||||
|
||||
/// <summary>
|
||||
/// Sets all values to the maximum value.
|
||||
/// </summary>
|
||||
/// <param name="pk">Data to clear from</param>
|
||||
/// <param name="pk">Data to set values for</param>
|
||||
public static void AwakeningMax(this IAwakened pk) => pk.AwakeningSetAllTo(Legal.AwakeningMax);
|
||||
|
||||
/// <summary>
|
||||
/// Sets all values to the specified value.
|
||||
/// </summary>
|
||||
/// <param name="pk">Data to clear from</param>
|
||||
/// <param name="pk">Data to set values for</param>
|
||||
/// <param name="value">Value to set all to</param>
|
||||
public static void AwakeningSetAllTo(this IAwakened pk, int value) => pk.AV_HP = pk.AV_ATK = pk.AV_DEF = pk.AV_SPE = pk.AV_SPA = pk.AV_SPD = value;
|
||||
|
||||
/// <summary>
|
||||
/// Sets all values to the specified value.
|
||||
/// </summary>
|
||||
/// <param name="pk">Data to set values for</param>
|
||||
/// <param name="min">Minimum value to set</param>
|
||||
/// <param name="max">Maximum value to set</param>
|
||||
public static void AwakeningSetRandom(this IAwakened pk, int min = 0, int max = Legal.AwakeningMax)
|
||||
{
|
||||
var rnd = Util.Rand;
|
||||
int randClamp = max + 1;
|
||||
for (int index = 0; index < 6; index++)
|
||||
pk.SetAV(index, rnd.Next(min, randClamp));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets if all values are within legal limits.
|
||||
/// </summary>
|
||||
|
||||
@@ -239,12 +239,13 @@ private void UpdateHackedStatText(object sender, EventArgs e)
|
||||
tb.Text = "65535";
|
||||
}
|
||||
|
||||
private void UpdateHyperTrainingFlag(int i, bool value)
|
||||
private void UpdateHyperTrainingFlag(int index, bool value)
|
||||
{
|
||||
var tb = MT_IVs[index];
|
||||
if (value)
|
||||
MT_IVs[i].BackColor = StatHyperTrained;
|
||||
tb.BackColor = StatHyperTrained;
|
||||
else
|
||||
MT_IVs[i].ResetBackColor();
|
||||
tb.ResetBackColor();
|
||||
}
|
||||
|
||||
private void UpdateHPType(object sender, EventArgs e)
|
||||
@@ -267,7 +268,7 @@ private void ClickStatLabel(object sender, MouseEventArgs e)
|
||||
if ((ModifierKeys & Keys.Alt) != 0) // EV
|
||||
{
|
||||
bool min = e.Button != MouseButtons.Left;
|
||||
if (Entity is PB7)
|
||||
if (Entity is IAwakened)
|
||||
{
|
||||
var value = min ? 0 : 200;
|
||||
MT_AVs[index].Text = value.ToString();
|
||||
@@ -328,7 +329,10 @@ private Color GetEVTotalColor(int evtotal, Color defaultColor)
|
||||
public void UpdateStats()
|
||||
{
|
||||
// Generate the stats.
|
||||
if (!CHK_HackedStats.Checked || Entity.Stat_HPCurrent == 0) // no stats when initially loaded from non-partyformat slot
|
||||
// Some entity formats don't store stat values regardless of Box/Party/Etc format.
|
||||
// If its attack stat is zero, we need to generate party stats.
|
||||
// PK1 format stores Current HP in the compact format, so we have to use attack stat!
|
||||
if (!CHK_HackedStats.Checked || Entity.Stat_ATK == 0)
|
||||
{
|
||||
var pt = MainEditor.RequestSaveFile.Personal;
|
||||
var pi = pt.GetFormeEntry(Entity.Species, Entity.AltForm);
|
||||
@@ -369,12 +373,10 @@ private void UpdateRandomAVs(object sender, EventArgs e)
|
||||
a.SetSuggestedAwakenedValues(Entity);
|
||||
break;
|
||||
case Keys.Alt:
|
||||
a.AwakeningSetAllTo(0);
|
||||
a.AwakeningClear();
|
||||
break;
|
||||
default:
|
||||
var rnd = Util.Rand;
|
||||
foreach (var index in Enumerable.Range(0, 6))
|
||||
a.SetAV(index, rnd.Next(Legal.AwakeningMax + 1));
|
||||
a.AwakeningSetRandom();
|
||||
break;
|
||||
}
|
||||
LoadAVs(a);
|
||||
|
||||
Reference in New Issue
Block a user