mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 08:47:14 +00:00
Merge Error flag into Parsed
Simplify some logic with ??=
This commit is contained in:
parent
c5593470df
commit
5dde0f5c43
1 changed files with 10 additions and 14 deletions
|
@ -14,7 +14,6 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
internal readonly PKM pkm;
|
internal readonly PKM pkm;
|
||||||
internal readonly PersonalInfo PersonalInfo;
|
internal readonly PersonalInfo PersonalInfo;
|
||||||
private readonly bool Error;
|
|
||||||
private readonly List<CheckResult> Parse = new List<CheckResult>();
|
private readonly List<CheckResult> Parse = new List<CheckResult>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -70,11 +69,9 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_allSuggestedMoves != null)
|
if (!Parsed)
|
||||||
return _allSuggestedMoves;
|
|
||||||
if (Error || Info == null)
|
|
||||||
return new int[4];
|
return new int[4];
|
||||||
return _allSuggestedMoves = GetSuggestedMoves(true, true, true);
|
return _allSuggestedMoves ??= GetSuggestedMoves(true, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +79,9 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_allSuggestedRelearnMoves != null)
|
if (!Parsed)
|
||||||
return _allSuggestedRelearnMoves;
|
|
||||||
if (Error || Info == null)
|
|
||||||
return new int[4];
|
return new int[4];
|
||||||
var enc = Info.EncounterMatch;
|
return _allSuggestedRelearnMoves ??= Legal.GetValidRelearn(pkm, Info.EncounterMatch.Species, Info.EncounterMatch.Form, (GameVersion)pkm.Version).ToArray();
|
||||||
return _allSuggestedRelearnMoves = Legal.GetValidRelearn(pkm, enc.Species, enc.Form, (GameVersion)pkm.Version).ToArray();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +128,11 @@ namespace PKHeX.Core
|
||||||
AddLine(Severity.Invalid, LEncConditionBadSpecies, CheckIdentifier.GameOrigin);
|
AddLine(Severity.Invalid, LEncConditionBadSpecies, CheckIdentifier.GameOrigin);
|
||||||
GetParseMethod()();
|
GetParseMethod()();
|
||||||
|
|
||||||
if (Parse.Count == 0)
|
if (Parse.Count == 0) // shouldn't ever happen as at least one is yielded above.
|
||||||
|
{
|
||||||
|
AddLine(Severity.Invalid, L_AError, CheckIdentifier.Misc);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Valid = Parse.All(chk => chk.Valid)
|
Valid = Parse.All(chk => chk.Valid)
|
||||||
&& Info.Moves.All(m => m.Valid)
|
&& Info.Moves.All(m => m.Valid)
|
||||||
|
@ -143,18 +140,17 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
if (!Valid && pkm.FatefulEncounter && Info.Relearn.Any(chk => !chk.Valid) && EncounterMatch is EncounterInvalid)
|
if (!Valid && pkm.FatefulEncounter && Info.Relearn.Any(chk => !chk.Valid) && EncounterMatch is EncounterInvalid)
|
||||||
AddLine(Severity.Indeterminate, LFatefulGiftMissing, CheckIdentifier.Fateful);
|
AddLine(Severity.Indeterminate, LFatefulGiftMissing, CheckIdentifier.Fateful);
|
||||||
|
Parsed = true;
|
||||||
}
|
}
|
||||||
#if SUPPRESS
|
#if SUPPRESS
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Info = new LegalInfo(pkm);
|
|
||||||
System.Diagnostics.Debug.WriteLine(e.Message);
|
System.Diagnostics.Debug.WriteLine(e.Message);
|
||||||
|
Info = new LegalInfo(pkm);
|
||||||
Valid = false;
|
Valid = false;
|
||||||
AddLine(Severity.Invalid, L_AError, CheckIdentifier.Misc);
|
AddLine(Severity.Invalid, L_AError, CheckIdentifier.Misc);
|
||||||
Error = true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Parsed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action GetParseMethod()
|
private Action GetParseMethod()
|
||||||
|
|
Loading…
Reference in a new issue