Move version value from Slot to Area to reduce member size & value passing

Restrict some setters to protected only
This commit is contained in:
Kurt 2020-08-30 11:08:21 -07:00
parent 6ee7a8724b
commit ce5897ff94
29 changed files with 112 additions and 125 deletions

View File

@ -6,12 +6,15 @@ namespace PKHeX.Core
/// <summary>
/// Represents an Area where <see cref="PKM"/> can be encountered, which contains a Location ID and <see cref="EncounterSlot"/> data.
/// </summary>
public abstract class EncounterArea
public abstract class EncounterArea : IVersion
{
public GameVersion Version { get; }
public int Location { get; protected set; }
public SlotType Type { get; protected set; } = SlotType.Any;
public EncounterSlot[] Slots = Array.Empty<EncounterSlot>();
protected EncounterArea(GameVersion game) => Version = game;
/// <summary>
/// Gets the slots contained in the area that match the provided data.
/// </summary>

View File

@ -18,7 +18,7 @@ public static EncounterArea1[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea1(byte[] data, GameVersion game)
private EncounterArea1(byte[] data, GameVersion game) : base(game)
{
Location = data[0];
// 1 byte unused
@ -34,7 +34,7 @@ private EncounterArea1(byte[] data, GameVersion game)
int slotNum = data[offset + 1];
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot1(this, species, min, max, slotNum, game);
slots[i] = new EncounterSlot1(this, species, min, max, slotNum);
}
Slots = slots;
}

View File

@ -25,7 +25,7 @@ public static EncounterArea2[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea2(byte[] data, GameVersion game)
private EncounterArea2(byte[] data, GameVersion game) : base(game)
{
Location = data[0];
Time = (EncounterTime)data[1];
@ -42,7 +42,7 @@ private EncounterArea2(byte[] data, GameVersion game)
rates[i] = data[4 + i];
Rates = rates;
Slots = ReadSlots(data, count, 4 + count, game);
Slots = ReadSlots(data, count, 4 + count);
}
else
{
@ -51,11 +51,11 @@ private EncounterArea2(byte[] data, GameVersion game)
const int size = 4;
int count = (data.Length - 4) / size;
Rates = type == SlotType.BugContest ? BCC_SlotRates : (type == SlotType.Grass) ? RatesGrass : RatesSurf;
Slots = ReadSlots(data, count, 4, game);
Slots = ReadSlots(data, count, 4);
}
}
private EncounterSlot2[] ReadSlots(byte[] data, int count, int start, GameVersion game)
private EncounterSlot2[] ReadSlots(byte[] data, int count, int start)
{
var slots = new EncounterSlot2[count];
for (int i = 0; i < slots.Length; i++)
@ -65,7 +65,7 @@ private EncounterSlot2[] ReadSlots(byte[] data, int count, int start, GameVersio
int slotNum = data[offset + 1];
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot2(this, species, min, max, slotNum, game);
slots[i] = new EncounterSlot2(this, species, min, max, slotNum);
}
return slots;

View File

@ -11,8 +11,6 @@ public sealed class EncounterArea3 : EncounterArea
{
public readonly int Rate;
internal EncounterArea3() { }
public static EncounterArea3[] GetAreas(byte[][] input, GameVersion game)
{
var result = new EncounterArea3[input.Length];
@ -29,25 +27,25 @@ public static EncounterArea3[] GetAreasSwarm(byte[][] input, GameVersion game)
return result;
}
private EncounterArea3(byte[] data, GameVersion game)
private EncounterArea3(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = (SlotType)data[2];
Rate = data[3];
Slots = ReadRegularSlots(data, game);
Slots = ReadRegularSlots(data);
}
private EncounterArea3(byte[] data, GameVersion game, bool _)
private EncounterArea3(byte[] data, GameVersion game, bool _) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = SlotType.Swarm | SlotType.Grass;
Rate = data[3];
Slots = ReadSwarmSlots(data, game);
Slots = ReadSwarmSlots(data);
}
private EncounterSlot3[] ReadRegularSlots(byte[] data, GameVersion game)
private EncounterSlot3[] ReadRegularSlots(byte[] data)
{
const int size = 10;
int count = (data.Length - 4) / size;
@ -66,13 +64,13 @@ private EncounterSlot3[] ReadRegularSlots(byte[] data, GameVersion game)
int mpc = data[offset + 7];
int sti = data[offset + 8];
int stc = data[offset + 9];
slots[i] = new EncounterSlot3(this, species, form, min, max, slotNum, mpi, mpc, sti, stc, game);
slots[i] = new EncounterSlot3(this, species, form, min, max, slotNum, mpi, mpc, sti, stc);
}
return slots;
}
private EncounterSlot3[] ReadSwarmSlots(byte[] data, GameVersion game)
private EncounterSlot3[] ReadSwarmSlots(byte[] data)
{
const int size = 14;
int count = (data.Length - 4) / size;
@ -95,7 +93,7 @@ private EncounterSlot3[] ReadSwarmSlots(byte[] data, GameVersion game)
BitConverter.ToUInt16(data, offset + 12),
};
slots[i] = new EncounterSlot3Swarm(this, species, min, max, slotNum, game, moves);
slots[i] = new EncounterSlot3Swarm(this, species, min, max, slotNum, moves);
}
return slots;

