mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Make Move[] readonly list
contract: don't modify the template movesets mystery gift now exposes IRelearn, remove unnecessary type checks
This commit is contained in:
parent
0cd9c47953
commit
8312c52cc1
22 changed files with 98 additions and 77 deletions
|
@ -241,12 +241,12 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="pk">Pokémon to modify.</param>
|
||||
/// <param name="moves"><see cref="PKM.Moves"/> to use (if already known). Will fetch the current <see cref="PKM.Moves"/> if not provided.</param>
|
||||
public static void SetMaximumPPCurrent(this PKM pk, int[] moves)
|
||||
public static void SetMaximumPPCurrent(this PKM pk, IReadOnlyList<int> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -100,14 +100,14 @@ namespace PKHeX.Core
|
|||
var list = new List<EncounterStatic>();
|
||||
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] };
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace PKHeX.Core
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
internal sealed class EncounterSlot3Swarm : EncounterSlot, IMoveset
|
||||
{
|
||||
public int[] Moves { get; }
|
||||
public IReadOnlyList<int> Moves { get; }
|
||||
|
||||
public EncounterSlot3Swarm(int[] moves) => Moves = moves;
|
||||
}
|
||||
|
|
|
@ -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<int>();
|
||||
public IReadOnlyList<int> Moves { get; set; } = Array.Empty<int>();
|
||||
public virtual int Level { get; set; }
|
||||
|
||||
public virtual int LevelMin => Level;
|
||||
|
@ -53,7 +53,6 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<int>();
|
||||
public IReadOnlyList<int> Moves { get; set; } = Array.Empty<int>();
|
||||
public int Level { get; set; }
|
||||
public int LevelMin => Level;
|
||||
public int LevelMax => 100;
|
||||
|
@ -173,10 +174,10 @@ namespace PKHeX.Core
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ namespace PKHeX.Core
|
|||
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 _:
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace PKHeX.Core
|
|||
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<int> SpecialMoves, EncounterEgg e)
|
||||
{
|
||||
var infoset = new EggInfoSource(pkm, SpecialMoves, e);
|
||||
return VerifyPreRelearnEggBase(pkm, Moves, infoset);
|
||||
|
@ -102,7 +102,7 @@ namespace PKHeX.Core
|
|||
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 @@ namespace PKHeX.Core
|
|||
return ParseMoves(pkm, source, info);
|
||||
}
|
||||
|
||||
private static int[] GetSpecialMoves(IEncounterable EncounterMatch)
|
||||
private static IReadOnlyList<int> GetSpecialMoves(IEncounterable EncounterMatch)
|
||||
{
|
||||
if (EncounterMatch is IMoveset mg)
|
||||
return mg.Moves;
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace PKHeX.Core
|
|||
|
||||
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),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -6,7 +7,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
private static readonly int[] Empty = Array.Empty<int>();
|
||||
public int[] CurrentMoves { get; set; } = Empty;
|
||||
public int[] SpecialSource { get; set; } = Empty;
|
||||
public IReadOnlyList<int> SpecialSource { get; set; } = Empty;
|
||||
public int[] NonTradeBackLevelUpMoves { get; set; } = Empty;
|
||||
|
||||
/// <summary>
|
||||
|
@ -16,6 +17,6 @@ namespace PKHeX.Core
|
|||
|
||||
public int[] EggLevelUpSource { get; set; } = Empty;
|
||||
public int[] EggMoveSource { get; set; } = Empty;
|
||||
public int[] EggEventSource { get; set; } = Empty;
|
||||
public IReadOnlyList<int> EggEventSource { get; set; } = Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a Moveset for the object.
|
||||
/// </summary>
|
||||
internal interface IMoveset
|
||||
{
|
||||
int[] Moves { get; }
|
||||
IReadOnlyList<int> Moves { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Mystery Gift Template File
|
||||
/// </summary>
|
||||
public abstract class MysteryGift : IEncounterable, IMoveset, IGeneration, ILocation
|
||||
public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, IGeneration, ILocation
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether or not the given length of bytes is valid for a mystery gift.
|
||||
|
@ -187,8 +187,8 @@ namespace PKHeX.Core
|
|||
public virtual string CardHeader => (CardID > 0 ? $"Card #: {CardID:0000}" : "N/A") + $" - {CardTitle.Replace('\u3000',' ').Trim()}";
|
||||
|
||||
// Search Properties
|
||||
public virtual int[] Moves { get => Array.Empty<int>(); set { } }
|
||||
public virtual int[] RelearnMoves { get => Array.Empty<int>(); set { } }
|
||||
public virtual IReadOnlyList<int> Moves { get => Array.Empty<int>(); set { } }
|
||||
public virtual IReadOnlyList<int> Relearn { get => Array.Empty<int>(); set { } }
|
||||
public virtual int[] IVs { get => Array.Empty<int>(); set { } }
|
||||
public virtual bool IsShiny => false;
|
||||
public virtual bool IsEgg { get => false; set { } }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -85,7 +86,7 @@ namespace PKHeX.Core
|
|||
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<int> 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; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PKHeX.Core
|
||||
|
@ -155,7 +156,7 @@ namespace PKHeX.Core
|
|||
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<int> 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; } }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
|
@ -115,7 +116,7 @@ namespace PKHeX.Core
|
|||
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<int> 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; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
@ -264,27 +265,27 @@ namespace PKHeX.Core
|
|||
|
||||
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
|
||||
|
||||
public override int[] Moves
|
||||
public override IReadOnlyList<int> 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<int> 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -28,7 +30,7 @@ namespace PKHeX.Core
|
|||
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<int>();
|
||||
public override IReadOnlyList<int> Moves { get; set; } = Array.Empty<int>();
|
||||
public bool NotDistributed { get; set; }
|
||||
public Shiny Shiny { get; set; } = Shiny.Random;
|
||||
public bool Fateful { get; set; } // Obedience Flag
|
||||
|
@ -146,16 +148,16 @@ namespace PKHeX.Core
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
@ -240,27 +241,27 @@ namespace PKHeX.Core
|
|||
public bool IsNicknamed => Nickname.Length > 0;
|
||||
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
|
||||
|
||||
public override int[] Moves
|
||||
public override IReadOnlyList<int> 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<int> 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
@ -283,27 +284,27 @@ namespace PKHeX.Core
|
|||
public bool IsNicknamed => Nickname.Length > 0 || IsEgg;
|
||||
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
|
||||
|
||||
public override int[] Moves
|
||||
public override IReadOnlyList<int> 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<int> 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ namespace PKHeX.Core
|
|||
|
||||
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
|
||||
|
||||
public override int[] Moves
|
||||
public override IReadOnlyList<int> 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<int> 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -460,6 +460,14 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public void SetMoves(IReadOnlyList<int> 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 };
|
||||
|
|
|
@ -677,7 +677,7 @@ namespace PKHeX.WinForms
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue