Add Fateful Encounter check

Cleared up the Event check a little to allow Fateful Encounters to slip
through.
This commit is contained in:
Kaphotics 2016-04-21 19:32:22 -07:00
parent 13ec0e9e89
commit 214473756e
3 changed files with 20 additions and 8 deletions

View file

@ -10,8 +10,8 @@ namespace PKHeX
private object EncounterMatch;
private List<WC6> CardMatch;
private Type EncounterType;
private LegalityCheck ECPID, Nickname, IDs, IVs, EVs, Encounter, Level, Ribbons, Ability, Ball, HandlerMemories, Form;
private LegalityCheck[] Checks => new[] { Encounter, Level, Form, Ball, Ability, Ribbons, ECPID, Nickname, IVs, EVs, IDs, HandlerMemories };
private LegalityCheck ECPID, Nickname, IDs, IVs, EVs, Encounter, Level, Ribbons, Ability, Ball, HandlerMemories, Form, Misc;
private LegalityCheck[] Checks => new[] { Encounter, Level, Form, Ball, Ability, Ribbons, ECPID, Nickname, IVs, EVs, IDs, HandlerMemories, Misc };
public bool Valid = true;
public bool SecondaryChecked;
@ -58,6 +58,7 @@ namespace PKHeX
Ball = verifyBall();
HandlerMemories = verifyHandlerMemories();
Form = verifyForm();
Misc = verifyMisc();
SecondaryChecked = true;
}
private string getLegalityReport()

View file

@ -201,18 +201,18 @@ namespace PKHeX
// Should NOT be Fateful, and should be in Database
EncounterLink enc = EncounterMatch as EncounterLink;
if (enc == null)
return new LegalityCheck(Severity.Invalid, "Not a valid Link gift -- unable to find matching gift.");
return new LegalityCheck(Severity.Invalid, "Invalid Link Gift: unable to find matching gift.");
if (pk6.XY && !enc.XY)
return new LegalityCheck(Severity.Invalid, "Not a valid Link gift -- can't obtain in XY.");
return new LegalityCheck(Severity.Invalid, "Invalid Link Gift: can't obtain in XY.");
if (pk6.AO && !enc.ORAS)
return new LegalityCheck(Severity.Invalid, "Not a valid Link gift -- can't obtain in ORAS.");
return new LegalityCheck(Severity.Invalid, "Invalid Link Gift: can't obtain in ORAS.");
if (enc.Shiny != null && (bool)enc.Shiny ^ pk6.IsShiny)
return new LegalityCheck(Severity.Invalid, "Shiny Link gift mismatch.");
return pk6.FatefulEncounter
? new LegalityCheck(Severity.Invalid, "Not a valid Link gift -- should not be Fateful Encounter.")
? new LegalityCheck(Severity.Invalid, "Invalid Link Gift: should not be Fateful Encounter.")
: new LegalityCheck(Severity.Valid, "Valid Link gift.");
}
if (pk6.WasEvent || pk6.WasEventEgg)
@ -647,6 +647,17 @@ namespace PKHeX
? new LegalityCheck(Severity.Invalid, "Form cannot exist outside of a battle.")
: new LegalityCheck();
}
private LegalityCheck verifyMisc()
{
if (pk6.Gen6 && Encounter.Valid && EncounterType == typeof(WC6) ^ pk6.FatefulEncounter)
{
if (EncounterType == typeof(EncounterStatic) && pk6.Species == 386) // Deoxys Matched @ Sky Pillar
return new LegalityCheck();
return new LegalityCheck(Severity.Invalid, "Fateful Encounter mismatch.");
}
return new LegalityCheck();
}
private LegalityCheck[] verifyMoves()
{
int[] Moves = pk6.Moves;

View file

@ -750,8 +750,8 @@ namespace PKHeX
// Legality Properties
public bool WasLink => Met_Location == 30011;
public bool WasEgg => Legal.EggLocations.Contains(Egg_Location);
public bool WasEvent => FatefulEncounter && Met_Location > 40000;
public bool WasEventEgg => FatefulEncounter && (Egg_Location > 40000 || Egg_Location == 30002) && Met_Level == 1;
public bool WasEvent => Met_Location > 40000 && Met_Location < 50000;
public bool WasEventEgg => ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location == 30002)) && Met_Level == 1;
public bool WasTradedEgg => Egg_Location == 30002;
public bool WasIngameTrade => Met_Location == 30001;
}