diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs index 4a4682568..a2d32fa80 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs @@ -79,7 +79,7 @@ namespace PKHeX.Core { foreach (EncounterArea Area in Areas.Where(a => a.Location == location)) foreach (EncounterSlot Slot in Area.Slots) - Slot.Type = Slot.Type.GetSafariSlotType3(); + Slot.Type |= SlotType.Safari; } private static readonly int[] Roaming_MetLocation_FRLG = diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs index bf1560f35..34dfbe884 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs @@ -148,7 +148,7 @@ namespace PKHeX.Core { foreach (EncounterArea Area in Areas.Where(a => a.Location == location)) foreach (EncounterSlot Slot in Area.Slots) - Slot.Type = Slot.Type.GetSafariSlotType4(); + Slot.Type |= SlotType.Safari; } private static void MarkG4SwarmSlots(ref EncounterArea[] Areas, EncounterArea[] SwarmAreas) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs index 9ae6dd36f..891661058 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs @@ -1377,9 +1377,7 @@ namespace PKHeX.Core } internal static bool IsSafariSlot(SlotType t) { - return t == SlotType.Grass_Safari || t == SlotType.Surf_Safari || - t == SlotType.Rock_Smash_Safari || t == SlotType.Pokeradar_Safari || - t == SlotType.Old_Rod_Safari || t == SlotType.Good_Rod_Safari || t == SlotType.Super_Rod_Safari; + return t.HasFlag(SlotType.Safari); } internal static bool IsDexNavValid(PKM pkm) { diff --git a/PKHeX.Core/Legality/Structures/SlotType.cs b/PKHeX.Core/Legality/Structures/SlotType.cs index d82226df7..fc47c9df2 100644 --- a/PKHeX.Core/Legality/Structures/SlotType.cs +++ b/PKHeX.Core/Legality/Structures/SlotType.cs @@ -1,84 +1,110 @@ -namespace PKHeX.Core +using System; + +namespace PKHeX.Core { /// /// Wild Encounter data Type /// /// /// Different from , this corresponds to the method that the may be encountered. + [Flags] public enum SlotType { - Any, - Grass, - Rough_Terrain, - Yellow_Flowers, - Purple_Flowers, - Red_Flowers, - Surf, - Old_Rod, - Good_Rod, - Super_Rod, - Rock_Smash, - Horde, - FriendSafari, - Special, - SOS, - Swarm, - Headbutt, - Headbutt_Special, - Pokeradar, - HoneyTree, - HiddenGrotto, - BugContest, - Grass_Safari, - Surf_Safari, - Old_Rod_Safari, - Good_Rod_Safari, - Super_Rod_Safari, - Rock_Smash_Safari, - Pokeradar_Safari + /// + /// Default (un-assigned) encounter slot type. + /// + Any = 0, + /// + /// Slot is encountered via Grass. + /// + Grass = 1 << 00, + /// + /// Slot is encountered via Surfing. + /// + Surf = 1 << 01, + /// + /// Slot is encountered via Old Rod (Fishing). + /// + Old_Rod = 1 << 02, + /// + /// Slot is encountered via Good Rod (Fishing). + /// + Good_Rod = 1 << 03, + /// + /// Slot is encountered via Super Rod (Fishing). + /// + Super_Rod = 1 << 04, + /// + /// Slot is encountered via Rock Smash. + /// + Rock_Smash = 1 << 05, + /// + /// Slot is encountered via a Horde. + /// + Horde = 1 << 06, + /// + /// Slot is encountered via the Friend Safari. + /// + FriendSafari = 1 << 07, + /// + /// Slot is encountered through special means. Used to signify special slots for Gen2, sometimes for later follow-up). + /// + Special = 1 << 08, + /// + /// Slot is encountered via SOS signal. + /// + SOS = 1 << 09, + /// + /// Slot is encountered in a Swarm. + /// + Swarm = 1 << 10, + /// + /// Slot is encountered via Headbutt. + /// + Headbutt = 1 << 11, + /// + /// Slot is encountered via the Poké Radar. + /// + Pokeradar = 1 << 12, + /// + /// Slot is encountered via a Honey Tree. + /// + HoneyTree = 1 << 13, + /// + /// Slot is encountered via a Hidden Grotto. + /// + HiddenGrotto = 1 << 14, + /// + /// Slot is encountered via the Bug Catching Contest. + /// + BugContest = 1 << 15, + /// + /// Slot is encountered in the Safari Zone. + /// + Safari = 1 << 16, // always used as a modifier to another slot type + + Rough_Terrain = 1 << 17, + Yellow_Flowers = 1 << 18, + Purple_Flowers = 1 << 19, + Red_Flowers = 1 << 20, + + // Combined + Headbutt_Special = Headbutt | Special, + + Grass_Safari = Grass | Safari, + Surf_Safari = Surf | Safari, + Old_Rod_Safari = Old_Rod | Safari, + Good_Rod_Safari = Good_Rod | Safari, + Super_Rod_Safari = Super_Rod | Safari, + Rock_Smash_Safari = Rock_Smash | Safari, + Pokeradar_Safari = Pokeradar | Safari, } public static partial class Extensions { - internal static SlotType GetSafariSlotType3(this SlotType t) - { - switch (t) - { - case SlotType.Grass: return SlotType.Grass_Safari; - case SlotType.Surf: return SlotType.Surf_Safari; - case SlotType.Old_Rod: return SlotType.Old_Rod_Safari; - case SlotType.Good_Rod: return SlotType.Good_Rod_Safari; - case SlotType.Super_Rod: return SlotType.Super_Rod_Safari; - case SlotType.Rock_Smash: return SlotType.Rock_Smash_Safari; - default: return t; - } - } - internal static SlotType GetSafariSlotType4(this SlotType t) - { - switch (t) - { - case SlotType.Grass: return SlotType.Grass_Safari; - case SlotType.Surf: return SlotType.Surf_Safari; - case SlotType.Old_Rod: return SlotType.Old_Rod_Safari; - case SlotType.Good_Rod: return SlotType.Good_Rod_Safari; - case SlotType.Super_Rod: return SlotType.Super_Rod_Safari; - case SlotType.Pokeradar: return SlotType.Pokeradar_Safari; - default: return t; - } - } internal static bool IsFishingRodType(this SlotType t) { - switch (t) - { - case SlotType.Old_Rod: - case SlotType.Good_Rod: - case SlotType.Super_Rod: - case SlotType.Old_Rod_Safari: - case SlotType.Good_Rod_Safari: - case SlotType.Super_Rod_Safari: - return true; - default: return false; - } + return t.HasFlag(SlotType.Old_Rod) || t.HasFlag(SlotType.Good_Rod) || t.HasFlag(SlotType.Super_Rod); } } }