2020-08-30 17:23:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2021-01-01 18:55:33 +00:00
|
|
|
|
/// <inheritdoc cref="EncounterArea" />
|
2020-08-30 17:23:22 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <see cref="GameVersion.XD"/> encounter area
|
|
|
|
|
/// </summary>
|
2021-01-01 18:55:33 +00:00
|
|
|
|
public sealed record EncounterArea3XD : EncounterArea
|
2020-08-30 17:23:22 +00:00
|
|
|
|
{
|
2021-06-30 03:58:06 +00:00
|
|
|
|
public readonly EncounterSlot3PokeSpot[] Slots;
|
|
|
|
|
|
|
|
|
|
protected override IReadOnlyList<EncounterSlot> Raw => Slots;
|
|
|
|
|
|
2022-03-07 07:25:47 +00:00
|
|
|
|
public EncounterArea3XD(int loc, ushort s0, byte l0, ushort s1, byte l1, ushort s2, byte l2) : base(GameVersion.XD)
|
2020-08-30 17:23:22 +00:00
|
|
|
|
{
|
|
|
|
|
Location = loc;
|
|
|
|
|
Type = SlotType.Grass;
|
|
|
|
|
Slots = new[]
|
|
|
|
|
{
|
|
|
|
|
new EncounterSlot3PokeSpot(this, s0, 10, l0, 0),
|
|
|
|
|
new EncounterSlot3PokeSpot(this, s1, 10, l1, 1),
|
|
|
|
|
new EncounterSlot3PokeSpot(this, s2, 10, l2, 2),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-08 01:29:36 +00:00
|
|
|
|
public override IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, EvoCriteria[] chain)
|
2020-08-30 17:23:22 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Format != 3) // Met Location and Met Level are changed on PK3->PK4
|
|
|
|
|
return GetSlotsFuzzy(chain);
|
|
|
|
|
if (pkm.Met_Location != Location)
|
2021-06-30 03:58:06 +00:00
|
|
|
|
return Array.Empty<EncounterSlot3PokeSpot>();
|
2020-08-30 17:23:22 +00:00
|
|
|
|
return GetSlotsMatching(chain, pkm.Met_Level);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-08 01:29:36 +00:00
|
|
|
|
private IEnumerable<EncounterSlot3PokeSpot> GetSlotsMatching(EvoCriteria[] chain, int lvl)
|
2020-08-30 17:23:22 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (var slot in Slots)
|
|
|
|
|
{
|
|
|
|
|
foreach (var evo in chain)
|
|
|
|
|
{
|
|
|
|
|
if (slot.Species != evo.Species)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (slot.Form != evo.Form)
|
|
|
|
|
break;
|
|
|
|
|
if (!slot.IsLevelWithinRange(lvl))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
yield return slot;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-08 01:29:36 +00:00
|
|
|
|
private IEnumerable<EncounterSlot3PokeSpot> GetSlotsFuzzy(EvoCriteria[] chain)
|
2020-08-30 17:23:22 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (var slot in Slots)
|
|
|
|
|
{
|
|
|
|
|
foreach (var evo in chain)
|
|
|
|
|
{
|
|
|
|
|
if (slot.Species != evo.Species)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (slot.Form != evo.Form)
|
|
|
|
|
break;
|
2022-04-24 04:33:17 +00:00
|
|
|
|
if (slot.LevelMin > evo.LevelMax)
|
2020-08-30 17:23:22 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
yield return slot;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|