mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-24 04:53:08 +00:00
734aa33898
Now logic is reasonably split, and each format of area has its own way of yielding slots Too much junk with checking flute boosts or catch combo applicability; just let the area dictate how slots match.
60 lines
No EOL
2.4 KiB
C#
60 lines
No EOL
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// <see cref="GameVersion.ORAS"/> encounter area
|
|
/// </summary>
|
|
public sealed class EncounterArea6AO : EncounterArea32
|
|
{
|
|
private const int FluteBoostMax = 3; // Black Flute increases levels, White Flute decreases levels.
|
|
private const int DexNavBoost = 30;
|
|
|
|
protected override IEnumerable<EncounterSlot> GetMatchFromEvoLevel(PKM pkm, IEnumerable<DexLevel> vs, int minLevel)
|
|
{
|
|
var slots = Slots.Where(slot => vs.Any(evo => evo.Species == slot.Species && evo.Level >= (slot.LevelMin - FluteBoostMax)));
|
|
|
|
int getMaxLevelBoost(EncounterSlot s) => s.Type == SlotType.Rock_Smash ? FluteBoostMax : DexNavBoost;
|
|
int fluteMinLevel = minLevel - FluteBoostMax;
|
|
// Get slots where pokemon can exist with respect to level constraints
|
|
return slots.Where(s => s.IsLevelWithinRange(fluteMinLevel, minLevel - getMaxLevelBoost(s)));
|
|
}
|
|
|
|
protected override IEnumerable<EncounterSlot> GetFilteredSlots(PKM pkm, IEnumerable<EncounterSlot> slots, int minLevel)
|
|
{
|
|
EncounterSlot slotMax = null;
|
|
foreach (EncounterSlot s in slots)
|
|
{
|
|
if (Legal.WildForms.Contains(pkm.Species) && s.Form != pkm.AltForm)
|
|
{
|
|
CachePressureSlot(s);
|
|
continue;
|
|
}
|
|
bool nav = s.Permissions.AllowDexNav && (pkm.RelearnMove1 != 0 || pkm.AbilityNumber == 4);
|
|
EncounterSlot slot = s.Clone();
|
|
slot.Permissions.DexNav = nav;
|
|
|
|
if (slot.LevelMin > minLevel)
|
|
slot.Permissions.WhiteFlute = true;
|
|
if (slot.LevelMax + 1 <= minLevel && minLevel <= slot.LevelMax + FluteBoostMax)
|
|
slot.Permissions.BlackFlute = true;
|
|
if (slot.LevelMax != minLevel && slot.Permissions.AllowDexNav)
|
|
slot.Permissions.DexNav = true;
|
|
yield return slot;
|
|
|
|
CachePressureSlot(slot);
|
|
}
|
|
|
|
void CachePressureSlot(EncounterSlot s)
|
|
{
|
|
if (slotMax != null && s.LevelMax > slotMax.LevelMax)
|
|
slotMax = s;
|
|
}
|
|
// Pressure Slot
|
|
if (slotMax != null)
|
|
yield return GetPressureSlot(slotMax, pkm);
|
|
}
|
|
}
|
|
} |