diff --git a/PKHeX.Core/Legality/Areas/EncounterArea.cs b/PKHeX.Core/Legality/Areas/EncounterArea.cs index 1f237acab..d55490896 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea.cs @@ -9,8 +9,8 @@ namespace PKHeX.Core public abstract class EncounterArea : IVersion { public GameVersion Version { get; } - public int Location { get; protected set; } - public SlotType Type { get; protected set; } = SlotType.Any; + public int Location { get; protected init; } + public SlotType Type { get; protected init; } = SlotType.Any; public EncounterSlot[] Slots = Array.Empty(); protected EncounterArea(GameVersion game) => Version = game; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs index 9a62e7513..6039f6388 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs @@ -8,10 +8,10 @@ namespace PKHeX.Core /// Wild encounter slots are found as random encounters in-game. public abstract class EncounterSlot : IEncounterable, ILocation { - public int Species { get; protected set; } - public int Form { get; protected set; } - public int LevelMin { get; protected set; } - public int LevelMax { get; protected set; } + public int Species { get; protected init; } + public int Form { get; protected init; } + public int LevelMin { get; protected init; } + public int LevelMax { get; protected init; } public abstract int Generation { get; } public bool EggEncounter => false; public override string ToString() => $"{(Species) Species} @ {LevelMin}-{LevelMax}"; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs index 4fcb17e81..02213bc83 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core public sealed class EncounterSlot6XY : EncounterSlot { public override int Generation => 6; - public bool Pressure { get; set; } + public bool Pressure { get; init; } public EncounterSlot6XY(EncounterArea6XY area, int species, int form, int min, int max) : base(area) { @@ -31,10 +31,7 @@ public override string GetConditionString(out bool valid) public EncounterSlot6XY CreatePressureFormCopy(int evoForm) { - var clone = (EncounterSlot6XY)Clone(); - clone.Form = evoForm; - clone.Pressure = true; - return clone; + return new((EncounterArea6XY) Area, Species, evoForm, LevelMin, LevelMax) {Pressure = true}; } } } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs index ba4a2c67c..da617848d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs @@ -11,32 +11,32 @@ namespace PKHeX.Core /// public abstract class EncounterStatic : IEncounterable, IMoveset, ILocation, IVersionSet { - public int Species { get; set; } - public int Form { get; set; } - public virtual int Level { get; set; } + public int Species { get; init; } + public int Form { get; init; } + public virtual int Level { get; init; } public virtual int LevelMin => Level; public virtual int LevelMax => Level; public abstract int Generation { get; } public GameVersion Version { get; set; } = GameVersion.Any; - public virtual int Location { get; set; } - public int Ability { get; set; } - public Shiny Shiny { get; set; } = Shiny.Random; - public int Gender { get; set; } = -1; - public int EggLocation { get; set; } - public Nature Nature { get; set; } = Nature.Random; - public bool Gift { get; set; } - public int Ball { get; set; } = 4; // Only checked when is Gift + public virtual int Location { get; init; } + public int Ability { get; init; } + public Shiny Shiny { get; init; } = Shiny.Random; + public int Gender { get; init; } = -1; + public int EggLocation { get; init; } + public Nature Nature { get; init; } = Nature.Random; + public bool Gift { get; init; } + public int Ball { get; init; } = 4; // Only checked when is Gift - public IReadOnlyList Moves { get; set; } = Array.Empty(); - public IReadOnlyList IVs { get; set; } = Array.Empty(); - public int FlawlessIVCount { get; set; } + public IReadOnlyList Moves { get; init; } = Array.Empty(); + public IReadOnlyList IVs { get; init; } = Array.Empty(); + public int FlawlessIVCount { get; init; } - public int HeldItem { get; set; } - public int EggCycles { get; set; } + public int HeldItem { get; init; } + public int EggCycles { get; init; } - public bool Fateful { get; set; } - public bool SkipFormCheck { get; set; } + public bool Fateful { get; init; } + public bool SkipFormCheck { get; init; } public bool EggEncounter => EggLocation > 0; internal EncounterStatic Clone() => (EncounterStatic)MemberwiseClone(); diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs index 1299e2404..55c6d91e2 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs @@ -10,7 +10,7 @@ namespace PKHeX.Core public class EncounterStatic2 : EncounterStatic { public sealed override int Generation => 2; - public sealed override int Level { get; set; } + public sealed override int Level { get; init; } public EncounterStatic2(int species, int level, GameVersion ver) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs index 8de230d04..3ee55e98d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs @@ -16,8 +16,8 @@ public sealed class EncounterStatic8N : EncounterStatic8Nest private IReadOnlyList NestLocations => Encounters8Nest.NestLocations[NestID]; - public override int Location { get => SharedNest; set { } } - public override int Level { get => LevelMin; set { } } + public override int Location { get => SharedNest; init { } } + public override int Level { get => LevelMin; init { } } public override int LevelMin => LevelCaps[MinRank * 2]; public override int LevelMax => LevelCaps[(MaxRank * 2) + 1]; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs index dd194e093..7a178639f 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8NC.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// public sealed class EncounterStatic8NC : EncounterStatic8Nest { - public override int Location { get => SharedNest; set { } } + public override int Location { get => SharedNest; init { } } protected override bool IsMatchLocation(PKM pkm) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs index ed04800d0..9494a0860 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8Nest.cs @@ -15,7 +15,7 @@ public abstract class EncounterStatic8Nest : EncounterStatic, IGigantamax, ID public bool CanGigantamax { get; set; } public byte DynamaxLevel { get; set; } - public override int Location { get => SharedNest; set { } } + public override int Location { get => SharedNest; init { } } protected override bool IsMatchLevel(PKM pkm, DexLevel evo) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs index 95a3b045a..5fe8b4318 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8S.cs @@ -10,8 +10,8 @@ namespace PKHeX.Core /// public sealed class EncounterStatic8S : EncounterStatic8 { - public override int Location { get => Locations[0]; set { } } - public IReadOnlyList Locations { get; internal set; } = Array.Empty(); + public override int Location { get => Locations[0]; init { } } + public IReadOnlyList Locations { get; init; } = Array.Empty(); protected override bool IsMatchLocation(PKM pkm) => Locations.Contains(pkm.Met_Location); } } \ No newline at end of file diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs index cc5521149..e1b271bf5 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core /// public sealed class EncounterStatic8U : EncounterStatic8Nest { - public override int Location { get => MaxLair; set { } } + public override int Location { get => MaxLair; init { } } public EncounterStatic8U(int species, int form, int level) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs index 6af14b6bb..096ce4f5c 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStaticTyped.cs @@ -9,12 +9,12 @@ namespace PKHeX.Core /// public sealed class EncounterStaticTyped : EncounterStatic4, IEncounterTypeTile { - public bool Roaming { get; set; } + public bool Roaming { get; init; } /// /// values permitted for the encounter. /// - public EncounterType TypeEncounter { get; internal set; } = EncounterType.None; + public EncounterType TypeEncounter { get; init; } = EncounterType.None; protected override bool IsMatchLocation(PKM pkm) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs index c59977748..460c27981 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs @@ -12,33 +12,33 @@ namespace PKHeX.Core /// public abstract class EncounterTrade : IEncounterable, IMoveset, ILocation, IVersionSet { - public int Species { get; set; } - public int Form { get; set; } - public int Level { get; set; } + public int Species { get; init; } + public int Form { get; init; } + public int Level { get; init; } public virtual int LevelMin => Level; public int LevelMax => 100; - public IReadOnlyList Moves { get; set; } = Array.Empty(); + public IReadOnlyList Moves { get; init; } = Array.Empty(); public abstract int Generation { get; } - public int CurrentLevel { get; set; } = -1; - public int Location { get; set; } - public int Ability { get; set; } - public int Gender { get; set; } = -1; + public int CurrentLevel { get; init; } = -1; + public int Location { get; init; } + public int Ability { get; init; } + public int Gender { get; init; } = -1; public Nature Nature = Nature.Random; - public virtual Shiny Shiny { get; set; } = Shiny.Never; - public int Ball { get; set; } = 4; + public Shiny Shiny { get; init; } = Shiny.Never; + public int Ball { get; init; } = 4; - public int TID { get; set; } - public int SID { get; set; } - public int OTGender { get; set; } = -1; + public int TID { get; internal set; } + public int SID { get; internal set; } + public int OTGender { get; init; } = -1; public GameVersion Version { get; set; } = GameVersion.Any; - public IReadOnlyList IVs { get; set; } = Array.Empty(); - public int FlawlessIVCount { get; set; } + public IReadOnlyList IVs { get; init; } = Array.Empty(); + public int FlawlessIVCount { get; init; } public bool EggEncounter => false; - public int EggLocation { get; set; } - public bool EvolveOnTrade { get; set; } + public int EggLocation { get; init; } + public bool EvolveOnTrade { get; init; } public int TID7 { @@ -52,7 +52,7 @@ public int TID7 private const string _name = "In-game Trade"; public string Name => _name; public string LongName => _name; - public bool IsNicknamed { get; set; } = true; + public bool IsNicknamed { get; init; } = true; public IReadOnlyList Nicknames { get; internal set; } = Array.Empty(); public IReadOnlyList TrainerNames { get; internal set; } = Array.Empty();