View File

@ -9,7 +9,7 @@ namespace PKHeX.Core
/// </summary>
public sealed class EncounterArea3XD : EncounterArea
{
public EncounterArea3XD(int loc, int s0, int l0, int s1, int l1, int s2, int l2)
public EncounterArea3XD(int loc, int s0, int l0, int s1, int l1, int s2, int l2) : base(GameVersion.XD)
{
Location = loc;
Type = SlotType.Grass;

View File

@ -20,17 +20,17 @@ public static EncounterArea4[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea4(byte[] data, GameVersion game)
private EncounterArea4(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = (SlotType)data[2];
Rate = data[3];
TypeEncounter = (EncounterType) BitConverter.ToUInt16(data, 4);
Slots = ReadRegularSlots(data, game);
Slots = ReadRegularSlots(data);
}
private EncounterSlot4[] ReadRegularSlots(byte[] data, GameVersion game)
private EncounterSlot4[] ReadRegularSlots(byte[] data)
{
const int size = 10;
int count = (data.Length - 6) / size;
@ -49,7 +49,7 @@ private EncounterSlot4[] ReadRegularSlots(byte[] data, GameVersion game)
int mpc = data[offset + 7];
int sti = data[offset + 8];
int stc = data[offset + 9];
slots[i] = new EncounterSlot4(this, species, form, min, max, slotNum, mpi, mpc, sti, stc, game);
slots[i] = new EncounterSlot4(this, species, form, min, max, slotNum, mpi, mpc, sti, stc);
}
return slots;

View File

@ -17,15 +17,15 @@ public static EncounterArea5[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea5(byte[] data, GameVersion game)
private EncounterArea5(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = (SlotType)data[2];
Slots = ReadSlots(data, game);
Slots = ReadSlots(data);
}
private EncounterSlot5[] ReadSlots(byte[] data, GameVersion game)
private EncounterSlot5[] ReadSlots(byte[] data)
{
const int size = 4;
int count = (data.Length - 4) / size;
@ -38,7 +38,7 @@ private EncounterSlot5[] ReadSlots(byte[] data, GameVersion game)
int form = SpecForm >> 11;
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot5(this, species, form, min, max, game);
slots[i] = new EncounterSlot5(this, species, form, min, max);
}
return slots;

View File

@ -17,15 +17,15 @@ public static EncounterArea6AO[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea6AO(byte[] data, GameVersion game)
private EncounterArea6AO(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = (SlotType)data[2];
Slots = ReadSlots(data, game);
Slots = ReadSlots(data);
}
private EncounterSlot6AO[] ReadSlots(byte[] data, GameVersion game)
private EncounterSlot6AO[] ReadSlots(byte[] data)
{
const int size = 4;
int count = (data.Length - 4) / size;
@ -38,7 +38,7 @@ private EncounterSlot6AO[] ReadSlots(byte[] data, GameVersion game)
int form = SpecForm >> 11;
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot6AO(this, species, form, min, max, game);
slots[i] = new EncounterSlot6AO(this, species, form, min, max);
}
return slots;

View File

@ -17,7 +17,7 @@ public static EncounterArea6XY[] GetAreas(byte[][] input, GameVersion game)
return result;
}
public EncounterArea6XY(ICollection<int> species)
public EncounterArea6XY(ICollection<int> species) : base(GameVersion.XY)
{
Location = 148;
Type = SlotType.FriendSafari;
@ -25,19 +25,19 @@ public EncounterArea6XY(ICollection<int> species)
var slots = new EncounterSlot6XY[species.Count];
int ctr = 0;
foreach (var s in species)
slots[ctr++] = new EncounterSlot6XY(this, s, 0, 30, 30, GameVersion.XY);
slots[ctr++] = new EncounterSlot6XY(this, s, 0, 30, 30);
Slots = slots;
}
private EncounterArea6XY(byte[] data, GameVersion game)
private EncounterArea6XY(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = (SlotType)data[2];
Slots = ReadSlots(data, game);
Slots = ReadSlots(data);
}
private EncounterSlot6XY[] ReadSlots(byte[] data, GameVersion game)
private EncounterSlot6XY[] ReadSlots(byte[] data)
{
const int size = 4;
int count = (data.Length - 4) / size;
@ -50,7 +50,7 @@ private EncounterSlot6XY[] ReadSlots(byte[] data, GameVersion game)
int form = SpecForm >> 11;
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot6XY(this, species, form, min, max, game);
slots[i] = new EncounterSlot6XY(this, species, form, min, max);
}
return slots;
@ -83,10 +83,7 @@ public override IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, IReadOnlyLi
if (maxLevel != pkm.Met_Level)
break;
var clone = (EncounterSlot6XY)slot.Clone();
clone.Form = evo.Form;
clone.Pressure = true;
yield return clone;
yield return ((EncounterSlot6XY)slot).CreatePressureFormCopy(evo.Form);
break;
}

View File

@ -17,15 +17,15 @@ public static EncounterArea7[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea7(byte[] data, GameVersion game)
private EncounterArea7(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Type = (SlotType)data[2];
Slots = ReadSlots(data, game);
Slots = ReadSlots(data);
}
private EncounterSlot7[] ReadSlots(byte[] data, GameVersion game)
private EncounterSlot7[] ReadSlots(byte[] data)
{
const int size = 4;
int count = (data.Length - 4) / size;
@ -38,7 +38,7 @@ private EncounterSlot7[] ReadSlots(byte[] data, GameVersion game)
int form = SpecForm >> 11;
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot7(this, species, form, min, max, game);
slots[i] = new EncounterSlot7(this, species, form, min, max);
}
return slots;

View File

@ -17,13 +17,13 @@ public static EncounterArea7b[] GetAreas(byte[][] input, GameVersion game)
return result;
}
private EncounterArea7b(byte[] data, GameVersion game)
private EncounterArea7b(byte[] data, GameVersion game) : base(game)
{
Location = data[0] | (data[1] << 8);
Slots = ReadSlots(data, game);
Slots = ReadSlots(data);
}
private EncounterSlot7b[] ReadSlots(byte[] data, GameVersion game)
private EncounterSlot7b[] ReadSlots(byte[] data)
{
const int size = 4;
int count = (data.Length - 2) / size;
@ -35,7 +35,7 @@ private EncounterSlot7b[] ReadSlots(byte[] data, GameVersion game)
int species = SpecForm & 0x3FF;
int min = data[offset + 2];
int max = data[offset + 3];
slots[i] = new EncounterSlot7b(this, species, min, max, game);
slots[i] = new EncounterSlot7b(this, species, min, max);
}
return slots;

View File

@ -9,12 +9,14 @@ namespace PKHeX.Core
/// </summary>
public sealed class EncounterArea7g : EncounterArea
{
private EncounterArea7g() : base(GameVersion.GO) { }
internal static EncounterArea7g[] GetArea()
{
var area = new EncounterArea7g { Location = 50, Type = SlotType.GoPark };
static EncounterSlot GetSlot(EncounterArea7g area, int species, int form)
static EncounterSlot7GO GetSlot(EncounterArea7g area, int species, int form)
{
return new EncounterSlot7GO(area, species, form, 1, 40, GameVersion.GO);
return new EncounterSlot7GO(area, species, form, 1, 40);
}
var obtainable = Enumerable.Range(1, 150).Concat(Enumerable.Range(808, 2)); // count : 152
@ -47,11 +49,11 @@ static EncounterSlot GetSlot(EncounterArea7g area, int species, int form)
var alolan = AlolanKanto.Select(z => GetSlot(area, z, 1));
var slots = regular.Concat(alolan).ToArray();
slots[slots.Length - 1].LevelMin = 15; // Raichu
slots[(int)Species.Mewtwo - 1].LevelMin = 15;
slots[(int)Species.Articuno - 1].LevelMin = 15;
slots[(int)Species.Zapdos - 1].LevelMin = 15;
slots[(int)Species.Moltres - 1].LevelMin = 15;
slots[slots.Length - 1].ClampMinRaid(15); // Raichu
slots[(int)Species.Mewtwo - 1].ClampMinRaid(15);
slots[(int)Species.Articuno - 1].ClampMinRaid(15);
slots[(int)Species.Zapdos - 1].ClampMinRaid(15);
slots[(int)Species.Moltres - 1].ClampMinRaid(15);
area.Slots = slots;
return new[] { area };

View File

@ -8,7 +8,7 @@ namespace PKHeX.Core
/// <summary>
/// <see cref="GameVersion.SWSH"/> encounter area
/// </summary>
public sealed class EncounterArea8 : EncounterAreaSH
public sealed class EncounterArea8 : EncounterArea
{
/// <inheritdoc />
public override bool IsMatchLocation(int location)
@ -185,42 +185,35 @@ private IEnumerable<EncounterSlot> GetBoostedMatches(IReadOnlyList<EvoCriteria>
// Honeycalm Island
{192, new byte[] {194}},
};
}
public abstract class EncounterAreaSH : EncounterArea
{
/// <summary>
/// Slots from this area can cross over to another area, resulting in a different met location.
/// </summary>
public bool PermitCrossover { get; internal set; }
/// <summary>
/// Gets an array of areas from an array of raw area data
/// </summary>
/// <param name="entries">Simplified raw format of an Area</param>
/// <param name="game">Game of origin</param>
/// <returns>Array of areas</returns>
public static T[] GetArray<T>(byte[][] entries, GameVersion game) where T : EncounterAreaSH, new()
public static EncounterArea8[] GetAreas(byte[][] input, GameVersion game)
{
T[] data = new T[entries.Length];
for (int i = 0; i < data.Length; i++)
{
var loc = data[i] = new T();
loc.LoadSlots(entries[i], game);
}
return data;
var result = new EncounterArea8[input.Length];
for (int i = 0; i < input.Length; i++)
result[i] = new EncounterArea8(input[i], game);
return result;
}
private void LoadSlots(byte[] areaData, GameVersion game)
private EncounterArea8(byte[] areaData, GameVersion game) : base(game)
{
Location = areaData[0];
Slots = new EncounterSlot[areaData[1]];
Slots = ReadSlots(areaData, areaData[1]);
}
private EncounterSlot[] ReadSlots(byte[] areaData, byte slotCount)
{
var slots = new EncounterSlot[slotCount];
int ctr = 0;
int ofs = 2;
do
{
var flags = (AreaWeather8)BitConverter.ToUInt16(areaData, ofs);
var flags = (AreaWeather8) BitConverter.ToUInt16(areaData, ofs);
var min = areaData[ofs + 2];
var max = areaData[ofs + 3];
var count = areaData[ofs + 4];
@ -229,9 +222,11 @@ private void LoadSlots(byte[] areaData, GameVersion game)
for (int i = 0; i < count; i++, ctr++, ofs += 2)
{
var specForm = BitConverter.ToUInt16(areaData, ofs);
Slots[ctr] = new EncounterSlot8(this, specForm, min, max, flags, game);
slots[ctr] = new EncounterSlot8(this, specForm, min, max, flags);
}
} while (ctr != Slots.Length);
} while (ctr != slots.Length);
return slots;
}
}
@ -270,7 +265,7 @@ public sealed class EncounterSlot8 : EncounterSlot
public override string LongName => Weather == AreaWeather8.All ? wild : $"{wild} - {Weather.ToString().Replace("_", string.Empty)}";
public override int Generation => 8;
public EncounterSlot8(EncounterAreaSH area, int specForm, int min, int max, AreaWeather8 weather, GameVersion game) : base(area)
public EncounterSlot8(EncounterArea8 area, int specForm, int min, int max, AreaWeather8 weather) : base(area)
{
Species = specForm & 0x7FF;
Form = specForm >> 11;
@ -278,7 +273,6 @@ public EncounterSlot8(EncounterAreaSH area, int specForm, int min, int max, Area
LevelMax = max;
Weather = weather;
Version = game;
}
}
}

View File

@ -127,7 +127,7 @@ private static void ManuallyAddRareSpawns(IEnumerable<EncounterArea7b> areas)
var slots = table.Slots;
var first = slots[0];
var extra = species
.Select(z => new EncounterSlot7b(table, z, (z == 006 || z >= 144) ? 03 : first.LevelMin, (z == 006 || z >= 144) ? 56 : first.LevelMax, GameVersion.GG)).ToArray();
.Select(z => new EncounterSlot7b(table, z, (z == 006 || z >= 144) ? 03 : first.LevelMin, (z == 006 || z >= 144) ? 56 : first.LevelMax)).ToArray();
int count = slots.Length;
Array.Resize(ref slots, count + extra.Length);

View File

@ -15,10 +15,10 @@ namespace PKHeX.Core
/// </summary>
internal static class Encounters8
{
private static readonly EncounterArea8[] SlotsSW_Symbol = EncounterAreaSH.GetArray<EncounterArea8>(Get("sw_symbol", "sw"), SW);
private static readonly EncounterArea8[] SlotsSH_Symbol = EncounterAreaSH.GetArray<EncounterArea8>(Get("sh_symbol", "sh"), SH);
private static readonly EncounterArea8[] SlotsSW_Hidden = EncounterAreaSH.GetArray<EncounterArea8>(Get("sw_hidden", "sw"), SW);
private static readonly EncounterArea8[] SlotsSH_Hidden = EncounterAreaSH.GetArray<EncounterArea8>(Get("sh_hidden", "sh"), SH);
private static readonly EncounterArea8[] SlotsSW_Symbol = EncounterArea8.GetAreas(Get("sw_symbol", "sw"), SW);
private static readonly EncounterArea8[] SlotsSH_Symbol = EncounterArea8.GetAreas(Get("sh_symbol", "sh"), SH);
private static readonly EncounterArea8[] SlotsSW_Hidden = EncounterArea8.GetAreas(Get("sw_hidden", "sw"), SW);
private static readonly EncounterArea8[] SlotsSH_Hidden = EncounterArea8.GetAreas(Get("sh_hidden", "sh"), SH);
private static byte[][] Get(string resource, string ident) => BinLinker.Unpack(Util.GetBinaryResource($"encounter_{resource}.pkl"), ident);
internal static readonly EncounterArea8[] SlotsSW = ArrayUtil.ConcatAll(SlotsSW_Symbol, SlotsSW_Hidden);

View File

@ -5,20 +5,20 @@ namespace PKHeX.Core
/// <summary>
/// Wild Encounter Slot data
/// </summary>
public abstract class EncounterSlot : IEncounterable, ILocation, IVersionSet
public abstract class EncounterSlot : IEncounterable, ILocation
{
public int Species { get; set; }
public int Form { get; set; }
public int LevelMin { get; set; }
public int LevelMax { get; set; }
public GameVersion Version { get; set; }
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 abstract int Generation { get; }
public bool EggEncounter => false;
public int EggLocation { get => 0; set { } }
public override string ToString() => $"{(Species) Species} @ {LevelMin}-{LevelMax}";
internal readonly EncounterArea Area;
public GameVersion Version => Area.Version;
public int Location { get => Area.Location; set { } }
public int EggLocation { get => 0; set { } }
protected EncounterSlot(EncounterArea area) => Area = area;

View File

@ -8,13 +8,12 @@ public sealed class EncounterSlot1 : EncounterSlot, INumberedSlot
public override int Generation => 1;
public int SlotNumber { get; set; }
public EncounterSlot1(EncounterArea1 area, int species, int min, int max, int slot, GameVersion game) : base(area)
public EncounterSlot1(EncounterArea1 area, int species, int min, int max, int slot) : base(area)
{
Species = species;
LevelMin = min;
LevelMax = max;
SlotNumber = slot;
Version = game;
}
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)

View File

@ -11,13 +11,12 @@ public sealed class EncounterSlot2 : EncounterSlot, INumberedSlot
public override int Generation => 2;
public int SlotNumber { get; set; }
public EncounterSlot2(EncounterArea2 area, int species, int min, int max, int slot, GameVersion game) : base(area)
public EncounterSlot2(EncounterArea2 area, int species, int min, int max, int slot) : base(area)
{
Species = species;
LevelMin = min;
LevelMax = max;
SlotNumber = slot;
Version = game;
}
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)

View File

@ -11,14 +11,13 @@ public class EncounterSlot3 : EncounterSlot, IMagnetStatic, INumberedSlot
public int SlotNumber { get; set; }
public EncounterSlot3(EncounterArea3 area, int species, int form, int min, int max, int slot, int mpi, int mpc, int sti, int stc, GameVersion game) : base(area)
public EncounterSlot3(EncounterArea3 area, int species, int form, int min, int max, int slot, int mpi, int mpc, int sti, int stc) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
SlotNumber = slot;
Version = game;
MagnetPullIndex = mpi;
MagnetPullCount = mpc;

View File

@ -12,7 +12,6 @@ public EncounterSlot3PokeSpot(EncounterArea3XD area, int species, int min, int m
LevelMin = min;
LevelMax = max;
SlotNumber = slot;
Version = GameVersion.XD;
}
// PokeSpot encounters always have Fateful Encounter set.

View File

@ -7,8 +7,8 @@ internal sealed class EncounterSlot3Swarm : EncounterSlot3, IMoveset
public override int Generation => 3;
public IReadOnlyList<int> Moves { get; }
public EncounterSlot3Swarm(EncounterArea3 area, int species, int min, int max, int slot, GameVersion game,
IReadOnlyList<int> moves) : base(area, species, 0, min, max, slot, 0, 0, 0, 0, game) => Moves = moves;
public EncounterSlot3Swarm(EncounterArea3 area, int species, int min, int max, int slot,
IReadOnlyList<int> moves) : base(area, species, 0, min, max, slot, 0, 0, 0, 0) => Moves = moves;
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
{

View File

@ -12,14 +12,13 @@ public sealed class EncounterSlot4 : EncounterSlot, IMagnetStatic, INumberedSlot
public int SlotNumber { get; set; }
public EncounterSlot4(EncounterArea4 area, int species, int form, int min, int max, int slot, int mpi, int mpc, int sti, int stc, GameVersion game) : base(area)
public EncounterSlot4(EncounterArea4 area, int species, int form, int min, int max, int slot, int mpi, int mpc, int sti, int stc) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
SlotNumber = slot;
Version = game;
MagnetPullIndex = mpi;
MagnetPullCount = mpc;

View File

@ -4,13 +4,12 @@ public sealed class EncounterSlot5 : EncounterSlot
{
public override int Generation => 5;
public EncounterSlot5(EncounterArea5 area, int species, int form, int min, int max, GameVersion game) : base(area)
public EncounterSlot5(EncounterArea5 area, int species, int form, int min, int max) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
Version = game;
}
}
}

View File

@ -4,13 +4,12 @@ public sealed class EncounterSlot6AO : EncounterSlot
{
public override int Generation => 6;
public EncounterSlot6AO(EncounterArea6AO area, int species, int form, int min, int max, GameVersion game) : base(area)
public EncounterSlot6AO(EncounterArea6AO area, int species, int form, int min, int max) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
Version = game;
}
public bool Pressure { get; set; }

View File

@ -5,13 +5,12 @@ public sealed class EncounterSlot6XY : EncounterSlot
public override int Generation => 6;
public bool Pressure { get; set; }
public EncounterSlot6XY(EncounterArea6XY area, int species, int form, int min, int max, GameVersion game) : base(area)
public EncounterSlot6XY(EncounterArea6XY area, int species, int form, int min, int max) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
Version = game;
}
protected override void SetFormatSpecificData(PKM pk)
@ -25,5 +24,13 @@ public override string GetConditionString(out bool valid)
valid = true;
return Pressure ? LegalityCheckStrings.LEncConditionLead : LegalityCheckStrings.LEncCondition;
}
public EncounterSlot6XY CreatePressureFormCopy(int evoForm)
{
var clone = (EncounterSlot6XY)Clone();
clone.Form = evoForm;
clone.Pressure = true;
return clone;
}
}
}
}

