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;
|
|
|
|
|
|
2020-08-30 18:08:21 +00:00
|
|
|
|
public EncounterArea3XD(int loc, int s0, int l0, int s1, int l1, int s2, int 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),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, IReadOnlyList<EvoCriteria> chain)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 03:58:06 +00:00
|
|
|
|
private IEnumerable<EncounterSlot3PokeSpot> GetSlotsMatching(IReadOnlyList<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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 03:58:06 +00:00
|
|
|
|
private IEnumerable<EncounterSlot3PokeSpot> GetSlotsFuzzy(IReadOnlyList<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;
|
|
|
|
|
if (slot.LevelMin > evo.Level)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
yield return slot;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|