2017-05-14 21:42:18 +00:00
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
public class Frame
|
|
|
|
|
{
|
2017-05-15 06:21:34 +00:00
|
|
|
|
public readonly uint Seed;
|
2017-05-14 21:42:18 +00:00
|
|
|
|
public readonly LeadRequired Lead;
|
2017-05-15 06:21:34 +00:00
|
|
|
|
|
|
|
|
|
private readonly FrameType FrameType;
|
|
|
|
|
private readonly RNG RNG;
|
2017-05-14 21:42:18 +00:00
|
|
|
|
|
|
|
|
|
public uint ESV { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public void SetOriginSeed(int Offset) => OriginSeed = RNG.Reverse(Seed, Offset);
|
2017-05-15 06:21:34 +00:00
|
|
|
|
public bool LevelSlotModified => Lead > LeadRequired.SynchronizeFail;
|
|
|
|
|
|
|
|
|
|
public uint OriginSeed;
|
2017-05-14 21:42:18 +00:00
|
|
|
|
|
2017-05-15 06:21:34 +00:00
|
|
|
|
public Frame(uint seed, FrameType type, RNG rng, LeadRequired lead)
|
2017-05-14 21:42:18 +00:00
|
|
|
|
{
|
|
|
|
|
Seed = seed;
|
|
|
|
|
Lead = lead;
|
|
|
|
|
FrameType = type;
|
2017-05-15 06:21:34 +00:00
|
|
|
|
RNG = rng;
|
2017-05-14 21:42:18 +00:00
|
|
|
|
}
|
2017-11-27 00:09:24 +00:00
|
|
|
|
|
|
|
|
|
public int EncounterSlot(SlotType t, EncounterSlot slot)
|
|
|
|
|
{
|
|
|
|
|
if (Lead == LeadRequired.StaticMagnet)
|
|
|
|
|
{
|
|
|
|
|
if (slot.Permissions.MagnetPullIndex >= 0)
|
|
|
|
|
{
|
|
|
|
|
var index = ESV % slot.Permissions.MagnetPullCount;
|
|
|
|
|
return index == slot.Permissions.MagnetPullIndex ? slot.SlotNumber : -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (slot.Permissions.StaticIndex >= 0)
|
|
|
|
|
{
|
|
|
|
|
var index = ESV % slot.Permissions.StaticCount;
|
|
|
|
|
return index == slot.Permissions.StaticIndex ? slot.SlotNumber : -1;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return EncounterSlot(t);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Only use this for test methods.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="t"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int EncounterSlot(SlotType t) => SlotRange.GetSlot(t, ESV, FrameType, Seed);
|
2017-05-14 21:42:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|