diff --git a/PKHeX.Core/Editing/PKM/QR/QRPK7.cs b/PKHeX.Core/Editing/PKM/QR/QRPK7.cs index 1f3a8f8bd..d17760f35 100644 --- a/PKHeX.Core/Editing/PKM/QR/QRPK7.cs +++ b/PKHeX.Core/Editing/PKM/QR/QRPK7.cs @@ -7,8 +7,8 @@ public sealed class QRPK7 : IEncounterInfo { public GameVersion Version => (GameVersion)CassetteVersion; public bool EggEncounter => false; - public int LevelMin => Level; - public int LevelMax => Level; + public byte LevelMin => Level; + public byte LevelMax => Level; public int Generation => Version.GetGeneration(); public bool IsShiny => false; @@ -54,7 +54,7 @@ public sealed class QRPK7 : IEncounterInfo public int Unk_2A => Data[0x2A]; public int Friendship => Data[0x2B]; public int Ball => Data[0x2C]; - public int Level => Data[0x2D]; + public byte Level => Data[0x2D]; public int CassetteVersion => Data[0x2E]; public int Language => Data[0x2F]; diff --git a/PKHeX.Core/Legality/Areas/EncounterArea1.cs b/PKHeX.Core/Legality/Areas/EncounterArea1.cs index a4ade4386..1df559bbd 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea1.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea1.cs @@ -36,10 +36,10 @@ private EncounterArea1(ReadOnlySpan data, GameVersion game) : base(game) { const int size = 4; var entry = data.Slice(i * size, size); - int max = entry[3]; - int min = entry[2]; + byte max = entry[3]; + byte min = entry[2]; byte slotNum = entry[1]; - int species = entry[0]; + byte species = entry[0]; slots[i] = new EncounterSlot1(this, species, min, max, slotNum); } Slots = slots; diff --git a/PKHeX.Core/Legality/Areas/EncounterArea2.cs b/PKHeX.Core/Legality/Areas/EncounterArea2.cs index ad716ceba..325e806d7 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea2.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea2.cs @@ -64,10 +64,10 @@ private EncounterSlot2[] ReadSlots(ReadOnlySpan data, int count) for (int i = 0; i < slots.Length; i++) { var entry = data.Slice(i * size, size); - int max = entry[3]; - int min = entry[2]; + byte max = entry[3]; + byte min = entry[2]; byte slotNum = entry[1]; - int species = entry[0]; + byte species = entry[0]; slots[i] = new EncounterSlot2(this, species, min, max, slotNum); } return slots; diff --git a/PKHeX.Core/Legality/Areas/EncounterArea3.cs b/PKHeX.Core/Legality/Areas/EncounterArea3.cs index 68a40456d..13cf6bf34 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea3.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea3.cs @@ -66,11 +66,11 @@ private EncounterSlot3[] ReadRegularSlots(ReadOnlySpan data) private EncounterSlot3 ReadRegularSlot(ReadOnlySpan entry) { - int species = ReadUInt16LittleEndian(entry); - int form = entry[2]; + ushort species = ReadUInt16LittleEndian(entry); + byte form = entry[2]; byte slotNum = entry[3]; - int min = entry[4]; - int max = entry[5]; + byte min = entry[4]; + byte max = entry[5]; byte mpi = entry[6]; byte mpc = entry[7]; @@ -96,11 +96,11 @@ private EncounterSlot3[] ReadSwarmSlots(ReadOnlySpan data) private EncounterSlot3Swarm ReadSwarmSlot(ReadOnlySpan entry) { - int species = ReadUInt16LittleEndian(entry); + ushort species = ReadUInt16LittleEndian(entry); // form always 0 byte slotNum = entry[3]; - int min = entry[4]; - int max = entry[5]; + byte min = entry[4]; + byte max = entry[5]; int[] moves = { diff --git a/PKHeX.Core/Legality/Areas/EncounterArea3XD.cs b/PKHeX.Core/Legality/Areas/EncounterArea3XD.cs index e309cdeda..9a78abe3e 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea3XD.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea3XD.cs @@ -13,7 +13,7 @@ public sealed record EncounterArea3XD : EncounterArea protected override IReadOnlyList Raw => Slots; - public EncounterArea3XD(int loc, int s0, int l0, int s1, int l1, int s2, int l2) : base(GameVersion.XD) + public EncounterArea3XD(int loc, ushort s0, byte l0, ushort s1, byte l1, ushort s2, byte l2) : base(GameVersion.XD) { Location = loc; Type = SlotType.Grass; diff --git a/PKHeX.Core/Legality/Areas/EncounterArea4.cs b/PKHeX.Core/Legality/Areas/EncounterArea4.cs index 9a451909f..5bf657b7e 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea4.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea4.cs @@ -52,11 +52,11 @@ private EncounterSlot4[] ReadRegularSlots(ReadOnlySpan data) private EncounterSlot4 ReadRegularSlot(ReadOnlySpan entry) { - int species = ReadUInt16LittleEndian(entry); - int form = entry[2]; + ushort species = ReadUInt16LittleEndian(entry); + byte form = entry[2]; byte slotNum = entry[3]; - int min = entry[4]; - int max = entry[5]; + byte min = entry[4]; + byte max = entry[5]; byte mpi = entry[6]; byte mpc = entry[7]; byte sti = entry[8]; diff --git a/PKHeX.Core/Legality/Areas/EncounterArea5.cs b/PKHeX.Core/Legality/Areas/EncounterArea5.cs index 69f0a5ce8..9b1bf77ee 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea5.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea5.cs @@ -47,11 +47,11 @@ private EncounterSlot5[] ReadSlots(ReadOnlySpan data) private EncounterSlot5 ReadSlot(ReadOnlySpan entry) { - ushort SpecForm = ReadUInt16LittleEndian(entry); - int species = SpecForm & 0x3FF; - int form = SpecForm >> 11; - int min = entry[2]; - int max = entry[3]; + ushort species = ReadUInt16LittleEndian(entry); + byte form = (byte)(species >> 11); + species &= 0x3FF; + byte min = entry[2]; + byte max = entry[3]; return new EncounterSlot5(this, species, form, min, max); } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs b/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs index 9bb7e47b3..990cece33 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea6AO.cs @@ -47,11 +47,11 @@ private EncounterSlot6AO[] ReadSlots(ReadOnlySpan data) private EncounterSlot6AO ReadSlot(ReadOnlySpan entry) { - ushort SpecForm = ReadUInt16LittleEndian(entry); - int species = SpecForm & 0x3FF; - int form = SpecForm >> 11; - int min = entry[2]; - int max = entry[3]; + ushort species = ReadUInt16LittleEndian(entry); + byte form = (byte)(species >> 11); + species &= 0x3FF; + byte min = entry[2]; + byte max = entry[3]; return new EncounterSlot6AO(this, species, form, min, max); } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs b/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs index 8f8842451..6f3f70cce 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea6XY.cs @@ -45,7 +45,7 @@ private EncounterSlot6XY[] LoadSafariSlots() const int SpeciesFormSlots = 4; // Single form species - ushort[] species = + Span species = stackalloc ushort[] { 002, 005, 008, 012, 014, 016, 021, 025, 027, 035, 038, 039, 043, 044, 046, 049, 049, 051, 056, 058, @@ -93,11 +93,11 @@ private EncounterSlot6XY[] ReadSlots(ReadOnlySpan data) { int offset = 4 + (size * i); var entry = data.Slice(offset, size); - ushort SpecForm = ReadUInt16LittleEndian(entry); - int species = SpecForm & 0x3FF; - int form = SpecForm >> 11; - int min = entry[2]; - int max = entry[3]; + ushort species = ReadUInt16LittleEndian(entry); + byte form = (byte)(species >> 11); + species &= 0x3FF; + byte min = entry[2]; + byte max = entry[3]; slots[i] = new EncounterSlot6XY(this, species, form, min, max); } @@ -139,7 +139,7 @@ public override IEnumerable GetMatchingSlots(PKM pkm, IReadOnlyLi } } - private bool ExistsPressureSlot(DexLevel evo, ref int level) + private bool ExistsPressureSlot(DexLevel evo, ref byte level) { bool existsForm = false; foreach (var z in Slots) diff --git a/PKHeX.Core/Legality/Areas/EncounterArea7.cs b/PKHeX.Core/Legality/Areas/EncounterArea7.cs index 54a1c67e5..cc05af98c 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea7.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea7.cs @@ -47,11 +47,11 @@ private EncounterSlot7[] ReadSlots(ReadOnlySpan data) private EncounterSlot7 ReadSlot(ReadOnlySpan entry) { - ushort SpecForm = ReadUInt16LittleEndian(entry); - int species = SpecForm & 0x3FF; - int form = SpecForm >> 11; - int min = entry[2]; - int max = entry[3]; + ushort species = ReadUInt16LittleEndian(entry); + byte form = (byte)(species >> 11); + species &= 0x3FF; + byte min = entry[2]; + byte max = entry[3]; return new EncounterSlot7(this, species, form, min, max); } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea7b.cs b/PKHeX.Core/Legality/Areas/EncounterArea7b.cs index 0ad2879a6..11c73a85c 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea7b.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea7b.cs @@ -46,8 +46,8 @@ private EncounterSlot7b ReadSlot(ReadOnlySpan entry) { int species = entry[0]; // always < 255; only original 151 // form is always 0 - int min = entry[2]; - int max = entry[3]; + byte min = entry[2]; + byte max = entry[3]; return new EncounterSlot7b(this, species, min, max); } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea7g.cs b/PKHeX.Core/Legality/Areas/EncounterArea7g.cs index 4b39e3146..37cf1e001 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea7g.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea7g.cs @@ -20,7 +20,7 @@ public sealed record EncounterArea7g : EncounterArea, ISpeciesForm protected override IReadOnlyList Raw => Slots; - private EncounterArea7g(int species, int form, EncounterSlot7GO[] slots) : base(GameVersion.GO) + private EncounterArea7g(ushort species, byte form, EncounterSlot7GO[] slots) : base(GameVersion.GO) { Species = species; Form = form; @@ -40,9 +40,9 @@ internal static EncounterArea7g[] GetArea(BinLinkerAccessor data) private static EncounterArea7g GetArea(ReadOnlySpan data) { - var sf = ReadUInt16LittleEndian(data); - int species = sf & 0x7FF; - int form = sf >> 11; + var species = ReadUInt16LittleEndian(data); + byte form = (byte)(species >> 11); + species &= 0x3FF; var result = new EncounterSlot7GO[(data.Length - 2) / entrySize]; var area = new EncounterArea7g(species, form, result); @@ -56,7 +56,7 @@ private static EncounterArea7g GetArea(ReadOnlySpan data) return area; } - private static EncounterSlot7GO ReadSlot(ReadOnlySpan entry, EncounterArea7g area, int species, int form) + private static EncounterSlot7GO ReadSlot(ReadOnlySpan entry, EncounterArea7g area, ushort species, byte form) { int start = ReadInt32LittleEndian(entry); int end = ReadInt32LittleEndian(entry[4..]); diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8.cs b/PKHeX.Core/Legality/Areas/EncounterArea8.cs index ad450979f..a96dcd604 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8.cs @@ -392,9 +392,9 @@ private EncounterSlot8[] ReadSlots(ReadOnlySpan areaData, byte slotCount) for (int i = 0; i < count; i++, ctr++, ofs += bpe) { var entry = areaData.Slice(ofs, bpe); - var specForm = ReadUInt16LittleEndian(entry); - var species = specForm & 0x7FF; - var form = specForm >> 11; + var species = ReadUInt16LittleEndian(entry); + byte form = (byte)(species >> 11); + species &= 0x3FF; slots[ctr] = new EncounterSlot8(this, species, form, min, max, flags, slotType); } } while (ctr != slots.Length); diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8a.cs b/PKHeX.Core/Legality/Areas/EncounterArea8a.cs index 38ee0949a..ed021e061 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8a.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8a.cs @@ -79,8 +79,8 @@ private EncounterSlot8a[] ReadSlots(ReadOnlySpan areaData, byte slotCount) var entry = areaData.Slice(ofs, bpe); byte flawless = entry[7]; var gender = (Gender)entry[6]; - int max = entry[5]; - int min = entry[4]; + byte max = entry[5]; + byte min = entry[4]; var alpha = entry[3]; var form = entry[2]; var species = ReadUInt16LittleEndian(entry); diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8b.cs b/PKHeX.Core/Legality/Areas/EncounterArea8b.cs index 9c1a8bf69..1e984a6f7 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8b.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8b.cs @@ -46,11 +46,11 @@ private EncounterSlot8b[] ReadSlots(ReadOnlySpan data) private EncounterSlot8b ReadSlot(ReadOnlySpan data) { - ushort SpecForm = ReadUInt16LittleEndian(data); - int species = SpecForm & 0x3FF; - int form = SpecForm >> 11; - int min = data[2]; - int max = data[3]; + ushort species = ReadUInt16LittleEndian(data); + byte form = (byte)(species >> 11); + species &= 0x3FF; + byte min = data[2]; + byte max = data[3]; return new EncounterSlot8b(this, species, form, min, max); } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea8g.cs b/PKHeX.Core/Legality/Areas/EncounterArea8g.cs index 730bdad28..2f1fcfcc9 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea8g.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea8g.cs @@ -20,7 +20,7 @@ public sealed record EncounterArea8g : EncounterArea, ISpeciesForm protected override IReadOnlyList Raw => Slots; - private EncounterArea8g(int species, int form, EncounterSlot8GO[] slots) : base(GameVersion.GO) + private EncounterArea8g(ushort species, byte form, EncounterSlot8GO[] slots) : base(GameVersion.GO) { Species = species; Form = form; @@ -40,9 +40,9 @@ internal static EncounterArea8g[] GetArea(BinLinkerAccessor data) private static EncounterArea8g GetArea(ReadOnlySpan data) { - var sf = ReadUInt16LittleEndian(data); - int species = sf & 0x7FF; - int form = sf >> 11; + var species = ReadUInt16LittleEndian(data); + byte form = (byte)(species >> 11); + species &= 0x3FF; var group = GetGroup(species, form); @@ -58,7 +58,7 @@ private static EncounterArea8g GetArea(ReadOnlySpan data) return area; } - private static EncounterSlot8GO ReadSlot(ReadOnlySpan entry, EncounterArea8g area, int species, int form, GameVersion group) + private static EncounterSlot8GO ReadSlot(ReadOnlySpan entry, EncounterArea8g area, ushort species, byte form, GameVersion group) { int start = ReadInt32LittleEndian(entry); int end = ReadInt32LittleEndian(entry[4..]); diff --git a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs index 8cd689ea7..03497019b 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterEgg.cs @@ -5,14 +5,14 @@ namespace PKHeX.Core /// /// Egg Encounter Data /// - public sealed record EncounterEgg(int Species, int Form, int Level, int Generation, GameVersion Version) : IEncounterable + public sealed record EncounterEgg(int Species, int Form, byte Level, int Generation, GameVersion Version) : IEncounterable { public string Name => "Egg"; public string LongName => "Egg"; public bool EggEncounter => true; - public int LevelMin => Level; - public int LevelMax => Level; + public byte LevelMin => Level; + public byte LevelMax => Level; public bool IsShiny => false; public int Location => 0; public int EggLocation => Locations.GetDaycareLocation(Generation, Version); diff --git a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs index c315ecaff..3509f3916 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterMisc/EncounterInvalid.cs @@ -11,8 +11,8 @@ public sealed record EncounterInvalid : IEncounterable public int Species { get; } public int Form { get; } - public int LevelMin { get; } - public int LevelMax { get; } + public byte LevelMin { get; } + public byte LevelMax { get; } public bool EggEncounter { get; } public int Generation { get; } public GameVersion Version { get; } @@ -32,8 +32,8 @@ public EncounterInvalid(PKM pkm) { Species = pkm.Species; Form = pkm.Form; - LevelMin = pkm.Met_Level; - LevelMax = pkm.CurrentLevel; + LevelMin = (byte)pkm.Met_Level; + LevelMax = (byte)pkm.CurrentLevel; EggEncounter = pkm.WasEgg; Generation = pkm.Generation; Version = (GameVersion)pkm.Version; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs index 489d441e7..804b7fb39 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core /// Wild Encounter Slot data /// /// Wild encounter slots are found as random encounters in-game. - public abstract record EncounterSlot(EncounterArea Area, int Species, int Form, int LevelMin, int LevelMax) : IEncounterable, IEncounterMatch + public abstract record EncounterSlot(EncounterArea Area, int Species, int Form, byte LevelMin, byte LevelMax) : IEncounterable, IEncounterMatch { public abstract int Generation { get; } public bool EggEncounter => false; @@ -39,7 +39,7 @@ public abstract record EncounterSlot(EncounterArea Area, int Species, int Form, /// Highest value the low end of levels can be /// Lowest value the high end of levels can be /// True if within slot's range, false if impossible. - public bool IsLevelWithinRange(int min, int max) => LevelMin <= max && min <= LevelMax; + public bool IsLevelWithinRange(byte min, byte max) => LevelMin <= max && min <= LevelMax; /// /// Gets if the specified level inputs are within range of the and @@ -58,7 +58,7 @@ public abstract record EncounterSlot(EncounterArea Area, int Species, int Form, /// Highest value the low end of levels can be /// Lowest value the high end of levels can be /// True if within slot's range, false if impossible. - public bool IsLevelWithinRange(int min, int max, int minDecrease, int maxIncrease) => LevelMin - minDecrease <= max && min <= LevelMax + maxIncrease; + public bool IsLevelWithinRange(byte min, byte max, int minDecrease, int maxIncrease) => LevelMin - minDecrease <= max && min <= LevelMax + maxIncrease; public virtual string LongName { diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs index be0985db9..210a1095b 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot1.cs @@ -10,7 +10,7 @@ public sealed record EncounterSlot1 : EncounterSlot, INumberedSlot public byte SlotNumber { get; } public override Ball FixedBall => Ball.Poke; - public EncounterSlot1(EncounterArea1 area, int species, int min, int max, byte slot) : base(area, species, 0, min, max) + public EncounterSlot1(EncounterArea1 area, byte species, byte min, byte max, byte slot) : base(area, species, 0, min, max) { SlotNumber = slot; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs index 2badd7c22..b8b76cad9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot2.cs @@ -15,7 +15,7 @@ public sealed record EncounterSlot2 : EncounterSlot, INumberedSlot public byte SlotNumber { get; } public override Ball FixedBall => Ball.Poke; - public EncounterSlot2(EncounterArea2 area, int species, int min, int max, byte slot) : base(area, species, species == 201 ? FormRandom : 0, min, max) + public EncounterSlot2(EncounterArea2 area, byte species, byte min, byte max, byte slot) : base(area, species, species == 201 ? FormRandom : 0, min, max) { SlotNumber = slot; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs index 892ff89a8..991704046 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3.cs @@ -17,7 +17,7 @@ public record EncounterSlot3 : EncounterSlot, IMagnetStatic, INumberedSlot, ISlo public byte SlotNumber { get; } public override Ball FixedBall => Locations.IsSafariZoneLocation3(Location) ? Ball.Safari : Ball.None; - public EncounterSlot3(EncounterArea3 area, int species, int form, int min, int max, byte slot, byte mpi, byte mpc, byte sti, byte stc) : base(area, species, form, min, max) + public EncounterSlot3(EncounterArea3 area, ushort species, byte form, byte min, byte max, byte slot, byte mpi, byte mpc, byte sti, byte stc) : base(area, species, form, min, max) { SlotNumber = slot; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs index 266ccdbc1..4805551f7 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3PokeSpot.cs @@ -10,7 +10,7 @@ public sealed record EncounterSlot3PokeSpot : EncounterSlot, INumberedSlot public byte SlotNumber { get; } - public EncounterSlot3PokeSpot(EncounterArea3XD area, int species, int min, int max, byte slot) : base(area, species, 0, min, max) + public EncounterSlot3PokeSpot(EncounterArea3XD area, int species, byte min, byte max, byte slot) : base(area, species, 0, min, max) { SlotNumber = slot; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs index ac59c0a65..ab1f1f95c 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot3Swarm.cs @@ -13,7 +13,7 @@ internal sealed record EncounterSlot3Swarm : EncounterSlot3, IMoveset { public IReadOnlyList Moves { get; } - public EncounterSlot3Swarm(EncounterArea3 area, int species, int min, int max, byte slot, + public EncounterSlot3Swarm(EncounterArea3 area, ushort species, byte min, byte max, byte slot, IReadOnlyList moves) : base(area, species, 0, min, max, slot, 0, 0, 0, 0) => Moves = moves; protected override void SetEncounterMoves(PKM pk, GameVersion version, int level) diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs index 0470ec4fc..a85b36779 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot4.cs @@ -19,7 +19,7 @@ public sealed record EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlo public override Ball FixedBall => GetRequiredBallValue(); public bool CanUseRadar => !GameVersion.HGSS.Contains(Version) && GroundTile.HasFlag(GroundTilePermission.Grass); - public EncounterSlot4(EncounterArea4 area, int species, int form, int min, int max, byte slot, byte mpi, byte mpc, byte sti, byte stc) : base(area, species, form, min, max) + public EncounterSlot4(EncounterArea4 area, ushort species, byte form, byte min, byte max, byte slot, byte mpi, byte mpc, byte sti, byte stc) : base(area, species, form, min, max) { SlotNumber = slot; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs index 1f46df7d9..5b3eacca3 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot5.cs @@ -8,7 +8,7 @@ public sealed record EncounterSlot5 : EncounterSlot { public override int Generation => 5; - public EncounterSlot5(EncounterArea5 area, int species, int form, int min, int max) : base(area, species, form, min, max) + public EncounterSlot5(EncounterArea5 area, ushort species, byte form, byte min, byte max) : base(area, species, form, min, max) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs index 9f1ee9e95..e48604162 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6AO.cs @@ -15,7 +15,7 @@ public sealed record EncounterSlot6AO : EncounterSlot public bool WhiteFlute { get; init; } public bool BlackFlute { get; init; } - public EncounterSlot6AO(EncounterArea6AO area, int species, int form, int min, int max) : base(area, species, form, min, max) + public EncounterSlot6AO(EncounterArea6AO area, ushort species, byte form, byte min, byte max) : base(area, species, form, min, max) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs index b805f7a39..b837ad4fc 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs @@ -11,7 +11,7 @@ public sealed record EncounterSlot6XY : EncounterSlot public bool IsFriendSafari => Area.Type == SlotType.FriendSafari; public bool IsHorde => Area.Type == SlotType.Horde; - public EncounterSlot6XY(EncounterArea6XY area, int species, int form, int min, int max) : base(area, species, form, min, max) + public EncounterSlot6XY(EncounterArea6XY area, int species, int form, byte min, byte max) : base(area, species, form, min, max) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs index 1ee3de9ec..2a4b66ee9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7.cs @@ -9,7 +9,7 @@ public sealed record EncounterSlot7 : EncounterSlot public override int Generation => 7; public bool IsSOS => Area.Type == SlotType.SOS; - public EncounterSlot7(EncounterArea7 area, int species, int form, int min, int max) : base(area, species, form, min, max) + public EncounterSlot7(EncounterArea7 area, ushort species, byte form, byte min, byte max) : base(area, species, form, min, max) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs index b48355196..ee5eb14f1 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot7b.cs @@ -8,7 +8,7 @@ public sealed record EncounterSlot7b : EncounterSlot { public override int Generation => 7; - public EncounterSlot7b(EncounterArea7b area, int species, int min, int max) : base(area, species, 0, min, max) + public EncounterSlot7b(EncounterArea7b area, int species, byte min, byte max) : base(area, species, 0, min, max) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs index 6342bd99d..80164d9be 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8.cs @@ -13,7 +13,7 @@ public sealed record EncounterSlot8 : EncounterSlot, IOverworldCorrelation8 public override string LongName => $"{wild} [{SlotType}] - {Weather.ToString().Replace("_", string.Empty)}"; public override int Generation => 8; - public EncounterSlot8(EncounterArea8 area, int species, int form, int min, int max, AreaWeather8 weather, AreaSlotType8 slotType) : base(area, species, form, min, max) + public EncounterSlot8(EncounterArea8 area, ushort species, byte form, byte min, byte max, AreaWeather8 weather, AreaSlotType8 slotType) : base(area, species, form, min, max) { Weather = weather; SlotType = slotType; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs index 939e99b23..e49ca79e5 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs @@ -16,7 +16,7 @@ public sealed record EncounterSlot8a : EncounterSlot, IAlpha public Gender Gender { get; } public byte AlphaType { get; } // 0=Never, 1=Random, 2=Guaranteed - public EncounterSlot8a(EncounterArea8a area, int species, int form, int min, int max, byte alphaType, byte flawlessIVs, Gender gender) : base(area, species, form, min, max) + public EncounterSlot8a(EncounterArea8a area, ushort species, byte form, byte min, byte max, byte alphaType, byte flawlessIVs, Gender gender) : base(area, species, form, min, max) { AlphaType = alphaType; FlawlessIVCount = flawlessIVs; diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8b.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8b.cs index e5b43d45f..c74ca4793 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8b.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8b.cs @@ -15,7 +15,7 @@ public sealed record EncounterSlot8b : EncounterSlot public readonly bool IsBCAT; public override Ball FixedBall => IsMarsh ? Ball.Safari : Ball.None; - public EncounterSlot8b(EncounterArea area, int species, int form, int min, int max, bool isBCAT = false) : base(area, species, form, min, max) + public EncounterSlot8b(EncounterArea area, ushort species, byte form, byte min, byte max, bool isBCAT = false) : base(area, species, form, min, max) { IsBCAT = isBCAT; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/PogoType.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/PogoType.cs index ec970382f..f8c82fced 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/PogoType.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/GO/PogoType.cs @@ -48,7 +48,7 @@ public static class PogoTypeExtensions /// Gets the minimum level (relative to GO's 1-) the must have. /// /// Descriptor indicating how the Pokémon was encountered in GO. - public static int GetMinLevel(this PogoType encounterType) => encounterType switch + public static byte GetMinLevel(this PogoType encounterType) => encounterType switch { PogoType.EggS => 8, PogoType.Raid => 20, diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs index 279848bd1..7c2f21378 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core /// /// Intermediary Representation of Dream World Data /// - internal record DreamWorldEntry(int Species, int Level, ushort Move1 = 0, ushort Move2 = 0, ushort Move3 = 0, byte Form = 0, sbyte Gender = -1) + internal record DreamWorldEntry(ushort Species, byte Level, ushort Move1 = 0, ushort Move2 = 0, ushort Move3 = 0, byte Form = 0, sbyte Gender = -1) { private int EntryCount => Move1 == 0 ? 1 : Move2 == 0 ? 1 : Move3 == 0 ? 2 : 3; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs index 797d63f29..e1d778a1f 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs @@ -13,9 +13,9 @@ public abstract record EncounterStatic(GameVersion Version) : IEncounterable, IM { 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 virtual byte Level { get; init; } + public virtual byte LevelMin => Level; + public virtual byte LevelMax => Level; public abstract int Generation { get; } public virtual int Location { get; init; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs index 247cc5b85..50f17e375 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1.cs @@ -7,11 +7,11 @@ public record EncounterStatic1 : EncounterStatic { public override int Generation => 1; - public sealed override int Level { get; init; } + public sealed override byte Level { get; init; } private const int LightBallPikachuCatchRate = 0xA3; // 163 - public EncounterStatic1(int species, int level, GameVersion game) : base(game) + public EncounterStatic1(byte species, byte level, GameVersion game) : base(game) { Species = species; Level = level; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs index 6c819032c..a424b3ef6 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic1E.cs @@ -20,7 +20,7 @@ public sealed record EncounterStatic1E : EncounterStatic1, IFixedGBLanguage /// Trainer ID for the event. public int TID { get; init; } = -1; - public EncounterStatic1E(int species, int level, GameVersion game) : base(species, level, game) + public EncounterStatic1E(byte species, byte level, GameVersion game) : base(species, level, game) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs index a3a72f0eb..73ba84002 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2.cs @@ -9,9 +9,9 @@ namespace PKHeX.Core public record EncounterStatic2 : EncounterStatic { public sealed override int Generation => 2; - public sealed override int Level { get; init; } + public sealed override byte Level { get; init; } - public EncounterStatic2(int species, int level, GameVersion game) : base(game) + public EncounterStatic2(byte species, byte level, GameVersion game) : base(game) { Species = species; Level = level; @@ -98,7 +98,7 @@ protected override void SetMetData(PKM pk, int level, DateTime today) public sealed record EncounterStatic2Odd : EncounterStatic2 { - public EncounterStatic2Odd(int species) : base(species, 5, GameVersion.C) + public EncounterStatic2Odd(byte species) : base(species, 5, GameVersion.C) { EggLocation = 256; EggCycles = 20; @@ -125,7 +125,7 @@ public sealed record EncounterStatic2Roam : EncounterStatic2 private const ulong RoamLocations = 0b10_1000_1010_0100_0000_0110_0011_0100_1000_1001_0011_0100; public override int Location => 2; - public EncounterStatic2Roam(int species, int level, GameVersion ver) : base(species, level, ver) { } + public EncounterStatic2Roam(byte species, byte level, GameVersion ver) : base(species, level, ver) { } protected override bool IsMatchLocation(PKM pkm) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs index 53c64715a..a5c079c8f 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic2E.cs @@ -24,7 +24,7 @@ public sealed record EncounterStatic2E : EncounterStatic2, IFixedGBLanguage public int CurrentLevel { get; init; } = -1; - public EncounterStatic2E(int species, int level, GameVersion ver) : base(species, level, ver) + public EncounterStatic2E(byte species, byte level, GameVersion ver) : base(species, level, ver) { } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs index 161aa31f5..9d92672e2 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic3.cs @@ -12,7 +12,7 @@ public sealed record EncounterStatic3 : EncounterStatic public override int Generation => 3; public bool Roaming { get; init; } - public EncounterStatic3(int species, int level, GameVersion game) : base(game) + public EncounterStatic3(ushort species, byte level, GameVersion game) : base(game) { Species = species; Level = level; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs index 19e9d2a8e..575e1494d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic4Pokewalker.cs @@ -8,7 +8,7 @@ public sealed record EncounterStatic4Pokewalker : EncounterStatic { public override int Generation => 4; - public EncounterStatic4Pokewalker(int species, sbyte gender, int level) : base(GameVersion.HGSS) + public EncounterStatic4Pokewalker(ushort species, sbyte gender, byte level) : base(GameVersion.HGSS) { Species = species; Gender = gender; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs index 74e0242f0..0eb245d12 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic7.cs @@ -58,7 +58,7 @@ protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteri pk.SetRandomEC(); } - internal static EncounterStatic7 GetVC1(int species, int metLevel) + internal static EncounterStatic7 GetVC1(int species, byte metLevel) { bool mew = species == (int)Core.Species.Mew; return new EncounterStatic7(GameVersion.RBY) @@ -74,7 +74,7 @@ internal static EncounterStatic7 GetVC1(int species, int metLevel) }; } - internal static EncounterStatic7 GetVC2(int species, int metLevel) + internal static EncounterStatic7 GetVC2(int species, byte metLevel) { bool mew = species == (int)Core.Species.Mew; bool fateful = mew || species == (int)Core.Species.Celebi; diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs index f9603daea..0f0e3867e 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8N.cs @@ -16,9 +16,9 @@ public sealed record EncounterStatic8N : EncounterStatic8Nest private IReadOnlyList NestLocations => Encounters8Nest.NestLocations[NestID]; - public override int Level { get => LevelMin; init { } } - public override int LevelMin => LevelCaps[MinRank * 2]; - public override int LevelMax => LevelCaps[(MaxRank * 2) + 1]; + public override byte Level { get => LevelMin; init { } } + public override byte LevelMin => LevelCaps[MinRank * 2]; + public override byte LevelMax => LevelCaps[(MaxRank * 2) + 1]; public EncounterStatic8N(byte nestID, uint minRank, uint maxRank, byte val, GameVersion game) : base(game) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs index 58619d28d..8115a5382 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8U.cs @@ -10,7 +10,7 @@ public sealed record EncounterStatic8U : EncounterStatic8Nest { public override int Location { get => MaxLair; init { } } - public EncounterStatic8U(int species, int form, int level) : base(GameVersion.SWSH) // no difference in met location for hosted raids + public EncounterStatic8U(ushort species, byte form, byte level) : base(GameVersion.SWSH) // no difference in met location for hosted raids { Species = species; Form = form; diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs index 793ee1fa9..9568e8462 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs @@ -14,9 +14,9 @@ public abstract record EncounterTrade(GameVersion Version) : IEncounterable, IMo { 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 byte Level { get; init; } + public virtual byte LevelMin => Level; + public byte LevelMax => 100; public abstract int Generation { get; } public int CurrentLevel { get; init; } = -1; @@ -81,7 +81,7 @@ protected virtual void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria int lang = (int)Language.GetSafeLanguage(Generation, (LanguageID)sav.Language, version); int level = CurrentLevel > 0 ? CurrentLevel : LevelMin; if (level == 0) - level = Math.Max(1, LevelMin); + level = Math.Max((byte)1, LevelMin); int species = Species; if (EvolveOnTrade) diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade1.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade1.cs index 27e1cc64e..ac78d6e38 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade1.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade1.cs @@ -12,14 +12,14 @@ namespace PKHeX.Core public sealed record EncounterTrade1 : EncounterTradeGB { public override int Generation => 1; - public override int LevelMin => CanObtainMinGSC() ? LevelMinGSC : LevelMinRBY; + public override byte LevelMin => CanObtainMinGSC() ? LevelMinGSC : LevelMinRBY; - private readonly int LevelMinRBY; - private readonly int LevelMinGSC; + private readonly byte LevelMinRBY; + private readonly byte LevelMinGSC; public override int Location => 0; public override Shiny Shiny => Shiny.Random; - public EncounterTrade1(int species, GameVersion game, int rby, int gsc) : base(species, gsc, game) + public EncounterTrade1(int species, GameVersion game, byte rby, byte gsc) : base(species, gsc, game) { TrainerNames = StringConverter12.G1TradeOTName; @@ -27,7 +27,7 @@ public EncounterTrade1(int species, GameVersion game, int rby, int gsc) : base(s LevelMinGSC = gsc; } - public EncounterTrade1(int species, GameVersion game, int rby) : this(species, game, rby, rby) { } + public EncounterTrade1(int species, GameVersion game, byte rby) : this(species, game, rby, rby) { } public byte GetInitialCatchRate() { diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs index 960c04902..90535f554 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs @@ -11,7 +11,7 @@ public sealed record EncounterTrade2 : EncounterTradeGB public override int Generation => 2; public override int Location => Locations.LinkTrade2NPC; - public EncounterTrade2(int species, int level, ushort tid) : base(species, level, GameVersion.GSC) + public EncounterTrade2(ushort species, byte level, ushort tid) : base(species, level, GameVersion.GSC) { TID = tid; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade3.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade3.cs index 7db0d5a34..48ec08b6f 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade3.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade3.cs @@ -38,7 +38,7 @@ public IReadOnlyList Contest } } - public EncounterTrade3(GameVersion game, uint pid, int species, int level) : base(game) + public EncounterTrade3(GameVersion game, uint pid, ushort species, byte level) : base(game) { PID = pid; Species = species; diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade4.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade4.cs index 0e7e7eb2b..b272fe12b 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade4.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade4.cs @@ -24,7 +24,7 @@ public sealed record EncounterTrade4PID : EncounterTrade4, IContestStats public override Shiny Shiny => Shiny.FixedValue; - public EncounterTrade4PID(GameVersion game, uint pid, int species, int level) : base(game) + public EncounterTrade4PID(GameVersion game, uint pid, ushort species, byte level) : base(game) { PID = pid; Species = species; @@ -119,7 +119,7 @@ public sealed record EncounterTrade4RanchGift : EncounterTrade4 public override int Location => MetLocation; public override Shiny Shiny => Shiny.FixedValue; - public EncounterTrade4RanchGift(uint pid, int species, int level) : base(GameVersion.D) + public EncounterTrade4RanchGift(uint pid, ushort species, byte level) : base(GameVersion.D) { PID = pid; Species = species; @@ -150,7 +150,7 @@ public sealed record EncounterTrade4RanchSpecial : EncounterTrade4 { public override int Location => 3000; - public EncounterTrade4RanchSpecial(int species, int level) : base(GameVersion.D) + public EncounterTrade4RanchSpecial(ushort species, byte level) : base(GameVersion.D) { Species = species; Level = level; diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs index 8ea5db08f..f64dca98b 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs @@ -21,7 +21,7 @@ public sealed record EncounterTrade8 : EncounterTrade, IDynamaxLevel, IRelearn, public byte FlawlessIVCount { get; init; } public override Shiny Shiny { get; } - public EncounterTrade8(GameVersion game, int species, int level, byte memory, ushort arg, byte feel, byte intensity, Shiny shiny = Shiny.Never) : base(game) + public EncounterTrade8(GameVersion game, int species, byte level, byte memory, ushort arg, byte feel, byte intensity, Shiny shiny = Shiny.Never) : base(game) { Species = species; Level = level; diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTradeGB.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTradeGB.cs index 12e31e573..12bc76571 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTradeGB.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTradeGB.cs @@ -3,7 +3,7 @@ /// public abstract record EncounterTradeGB : EncounterTrade { - protected EncounterTradeGB(int species, int level, GameVersion game) : base(game) + protected EncounterTradeGB(int species, byte level, GameVersion game) : base(game) { Species = species; Level = level; diff --git a/PKHeX.Core/Legality/Encounters/Generator/Specific/EncounterEggGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/Specific/EncounterEggGenerator.cs index aa02807d7..c08e9b005 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Specific/EncounterEggGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Specific/EncounterEggGenerator.cs @@ -30,7 +30,7 @@ public static IEnumerable GenerateEggs(PKM pkm, IReadOnlyList GetMatchingStaticEncounters(PKM pkm, internal static EncounterStatic7 GetVCStaticTransferEncounter(PKM pkm, IEncounterTemplate enc, IReadOnlyList chain) { // Obtain the lowest evolution species with matching OT friendship. Not all species chains have the same base friendship. - var met = pkm.Met_Level; + var met = (byte)pkm.Met_Level; if (pkm.VC1) { // Only yield a VC1 template if it could originate in VC1. @@ -123,9 +123,9 @@ internal static EncounterStatic7 GetVCStaticTransferEncounter(PKM pkm, IEncounte switch (pkm.Generation) { case 1: - return EncounterStatic7.GetVC1(MaxSpeciesID_1, pkm.Met_Level); + return EncounterStatic7.GetVC1(MaxSpeciesID_1, (byte)pkm.Met_Level); case 2: - return EncounterStatic7.GetVC2(MaxSpeciesID_2, pkm.Met_Level); + return EncounterStatic7.GetVC2(MaxSpeciesID_2, (byte)pkm.Met_Level); default: return GetPossible(pkm, chain) .OrderBy(z => !chain.Any(s => s.Species == z.Species && s.Form == z.Form)) diff --git a/PKHeX.Core/Legality/Encounters/IEncounterTemplate.cs b/PKHeX.Core/Legality/Encounters/IEncounterTemplate.cs index 8c48799dc..02da0d657 100644 --- a/PKHeX.Core/Legality/Encounters/IEncounterTemplate.cs +++ b/PKHeX.Core/Legality/Encounters/IEncounterTemplate.cs @@ -10,8 +10,8 @@ public interface IEncounterTemplate : ISpeciesForm, IVersion, IGeneration, IShin /// /// Minimum level for the encounter. /// - int LevelMin { get; } - int LevelMax { get; } + byte LevelMin { get; } + byte LevelMax { get; } } public static partial class Extensions diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs index 6f1011b46..af173b094 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs @@ -165,7 +165,7 @@ internal static int GetEvoChainSpeciesIndex(IReadOnlyList chain, in private static List GetEvolutionChain(PKM pkm, IEncounterTemplate enc, int mostEvolvedSpecies, int maxlevel) { - var min = enc.LevelMin; + int min = enc.LevelMin; if (pkm.HasOriginalMetLocation && pkm.Met_Level != 0) min = pkm.Met_Level; var chain = GetValidPreEvolutions(pkm, minLevel: min); diff --git a/PKHeX.Core/Legality/Verifiers/Egg/EggStateLegality.cs b/PKHeX.Core/Legality/Verifiers/Egg/EggStateLegality.cs index edaa19998..85b79aeca 100644 --- a/PKHeX.Core/Legality/Verifiers/Egg/EggStateLegality.cs +++ b/PKHeX.Core/Legality/Verifiers/Egg/EggStateLegality.cs @@ -63,7 +63,7 @@ public static int GetMaximumEggHatchCycles(PKM pk, IEncounterTemplate enc) /// Level which eggs are given to the player. /// /// Generation the egg is given in - public static int GetEggLevel(int generation) => generation >= 4 ? 1 : 5; + public static byte GetEggLevel(int generation) => generation >= 4 ? (byte)1 : (byte)5; /// /// Met Level which eggs are given to the player. May change if transferred to future games. diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index 599fb81b5..57cba7af4 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -152,9 +152,9 @@ public virtual Shiny Shiny public abstract string OT_Name { get; set; } public abstract int Location { get; set; } - public abstract int Level { get; set; } - public int LevelMin => Level; - public int LevelMax => Level; + public abstract byte Level { get; set; } + public byte LevelMin => Level; + public byte LevelMax => Level; public abstract int Ball { get; set; } public virtual bool EggEncounter => IsEgg; public abstract int EggLocation { get; set; } diff --git a/PKHeX.Core/MysteryGifts/PCD.cs b/PKHeX.Core/MysteryGifts/PCD.cs index 2aeac10bb..e6db67deb 100644 --- a/PKHeX.Core/MysteryGifts/PCD.cs +++ b/PKHeX.Core/MysteryGifts/PCD.cs @@ -18,7 +18,7 @@ public sealed class PCD : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4 public const int Size = 0x358; // 856 public override int Generation => 4; - public override int Level + public override byte Level { get => Gift.Level; set => Gift.Level = value; diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs index 2e2a620f9..4471a7fc5 100644 --- a/PKHeX.Core/MysteryGifts/PGF.cs +++ b/PKHeX.Core/MysteryGifts/PGF.cs @@ -83,7 +83,7 @@ public override string OT_Name } public int OTGender { get => Data[0x5A]; set => Data[0x5A] = (byte)value; } - public override int Level { get => Data[0x5B]; set => Data[0x5C] = (byte)value; } + public override byte Level { get => Data[0x5B]; set => Data[0x5C] = value; } public override bool IsEgg { get => Data[0x5C] == 1; set => Data[0x5C] = value ? (byte)1 : (byte)0; } // Unused 0x5D 0x5E 0x5F public override string CardTitle diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs index 7802f9fa0..314107743 100644 --- a/PKHeX.Core/MysteryGifts/PGT.cs +++ b/PKHeX.Core/MysteryGifts/PGT.cs @@ -13,9 +13,9 @@ public sealed class PGT : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4 public const int Size = 0x104; // 260 public override int Generation => 4; - public override int Level + public override byte Level { - get => IsManaphyEgg ? 1 : IsPokémon ? PK.Met_Level : 0; + get => IsManaphyEgg ? (byte)1 : IsPokémon ? (byte)PK.Met_Level : (byte)0; set { if (IsPokémon) PK.Met_Level = value; } } diff --git a/PKHeX.Core/MysteryGifts/PL6.cs b/PKHeX.Core/MysteryGifts/PL6.cs index e667cdedc..f250f4978 100644 --- a/PKHeX.Core/MysteryGifts/PL6.cs +++ b/PKHeX.Core/MysteryGifts/PL6.cs @@ -113,7 +113,7 @@ public string Nickname public int PIDType { get => Data[0x3B]; set => Data[0x3B] = (byte)value; } public int EggLocation { get => ReadUInt16LittleEndian(Data.AsSpan(0x3C)); set => WriteUInt16LittleEndian(Data.AsSpan(0x3C), (ushort)value); } public int MetLocation { get => ReadUInt16LittleEndian(Data.AsSpan(0x3E)); set => WriteUInt16LittleEndian(Data.AsSpan(0x3E), (ushort)value); } - public int MetLevel { get => Data[0x40]; set => Data[0x40] = (byte)value; } + public byte MetLevel { get => Data[0x40]; set => Data[0x40] = value; } public int CNT_Cool { get => Data[0x41]; set => Data[0x41] = (byte)value; } public int CNT_Beauty { get => Data[0x42]; set => Data[0x42] = (byte)value; } @@ -169,8 +169,8 @@ public string OT public bool RibbonPremier { get => (RIB1 & (1 << 6)) == 1 << 6; set => RIB1 = (byte)((RIB1 & ~(1 << 6)) | (value ? 1 << 6 : 0)); } public bool RIB1_7 { get => (RIB1 & (1 << 7)) == 1 << 7; set => RIB1 = (byte)((RIB1 & ~(1 << 7)) | (value ? 1 << 7 : 0)); } - public int LevelMin => MetLevel; - public int LevelMax => MetLevel; + public byte LevelMin => MetLevel; + public byte LevelMax => MetLevel; public IReadOnlyList Moves { diff --git a/PKHeX.Core/MysteryGifts/WA8.cs b/PKHeX.Core/MysteryGifts/WA8.cs index 7312dae93..25164953f 100644 --- a/PKHeX.Core/MysteryGifts/WA8.cs +++ b/PKHeX.Core/MysteryGifts/WA8.cs @@ -161,7 +161,7 @@ public override int HeldItem public override int Species { get => ReadUInt16LittleEndian(Data.AsSpan(0x238)); set => WriteUInt16LittleEndian(Data.AsSpan(0x238), (ushort)value); } public override int Form { get => Data[0x23A]; set => Data[0x23A] = (byte)value; } public override int Gender { get => Data[0x23B]; set => Data[0x23B] = (byte)value; } - public override int Level { get => Data[0x23C]; set => Data[0x23C] = (byte)value; } + public override byte Level { get => Data[0x23C]; set => Data[0x23C] = value; } public override bool IsEgg { get => Data[0x23D] == 1; set => Data[0x23D] = value ? (byte)1 : (byte)0; } public int Nature { get => (sbyte)Data[0x23E]; set => Data[0x23E] = (byte)value; } public override int AbilityType { get => Data[0x23F]; set => Data[0x23F] = (byte)value; } diff --git a/PKHeX.Core/MysteryGifts/WB7.cs b/PKHeX.Core/MysteryGifts/WB7.cs index 6291a943e..2f2ed166d 100644 --- a/PKHeX.Core/MysteryGifts/WB7.cs +++ b/PKHeX.Core/MysteryGifts/WB7.cs @@ -207,7 +207,7 @@ public override int Ball // set => Encoding.Unicode.GetBytes(value.PadRight(value.Length + 1, '\0')).CopyTo(Data, CardStart + 0xB6); // } - public override int Level { get => Data[CardStart + 0xD0]; set => Data[CardStart + 0xD0] = (byte)value; } + public override byte Level { get => Data[CardStart + 0xD0]; set => Data[CardStart + 0xD0] = value; } public override bool IsEgg { get => Data[CardStart + 0xD1] == 1; set => Data[CardStart + 0xD1] = value ? (byte)1 : (byte)0; } public ushort AdditionalItem { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0xD2)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0xD2), value); } diff --git a/PKHeX.Core/MysteryGifts/WB8.cs b/PKHeX.Core/MysteryGifts/WB8.cs index 55d1b4d65..4879dcdb5 100644 --- a/PKHeX.Core/MysteryGifts/WB8.cs +++ b/PKHeX.Core/MysteryGifts/WB8.cs @@ -172,7 +172,7 @@ public override int HeldItem public override int Species { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x288)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x288), (ushort)value); } public override int Form { get => Data[CardStart + 0x28A]; set => Data[CardStart + 0x28A] = (byte)value; } public override int Gender { get => Data[CardStart + 0x28B]; set => Data[CardStart + 0x28B] = (byte)value; } - public override int Level { get => Data[CardStart + 0x28C]; set => Data[CardStart + 0x28C] = (byte)value; } + public override byte Level { get => Data[CardStart + 0x28C]; set => Data[CardStart + 0x28C] = value; } public override bool IsEgg { get => Data[CardStart + 0x28D] == 1; set => Data[CardStart + 0x28D] = value ? (byte)1 : (byte)0; } public int Nature { get => (sbyte)Data[CardStart + 0x28E]; set => Data[CardStart + 0x28E] = (byte)value; } public override int AbilityType { get => Data[CardStart + 0x28F]; set => Data[CardStart + 0x28F] = (byte)value; } diff --git a/PKHeX.Core/MysteryGifts/WC3.cs b/PKHeX.Core/MysteryGifts/WC3.cs index ae5817d21..3161c0c9f 100644 --- a/PKHeX.Core/MysteryGifts/WC3.cs +++ b/PKHeX.Core/MysteryGifts/WC3.cs @@ -37,7 +37,7 @@ public sealed class WC3 : MysteryGift, IRibbonSetEvent3, ILangNicknamedTemplate // Mystery Gift Properties public override int Generation => 3; - public override int Level { get; set; } + public override byte Level { get; set; } public override int Ball { get; set; } = 4; public override bool IsShiny => Shiny == Shiny.Always; public bool RibbonEarth { get; set; } diff --git a/PKHeX.Core/MysteryGifts/WC6.cs b/PKHeX.Core/MysteryGifts/WC6.cs index 3ae77d7b0..e36cadfaf 100644 --- a/PKHeX.Core/MysteryGifts/WC6.cs +++ b/PKHeX.Core/MysteryGifts/WC6.cs @@ -206,7 +206,7 @@ public override string OT_Name set => StringConverter6.SetString(Data.AsSpan(0xB6, 0x1A), value.AsSpan(), 12, StringConverterOption.ClearZero); } - public override int Level { get => Data[0xD0]; set => Data[0xD0] = (byte)value; } + public override byte Level { get => Data[0xD0]; set => Data[0xD0] = value; } public override bool IsEgg { get => Data[0xD1] == 1; set => Data[0xD1] = value ? (byte)1 : (byte)0; } public uint PID { get => ReadUInt32LittleEndian(Data.AsSpan(0xD4)); set => WriteUInt32LittleEndian(Data.AsSpan(0xD4), value); } diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs index 1869f139b..cc570ce8e 100644 --- a/PKHeX.Core/MysteryGifts/WC7.cs +++ b/PKHeX.Core/MysteryGifts/WC7.cs @@ -247,7 +247,7 @@ public override string OT_Name set => StringConverter7.SetString(Data.AsSpan(0xB6, 0x1A), value.AsSpan(), 12, Language, StringConverterOption.ClearZero); } - public override int Level { get => Data[0xD0]; set => Data[0xD0] = (byte)value; } + public override byte Level { get => Data[0xD0]; set => Data[0xD0] = value; } public override bool IsEgg { get => Data[0xD1] == 1; set => Data[0xD1] = value ? (byte)1 : (byte)0; } public ushort AdditionalItem { get => ReadUInt16LittleEndian(Data.AsSpan(0xD2)); set => WriteUInt16LittleEndian(Data.AsSpan(0xD2), value); } diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs index 523bb999b..39a0abe3d 100644 --- a/PKHeX.Core/MysteryGifts/WC8.cs +++ b/PKHeX.Core/MysteryGifts/WC8.cs @@ -168,7 +168,7 @@ public override int HeldItem public override int Species { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x240)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x240), (ushort)value); } public override int Form { get => Data[CardStart + 0x242]; set => Data[CardStart + 0x242] = (byte)value; } public override int Gender { get => Data[CardStart + 0x243]; set => Data[CardStart + 0x243] = (byte)value; } - public override int Level { get => Data[CardStart + 0x244]; set => Data[CardStart + 0x244] = (byte)value; } + public override byte Level { get => Data[CardStart + 0x244]; set => Data[CardStart + 0x244] = value; } public override bool IsEgg { get => Data[CardStart + 0x245] == 1; set => Data[CardStart + 0x245] = value ? (byte)1 : (byte)0; } public int Nature { get => (sbyte)Data[CardStart + 0x246]; set => Data[CardStart + 0x246] = (byte)value; } public override int AbilityType { get => Data[CardStart + 0x247]; set => Data[CardStart + 0x247] = (byte)value; } diff --git a/PKHeX.Core/MysteryGifts/WR7.cs b/PKHeX.Core/MysteryGifts/WR7.cs index 9a7d9b633..32202a431 100644 --- a/PKHeX.Core/MysteryGifts/WR7.cs +++ b/PKHeX.Core/MysteryGifts/WR7.cs @@ -64,10 +64,10 @@ public override int Species public override bool GiftUsed { get; set; } - public override int Level // are moves stored? mew has '1' but this could be move + public override byte Level // are moves stored? mew has '1' but this could be move { - get => ReadUInt16LittleEndian(Data.AsSpan(0x10E)); - set => WriteUInt16LittleEndian(Data.AsSpan(0x10E), (ushort)value); + get => Data[0x10E]; + set => Data[0x10E] = value; } public override int ItemID { get => ReadUInt16LittleEndian(Data.AsSpan(0x110)); set => WriteUInt16LittleEndian(Data.AsSpan(0x110), (ushort)value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs b/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs index 461d14e06..4a3fbaf97 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/GP1.cs @@ -15,8 +15,8 @@ public sealed class GP1 : IEncounterInfo, IFixedAbilityNumber public GameVersion Version => GameVersion.GO; public bool EggEncounter => false; - public int LevelMin => Level; - public int LevelMax => Level; + public byte LevelMin => Level; + public byte LevelMax => Level; public int Generation => 7; public AbilityPermission Ability => AbilityPermission.Any12; public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPB7(sav); @@ -65,7 +65,7 @@ public static byte[] GetBlank() public int Species => ReadInt32LittleEndian(Data.AsSpan(0x28)); public int CP => ReadInt32LittleEndian(Data.AsSpan(0x2C)); public float LevelF => ReadSingleLittleEndian(Data.AsSpan(0x30)); - public int Level => Math.Max(1, (int)Math.Round(LevelF)); + public byte Level => Math.Max((byte)1, (byte)Math.Round(LevelF)); public int Stat_HP => ReadInt32LittleEndian(Data.AsSpan(0x34)); // geolocation data 0x38-0x47? public float HeightF => ReadSingleLittleEndian(Data.AsSpan(0x48));