using System; using System.Collections.Generic; namespace PKHeX.Core { /// /// Logic for applying a moveset to a . /// public static class MoveApplicator { /// /// Sets the individual PP Up count values depending if a Move is present in the move's slot or not. /// /// Pokémon to modify. /// to use (if already known). Will fetch the current if not provided. public static void SetMaximumPPUps(this PKM pk, int[] moves) { pk.Move1_PPUps = GetPPUpCount(moves[0]); pk.Move2_PPUps = GetPPUpCount(moves[1]); pk.Move3_PPUps = GetPPUpCount(moves[2]); pk.Move4_PPUps = GetPPUpCount(moves[3]); pk.SetMaximumPPCurrent(moves); static int GetPPUpCount(int moveID) => moveID > 0 ? 3 : 0; } /// /// Sets the individual PP Up count values depending if a Move is present in the move slot or not. /// /// Pokémon to modify. public static void SetMaximumPPUps(this PKM pk) => pk.SetMaximumPPUps(pk.Moves); /// /// Updates the and updates the current PP counts. /// /// Pokémon to modify. /// to set. Will be resized if 4 entries are not present. /// Option to maximize PP Ups public static void SetMoves(this PKM pk, int[] moves, bool maxPP = false) { if (Array.FindIndex(moves, z => z > pk.MaxMoveID) != -1) moves = Array.FindAll(moves, z => z <= pk.MaxMoveID); if (moves.Length != 4) Array.Resize(ref moves, 4); pk.Moves = moves; if (maxPP && Legal.IsPPUpAvailable(pk)) pk.SetMaximumPPUps(moves); else pk.SetMaximumPPCurrent(moves); pk.FixMoves(); } /// /// Updates the individual PP count values for each move slot based on the maximum possible value. /// /// Pokémon to modify. /// to use (if already known). Will fetch the current if not provided. public static void SetMaximumPPCurrent(this PKM pk, IReadOnlyList moves) { pk.Move1_PP = moves.Count == 0 ? 0 : pk.GetMovePP(moves[0], pk.Move1_PPUps); pk.Move2_PP = moves.Count <= 1 ? 0 : pk.GetMovePP(moves[1], pk.Move2_PPUps); pk.Move3_PP = moves.Count <= 2 ? 0 : pk.GetMovePP(moves[2], pk.Move3_PPUps); pk.Move4_PP = moves.Count <= 3 ? 0 : pk.GetMovePP(moves[3], pk.Move4_PPUps); } /// /// Updates the individual PP count values for each move slot based on the maximum possible value. /// /// Pokémon to modify. public static void SetMaximumPPCurrent(this PKM pk) => pk.SetMaximumPPCurrent(pk.Moves); /// /// Refreshes the Move PP for the desired move. /// /// Pokémon to modify. /// Move PP to refresh. public static void SetSuggestedMovePP(this PKM pk, int index) => pk.HealPPIndex(index); } }