mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Refactoring r2
Don't calculate suggested moves until prompted Don't check EncounterType for gen7 pkm (no field to check)
This commit is contained in:
parent
bcf1e63310
commit
016497bece
2 changed files with 37 additions and 19 deletions
|
@ -26,14 +26,36 @@ namespace PKHeX.Core
|
|||
|
||||
public readonly bool Parsed;
|
||||
public readonly bool Valid;
|
||||
public readonly bool Error;
|
||||
public bool ParsedValid => Parsed && Valid;
|
||||
public bool ParsedInvalid => Parsed && !Valid;
|
||||
public CheckResult[] vMoves = new CheckResult[4];
|
||||
public CheckResult[] vRelearn = new CheckResult[4];
|
||||
public string Report(bool verbose = false) => verbose ? getVerboseLegalityReport() : getLegalityReport();
|
||||
public readonly int[] AllSuggestedMoves;
|
||||
public readonly int[] AllSuggestedRelearnMoves;
|
||||
public readonly int[] AllSuggestedMovesAndRelearn;
|
||||
public string Report(bool verbose = false) => verbose ? getVerboseLegalityReport() : getLegalityReport();
|
||||
private IEnumerable<int> AllSuggestedMoves
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Error)
|
||||
return new int[4];
|
||||
if (_allSuggestedMoves == null)
|
||||
return _allSuggestedMoves = !pkm.IsOriginValid ? new int[4] : getSuggestedMoves(true, true, true);
|
||||
return _allSuggestedMoves;
|
||||
}
|
||||
}
|
||||
private IEnumerable<int> AllSuggestedRelearnMoves
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Error)
|
||||
return new int[4];
|
||||
if (_allSuggestedRelearnMoves == null)
|
||||
return _allSuggestedRelearnMoves = !pkm.IsOriginValid ? new int[4] : Legal.getValidRelearn(pkm, -1).ToArray();
|
||||
return _allSuggestedRelearnMoves;
|
||||
}
|
||||
}
|
||||
private int[] _allSuggestedMoves, _allSuggestedRelearnMoves;
|
||||
public int[] AllSuggestedMovesAndRelearn => AllSuggestedMoves.Concat(AllSuggestedRelearnMoves).ToArray();
|
||||
|
||||
public LegalityAnalysis(PKM pk)
|
||||
{
|
||||
|
@ -76,8 +98,6 @@ namespace PKHeX.Core
|
|||
if (pkm.FatefulEncounter && vRelearn.Any(chk => !chk.Valid) && EncounterMatch == null)
|
||||
AddLine(Severity.Indeterminate, V188, CheckIdentifier.Fateful);
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -85,12 +105,8 @@ namespace PKHeX.Core
|
|||
Valid = false;
|
||||
Parsed = true;
|
||||
AddLine(Severity.Invalid, V190, CheckIdentifier.Misc);
|
||||
AllSuggestedMoves = AllSuggestedRelearnMoves = AllSuggestedMovesAndRelearn = new int[0];
|
||||
return;
|
||||
Error = true;
|
||||
}
|
||||
AllSuggestedMoves = !pkm.IsOriginValid ? new int[4] : getSuggestedMoves(true, true, true);
|
||||
AllSuggestedRelearnMoves = !pkm.IsOriginValid ? new int[4] : Legal.getValidRelearn(pkm, -1).ToArray();
|
||||
AllSuggestedMovesAndRelearn = AllSuggestedMoves.Concat(AllSuggestedRelearnMoves).ToArray();
|
||||
}
|
||||
|
||||
private void AddLine(Severity s, string c, CheckIdentifier i)
|
||||
|
|
|
@ -701,9 +701,9 @@ namespace PKHeX.Core
|
|||
switch (pkm.GenNumber)
|
||||
{
|
||||
case 4:
|
||||
if(pkm.HasOriginalMetLocation && pkm.Met_Location == 193 && enc.All( t => t.Type == SlotType.Surf))
|
||||
if (pkm.HasOriginalMetLocation && pkm.Met_Location == 193 && enc.All(t => t.Type == SlotType.Surf))
|
||||
{
|
||||
// Pokemon surfing in Jhoto Route 45
|
||||
// Pokemon surfing in Johto Route 45
|
||||
return new CheckResult(Severity.Invalid, V384, CheckIdentifier.Encounter);
|
||||
}
|
||||
break;
|
||||
|
@ -749,7 +749,7 @@ namespace PKHeX.Core
|
|||
return new CheckResult(Severity.Invalid, V383, CheckIdentifier.Encounter);
|
||||
if (pkm.Species == 492 && s.Location == 063 && !pkm.Pt) // DP Shaymin
|
||||
return new CheckResult(Severity.Invalid, V354, CheckIdentifier.Encounter);
|
||||
if (s.Location == 193 && (s as EncounterStaticTyped)?.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfin in Jhoto Route 45
|
||||
if (s.Location == 193 && (s as EncounterStaticTyped)?.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfin in Johto Route 45
|
||||
return new CheckResult(Severity.Invalid, V384, CheckIdentifier.Encounter);
|
||||
break;
|
||||
case 7:
|
||||
|
@ -813,11 +813,14 @@ namespace PKHeX.Core
|
|||
}
|
||||
private void verifyEncounterType()
|
||||
{
|
||||
if (pkm.Format >= 7)
|
||||
return;
|
||||
|
||||
EncounterType type = EncounterType.None;
|
||||
// Encounter type data is only stored for gen 4 encounters
|
||||
// Gen 6 -> 7 transfer delete encounter type data
|
||||
// All eggs have encounter type none, even if they are from static encounters
|
||||
if (pkm.Format < 7 && pkm.Gen4 && !pkm.WasEgg)
|
||||
if (pkm.Gen4 && !pkm.WasEgg)
|
||||
{
|
||||
if (EncounterMatch is EncounterSlot[])
|
||||
// If there is more than one slot, the get wild encounter have filter for the pkm type encounter like safari/sports ball
|
||||
|
@ -831,12 +834,11 @@ namespace PKHeX.Core
|
|||
AddLine(Severity.NotImplemented, V382, CheckIdentifier.Encounter);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type != (EncounterType)pkm.EncounterType)
|
||||
{
|
||||
AddLine(Severity.Invalid, V381, CheckIdentifier.Encounter);
|
||||
return;
|
||||
}
|
||||
AddLine(Severity.Valid, V380, CheckIdentifier.Encounter);
|
||||
else
|
||||
AddLine(Severity.Valid, V380, CheckIdentifier.Encounter);
|
||||
}
|
||||
|
||||
private CheckResult verifyEncounter()
|
||||
|
|
Loading…
Reference in a new issue