View File

@ -2,13 +2,12 @@ namespace PKHeX.Core
{
public sealed class EncounterSlot7 : EncounterSlot
{
public EncounterSlot7(EncounterArea7 area, int species, int form, int min, int max, GameVersion game) : base(area)
public EncounterSlot7(EncounterArea7 area, int species, int form, int min, int max) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
Version = game;
}
public override int Generation => 7;

View File

@ -4,13 +4,14 @@ public sealed class EncounterSlot7GO : EncounterSlot
{
public override int Generation => 7;
public EncounterSlot7GO(EncounterArea7g area, int species, int form, int min, int max, GameVersion game) : base(area)
public EncounterSlot7GO(EncounterArea7g area, int species, int form, int min, int max) : base(area)
{
Species = species;
Form = form;
LevelMin = min;
LevelMax = max;
Version = game;
}
public void ClampMinRaid(int level) => LevelMin = level;
}
}
}

View File

@ -4,12 +4,11 @@ public sealed class EncounterSlot7b : EncounterSlot
{
public override int Generation => 7;
public EncounterSlot7b(EncounterArea7b area, int species, int min, int max, GameVersion game) : base(area)
public EncounterSlot7b(EncounterArea7b area, int species, int min, int max) : base(area)
{
Species = species;
LevelMin = min;
LevelMax = max;
Version = game;
}
}
}
}

View File

@ -32,12 +32,6 @@ public static GameVersion GetCompatibleVersion(this IVersion ver, GameVersion pr
}
}
internal static void SetVersion(this IEnumerable<EncounterArea> arr, GameVersion game)
{
foreach (var area in arr)
area.Slots.SetVersion(game);
}
private static GameVersion GetSingleVersion(this IVersion ver)
{
const int max = (int) GameVersion.RB;