Add memorycheck 14 (species can be captured)

This commit is contained in:
Kaphotics 2016-05-05 20:35:18 -07:00
parent e06c38151c
commit 3a424c8b5b
2 changed files with 45 additions and 0 deletions

View file

@ -648,6 +648,10 @@ namespace PKHeX
{
case 4: // {0} became {1}s friend when it arrived via Link Trade at... {2}. {4} that {3}.
return new LegalityCheck(Severity.Invalid, "OT Memory: Link Trade is not a valid first memory.");
case 14:
if (!Legal.getCanBeCaptured(pk6.OT_TextVar, pk6.Version))
return new LegalityCheck(Severity.Invalid, "OT Memory: Captured Species can not be captured in game.");
return new LegalityCheck(Severity.Valid, "OT Memory: Captured Species can be captured in game.");
}
if (pk6.XY && Legal.Memory_NotXY.Contains(pk6.OT_Memory))
return new LegalityCheck(Severity.Invalid, "OT Memory: OR/AS exclusive memory on X/Y origin.");
@ -667,6 +671,10 @@ namespace PKHeX
return new LegalityCheck(Severity.Invalid, "HT Memory: Handling Trainer did not capture this.");
case 2: // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
return new LegalityCheck(Severity.Invalid, "HT Memory: Handling Trainer did not hatch this.");
case 14:
if (!Legal.getCanBeCaptured(pk6.HT_TextVar))
return new LegalityCheck(Severity.Invalid, "HT Memory: Captured Species can not be captured in game.");
return new LegalityCheck(Severity.Valid, "HT Memory: Captured Species can be captured in game.");
}
return new LegalityCheck(Severity.Valid, "HT Memory is valid.");
}

View file

@ -353,6 +353,43 @@ namespace PKHeX
return res.Distinct();
}
internal static bool getCanBeCaptured(int species, int version = -1)
{
if (version < 0 || version == (int)GameVersion.X)
{
if (SlotsX.Any(loc => loc.Slots.Any(slot => slot.Species == species)))
return true;
if (FriendSafari.Contains(species))
return true;
if (StaticX.Any(enc => enc.Species == species && !enc.Gift))
return true;
}
if (version < 0 || version == (int)GameVersion.Y)
{
if (SlotsY.Any(loc => loc.Slots.Any(slot => slot.Species == species)))
return true;
if (FriendSafari.Contains(species))
return true;
if (StaticY.Any(enc => enc.Species == species && !enc.Gift))
return true;
}
if (version < 0 || version == (int)GameVersion.AS)
{
if (SlotsA.Any(loc => loc.Slots.Any(slot => slot.Species == species)))
return true;
if (StaticA.Any(enc => enc.Species == species && !enc.Gift))
return true;
}
if (version < 0 || version == (int)GameVersion.OR)
{
if (SlotsO.Any(loc => loc.Slots.Any(slot => slot.Species == species)))
return true;
if (StaticO.Any(enc => enc.Species == species && !enc.Gift))
return true;
}
return false;
}
private static int getBaseSpecies(PK6 pk6, int skipOption = 0)
{
if (pk6.Species == 292)