mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-16 21:38:40 +00:00
Make Relearn array for encounters readonly
No change em
This commit is contained in:
parent
40c2c483fb
commit
0cd9c47953
7 changed files with 18 additions and 14 deletions
|
@ -314,7 +314,7 @@ namespace PKHeX.Core
|
|||
return m;
|
||||
|
||||
var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.pkm);
|
||||
if (encounter is IRelearn r && r.Relearn.Length > 0)
|
||||
if (encounter is IRelearn r && r.Relearn.Count > 0)
|
||||
m = r.Relearn;
|
||||
|
||||
return m;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
|
@ -22,7 +23,7 @@ namespace PKHeX.Core
|
|||
public int Ability { get; set; }
|
||||
public int Form { get; set; }
|
||||
public virtual Shiny Shiny { get; set; } = Shiny.Random;
|
||||
public int[] Relearn { get; set; } = Array.Empty<int>();
|
||||
public IReadOnlyList<int> Relearn { get; set; } = Array.Empty<int>();
|
||||
public int Gender { get; set; } = -1;
|
||||
public int EggLocation { get; set; }
|
||||
public Nature Nature { get; set; } = Nature.Random;
|
||||
|
@ -53,7 +54,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
// dereference original arrays with new copies
|
||||
Moves = Moves.Length == 0 ? Moves : (int[])Moves.Clone();
|
||||
Relearn = Relearn.Length == 0 ? Relearn : (int[])Relearn.Clone();
|
||||
IVs = IVs.Length == 0 ? IVs : (int[])IVs.Clone();
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ namespace PKHeX.Core
|
|||
if (!IsMatchForm(pkm))
|
||||
return false;
|
||||
|
||||
if (EggLocation == Locations.Daycare5 && Relearn.Length == 0 && pkm.RelearnMoves.Any(z => z != 0)) // gen7 eevee edge case
|
||||
if (EggLocation == Locations.Daycare5 && Relearn.Count == 0 && pkm.RelearnMoves.Any(z => z != 0)) // gen7 eevee edge case
|
||||
return false;
|
||||
|
||||
if (!IsMatchIVs(pkm))
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public class EncounterTrade8 : EncounterTrade, IDynamaxLevel, IRelearn, IMemoryOT
|
||||
{
|
||||
public byte DynamaxLevel { get; set; }
|
||||
public int[] Relearn { get; set; } = Array.Empty<int>();
|
||||
public IReadOnlyList<int> Relearn { get; set; } = Array.Empty<int>();
|
||||
|
||||
public int OT_Memory { get; }
|
||||
public int OT_TextVar { get; }
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public interface IRelearn
|
||||
{
|
||||
int[] Relearn { get; }
|
||||
IReadOnlyList<int> Relearn { get; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
|
@ -171,7 +172,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
private readonly IEncounterable? Encounter;
|
||||
|
||||
public int[] Relearn => Encounter is IRelearn r ? r.Relearn : Array.Empty<int>();
|
||||
public IReadOnlyList<int> Relearn => Encounter is IRelearn r ? r.Relearn : Array.Empty<int>();
|
||||
|
||||
public EncounterSuggestionData(PKM pkm, IEncounterable enc, int met)
|
||||
{
|
||||
|
|
|
@ -21,26 +21,26 @@ namespace PKHeX.Core
|
|||
return info.EncounterMatch switch
|
||||
{
|
||||
MysteryGift g => VerifyRelearnSpecifiedMoveset(pkm, info, g.RelearnMoves),
|
||||
IRelearn s when s.Relearn.Length > 0 => VerifyRelearnSpecifiedMoveset(pkm, info, s.Relearn),
|
||||
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),
|
||||
_ => VerifyRelearnNone(pkm, info)
|
||||
};
|
||||
}
|
||||
|
||||
private static CheckResult[] VerifyRelearnSpecifiedMoveset(PKM pkm, LegalInfo info, int[] moves)
|
||||
private static CheckResult[] VerifyRelearnSpecifiedMoveset(PKM pkm, LegalInfo info, IReadOnlyList<int> relearn)
|
||||
{
|
||||
CheckResult[] res = new CheckResult[4];
|
||||
int[] RelearnMoves = pkm.RelearnMoves;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
res[i] = moves[i] != RelearnMoves[i]
|
||||
? new CheckResult(Severity.Invalid, string.Format(LMoveFExpect_0, MoveStrings[moves[i]]), CheckIdentifier.RelearnMove)
|
||||
res[i] = relearn[i] != RelearnMoves[i]
|
||||
? new CheckResult(Severity.Invalid, string.Format(LMoveFExpect_0, MoveStrings[relearn[i]]), CheckIdentifier.RelearnMove)
|
||||
: new CheckResult(CheckIdentifier.RelearnMove);
|
||||
}
|
||||
|
||||
info.RelearnBase = moves;
|
||||
info.RelearnBase = relearn;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace PKHeX.Tests.Saves
|
|||
[Fact]
|
||||
public void SizeCheck()
|
||||
{
|
||||
SCTypeCode.Common3.GetTypeSize().Should().Be(1);
|
||||
SCTypeCode.Bool3.GetTypeSize().Should().Be(1);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue