mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-21 06:41:56 +00:00
Delete duplicate HT bit fetch method
Make expression methods
This commit is contained in:
parent
11a2a7a318
commit
813180453e
3 changed files with 21 additions and 41 deletions
|
@ -348,7 +348,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (h.GetHT(i))
|
||||
if (h.IsHyperTrained(i))
|
||||
IVs[i] = pkm.MaxIV;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,56 +21,36 @@ namespace PKHeX.Core
|
|||
/// <param name="t">Hyper Trainable object</param>
|
||||
/// <param name="index">Battle Stat (H/A/B/S/C/D)</param>
|
||||
/// <returns>Final Hyper Training Flag value</returns>
|
||||
public static bool HyperTrainInvert(this IHyperTrain t, int index)
|
||||
public static bool HyperTrainInvert(this IHyperTrain t, int index) => index switch
|
||||
{
|
||||
return index switch
|
||||
{
|
||||
0 => (t.HT_HP ^= true),
|
||||
1 => (t.HT_ATK ^= true),
|
||||
2 => (t.HT_DEF ^= true),
|
||||
3 => (t.HT_SPE ^= true),
|
||||
4 => (t.HT_SPA ^= true),
|
||||
5 => (t.HT_SPD ^= true),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
0 => t.HT_HP ^= true,
|
||||
1 => t.HT_ATK ^= true,
|
||||
2 => t.HT_DEF ^= true,
|
||||
3 => t.HT_SPE ^= true,
|
||||
4 => t.HT_SPA ^= true,
|
||||
5 => t.HT_SPD ^= true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
public static bool IsHyperTrainedAll(this IHyperTrain t) => t.HyperTrainFlags == 0x3F;
|
||||
public static void HyperTrainClear(this IHyperTrain t) => t.HyperTrainFlags = 0;
|
||||
public static bool IsHyperTrained(this IHyperTrain t) => t.HyperTrainFlags != 0;
|
||||
|
||||
public static bool IsHyperTrained(this IHyperTrain t, int index)
|
||||
{
|
||||
return index switch
|
||||
{
|
||||
0 => t.HT_HP,
|
||||
1 => t.HT_ATK,
|
||||
2 => t.HT_DEF,
|
||||
3 => t.HT_SPE,
|
||||
4 => t.HT_SPA,
|
||||
5 => t.HT_SPD,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets one of the <see cref="IHyperTrain"/> values based on its index within the array.
|
||||
/// </summary>
|
||||
/// <param name="pk">Pokémon to check.</param>
|
||||
/// <param name="t">Entity to check.</param>
|
||||
/// <param name="index">Index to get</param>
|
||||
public static bool GetHT(this IHyperTrain pk, int index)
|
||||
public static bool IsHyperTrained(this IHyperTrain t, int index) => index switch
|
||||
{
|
||||
return index switch
|
||||
{
|
||||
0 => pk.HT_HP,
|
||||
1 => pk.HT_ATK,
|
||||
2 => pk.HT_DEF,
|
||||
3 => pk.HT_SPE,
|
||||
4 => pk.HT_SPA,
|
||||
5 => pk.HT_SPD,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
}
|
||||
0 => t.HT_HP,
|
||||
1 => t.HT_ATK,
|
||||
2 => t.HT_DEF,
|
||||
3 => t.HT_SPE,
|
||||
4 => t.HT_SPA,
|
||||
5 => t.HT_SPD,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="IHyperTrain.HyperTrainFlags"/> to valid values which may best enhance the <see cref="PKM"/> stats.
|
||||
|
|
|
@ -296,7 +296,7 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
|
||||
for (int i = 0; i < MT_IVs.Length; i++)
|
||||
UpdateHyperTrainingFlag(i, h.GetHT(i));
|
||||
UpdateHyperTrainingFlag(i, h.IsHyperTrained(i));
|
||||
}
|
||||
|
||||
private void UpdateAVTotals()
|
||||
|
|
Loading…
Reference in a new issue