namespace PKHeX.Core; /// /// Settings for Parsing Legality /// /// public static class ParseSettings { /// /// Current Trainer of the active Save Data. /// /// /// Used for legality checks to determine if the data is from the active save file. /// Defaults to a blank trainer with no data to prevent matching unless another reference (save file) is loaded. /// internal static ITrainerInfo? ActiveTrainer { get; private set; } /// /// Resets active trainer to null, disabling any legality checks that compare to a currently loaded trainer. /// /// Shouldn't need to use this unless you want to undo any loading of save data to revert to an uninitialized state. public static void ClearActiveTrainer() => ActiveTrainer = null; /// /// Master settings configuration for legality analysis. /// /// Allows configuring severities away from the default settings for users who want to deviate. public static LegalitySettings Settings { get; set; } = new(); /// /// Setting to specify if an analysis should permit data sourced from the physical cartridge era of Game Boy games. /// /// If false, indicates to use Virtual Console rules (which are transferable to Gen7+) public static bool AllowEraCartGB { private get; set; } /// /// Setting to specify if an analysis should permit data sourced from the physical cartridge era of Game Boy Advance games. /// public static bool AllowEraCartGBA { private get; set; } = true; /// /// Setting to specify if an analysis should permit data sourced from the Nintendo Switch Virtual Console era of Game Boy Advance games. /// public static bool AllowEraSwitchGBA { private get; set; } /// /// Setting to specify if an analysis should permit trading a Generation 1 origin file to Generation 2, then back. Useful for checking RBY Metagame rules. /// public static bool AllowGen1Tradeback => Settings.Tradeback.AllowGen1Tradeback; public static void Initialize(LegalitySettings settings) => Settings = settings; /// /// Checks to see if Crystal is available to visit/originate from. /// /// Data being checked /// True if Crystal data is allowed public static bool AllowGen2Crystal(PKM pk) => !pk.Korean; /// /// Checks to see if the Move Reminder (Relearner) is available. /// /// Pokémon Stadium 2 was never released in Korea. /// Data being checked /// True if Crystal data is allowed public static bool AllowGen2MoveReminder(PKM pk) => !pk.Korean && AllowGBStadium2; public static bool AllowGen2OddEgg(PKM pk) => !pk.Japanese || AllowEraCartGB; public static bool AllowGBVirtualConsole3DS => !AllowEraCartGB; public static bool AllowGBEraEvents => AllowEraCartGB; public static bool AllowGBStadium2 => AllowEraCartGB; // This logic will likely need to change (format check): TODO HOME FR/LG public static bool AllowGBACrossTransferXD(PKM pk) => AllowEraCartGBA; public static bool AllowGBACrossTransferRSE(PKM pk) => AllowEraCartGBA; public static bool AllowGen3EventTicketsAll(PKM pk) => AllowEraSwitchGBA; /// /// Initializes certain settings /// /// Newly loaded save file /// Save file is Physical GB cartridge save file (not Virtual Console) public static void InitFromSaveFileData(SaveFile sav) { ActiveTrainer = sav; AllowEraCartGB = sav switch { SAV1 { IsVirtualConsole: true } => false, SAV2 { IsVirtualConsole: true } => false, { Generation: 1 or 2 } => true, _ => false, }; var isVirtual3 = sav is SAV3 { IsVirtualConsole: true }; AllowEraSwitchGBA = isVirtual3; AllowEraCartGBA = !isVirtual3; // sav.Generation >= 8; TODO HOME FR/LG } internal static bool IgnoreTransferIfNoTracker => Settings.HOMETransfer.HOMETransferTrackerNotPresent == Severity.Invalid; }