Rework lead required to flags

This commit is contained in:
Kurt 2017-12-01 17:27:09 -08:00
parent 15ab0d5aff
commit 48242109fd
3 changed files with 31 additions and 13 deletions

View File

@ -12,7 +12,7 @@ public class Frame
public uint RandESV { get; set; }
public uint OriginSeed { get; set; }
public bool LevelSlotModified => Lead > LeadRequired.SynchronizeFail;
public bool LevelSlotModified => Lead.IsLevelOrSlotModified();
public Frame(uint seed, FrameType type, RNG rng, LeadRequired lead)
{

View File

@ -58,7 +58,8 @@ private static IEnumerable<Frame> RefineFrames3(IEnumerable<Frame> frames, Frame
var rand = prev >> 16;
f.RandESV = rand;
f.RandLevel = f.Seed >> 16;
yield return f;
if (f.Lead != LeadRequired.CuteCharm) // needs proc checking
yield return f;
// Generate frames for other slots after the regular slots
if (info.AllowLeads && (f.Lead == LeadRequired.CuteCharm || f.Lead == LeadRequired.None))

View File

@ -1,20 +1,37 @@
namespace PKHeX.Core
using System;
namespace PKHeX.Core
{
[Flags]
public enum LeadRequired
{
None,
CuteCharm,
CuteCharmFail,
Synchronize,
SynchronizeFail,
None = 0,
CuteCharm = 1 << 0,
Synchronize = 1 << 1,
// Slot Modifiers
StaticMagnet,
StaticMagnetFail,
StaticMagnet = 1 << 2,
// Level Modifiers
IntimidateKeenEye, // Keen Eye
PressureHustleSpirit,
PressureHustleSpiritFail,
IntimidateKeenEye = 1 << 3,
PressureHustleSpirit = 1 << 4,
SuctionCups = 1 << 5,
NoLevelCall = 1 << 6,
Fail = 1 << 7,
CuteCharmFail = CuteCharm | Fail,
SynchronizeFail = Synchronize | Fail,
StaticMagnetFail = StaticMagnet | Fail,
PressureHustleSpiritFail = PressureHustleSpirit | Fail,
AllFlags = NoLevelCall | Fail,
NoFlags = ~AllFlags,
}
public static partial class Extensions
{
internal static bool IsLevelOrSlotModified(this LeadRequired Lead) => Lead.RemoveFlags() > LeadRequired.Synchronize;
internal static LeadRequired RemoveFlags(this LeadRequired Lead) => Lead & LeadRequired.NoFlags;
}
}