2017-05-28 04:17:53 +00:00
using System.Collections.Generic ;
2017-07-04 20:24:12 +00:00
using System.Linq ;
2017-05-28 04:17:53 +00:00
namespace PKHeX.Core
{
2017-10-24 06:12:58 +00:00
/// <summary>
/// Calculated Information storage with properties useful for parsing the legality of the input <see cref="PKM"/>.
/// </summary>
2017-05-28 04:17:53 +00:00
public class LegalInfo
{
/// <summary>The <see cref="PKM"/> object used for comparisons.</summary>
private readonly PKM pkm ;
2017-09-04 02:51:29 +00:00
/// <summary>The generation of games the <see cref="PKM"/> originated from.</summary>
2017-06-18 01:37:19 +00:00
public int Generation { get ; set ; }
2017-05-28 04:17:53 +00:00
2017-09-04 02:51:29 +00:00
/// <summary>The Game the <see cref="PKM"/> originated from.</summary>
2017-05-28 23:56:51 +00:00
public GameVersion Game { get ; set ; }
2017-05-28 04:17:53 +00:00
/// <summary>The matched Encounter details for the <see cref="PKM"/>. </summary>
public IEncounterable EncounterMatch
{
get = > _match ;
set
{
if ( EncounterMatch ! = null & & ( value . LevelMin ! = EncounterMatch . LevelMin | | value . Species ! = EncounterMatch . Species ) )
_evochains = null ;
_match = value ;
Parse . Clear ( ) ;
}
}
2017-09-04 02:51:29 +00:00
private IEncounterable _match ;
2017-05-28 04:17:53 +00:00
2017-09-04 02:51:29 +00:00
/// <summary>Indicates whether or not the <see cref="PKM"/> originated from <see cref="GameVersion.XD"/>.</summary>
2018-04-29 15:31:57 +00:00
public bool WasXD = > pkm ? . Version = = 15 & & EncounterMatch is IVersion v & & v . Version = = GameVersion . XD ;
2017-09-04 02:51:29 +00:00
/// <summary>Base Relearn Moves for the <see cref="EncounterMatch"/>.</summary>
2017-06-18 01:37:19 +00:00
public int [ ] RelearnBase { get ; set ; }
2017-05-28 04:17:53 +00:00
2017-09-04 02:51:29 +00:00
/// <summary>Top level Legality Check result list for the <see cref="EncounterMatch"/>.</summary>
2017-05-28 04:17:53 +00:00
public readonly List < CheckResult > Parse = new List < CheckResult > ( ) ;
2017-06-18 01:37:19 +00:00
public CheckResult [ ] Relearn { get ; set ; } = new CheckResult [ 4 ] ;
public CheckMoveResult [ ] Moves { get ; set ; } = new CheckMoveResult [ 4 ] ;
2017-05-28 04:17:53 +00:00
public ValidEncounterMoves EncounterMoves { get ; set ; }
2017-09-04 02:51:29 +00:00
public DexLevel [ ] [ ] EvoChainsAllGens = > _evochains ? ? ( _evochains = Legal . GetEvolutionChainsAllGens ( pkm , EncounterMatch ) ) ;
2017-05-28 04:17:53 +00:00
private DexLevel [ ] [ ] _evochains ;
2017-09-04 02:51:29 +00:00
/// <summary><see cref="RNG"/> related information that generated the <see cref="PKM.PID"/>/<see cref="PKM.IVs"/> value(s).</summary>
2017-06-18 01:37:19 +00:00
public PIDIV PIDIV { get ; set ; }
2017-07-29 18:54:52 +00:00
2017-09-04 02:51:29 +00:00
/// <summary>Indicates whether or not the <see cref="PIDIV"/> can originate from the <see cref="EncounterMatch"/>.</summary>
2017-11-29 05:30:53 +00:00
/// <remarks>This boolean is true until all valid <see cref="PIDIV"/> encounters are tested, after which it is false.</remarks>
2017-06-18 01:37:19 +00:00
public bool PIDIVMatches { get ; set ; } = true ;
2017-05-28 04:17:53 +00:00
2017-11-29 05:30:53 +00:00
/// <summary>Indicates whether or not the <see cref="PIDIV"/> can originate from the <see cref="EncounterMatch"/> with explicit <see cref="RNG"/> <see cref="Frame"/> matching.</summary>
/// <remarks>This boolean is true until all valid <see cref="Frame"/> entries are tested for all possible <see cref="EncounterSlot"/> matches, after which it is false.</remarks>
public bool FrameMatches { get ; set ; } = true ;
2017-09-23 23:24:22 +00:00
public readonly bool Korean ;
2017-05-28 23:56:51 +00:00
public LegalInfo ( PKM pk )
{
pkm = pk ;
2017-09-23 23:24:22 +00:00
Korean = pk . Korean ;
2017-09-04 02:51:29 +00:00
// Store repeatedly accessed values
Game = ( GameVersion ) pkm . Version ;
2017-05-28 23:56:51 +00:00
Generation = pkm . GenNumber ;
}
2017-07-12 16:02:03 +00:00
2017-09-04 02:51:29 +00:00
/// <summary>List of all near-matches that were rejected for a given reason.</summary>
public List < EncounterRejected > InvalidMatches ;
2017-07-12 16:02:03 +00:00
internal void Reject ( CheckResult c )
{
if ( InvalidMatches = = null )
2017-09-04 02:51:29 +00:00
InvalidMatches = new List < EncounterRejected > ( ) ;
InvalidMatches . Add ( new EncounterRejected ( EncounterMatch , c ) ) ;
2017-07-12 16:02:03 +00:00
}
2017-05-28 04:17:53 +00:00
}
}