mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-12 20:47:11 -05:00
Add slot legality fetch for pk6
calling getEncounterSlots(pk6) yields a list of locations and valid slots for given input pk6. For later use in suggestion of legal values. Flexible enough for future fetch of past gen, but I doubt I'd ever be motivated enough to implement past gen checks.
This commit is contained in:
@@ -96,6 +96,21 @@ internal static IEnumerable<WC6> getValidWC6s(PK6 pk6)
|
||||
vs.Any(dl => dl.Species == wc6.Species) &&
|
||||
wc6.OT == pk6.OT_Name);
|
||||
}
|
||||
internal static IEnumerable<EncounterArea> getEncounterSlots(PK6 pk6)
|
||||
{
|
||||
switch (pk6.Version)
|
||||
{
|
||||
case 24: // X
|
||||
return getSlots(pk6, SlotsX);
|
||||
case 25: // Y
|
||||
return getSlots(pk6, SlotsY);
|
||||
case 26: // AS
|
||||
return getSlots(pk6, SlotsA);
|
||||
case 27: // OR
|
||||
return getSlots(pk6, SlotsO);
|
||||
default: return new List<EncounterArea>();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getBaseSpecies(PK6 pk6, int skipOption)
|
||||
{
|
||||
@@ -124,6 +139,23 @@ private static IEnumerable<EncounterSlot> getValidEncounterSlots(PK6 pk6, Encoun
|
||||
slots = slots.Where(slot => slot.Form == pk6.AltForm);
|
||||
return slots;
|
||||
}
|
||||
private static IEnumerable<EncounterArea> getSlots(PK6 pk6, IEnumerable<EncounterArea> tables)
|
||||
{
|
||||
int species = pk6.Species;
|
||||
IEnumerable<DexLevel> vs = getValidPreEvolutions(pk6);
|
||||
List<EncounterArea> slotLocations = new List<EncounterArea>();
|
||||
foreach (var loc in tables)
|
||||
{
|
||||
IEnumerable<EncounterSlot> slots = loc.Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && evo.Level >= slot.LevelMin));
|
||||
if (WildForms.Contains(species))
|
||||
slots = slots.Where(slot => slot.Form == pk6.AltForm);
|
||||
|
||||
EncounterSlot[] es = slots.ToArray();
|
||||
if (es.Length > 0)
|
||||
slotLocations.Add(new EncounterArea { Location = loc.Location, Slots = es });
|
||||
}
|
||||
return slotLocations;
|
||||
}
|
||||
private static IEnumerable<DexLevel> getValidPreEvolutions(PK6 pk6)
|
||||
{
|
||||
var evos = Evolves[pk6.Species].Evos;
|
||||
|
||||
@@ -100,8 +100,9 @@ public class DexLevel
|
||||
|
||||
public class EncounterArea
|
||||
{
|
||||
public readonly int Location;
|
||||
public int Location;
|
||||
public EncounterSlot[] Slots;
|
||||
public EncounterArea() { }
|
||||
public EncounterArea(byte[] data)
|
||||
{
|
||||
Location = BitConverter.ToUInt16(data, 0);
|
||||
|
||||
Reference in New Issue
Block a user