2019-09-13 06:20:52 +00:00
|
|
|
|
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;
|
Fix flute level amp direction
The inputs to "IsLevelWithinRange" are the highest value the
lowest-level can be, and the lowest value the highest level can be...
seems confusing (hence the original error).
If a slot is 6-7, with a wild encounter (flute), we can go +/-3 from
6-7, which is 3-10.
With an encounter of level 5, the inputs are: 5+3, and 5-3 (8, 2).
Since 8>lvlmin and 2<lvlhi, we can get a level 5 pkm from the slot
(using a negative flute yielding a -1 adjustment).
I could probably refactor it to be a 3-input signature (lvl, lvlneg,
lvlpos), and have it do LevelMin - lvlneg <= lvl && lvl <= LevelMax +
lvlpos
I should probably refactor these methods to do minLevel & maxLevel (so
baseSpecies.Level to CurrentLevel for pkm that lost their original met
data) but nothing needs the extra logic at this time.
2019-09-20 05:37:56 +00:00
|
|
|
|
int fluteMinLevel = minLevel + FluteBoostMax; // highest possible min-level of slot before flute decrease
|
2019-09-13 06:20:52 +00:00
|
|
|
|
// 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|