From afdd2bd57e5311d0e654c0b632189200f9ffca11 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 23 Dec 2020 20:40:59 -0800 Subject: [PATCH] Mark EncounterSlot/Static types as immutable record types --- PKHeX.Core/Legality/Areas/EncounterArea6AO.cs | 26 ++++++------------- .../Encounters/EncounterMisc/EncounterEgg.cs | 4 +-- .../EncounterMisc/EncounterInvalid.cs | 2 +- .../EncounterMisc/EncounterRejected.cs | 2 +- .../Encounters/EncounterSlot/EncounterSlot.cs | 4 +-- .../EncounterSlot/EncounterSlot1.cs | 2 +- .../EncounterSlot/EncounterSlot2.cs | 2 +- .../EncounterSlot/EncounterSlot3.cs | 2 +- .../EncounterSlot/EncounterSlot3PokeSpot.cs | 2 +- .../EncounterSlot/EncounterSlot3Swarm.cs | 2 +- .../EncounterSlot/EncounterSlot4.cs | 2 +- .../EncounterSlot/EncounterSlot5.cs | 2 +- .../EncounterSlot/EncounterSlot6AO.cs | 10 +++---- .../EncounterSlot/EncounterSlot6XY.cs | 2 +- .../EncounterSlot/EncounterSlot7.cs | 2 +- .../EncounterSlot/EncounterSlot7b.cs | 2 +- .../EncounterSlot/EncounterSlot8.cs | 2 +- .../EncounterSlot/GO/EncounterSlot7GO.cs | 4 +-- .../EncounterSlot/GO/EncounterSlot8GO.cs | 4 +-- .../EncounterSlot/GO/EncounterSlotGO.cs | 2 +- .../EncounterStatic/EncounterStatic.cs | 4 +-- .../EncounterStatic/EncounterStatic1.cs | 2 +- .../EncounterStatic/EncounterStatic1E.cs | 2 +- .../EncounterStatic/EncounterStatic2.cs | 6 ++--- .../EncounterStatic/EncounterStatic2E.cs | 2 +- .../EncounterStatic/EncounterStatic3.cs | 2 +- .../EncounterStatic/EncounterStatic4.cs | 2 +- .../EncounterStatic4Pokewalker.cs | 2 +- .../EncounterStatic/EncounterStatic5.cs | 2 +- .../EncounterStatic/EncounterStatic5DR.cs | 2 +- .../EncounterStatic/EncounterStatic5N.cs | 2 +- .../EncounterStatic/EncounterStatic6.cs | 2 +- .../EncounterStatic/EncounterStatic7.cs | 2 +- .../EncounterStatic/EncounterStatic7b.cs | 2 +- .../EncounterStatic/EncounterStatic8.cs | 2 +- .../EncounterStatic/EncounterStatic8N.cs | 2 +- .../EncounterStatic/EncounterStatic8NC.cs | 2 +- .../EncounterStatic/EncounterStatic8ND.cs | 2 +- .../EncounterStatic/EncounterStatic8Nest.cs | 2 +- .../EncounterStatic/EncounterStatic8S.cs | 2 +- .../EncounterStatic/EncounterStatic8U.cs | 2 +- .../EncounterStatic/EncounterStaticShadow.cs | 2 +- PKHeX.Core/Legality/Structures/LegalInfo.cs | 2 +- .../Legality/Verifiers/NHarmoniaVerifier.cs | 2 +- PKHeX.Core/MysteryGifts/WC3.cs | 14 +++++----- 45 files changed, 67 insertions(+), 81 deletions(-) diff --git a/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs b/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs index 80a4b27b7..75e462826 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs @@ -67,28 +67,18 @@ namespace PKHeX.Core if (slot.Form != evo.Form && slot.Form != RandomForm) break; - var clone = (EncounterSlot6AO)slot.Clone(); - MarkSlotDetails(pkm, clone, evo); + // Track some metadata about how this slot was matched. + var ao = (EncounterSlot6AO)slot; + var clone = ao with + { + WhiteFlute = evo.MinLevel < slot.LevelMin, + BlackFlute = evo.MinLevel > slot.LevelMax && evo.MinLevel <= slot.LevelMax + FluteBoostMax, + DexNav = ao.CanDexNav && (evo.MinLevel != slot.LevelMax || pkm.RelearnMove1 != 0 || pkm.AbilityNumber == 4), + }; yield return clone; break; } } } - - private static void MarkSlotDetails(PKM pkm, EncounterSlot6AO slot, EvoCriteria evo) - { - if (slot.LevelMin > evo.MinLevel) - slot.WhiteFlute = true; - if (slot.LevelMax + 1 <= evo.MinLevel && evo.MinLevel <= slot.LevelMax + FluteBoostMax) - slot.BlackFlute = true; - - if (!slot.CanDexNav) - return; - - if (slot.LevelMax != evo.MinLevel) - slot.DexNav = true; - if (pkm.RelearnMove1 != 0 || pkm.AbilityNumber == 4) - slot.DexNav = true; - } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs index 8842c968c..e586cfb2a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// /// Egg Encounter Data /// - public class EncounterEgg : IEncounterable + public record EncounterEgg : IEncounterable { public int Species { get; } public int Form { get; } @@ -144,7 +144,7 @@ namespace PKHeX.Core } } - public sealed class EncounterEggSplit : EncounterEgg + public sealed record EncounterEggSplit : EncounterEgg { public int OtherSpecies { get; } public EncounterEggSplit(int species, int form, int level, int gen, GameVersion game, int otherSpecies) : base(species, form, level, gen, game) => OtherSpecies = otherSpecies; diff --git a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs index 6c4f63aee..a3039cca0 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core /// /// Invalid Encounter Data /// - public sealed class EncounterInvalid : IEncounterable + public sealed record EncounterInvalid : IEncounterable { public static readonly EncounterInvalid Default = new(); diff --git a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterRejected.cs b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterRejected.cs index c747a7681..928cf2f50 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterRejected.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterRejected.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core /// /// Rejected Encounter Data containing a reason why the encounter was rejected (not compatible). /// - public sealed class EncounterRejected : IEncounterable + public sealed record EncounterRejected : IEncounterable { public readonly IEncounterable Encounter; public readonly CheckResult Check; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs index 6039f6388..cd4316cf6 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// Wild Encounter Slot data /// /// Wild encounter slots are found as random encounters in-game. - public abstract class EncounterSlot : IEncounterable, ILocation + public abstract record EncounterSlot : IEncounterable, ILocation { public int Species { get; protected init; } public int Form { get; protected init; } @@ -23,8 +23,6 @@ namespace PKHeX.Core protected EncounterSlot(EncounterArea area) => Area = area; - public EncounterSlot Clone() => (EncounterSlot)MemberwiseClone(); - public bool FixedLevel => LevelMin == LevelMax; private protected const string wild = "Wild Encounter"; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs index f55b29728..9940d82ac 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs @@ -4,7 +4,7 @@ /// Encounter Slot found in . /// /// - public sealed class EncounterSlot1 : EncounterSlot, INumberedSlot + public sealed record EncounterSlot1 : EncounterSlot, INumberedSlot { public override int Generation => 1; public int SlotNumber { get; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs index 6e559bbfc..bbdae6464 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs @@ -7,7 +7,7 @@ /// Referenced Area object contains Time data which is used for origin data. /// /// - public sealed class EncounterSlot2 : EncounterSlot, INumberedSlot + public sealed record EncounterSlot2 : EncounterSlot, INumberedSlot { public override int Generation => 2; public int SlotNumber { get; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs index 0ac98ed4d..0cf0e947a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public class EncounterSlot3 : EncounterSlot, IMagnetStatic, INumberedSlot + public record EncounterSlot3 : EncounterSlot, IMagnetStatic, INumberedSlot { public sealed override int Generation => 3; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs index cecd0f8a3..8192801f9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot3PokeSpot : EncounterSlot, INumberedSlot + public sealed record EncounterSlot3PokeSpot : EncounterSlot, INumberedSlot { public override int Generation => 3; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs index 73fd1be73..4e995ca84 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs @@ -9,7 +9,7 @@ namespace PKHeX.Core /// Handled differently as these slots have fixed moves that are different from their normal level-up moves. /// /// - internal sealed class EncounterSlot3Swarm : EncounterSlot3, IMoveset + internal sealed record EncounterSlot3Swarm : EncounterSlot3, IMoveset { public IReadOnlyList Moves { get; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs index bc9f31e0b..e293e11d2 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlot, IEncounterTypeTile + public sealed record EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlot, IEncounterTypeTile { public override int Generation => 4; public EncounterType TypeEncounter => ((EncounterArea4)Area).TypeEncounter; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs index af45abbae..1c3409b3a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot5 : EncounterSlot + public sealed record EncounterSlot5 : EncounterSlot { public override int Generation => 5; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs index 4944acbba..a59ec3a44 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs @@ -4,15 +4,15 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot6AO : EncounterSlot + public sealed record EncounterSlot6AO : EncounterSlot { public override int Generation => 6; public bool CanDexNav => Area.Type != SlotType.Rock_Smash; - public bool Pressure { get; set; } - public bool DexNav { get; set; } - public bool WhiteFlute { get; set; } - public bool BlackFlute { get; set; } + public bool Pressure { get; init; } + public bool DexNav { get; init; } + public bool WhiteFlute { get; init; } + public bool BlackFlute { get; init; } public EncounterSlot6AO(EncounterArea6AO area, int species, int form, int min, int max) : base(area) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs index 02213bc83..fad00b026 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot6XY : EncounterSlot + public sealed record EncounterSlot6XY : EncounterSlot { public override int Generation => 6; public bool Pressure { get; init; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs index 97bb394b3..b084740c3 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot7 : EncounterSlot + public sealed record EncounterSlot7 : EncounterSlot { public override int Generation => 7; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs index e704e8d75..4fc6aca1e 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot7b : EncounterSlot + public sealed record EncounterSlot7b : EncounterSlot { public override int Generation => 7; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs index e671b0ddd..867ae198e 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core /// Encounter Slot found in . /// /// - public sealed class EncounterSlot8 : EncounterSlot + public sealed record EncounterSlot8 : EncounterSlot { public readonly AreaWeather8 Weather; public override string LongName => Weather == AreaWeather8.All ? wild : $"{wild} - {Weather.ToString().Replace("_", string.Empty)}"; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs index 93154e5f6..8d27e8062 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot7GO.cs @@ -2,9 +2,9 @@ namespace PKHeX.Core { /// /// Encounter Slot found in (GO Park, ). - /// + /// /// - public sealed class EncounterSlot7GO : EncounterSlotGO + public sealed record EncounterSlot7GO : EncounterSlotGO { public override int Generation => 7; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs index b8244f0a7..6649cdabd 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlot8GO.cs @@ -2,9 +2,9 @@ namespace PKHeX.Core { /// /// Encounter Slot representing data transferred to (HOME). - /// + /// /// - public sealed class EncounterSlot8GO : EncounterSlotGO + public sealed record EncounterSlot8GO : EncounterSlotGO { public override int Generation => 8; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs index d4af68637..d8583ca20 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/EncounterSlotGO.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core /// /// Contains details about an encounter that can be found in . /// - public abstract class EncounterSlotGO : EncounterSlot, IPogoSlot + public abstract record EncounterSlotGO : EncounterSlot, IPogoSlot { /// public int Start { get; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs index be00b80b6..99580ce4a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs @@ -9,7 +9,7 @@ namespace PKHeX.Core /// /// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions. /// - public abstract class EncounterStatic : IEncounterable, IMoveset, ILocation, IVersionSet + public abstract record EncounterStatic : IEncounterable, IMoveset, ILocation, IVersionSet { public int Species { get; init; } public int Form { get; init; } @@ -39,8 +39,6 @@ namespace PKHeX.Core public bool SkipFormCheck { get; init; } public bool EggEncounter => EggLocation > 0; - internal EncounterStatic Clone() => (EncounterStatic)MemberwiseClone(); - private const string _name = "Static Encounter"; public string Name => _name; public string LongName => Version == GameVersion.Any ? _name : $"{_name} ({Version})"; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs index 0e3f5abfb..1775c90af 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs @@ -4,7 +4,7 @@ /// Generation 1 Static Encounter /// /// - public class EncounterStatic1 : EncounterStatic + public record EncounterStatic1 : EncounterStatic { public override int Generation => 1; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs index cfa56184d..a26ee866c 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// Event data for Generation 1 /// /// - public sealed class EncounterStatic1E : EncounterStatic1, IFixedGBLanguage + public sealed record EncounterStatic1E : EncounterStatic1, IFixedGBLanguage { public EncounterGBLanguage Language { get; init; } = EncounterGBLanguage.Japanese; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs index 55c6d91e2..dd1c2b018 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Generation 2 Static Encounter /// /// - public class EncounterStatic2 : EncounterStatic + public record EncounterStatic2 : EncounterStatic { public sealed override int Generation => 2; public sealed override int Level { get; init; } @@ -81,7 +81,7 @@ namespace PKHeX.Core } } - public sealed class EncounterStatic2Odd : EncounterStatic2 + public sealed record EncounterStatic2Odd : EncounterStatic2 { private const int Dizzy = 146; private static readonly int[] _dizzy = { Dizzy }; @@ -106,7 +106,7 @@ namespace PKHeX.Core } } - public sealed class EncounterStatic2Roam : EncounterStatic2 + public sealed record EncounterStatic2Roam : EncounterStatic2 { private static readonly int[] Roaming_MetLocation_GSC_Grass = { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs index 043502739..d8ed467c4 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// Event data for Generation 2 /// /// - public sealed class EncounterStatic2E : EncounterStatic2, IFixedGBLanguage + public sealed record EncounterStatic2E : EncounterStatic2, IFixedGBLanguage { public EncounterGBLanguage Language { get; init; } = EncounterGBLanguage.Japanese; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs index 6edbb37e4..342890c7d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Generation 3 Static Encounter /// /// - public sealed class EncounterStatic3 : EncounterStatic + public sealed record EncounterStatic3 : EncounterStatic { public override int Generation => 3; public bool Roaming { get; init; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs index 913ded315..e68d9b899 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Generation 4 Static Encounter /// /// - public sealed class EncounterStatic4 : EncounterStatic, IEncounterTypeTile + public sealed record EncounterStatic4 : EncounterStatic, IEncounterTypeTile { public override int Generation => 4; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs index 35f67bf8b..1b6aa85c6 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs @@ -4,7 +4,7 @@ /// Generation 4 Pokéwalker Encounter /// /// - public sealed class EncounterStatic4Pokewalker : EncounterStatic + public sealed record EncounterStatic4Pokewalker : EncounterStatic { public override int Generation => 4; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5.cs index d22b02306..1dbc47889 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// Generation 5 Static Encounter /// /// - public class EncounterStatic5 : EncounterStatic + public record EncounterStatic5 : EncounterStatic { public sealed override int Generation => 5; public bool Roaming { get; init; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5DR.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5DR.cs index 3872fff0e..cf68e17c9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5DR.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5DR.cs @@ -4,7 +4,7 @@ /// Generation 5 Dream Radar gift encounters /// /// - public sealed class EncounterStatic5DR : EncounterStatic5 + public sealed record EncounterStatic5DR : EncounterStatic5 { public EncounterStatic5DR(int species, int form, int abilityIndex = 4) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs index 4af5fe27c..38b8a86ba 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic5N.cs @@ -4,7 +4,7 @@ /// Generation 5 Static Encounter from N /// /// - internal sealed class EncounterStatic5N : EncounterStatic5 + internal sealed record EncounterStatic5N : EncounterStatic5 { public readonly uint PID; public const bool NSparkle = true; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic6.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic6.cs index 92e75b764..f37d44ec3 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic6.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic6.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// Generation 6 Static Encounter /// /// - public sealed class EncounterStatic6 : EncounterStatic, IContestStats + public sealed record EncounterStatic6 : EncounterStatic, IContestStats { public override int Generation => 6; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs index da258102e..93fb16f94 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Generation 7 Static Encounter /// /// - public sealed class EncounterStatic7 : EncounterStatic, IRelearn + public sealed record EncounterStatic7 : EncounterStatic, IRelearn { public override int Generation => 7; public IReadOnlyList Relearn { get; init; } = Array.Empty(); diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7b.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7b.cs index f75d7f6c0..88b779d17 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7b.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7b.cs @@ -4,7 +4,7 @@ /// Generation 7 Static Encounter ( /// /// - public sealed class EncounterStatic7b : EncounterStatic + public sealed record EncounterStatic7b : EncounterStatic { public override int Generation => 7; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs index 21f70a1a2..69c11486a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Generation 8 Static Encounter /// /// - public class EncounterStatic8 : EncounterStatic, IDynamaxLevel, IGigantamax, IRelearn + public record EncounterStatic8 : EncounterStatic, IDynamaxLevel, IGigantamax, IRelearn { public sealed override int Generation => 8; public bool ScriptedNoMarks { get; init; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs index 68cc5eb17..dee5ad8e9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// Generation 8 Nest Encounter (Regular Raid Dens) /// /// - public sealed class EncounterStatic8N : EncounterStatic8Nest + public sealed record EncounterStatic8N : EncounterStatic8Nest { private readonly uint MinRank; private readonly uint MaxRank; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs index f3d9fa811..216bb3261 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// Generation 8 Nest Encounter (Distributed Crystal Data) /// /// - public sealed class EncounterStatic8NC : EncounterStatic8Nest + public sealed record EncounterStatic8NC : EncounterStatic8Nest { protected override bool IsMatchLocation(PKM pkm) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs index 6af827748..6d7a80a55 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8ND.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// Generation 8 Nest Encounter (Distributed Data) /// /// - public sealed class EncounterStatic8ND : EncounterStatic8Nest + public sealed record EncounterStatic8ND : EncounterStatic8Nest { public EncounterStatic8ND(byte lvl, byte dyna, byte flawless) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs index 9494a0860..c640f63a5 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Generation 8 Nest Encounter (Raid) /// /// - public abstract class EncounterStatic8Nest : EncounterStatic, IGigantamax, IDynamaxLevel where T : EncounterStatic8Nest + public abstract record EncounterStatic8Nest : EncounterStatic, IGigantamax, IDynamaxLevel where T : EncounterStatic8Nest { public sealed override int Generation => 8; public static Func? VerifyCorrelation { private get; set; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs index 5fe8b4318..62b32cea9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// with multiple references (used for multiple met locations) /// /// - public sealed class EncounterStatic8S : EncounterStatic8 + public sealed record EncounterStatic8S : EncounterStatic8 { public override int Location { get => Locations[0]; init { } } public IReadOnlyList Locations { get; init; } = Array.Empty(); diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs index e1b271bf5..2ebbaf068 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// Generation 8 Nest Encounter (Max Raid) Underground /// /// - public sealed class EncounterStatic8U : EncounterStatic8Nest + public sealed record EncounterStatic8U : EncounterStatic8Nest { public override int Location { get => MaxLair; init { } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticShadow.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticShadow.cs index abd1e46e8..26c19dda1 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticShadow.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticShadow.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// Shadow Pokémon Encounter found in /// /// - public sealed class EncounterStaticShadow : EncounterStatic + public sealed record EncounterStaticShadow : EncounterStatic { public override int Generation => 3; diff --git a/PKHeX.Core/Legality/Structures/LegalInfo.cs b/PKHeX.Core/Legality/Structures/LegalInfo.cs index cd1a569d9..f2f80dc71 100644 --- a/PKHeX.Core/Legality/Structures/LegalInfo.cs +++ b/PKHeX.Core/Legality/Structures/LegalInfo.cs @@ -22,7 +22,7 @@ namespace PKHeX.Core get => _match; set { - if (_match != EncounterInvalid.Default && (value.LevelMin != _match.LevelMin || value.Species != _match.Species)) + if (!ReferenceEquals(_match, EncounterInvalid.Default) && (value.LevelMin != _match.LevelMin || value.Species != _match.Species)) _evochains = null; // clear if evo chain has the potential to be different _match = value; Parse.Clear(); diff --git a/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs b/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs index 4a06b2267..45929a75c 100644 --- a/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NHarmoniaVerifier.cs @@ -28,7 +28,7 @@ namespace PKHeX.Core return; if (pkm.OT_Gender != 0) - data.AddLine(GetInvalid(LG5OTGenderN, CheckIdentifier.Shiny)); + data.AddLine(GetInvalid(LG5OTGenderN, CheckIdentifier.Trainer)); if (pkm.IVTotal != 30*6) data.AddLine(GetInvalid(LG5IVAll30, CheckIdentifier.IVs)); if (!VerifyNsPKMOTValid(pkm)) diff --git a/PKHeX.Core/MysteryGifts/WC3.cs b/PKHeX.Core/MysteryGifts/WC3.cs index 4d0f7f395..9ca2a05d5 100644 --- a/PKHeX.Core/MysteryGifts/WC3.cs +++ b/PKHeX.Core/MysteryGifts/WC3.cs @@ -21,19 +21,19 @@ namespace PKHeX.Core public PIDType Method; public override string OT_Name { get; set; } = string.Empty; - public int OT_Gender { get; set; } = 3; + public int OT_Gender { get; init; } = 3; public override int TID { get; set; } public override int SID { get; set; } public override int Location { get; set; } = 255; public override int EggLocation { get => 0; set {} } public override GameVersion Version { get; set; } - public int Language { get; set; } = -1; + public int Language { get; init; } = -1; public override int Species { get; set; } public override bool IsEgg { get; set; } 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 + public bool NotDistributed { get; init; } + public Shiny Shiny { get; init; } = Shiny.Random; + public bool Fateful { get; init; } // Obedience Flag // Mystery Gift Properties public override int Generation => 3; @@ -62,12 +62,12 @@ namespace PKHeX.Core public override int Form { get; set; } // Synthetic - private int? _metLevel; + private readonly int? _metLevel; public int Met_Level { get => _metLevel ?? (IsEgg ? 0 : Level); - set => _metLevel = value; + init => _metLevel = value; } public override PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria)