mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-24 04:53:08 +00:00
3138fb20c6
vs -> chain (clarity on what it is; an evolution chain, rather than e.v.o.s - vs) Clamp origin chain for transferred where we can use the max origin level
84 lines
No EOL
2.5 KiB
C#
84 lines
No EOL
2.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// <see cref="GameVersion.XY"/> encounter area
|
|
/// </summary>
|
|
public sealed class EncounterArea6XY : EncounterArea32
|
|
{
|
|
protected override IEnumerable<EncounterSlot> GetFilteredSlots(PKM pkm, IEnumerable<EncounterSlot> slots, int minLevel)
|
|
{
|
|
EncounterSlot? slotMax = null;
|
|
void CachePressureSlot(EncounterSlot s)
|
|
{
|
|
if (slotMax == null || s.LevelMax > slotMax.LevelMax)
|
|
slotMax = s;
|
|
}
|
|
|
|
int species = pkm.Species;
|
|
int form = pkm.AltForm;
|
|
bool ShouldMatchSlotForm() => Legal.WildForms.Contains(species);
|
|
|
|
if (ShouldMatchSlotForm()) // match slot form
|
|
{
|
|
foreach (var slot in slots)
|
|
{
|
|
if (slot.Form == form)
|
|
yield return slot;
|
|
CachePressureSlot(slot);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var slot in slots)
|
|
{
|
|
yield return slot; // no form checking
|
|
CachePressureSlot(slot);
|
|
}
|
|
}
|
|
|
|
// Filter for Form Specific
|
|
// Pressure Slot
|
|
if (slotMax == null)
|
|
yield break;
|
|
|
|
if (ShouldMatchSlotForm()) // match slot form
|
|
{
|
|
if (slotMax.Form == form)
|
|
yield return GetPressureSlot(slotMax, pkm);
|
|
}
|
|
else
|
|
{
|
|
yield return GetPressureSlot(slotMax, pkm);
|
|
}
|
|
}
|
|
|
|
public static bool WasFriendSafari(PKM pkm)
|
|
{
|
|
if (!pkm.XY)
|
|
return false;
|
|
if (pkm.Met_Location != 148)
|
|
return false;
|
|
if (pkm.Met_Level != 30)
|
|
return false;
|
|
if (pkm.Egg_Location != 0)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
public static IEnumerable<EncounterSlot> GetValidFriendSafari(PKM pkm)
|
|
{
|
|
var chain = EvolutionChain.GetValidPreEvolutions(pkm);
|
|
return GetValidFriendSafari(chain);
|
|
}
|
|
|
|
public static IEnumerable<EncounterSlot> GetValidFriendSafari(IReadOnlyList<DexLevel> chain)
|
|
{
|
|
var valid = chain.Where(d => d.Level >= 30);
|
|
return valid.SelectMany(z => Encounters6.FriendSafari[z.Species]);
|
|
}
|
|
}
|
|
} |