2020-11-27 18:45:06 -08:00
using System.Collections.Generic ;
using System.Linq ;
namespace PKHeX.Core
2018-10-05 19:58:30 -07:00
{
public static class ParseSettings
{
2019-11-26 16:55:28 -08:00
internal static ITrainerInfo ActiveTrainer { get ; set ; } = new SimpleTrainerInfo ( GameVersion . Any ) { OT = string . Empty , Language = - 1 } ;
2018-10-05 19:58:30 -07:00
/// <summary>
/// Toggles whether or not the word filter should be used when checking the data.
/// </summary>
public static bool CheckWordFilter { get ; set ; } = true ;
/// <summary>
/// Setting to specify if an analysis should permit data sourced from the physical cartridge era of GameBoy games.
/// </summary>
2021-04-11 18:09:54 -07:00
/// <remarks>If false, indicates to use Virtual Console rules (which are transferable to Gen7+)</remarks>
2018-10-05 19:58:30 -07:00
public static bool AllowGBCartEra { get ; set ; }
/// <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>
2021-02-03 15:39:30 -08:00
public static bool AllowGen1Tradeback { get ; set ; } = true ;
2018-10-05 19:58:30 -07:00
2021-04-11 18:09:54 -07:00
public static Severity NicknamedTrade { get ; private set ; } = Severity . Invalid ;
public static Severity NicknamedMysteryGift { get ; private set ; } = Severity . Fishy ;
public static Severity RNGFrameNotFound { get ; private set ; } = Severity . Fishy ;
public static Severity Gen7TransferStarPID { get ; private set ; } = Severity . Fishy ;
2021-08-29 13:09:26 -07:00
public static Severity Gen8MemoryMissingHT { get ; private set ; } = Severity . Fishy ;
2021-04-11 18:09:54 -07:00
public static Severity Gen8TransferTrackerNotPresent { get ; private set ; } = Severity . Fishy ;
public static Severity NicknamedAnotherSpecies { get ; private set ; } = Severity . Fishy ;
2021-11-24 23:03:30 -08:00
public static Severity ZeroHeightWeight { get ; private set ; } = Severity . Fishy ;
2022-06-05 13:18:31 -07:00
public static Severity CurrentHandlerMismatch { get ; private set ; } = Severity . Invalid ;
public static bool CheckActiveHandler { get ; set ; }
2018-10-06 13:43:05 -07:00
2020-11-27 18:45:06 -08:00
public static IReadOnlyList < string > MoveStrings = Util . GetMovesList ( GameLanguage . DefaultLanguage ) ;
public static IReadOnlyList < string > SpeciesStrings = Util . GetSpeciesList ( GameLanguage . DefaultLanguage ) ;
2021-04-04 18:30:01 -07:00
public static string GetMoveName ( int move ) = > ( uint ) move > = MoveStrings . Count ? LegalityCheckStrings . L_AError : MoveStrings [ move ] ;
2020-11-27 18:45:06 -08:00
public static IEnumerable < string > GetMoveNames ( IEnumerable < int > moves ) = > moves . Select ( m = > ( uint ) m > = MoveStrings . Count ? LegalityCheckStrings . L_AError : MoveStrings [ m ] ) ;
public static void ChangeLocalizationStrings ( IReadOnlyList < string > moves , IReadOnlyList < string > species )
{
SpeciesStrings = species ;
MoveStrings = moves ;
}
2018-10-05 19:58:30 -07:00
/// <summary>
/// Checks to see if Crystal is available to visit/originate from.
/// </summary>
/// <remarks>Pokemon Crystal was never released in Korea.</remarks>
/// <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="pkm">Data being checked</param>
/// <returns>True if Crystal data is allowed</returns>
2018-10-07 15:36:32 -07:00
public static bool AllowGen2Crystal ( PKM pkm ) = > ! pkm . Korean ;
2018-10-05 19:58:30 -07:00
/// <summary>
/// Checks to see if the Move Reminder (Relearner) is available.
/// </summary>
/// <remarks> Pokemon Stadium 2 was never released in Korea.</remarks>
/// <param name="pkm">Data being checked</param>
/// <returns>True if Crystal data is allowed</returns>
public static bool AllowGen2MoveReminder ( PKM pkm ) = > ! pkm . Korean & & AllowGBCartEra ;
internal static bool IsFromActiveTrainer ( PKM pkm ) = > ActiveTrainer . IsFromTrainer ( pkm ) ;
2019-01-21 20:06:02 -08:00
/// <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>
2018-10-05 19:58:30 -07:00
public static bool InitFromSaveFileData ( SaveFile sav )
{
ActiveTrainer = sav ;
2021-10-21 22:13:21 -07:00
return AllowGBCartEra = sav switch
{
SAV1 { IsVirtualConsole : true } = > false ,
SAV2 { IsVirtualConsole : true } = > false ,
{ Generation : 1 or 2 } = > true ,
_ = > false ,
} ;
2018-10-05 19:58:30 -07:00
}
2021-04-11 18:09:54 -07:00
public static void InitFromSettings ( IParseSettings settings )
{
CheckWordFilter = settings . CheckWordFilter ;
AllowGen1Tradeback = settings . AllowGen1Tradeback ;
NicknamedTrade = settings . NicknamedTrade ;
NicknamedMysteryGift = settings . NicknamedMysteryGift ;
RNGFrameNotFound = settings . RNGFrameNotFound ;
Gen7TransferStarPID = settings . Gen7TransferStarPID ;
Gen8TransferTrackerNotPresent = settings . Gen8TransferTrackerNotPresent ;
2021-08-29 13:09:26 -07:00
Gen8MemoryMissingHT = settings . Gen8MemoryMissingHT ;
2021-04-11 18:09:54 -07:00
NicknamedAnotherSpecies = settings . NicknamedAnotherSpecies ;
2021-11-24 19:29:02 -08:00
ZeroHeightWeight = settings . ZeroHeightWeight ;
2022-06-05 13:18:31 -07:00
CurrentHandlerMismatch = settings . CurrentHandlerMismatch ;
CheckActiveHandler = settings . CheckActiveHandler ;
2021-04-11 18:09:54 -07:00
}
}
public interface IParseSettings
{
bool CheckWordFilter { get ; }
2022-06-05 13:18:31 -07:00
bool CheckActiveHandler { get ; }
2021-04-11 18:09:54 -07:00
bool AllowGen1Tradeback { get ; }
Severity NicknamedTrade { get ; }
Severity NicknamedMysteryGift { get ; }
Severity RNGFrameNotFound { get ; }
Severity Gen7TransferStarPID { get ; }
2021-08-29 13:09:26 -07:00
Severity Gen8MemoryMissingHT { get ; }
2021-04-11 18:09:54 -07:00
Severity Gen8TransferTrackerNotPresent { get ; }
Severity NicknamedAnotherSpecies { get ; }
2021-11-24 19:29:02 -08:00
Severity ZeroHeightWeight { get ; }
2022-06-05 13:18:31 -07:00
Severity CurrentHandlerMismatch { get ; }
}
public interface IBulkAnalysisSettings
{
bool CheckActiveHandler { get ; }
2018-10-05 19:58:30 -07:00
}
}