mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-12 14:48:41 -05:00
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
89 lines
3.8 KiB
C#
89 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Calculated Information storage with properties useful for parsing the legality of the input <see cref="PKM"/>.
|
|
/// </summary>
|
|
public sealed class LegalInfo
|
|
{
|
|
/// <summary>The <see cref="PKM"/> object used for comparisons.</summary>
|
|
private readonly PKM pkm;
|
|
|
|
/// <summary>The generation of games the <see cref="PKM"/> originated from.</summary>
|
|
public int Generation { get; internal set; }
|
|
|
|
/// <summary>The Game the <see cref="PKM"/> originated from.</summary>
|
|
public GameVersion Game { get; internal set; }
|
|
|
|
/// <summary>The matched Encounter details for the <see cref="PKM"/>. </summary>
|
|
public IEncounterable EncounterMatch
|
|
{
|
|
get => _match;
|
|
set
|
|
{
|
|
if (_match != EncounterInvalid.Default && (value.LevelMin != _match.LevelMin || value.Species != _match.Species))
|
|
_evochains = null; // clear if evo chain has the potential to be different
|
|
_match = value;
|
|
Parse.Clear();
|
|
}
|
|
}
|
|
|
|
private IEncounterable _match = EncounterInvalid.Default;
|
|
|
|
/// <summary>Base Relearn Moves for the <see cref="EncounterMatch"/>.</summary>
|
|
public IReadOnlyList<int> RelearnBase { get; internal set; } = Array.Empty<int>();
|
|
|
|
/// <summary>Top level Legality Check result list for the <see cref="EncounterMatch"/>.</summary>
|
|
public readonly List<CheckResult> Parse = new List<CheckResult>();
|
|
|
|
public CheckResult[] Relearn { get; internal set; } = new CheckResult[4];
|
|
public CheckMoveResult[] Moves { get; internal set; } = new CheckMoveResult[4];
|
|
|
|
private static readonly ValidEncounterMoves NONE = new ValidEncounterMoves();
|
|
public ValidEncounterMoves EncounterMoves { get; internal set; } = NONE;
|
|
public IReadOnlyList<EvoCriteria>[] EvoChainsAllGens => _evochains ??= EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterMatch);
|
|
private IReadOnlyList<EvoCriteria>[]? _evochains;
|
|
|
|
/// <summary><see cref="RNG"/> related information that generated the <see cref="PKM.PID"/>/<see cref="PKM.IVs"/> value(s).</summary>
|
|
public PIDIV PIDIV
|
|
{
|
|
get => _pidiv;
|
|
internal set
|
|
{
|
|
_pidiv = value;
|
|
PIDParsed = true;
|
|
}
|
|
}
|
|
|
|
public bool PIDParsed { get; private set; }
|
|
private PIDIV _pidiv = PIDIV.None;
|
|
|
|
/// <summary>Indicates whether or not the <see cref="PIDIV"/> can originate from the <see cref="EncounterMatch"/>.</summary>
|
|
/// <remarks>This boolean is true until all valid <see cref="PIDIV"/> encounters are tested, after which it is false.</remarks>
|
|
public bool PIDIVMatches { get; internal set; } = true;
|
|
|
|
/// <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; internal set; } = true;
|
|
|
|
public LegalInfo(PKM pk)
|
|
{
|
|
pkm = pk;
|
|
|
|
// Store repeatedly accessed values
|
|
Game = (GameVersion)pkm.Version;
|
|
Generation = pkm.GenNumber;
|
|
}
|
|
|
|
/// <summary>List of all near-matches that were rejected for a given reason.</summary>
|
|
public List<EncounterRejected>? InvalidMatches;
|
|
|
|
internal void Reject(CheckResult c)
|
|
{
|
|
(InvalidMatches ??= new List<EncounterRejected>()).Add(new EncounterRejected(EncounterMatch, c));
|
|
}
|
|
}
|
|
}
|