using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core;
///
/// Settings for Parsing Legality
///
///
public static class ParseSettings
{
internal static ITrainerInfo ActiveTrainer { get; set; } = new SimpleTrainerInfo(GameVersion.Any) { OT = string.Empty, Language = -1 };
///
/// Toggles whether or not the word filter should be used when checking the data.
///
public static bool CheckWordFilter { get; set; } = true;
///
/// Setting to specify if an analysis should permit data sourced from the physical cartridge era of GameBoy games.
///
/// If false, indicates to use Virtual Console rules (which are transferable to Gen7+)
public static bool AllowGBCartEra { 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 { get; set; } = true;
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;
public static Severity Gen8MemoryMissingHT { get; private set; } = Severity.Fishy;
public static Severity Gen8TransferTrackerNotPresent { get; private set; } = Severity.Fishy;
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 MoveStrings { get; private set; } = Util.GetMovesList(GameLanguage.DefaultLanguage);
public static IReadOnlyList SpeciesStrings { get; private set; } = Util.GetSpeciesList(GameLanguage.DefaultLanguage);
public static string GetMoveName(ushort move) => move >= MoveStrings.Count ? LegalityCheckStrings.L_AError : MoveStrings[move];
public static IEnumerable GetMoveNames(IEnumerable moves) => moves.Select(m => (uint)m >= MoveStrings.Count ? LegalityCheckStrings.L_AError : MoveStrings[m]);
public static void ChangeLocalizationStrings(IReadOnlyList moves, IReadOnlyList species)
{
SpeciesStrings = species;
MoveStrings = moves;
}
///
/// Checks to see if Crystal is available to visit/originate from.
///
/// Pokemon Crystal was never released in Korea.
/// Korean data being checked
/// True if Crystal data is allowed
public static bool AllowGen2Crystal(bool Korean) => !Korean;
///
/// 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.
///
/// Pokemon Stadium 2 was never released in Korea.
/// Data being checked
/// True if Crystal data is allowed
public static bool AllowGen2MoveReminder(PKM pk) => !pk.Korean && AllowGBCartEra;
internal static bool IsFromActiveTrainer(PKM pk) => ActiveTrainer.IsFromTrainer(pk);
///
/// Initializes certain settings
///
/// Newly loaded save file
/// Save file is Physical GB cartridge save file (not Virtual Console)
public static bool InitFromSaveFileData(SaveFile sav)
{
ActiveTrainer = sav;
return AllowGBCartEra = sav switch
{
SAV1 { IsVirtualConsole: true } => false,
SAV2 { IsVirtualConsole: true } => false,
{ Generation: 1 or 2 } => true,
_ => false,
};
}
internal static bool IgnoreTransferIfNoTracker => Gen8TransferTrackerNotPresent == Severity.Invalid;
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;
Gen8MemoryMissingHT = settings.Gen8MemoryMissingHT;
NicknamedAnotherSpecies = settings.NicknamedAnotherSpecies;
ZeroHeightWeight = settings.ZeroHeightWeight;
CurrentHandlerMismatch = settings.CurrentHandlerMismatch;
CheckActiveHandler = settings.CheckActiveHandler;
}
}
public interface IParseSettings
{
bool CheckWordFilter { get; }
bool CheckActiveHandler { get; }
bool AllowGen1Tradeback { get; }
Severity NicknamedTrade { get; }
Severity NicknamedMysteryGift { get; }
Severity RNGFrameNotFound { get; }
Severity Gen7TransferStarPID { get; }
Severity Gen8MemoryMissingHT { get; }
Severity Gen8TransferTrackerNotPresent { get; }
Severity NicknamedAnotherSpecies { get; }
Severity ZeroHeightWeight { get; }
Severity CurrentHandlerMismatch { get; }
}
public interface IBulkAnalysisSettings
{
bool CheckActiveHandler { get; }
}