mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Add smart move[] setter
Closes #1871 (smart-move setting is also done by batch editor)
This commit is contained in:
parent
426ef1403c
commit
42f5f9b051
3 changed files with 21 additions and 4 deletions
|
@ -162,6 +162,25 @@ namespace PKHeX.Core
|
|||
int GetPPUpCount(int moveID) => moveID > 0 ? 3 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the <see cref="PKM.Moves"/> and updates the current PP counts.
|
||||
/// </summary>
|
||||
/// <param name="pk">Pokémon to modify.</param>
|
||||
/// <param name="Moves"><see cref="PKM.Moves"/> to set. Will be resized if 4 entries are not present.</param>
|
||||
/// <param name="maxPP">Option to maximize PP Ups</param>
|
||||
public static void SetMoves(this PKM pk, int[] Moves, bool maxPP = false)
|
||||
{
|
||||
if (Moves.Length != 4)
|
||||
Array.Resize(ref Moves, 4);
|
||||
|
||||
pk.Moves = Moves;
|
||||
if (maxPP)
|
||||
pk.SetMaximumPPUps(Moves);
|
||||
else
|
||||
pk.SetMaximumPPCurrent(Moves);
|
||||
pk.FixMoves();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the individual PP count values for each moveslot based on the maximum possible value.
|
||||
/// </summary>
|
||||
|
|
|
@ -668,8 +668,7 @@ namespace PKHeX.WinForms.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
pkm.Moves = m;
|
||||
pkm.SetMaximumPPCurrent(m);
|
||||
pkm.SetMoves(m);
|
||||
FieldsLoaded = false;
|
||||
LoadMoves(pkm);
|
||||
FieldsLoaded = true;
|
||||
|
|
|
@ -555,8 +555,7 @@ namespace PKHeX.WinForms
|
|||
case nameof(PKM.Moves):
|
||||
var moves = info.SuggestedMoves;
|
||||
Util.Shuffle(moves);
|
||||
Array.Resize(ref moves, 4);
|
||||
PKM.Moves = moves;
|
||||
PKM.SetMoves(moves);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue