diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs index ef92c5e52..7c84e8f0d 100644 --- a/PKHeX.Core/Editing/CommonEdits.cs +++ b/PKHeX.Core/Editing/CommonEdits.cs @@ -241,12 +241,12 @@ public static void SetMoves(this PKM pk, int[] moves, bool maxPP = false) /// /// Pokémon to modify. /// to use (if already known). Will fetch the current if not provided. - public static void SetMaximumPPCurrent(this PKM pk, int[] moves) + public static void SetMaximumPPCurrent(this PKM pk, IReadOnlyList moves) { - pk.Move1_PP = moves.Length == 0 ? 0 : pk.GetMovePP(moves[0], pk.Move1_PPUps); - pk.Move2_PP = moves.Length <= 1 ? 0 : pk.GetMovePP(moves[1], pk.Move2_PPUps); - pk.Move3_PP = moves.Length <= 2 ? 0 : pk.GetMovePP(moves[2], pk.Move3_PPUps); - pk.Move4_PP = moves.Length <= 3 ? 0 : pk.GetMovePP(moves[3], pk.Move4_PPUps); + 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); } /// diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs index 0d0ed16b7..1e292cfd2 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs @@ -100,14 +100,14 @@ private static void MarkG5DreamWorld(ref EncounterStatic[] t) var list = new List(); foreach (EncounterStatic s in t) { - if (s.Moves.Length <= 1) // no special moves + if (s.Moves.Count <= 1) // no special moves { list.Add(s); continue; } var loc = s.Location; - for (int i = 0; i < s.Moves.Length; i++) + for (int i = 0; i < s.Moves.Count; i++) { var clone = s.Clone(loc); clone.Moves = new[] { s.Moves[i] }; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot.cs index 64e96beca..8caf85622 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot.cs @@ -123,7 +123,7 @@ public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) private void SetEncounterMoves(PKM pk, GameVersion version, int level) { var moves = this is IMoveset m ? m.Moves : MoveLevelUp.GetEncounterMoves(pk, level, version); - pk.Moves = moves; + pk.SetMoves(moves); pk.SetMaximumPPCurrent(moves); } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot3Swarm.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot3Swarm.cs index d3a8728a6..c304617ec 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot3Swarm.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot3Swarm.cs @@ -1,8 +1,10 @@ +using System.Collections.Generic; + namespace PKHeX.Core { internal sealed class EncounterSlot3Swarm : EncounterSlot, IMoveset { - public int[] Moves { get; } + public IReadOnlyList Moves { get; } public EncounterSlot3Swarm(int[] moves) => Moves = moves; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic.cs index be05dd203..90189f564 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic.cs @@ -13,7 +13,7 @@ namespace PKHeX.Core public class EncounterStatic : IEncounterable, IMoveset, IGeneration, ILocation, IContestStats, IVersion, IRelearn { public int Species { get; set; } - public int[] Moves { get; set; } = Array.Empty(); + public IReadOnlyList Moves { get; set; } = Array.Empty(); public virtual int Level { get; set; } public virtual int LevelMin => Level; @@ -53,7 +53,6 @@ public class EncounterStatic : IEncounterable, IMoveset, IGeneration, ILocation, private void CloneArrays() { // dereference original arrays with new copies - Moves = Moves.Length == 0 ? Moves : (int[])Moves.Clone(); IVs = IVs.Length == 0 ? IVs : (int[])IVs.Clone(); } @@ -192,8 +191,8 @@ private void SetMetData(PKM pk, int level, DateTime today) private void SetEncounterMoves(PKM pk, GameVersion version, int level) { - var moves = Moves.Length > 0 ? Moves : MoveLevelUp.GetEncounterMoves(pk, level, version); - pk.Moves = moves; + var moves = Moves.Count > 0 ? Moves : MoveLevelUp.GetEncounterMoves(pk, level, version); + pk.SetMoves(moves); pk.SetMaximumPPCurrent(moves); } diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade.cs index 091963e6c..e61d40f9c 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; namespace PKHeX.Core @@ -12,7 +13,7 @@ namespace PKHeX.Core public class EncounterTrade : IEncounterable, IMoveset, IGeneration, ILocation, IContestStats, IVersion { public int Species { get; set; } - public int[] Moves { get; set; } = Array.Empty(); + public IReadOnlyList Moves { get; set; } = Array.Empty(); public int Level { get; set; } public int LevelMin => Level; public int LevelMax => 100; @@ -173,10 +174,10 @@ protected void SetIVs(PKM pk) private void SetMoves(PKM pk, GameVersion version, int level) { - var moves = Moves.Length != 0 ? Moves : MoveLevelUp.GetEncounterMoves(pk, level, version); + var moves = Moves.Count != 0 ? Moves : MoveLevelUp.GetEncounterMoves(pk, level, version); if (pk.Format == 1 && moves.All(z => z == 0)) moves = ((PersonalInfoG1)PersonalTable.RB[Species]).Moves; - pk.Moves = moves; + pk.SetMoves(moves); pk.SetMaximumPPCurrent(moves); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs index fea94934c..8722b767a 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator.cs @@ -281,7 +281,7 @@ private static GBEncounterPriority GetGBEncounterPriority(PKM pkm, IEncounterabl case EncounterTrade t: return t.Generation == 2 ? GBEncounterPriority.TradeEncounterG2 : GBEncounterPriority.TradeEncounterG1; case EncounterStatic s: - if (s.Moves.Length != 0 && s.Moves[0] != 0 && pkm.Moves.Contains(s.Moves[0])) + if (s.Moves.Count != 0 && s.Moves[0] != 0 && pkm.Moves.Contains(s.Moves[0])) return GBEncounterPriority.SpecialEncounter; return GBEncounterPriority.StaticEncounter; case EncounterSlot _: diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs index 57db2dcaa..b69cf2f9d 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyCurrentMoves.cs @@ -93,7 +93,7 @@ private static CheckMoveResult[] ParseMovesForSmeargle(PKM pkm, int[] Moves, Leg return ParseMoves(pkm, source, info); } - private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, int[] SpecialMoves, EncounterEgg e) + private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, IReadOnlyList SpecialMoves, EncounterEgg e) { var infoset = new EggInfoSource(pkm, SpecialMoves, e); return VerifyPreRelearnEggBase(pkm, Moves, infoset); @@ -102,7 +102,7 @@ private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, private static CheckMoveResult[] ParseMovesWasEggPreRelearn(PKM pkm, int[] Moves, LegalInfo info, EncounterEgg e) { var EventEggMoves = GetSpecialMoves(info.EncounterMatch); - bool notEvent = EventEggMoves.Length == 0; + bool notEvent = EventEggMoves.Count == 0; // Level up moves could not be inherited if Ditto is parent, // that means genderless species and male only species (except Nidoran-M and Volbeat; they breed with Nidoran-F and Illumise) could not have level up moves as an egg var pi = pkm.PersonalInfo; @@ -212,7 +212,7 @@ private static CheckMoveResult[] ParseMovesSpecialMoveset(PKM pkm, int[] Moves, return ParseMoves(pkm, source, info); } - private static int[] GetSpecialMoves(IEncounterable EncounterMatch) + private static IReadOnlyList GetSpecialMoves(IEncounterable EncounterMatch) { if (EncounterMatch is IMoveset mg) return mg.Moves; diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs index ae630d53f..105273b52 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/VerifyRelearnMoves.cs @@ -20,7 +20,6 @@ public static CheckResult[] VerifyRelearn(PKM pkm, LegalInfo info) return info.EncounterMatch switch { - MysteryGift g => VerifyRelearnSpecifiedMoveset(pkm, info, g.RelearnMoves), IRelearn s when s.Relearn.Count > 0 => VerifyRelearnSpecifiedMoveset(pkm, info, s.Relearn), EncounterEgg e => VerifyRelearnEggBase(pkm, info, e), EncounterSlot z when pkm.RelearnMove1 != 0 && z.Permissions.DexNav => VerifyRelearnDexNav(pkm, info), diff --git a/PKHeX.Core/Legality/Moves/MoveParseSource.cs b/PKHeX.Core/Legality/Moves/MoveParseSource.cs index d87bc7b4d..1fd055bce 100644 --- a/PKHeX.Core/Legality/Moves/MoveParseSource.cs +++ b/PKHeX.Core/Legality/Moves/MoveParseSource.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace PKHeX.Core { @@ -6,7 +7,7 @@ internal class MoveParseSource { private static readonly int[] Empty = Array.Empty(); public int[] CurrentMoves { get; set; } = Empty; - public int[] SpecialSource { get; set; } = Empty; + public IReadOnlyList SpecialSource { get; set; } = Empty; public int[] NonTradeBackLevelUpMoves { get; set; } = Empty; /// @@ -16,6 +17,6 @@ internal class MoveParseSource public int[] EggLevelUpSource { get; set; } = Empty; public int[] EggMoveSource { get; set; } = Empty; - public int[] EggEventSource { get; set; } = Empty; + public IReadOnlyList EggEventSource { get; set; } = Empty; } } diff --git a/PKHeX.Core/Legality/Structures/IMoveset.cs b/PKHeX.Core/Legality/Structures/IMoveset.cs index 9ac7ded99..c02a24f1e 100644 --- a/PKHeX.Core/Legality/Structures/IMoveset.cs +++ b/PKHeX.Core/Legality/Structures/IMoveset.cs @@ -1,10 +1,12 @@ -namespace PKHeX.Core +using System.Collections.Generic; + +namespace PKHeX.Core { /// /// Interface that exposes a Moveset for the object. /// internal interface IMoveset { - int[] Moves { get; } + IReadOnlyList Moves { get; } } } diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index 721bc2abe..52ee2948b 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -41,7 +41,7 @@ public override MysteryGift Clone() /// /// Mystery Gift Template File /// - public abstract class MysteryGift : IEncounterable, IMoveset, IGeneration, ILocation + public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, IGeneration, ILocation { /// /// Determines whether or not the given length of bytes is valid for a mystery gift. @@ -187,8 +187,8 @@ public EncounterMatchRating IsMatch(PKM pkm) public virtual string CardHeader => (CardID > 0 ? $"Card #: {CardID:0000}" : "N/A") + $" - {CardTitle.Replace('\u3000',' ').Trim()}"; // Search Properties - public virtual int[] Moves { get => Array.Empty(); set { } } - public virtual int[] RelearnMoves { get => Array.Empty(); set { } } + public virtual IReadOnlyList Moves { get => Array.Empty(); set { } } + public virtual IReadOnlyList Relearn { get => Array.Empty(); set { } } public virtual int[] IVs { get => Array.Empty(); set { } } public virtual bool IsShiny => false; public virtual bool IsEgg { get => false; set { } } diff --git a/PKHeX.Core/MysteryGifts/PCD.cs b/PKHeX.Core/MysteryGifts/PCD.cs index 65eaa0dd8..cf617489f 100644 --- a/PKHeX.Core/MysteryGifts/PCD.cs +++ b/PKHeX.Core/MysteryGifts/PCD.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace PKHeX.Core { @@ -85,7 +86,7 @@ public override string CardTitle public ushort CardCompatibility => BitConverter.ToUInt16(Data, 0x14C); // rest of bytes we don't really care about public override int Species { get => Gift.IsManaphyEgg ? 490 : Gift.Species; set => Gift.Species = value; } - public override int[] Moves { get => Gift.Moves; set => Gift.Moves = value; } + public override IReadOnlyList Moves { get => Gift.Moves; set => Gift.Moves = value; } public override int HeldItem { get => Gift.HeldItem; set => Gift.HeldItem = value; } public override bool IsShiny => Gift.IsShiny; public override bool IsEgg { get => Gift.IsEgg; set => Gift.IsEgg = value; } diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs index aecbfc8dd..55a1caf73 100644 --- a/PKHeX.Core/MysteryGifts/PGF.cs +++ b/PKHeX.Core/MysteryGifts/PGF.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Text; namespace PKHeX.Core @@ -155,7 +156,7 @@ public override int[] IVs public bool IsNicknamed => Nickname.Length > 0; public override bool IsShiny => PIDType == 2; public override int Location { get => MetLocation; set => MetLocation = (ushort)value; } - public override int[] Moves => new[] { Move1, Move2, Move3, Move4 }; + public override IReadOnlyList Moves => new[] { Move1, Move2, Move3, Move4 }; public override bool IsPokémon { get => CardType == 1; set { if (value) CardType = 1; } } public override bool IsItem { get => CardType == 2; set { if (value) CardType = 2; } } public bool IsPower { get => CardType == 3; set { if (value) CardType = 3; } } diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs index 9fc0225b8..56b58c3ac 100644 --- a/PKHeX.Core/MysteryGifts/PGT.cs +++ b/PKHeX.Core/MysteryGifts/PGT.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; namespace PKHeX.Core @@ -115,7 +116,7 @@ private void EncryptPK() public override bool IsPokémon { get => PGTGiftType == GiftType.Pokémon || PGTGiftType == GiftType.PokémonEgg || PGTGiftType == GiftType.ManaphyEgg; set { } } public override int Species { get => IsManaphyEgg ? 490 : PK.Species; set => PK.Species = value; } - public override int[] Moves { get => PK.Moves; set => PK.Moves = value; } + public override IReadOnlyList Moves { get => PK.Moves; set => PK.SetMoves(value); } public override int HeldItem { get => PK.HeldItem; set => PK.HeldItem = value; } public override bool IsShiny => PK.IsShiny; public override int Gender { get => PK.Gender; set => PK.Gender = value; } diff --git a/PKHeX.Core/MysteryGifts/WB7.cs b/PKHeX.Core/MysteryGifts/WB7.cs index fec894bbf..df3dc9bb4 100644 --- a/PKHeX.Core/MysteryGifts/WB7.cs +++ b/PKHeX.Core/MysteryGifts/WB7.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Text; @@ -264,27 +265,27 @@ private static int GetLanguageIndex(int language) public override int Location { get => MetLocation; set => MetLocation = (ushort)value; } - public override int[] Moves + public override IReadOnlyList Moves { get => new[] { Move1, Move2, Move3, Move4 }; set { - if (value.Length > 0) Move1 = value[0]; - if (value.Length > 1) Move2 = value[1]; - if (value.Length > 2) Move3 = value[2]; - if (value.Length > 3) Move4 = value[3]; + if (value.Count > 0) Move1 = value[0]; + if (value.Count > 1) Move2 = value[1]; + if (value.Count > 2) Move3 = value[2]; + if (value.Count > 3) Move4 = value[3]; } } - public override int[] RelearnMoves + public override IReadOnlyList Relearn { get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; set { - if (value.Length > 0) RelearnMove1 = value[0]; - if (value.Length > 1) RelearnMove2 = value[1]; - if (value.Length > 2) RelearnMove3 = value[2]; - if (value.Length > 3) RelearnMove4 = value[3]; + if (value.Count > 0) RelearnMove1 = value[0]; + if (value.Count > 1) RelearnMove2 = value[1]; + if (value.Count > 2) RelearnMove3 = value[2]; + if (value.Count > 3) RelearnMove4 = value[3]; } } diff --git a/PKHeX.Core/MysteryGifts/WC3.cs b/PKHeX.Core/MysteryGifts/WC3.cs index 0dd9b8ae1..6dccb7381 100644 --- a/PKHeX.Core/MysteryGifts/WC3.cs +++ b/PKHeX.Core/MysteryGifts/WC3.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; namespace PKHeX.Core { @@ -28,7 +30,7 @@ public sealed class WC3 : MysteryGift, IRibbonSetEvent3, IVersion public int Language { get; set; } = -1; public override int Species { get; set; } public override bool IsEgg { get; set; } - public override int[] Moves { get; set; } = Array.Empty(); + public override IReadOnlyList Moves { get; set; } = Array.Empty(); public bool NotDistributed { get; set; } public Shiny Shiny { get; set; } = Shiny.Random; public bool Fateful { get; set; } // Obedience Flag @@ -146,16 +148,16 @@ private int GetVersion(ITrainerInfo SAV) private void SetMoves(PK3 pk) { - if (Moves.Length == 0) // not completely defined + if (Moves.Count == 0) // not completely defined Moves = Legal.GetBaseEggMoves(pk, Species, Form, (GameVersion)pk.Version, Level); - if (Moves.Length != 4) + if (Moves.Count != 4) { - var moves = Moves; + var moves = Moves.ToArray(); Array.Resize(ref moves, 4); Moves = moves; } - pk.Moves = Moves; + pk.SetMoves(Moves); pk.SetMaximumPPCurrent(Moves); } diff --git a/PKHeX.Core/MysteryGifts/WC6.cs b/PKHeX.Core/MysteryGifts/WC6.cs index c36b874aa..64c8fe008 100644 --- a/PKHeX.Core/MysteryGifts/WC6.cs +++ b/PKHeX.Core/MysteryGifts/WC6.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Text; @@ -240,27 +241,27 @@ public int[] EVs public bool IsNicknamed => Nickname.Length > 0; public override int Location { get => MetLocation; set => MetLocation = (ushort)value; } - public override int[] Moves + public override IReadOnlyList Moves { get => new[] { Move1, Move2, Move3, Move4 }; set { - if (value.Length > 0) Move1 = value[0]; - if (value.Length > 1) Move2 = value[1]; - if (value.Length > 2) Move3 = value[2]; - if (value.Length > 3) Move4 = value[3]; + if (value.Count > 0) Move1 = value[0]; + if (value.Count > 1) Move2 = value[1]; + if (value.Count > 2) Move3 = value[2]; + if (value.Count > 3) Move4 = value[3]; } } - public override int[] RelearnMoves + public override IReadOnlyList Relearn { get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; set { - if (value.Length > 0) RelearnMove1 = value[0]; - if (value.Length > 1) RelearnMove2 = value[1]; - if (value.Length > 2) RelearnMove3 = value[2]; - if (value.Length > 3) RelearnMove4 = value[3]; + if (value.Count > 0) RelearnMove1 = value[0]; + if (value.Count > 1) RelearnMove2 = value[1]; + if (value.Count > 2) RelearnMove3 = value[2]; + if (value.Count > 3) RelearnMove4 = value[3]; } } diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs index 4e252320c..27fc88891 100644 --- a/PKHeX.Core/MysteryGifts/WC7.cs +++ b/PKHeX.Core/MysteryGifts/WC7.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Text; @@ -283,27 +284,27 @@ public int[] EVs public bool IsNicknamed => Nickname.Length > 0 || IsEgg; public override int Location { get => MetLocation; set => MetLocation = (ushort)value; } - public override int[] Moves + public override IReadOnlyList Moves { get => new[] { Move1, Move2, Move3, Move4 }; set { - if (value.Length > 0) Move1 = value[0]; - if (value.Length > 1) Move2 = value[1]; - if (value.Length > 2) Move3 = value[2]; - if (value.Length > 3) Move4 = value[3]; + if (value.Count > 0) Move1 = value[0]; + if (value.Count > 1) Move2 = value[1]; + if (value.Count > 2) Move3 = value[2]; + if (value.Count > 3) Move4 = value[3]; } } - public override int[] RelearnMoves + public override IReadOnlyList Relearn { get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; set { - if (value.Length > 0) RelearnMove1 = value[0]; - if (value.Length > 1) RelearnMove2 = value[1]; - if (value.Length > 2) RelearnMove3 = value[2]; - if (value.Length > 3) RelearnMove4 = value[3]; + if (value.Count > 0) RelearnMove1 = value[0]; + if (value.Count > 1) RelearnMove2 = value[1]; + if (value.Count > 2) RelearnMove3 = value[2]; + if (value.Count > 3) RelearnMove4 = value[3]; } } diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs index 6a8c42026..727b5c96f 100644 --- a/PKHeX.Core/MysteryGifts/WC8.cs +++ b/PKHeX.Core/MysteryGifts/WC8.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Text; using static PKHeX.Core.RibbonIndex; @@ -246,27 +247,27 @@ private static int GetLanguageIndex(int language) public override int Location { get => MetLocation; set => MetLocation = (ushort)value; } - public override int[] Moves + public override IReadOnlyList Moves { get => new[] { Move1, Move2, Move3, Move4 }; set { - if (value.Length > 0) Move1 = value[0]; - if (value.Length > 1) Move2 = value[1]; - if (value.Length > 2) Move3 = value[2]; - if (value.Length > 3) Move4 = value[3]; + if (value.Count > 0) Move1 = value[0]; + if (value.Count > 1) Move2 = value[1]; + if (value.Count > 2) Move3 = value[2]; + if (value.Count > 3) Move4 = value[3]; } } - public override int[] RelearnMoves + public override IReadOnlyList Relearn { get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; set { - if (value.Length > 0) RelearnMove1 = value[0]; - if (value.Length > 1) RelearnMove2 = value[1]; - if (value.Length > 2) RelearnMove3 = value[2]; - if (value.Length > 3) RelearnMove4 = value[3]; + if (value.Count > 0) RelearnMove1 = value[0]; + if (value.Count > 1) RelearnMove2 = value[1]; + if (value.Count > 2) RelearnMove3 = value[2]; + if (value.Count > 3) RelearnMove4 = value[3]; } } diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 8a4afd697..26775789e 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -460,6 +460,14 @@ public int[] Moves } } + public void SetMoves(IReadOnlyList value) + { + Move1 = value.Count > 0 ? value[0] : 0; + Move2 = value.Count > 1 ? value[1] : 0; + Move3 = value.Count > 2 ? value[2] : 0; + Move4 = value.Count > 3 ? value[3] : 0; + } + public int[] RelearnMoves { get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs index f96337df9..c14db87f5 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs @@ -677,7 +677,7 @@ private void B_RandForest_Click(object sender, EventArgs e) source.Remove(slot); s.Species = slot.Species; s.Form = slot.Form; - s.Move = slot.Moves[Util.Rand.Next(slot.Moves.Length)]; + s.Move = slot.Moves[Util.Rand.Next(slot.Moves.Count)]; s.Gender = slot.Gender == -1 ? PersonalTable.B2W2[slot.Species].RandomGender() : slot.Gender; } ChangeArea(null, EventArgs.Empty); // refresh