namespace PKHeX.Core; /// /// Specification for , used for creating and validating. /// public enum Shiny : byte { /// PID is purely random; can be shiny or not shiny. Random = 0, /// PID is randomly created and forced to be not shiny. Never, /// PID is randomly created and forced to be shiny. Always, /// PID is randomly created and forced to be shiny as Stars. AlwaysStar, /// PID is randomly created and forced to be shiny as Squares. AlwaysSquare, /// PID is fixed to a specified value. FixedValue, } public static class ShinyExtensions { public static bool IsValid(this Shiny s, PKM pkm) => s switch { Shiny.Always => pkm.IsShiny, Shiny.Never => !pkm.IsShiny, Shiny.AlwaysSquare => pkm.ShinyXor == 0, Shiny.AlwaysStar => pkm.ShinyXor == 1, _ => true, }; public static bool IsShiny(this Shiny s) => s switch { Shiny.Always => true, Shiny.AlwaysSquare => true, Shiny.AlwaysStar => true, _ => false, }; public static bool ShowSquareBeforeGen8 { get; set; } public static Shiny GetType(PKM pk) { bool shiny = pk.IsShiny; if (!shiny) return Shiny.Never; if (IsSquareShinyExist(pk)) return Shiny.AlwaysSquare; return Shiny.AlwaysStar; } public static bool IsSquareShinyExist(PKM pk) { if (pk.Format < 8 && !ShowSquareBeforeGen8) return false; return pk.ShinyXor == 0 || pk.FatefulEncounter || pk.Version == (int)GameVersion.GO; } }