2019-09-13 06:20:52 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <see cref="GameVersion.XY"/> encounter area
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class EncounterArea6XY : EncounterArea32
|
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
private const int RandomForm = 31;
|
|
|
|
|
private const int RandomFormVivillon = RandomForm - 1;
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, IReadOnlyList<EvoCriteria> chain)
|
2019-09-13 06:20:52 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
foreach (var slot in Slots)
|
2019-09-13 06:20:52 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
foreach (var evo in chain)
|
|
|
|
|
{
|
|
|
|
|
if (slot.Species != evo.Species)
|
|
|
|
|
continue;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
if (!slot.IsLevelWithinRange(pkm.Met_Level))
|
|
|
|
|
break;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
if (slot.Form != evo.Form && slot.Form < RandomFormVivillon && !Legal.WildChangeFormAfter.Contains(slot.Species))
|
|
|
|
|
{
|
|
|
|
|
if (slot.Species != (int)Species.Flabébé)
|
|
|
|
|
break;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
var maxLevel = slot.LevelMax;
|
|
|
|
|
if (!ExistsPressureSlot(evo, ref maxLevel))
|
|
|
|
|
break;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
if (maxLevel != pkm.Met_Level)
|
|
|
|
|
break;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
var clone = (EncounterSlot6XY)slot.Clone();
|
|
|
|
|
clone.Form = evo.Form;
|
|
|
|
|
clone.Pressure = true;
|
|
|
|
|
yield return clone;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-03-14 18:32:27 +00:00
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
yield return slot;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-14 18:32:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 23:35:49 +00:00
|
|
|
|
private bool ExistsPressureSlot(DexLevel evo, ref int level)
|
2020-03-14 18:32:27 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
bool existsForm = false;
|
|
|
|
|
foreach (var z in Slots)
|
|
|
|
|
{
|
|
|
|
|
if (z.Species != evo.Species)
|
|
|
|
|
continue;
|
|
|
|
|
if (z.Form == evo.Form)
|
|
|
|
|
continue;
|
|
|
|
|
if (z.LevelMax < level)
|
|
|
|
|
continue;
|
|
|
|
|
level = z.LevelMax;
|
|
|
|
|
existsForm = true;
|
|
|
|
|
}
|
|
|
|
|
return existsForm;
|
2019-09-13 06:20:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-21 23:35:49 +00:00
|
|
|
|
}
|