2022-08-16 22:50:35 +00:00
using System.Collections.Generic ;
2020-11-28 02:45:06 +00:00
2022-06-18 18:04:24 +00:00
namespace PKHeX.Core ;
2022-08-21 08:39:16 +00:00
/// <summary>
/// Settings for Parsing Legality
/// </summary>
/// <remarks><see cref="LegalityAnalysis"/></remarks>
2022-06-18 18:04:24 +00:00
public static class ParseSettings
2018-10-06 02:58:30 +00:00
{
2022-06-18 18:04:24 +00:00
internal static ITrainerInfo ActiveTrainer { get ; set ; } = new SimpleTrainerInfo ( GameVersion . Any ) { OT = string . Empty , Language = - 1 } ;
/// <summary>
2023-12-04 04:13:20 +00:00
/// Toggles whether the word filter should be used when checking the data.
2022-06-18 18:04:24 +00:00
/// </summary>
public static bool CheckWordFilter { get ; set ; } = true ;
/// <summary>
2023-12-04 04:13:20 +00:00
/// Setting to specify if an analysis should permit data sourced from the physical cartridge era of Game Boy games.
2022-06-18 18:04:24 +00:00
/// </summary>
/// <remarks>If false, indicates to use Virtual Console rules (which are transferable to Gen7+)</remarks>
2023-08-12 23:01:16 +00:00
public static bool AllowGBCartEra { private get ; set ; }
2022-06-18 18:04:24 +00:00
/// <summary>
/// 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.
/// </summary>
public static bool AllowGen1Tradeback { get ; set ; } = true ;
public static Severity NicknamedTrade { get ; private set ; } = Severity . Invalid ;
public static Severity NicknamedMysteryGift { get ; private set ; } = Severity . Fishy ;
2024-02-23 03:20:54 +00:00
public static Severity RNGFrameNotFound3 { get ; private set ; } = Severity . Fishy ;
public static Severity RNGFrameNotFound4 { get ; private set ; } = Severity . Invalid ;
2022-06-18 18:04:24 +00:00
public static Severity Gen7TransferStarPID { get ; private set ; } = Severity . Fishy ;
public static Severity Gen8MemoryMissingHT { get ; private set ; } = Severity . Fishy ;
2024-02-23 03:20:54 +00:00
public static Severity HOMETransferTrackerNotPresent { get ; private set ; } = Severity . Fishy ;
2022-06-18 18:04:24 +00:00
public static Severity NicknamedAnotherSpecies { get ; private set ; } = Severity . Fishy ;
public static Severity ZeroHeightWeight { get ; private set ; } = Severity . Fishy ;
public static Severity CurrentHandlerMismatch { get ; private set ; } = Severity . Invalid ;
public static bool CheckActiveHandler { get ; set ; }
public static IReadOnlyList < string > MoveStrings { get ; private set ; } = Util . GetMovesList ( GameLanguage . DefaultLanguage ) ;
public static IReadOnlyList < string > SpeciesStrings { get ; private set ; } = Util . GetSpeciesList ( GameLanguage . DefaultLanguage ) ;
2022-08-27 06:43:36 +00:00
public static string GetMoveName ( ushort move ) = > move > = MoveStrings . Count ? LegalityCheckStrings . L_AError : MoveStrings [ move ] ;
2022-06-18 18:04:24 +00:00
public static void ChangeLocalizationStrings ( IReadOnlyList < string > moves , IReadOnlyList < string > species )
2018-10-06 02:58:30 +00:00
{
2022-06-18 18:04:24 +00:00
SpeciesStrings = species ;
MoveStrings = moves ;
2021-04-12 01:09:54 +00:00
}
2022-06-18 18:04:24 +00:00
/// <summary>
/// Checks to see if Crystal is available to visit/originate from.
/// </summary>
2023-12-04 04:13:20 +00:00
/// <remarks>Pokémon Crystal was never released in Korea.</remarks>
2022-06-18 18:04:24 +00:00
/// <param name="Korean">Korean data being checked</param>
/// <returns>True if Crystal data is allowed</returns>
public static bool AllowGen2Crystal ( bool Korean ) = > ! Korean ;
/// <summary>
/// Checks to see if Crystal is available to visit/originate from.
/// </summary>
/// <param name="pk">Data being checked</param>
/// <returns>True if Crystal data is allowed</returns>
public static bool AllowGen2Crystal ( PKM pk ) = > ! pk . Korean ;
/// <summary>
/// Checks to see if the Move Reminder (Relearner) is available.
/// </summary>
2023-12-04 04:13:20 +00:00
/// <remarks> Pokémon Stadium 2 was never released in Korea.</remarks>
2022-06-18 18:04:24 +00:00
/// <param name="pk">Data being checked</param>
/// <returns>True if Crystal data is allowed</returns>
2023-08-12 23:01:16 +00:00
public static bool AllowGen2MoveReminder ( PKM pk ) = > ! pk . Korean & & AllowGBStadium2 ;
public static bool AllowGen2OddEgg ( PKM pk ) = > ! pk . Japanese | | AllowGBCartEra ;
public static bool AllowGBVirtualConsole3DS = > ! AllowGBCartEra ;
public static bool AllowGBEraEvents = > AllowGBCartEra ;
public static bool AllowGBStadium2 = > AllowGBCartEra ;
2022-06-18 18:04:24 +00:00
internal static bool IsFromActiveTrainer ( PKM pk ) = > ActiveTrainer . IsFromTrainer ( pk ) ;
/// <summary>
/// Initializes certain settings
/// </summary>
/// <param name="sav">Newly loaded save file</param>
/// <returns>Save file is Physical GB cartridge save file (not Virtual Console)</returns>
public static bool InitFromSaveFileData ( SaveFile sav )
2021-04-12 01:09:54 +00:00
{
2022-06-18 18:04:24 +00:00
ActiveTrainer = sav ;
return AllowGBCartEra = sav switch
{
SAV1 { IsVirtualConsole : true } = > false ,
SAV2 { IsVirtualConsole : true } = > false ,
{ Generation : 1 or 2 } = > true ,
_ = > false ,
} ;
2022-06-05 20:18:31 +00:00
}
2024-02-23 03:20:54 +00:00
internal static bool IgnoreTransferIfNoTracker = > HOMETransferTrackerNotPresent = = Severity . Invalid ;
2022-08-16 22:50:35 +00:00
2022-06-18 18:04:24 +00:00
public static void InitFromSettings ( IParseSettings settings )
2022-06-05 20:18:31 +00:00
{
2022-06-18 18:04:24 +00:00
CheckWordFilter = settings . CheckWordFilter ;
AllowGen1Tradeback = settings . AllowGen1Tradeback ;
NicknamedTrade = settings . NicknamedTrade ;
NicknamedMysteryGift = settings . NicknamedMysteryGift ;
2024-02-23 03:20:54 +00:00
RNGFrameNotFound3 = settings . RNGFrameNotFound3 ;
RNGFrameNotFound4 = settings . RNGFrameNotFound4 ;
2022-06-18 18:04:24 +00:00
Gen7TransferStarPID = settings . Gen7TransferStarPID ;
2024-02-23 03:20:54 +00:00
HOMETransferTrackerNotPresent = settings . HOMETransferTrackerNotPresent ;
2022-06-18 18:04:24 +00:00
Gen8MemoryMissingHT = settings . Gen8MemoryMissingHT ;
NicknamedAnotherSpecies = settings . NicknamedAnotherSpecies ;
ZeroHeightWeight = settings . ZeroHeightWeight ;
CurrentHandlerMismatch = settings . CurrentHandlerMismatch ;
CheckActiveHandler = settings . CheckActiveHandler ;
2018-10-06 02:58:30 +00:00
}
}
2022-06-18 18:04:24 +00:00
public interface IParseSettings
{
bool CheckWordFilter { get ; }
bool CheckActiveHandler { get ; }
bool AllowGen1Tradeback { get ; }
Severity NicknamedTrade { get ; }
Severity NicknamedMysteryGift { get ; }
2024-02-23 03:20:54 +00:00
Severity RNGFrameNotFound3 { get ; }
Severity RNGFrameNotFound4 { get ; }
2022-06-18 18:04:24 +00:00
Severity Gen7TransferStarPID { get ; }
Severity Gen8MemoryMissingHT { get ; }
2024-02-23 03:20:54 +00:00
Severity HOMETransferTrackerNotPresent { get ; }
2022-06-18 18:04:24 +00:00
Severity NicknamedAnotherSpecies { get ; }
Severity ZeroHeightWeight { get ; }
Severity CurrentHandlerMismatch { get ; }
}
public interface IBulkAnalysisSettings
{
bool CheckActiveHandler { get ; }
}