Add smart move[] setter

Closes #1871 (smart-move setting is also done by batch editor)
This commit is contained in:
Kurt 2018-03-20 08:35:41 -07:00
parent 426ef1403c
commit 42f5f9b051
3 changed files with 21 additions and 4 deletions

View file

@ -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>

View file

@ -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;

View file

@ -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: