2017-07-29 18:54:52 +00:00
|
|
|
|
using System;
|
2017-09-30 21:08:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-29 18:54:52 +00:00
|
|
|
|
using System.Linq;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public static class EncounterVerifier
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the method to verify the <see cref="IEncounterable"/> data.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pkm">Source data to verify</param>
|
|
|
|
|
/// <returns>Returns the verification method appropriate for the input PKM</returns>
|
|
|
|
|
public static Func<PKM, LegalInfo, CheckResult> GetEncounterVerifierMethod(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
switch (pkm.GenNumber)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
return VerifyEncounterG12;
|
|
|
|
|
default:
|
|
|
|
|
return VerifyEncounter;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2017-08-01 00:09:16 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2017-08-01 00:09:16 +00:00
|
|
|
|
private static CheckResult VerifyEncounter(PKM pkm, LegalInfo info)
|
|
|
|
|
{
|
|
|
|
|
switch (info.EncounterMatch)
|
|
|
|
|
{
|
2018-08-03 03:11:42 +00:00
|
|
|
|
case EncounterEgg _: return VerifyEncounterEgg(pkm);
|
2018-03-09 05:18:32 +00:00
|
|
|
|
case EncounterLink l: return VerifyEncounterLink(pkm, l);
|
|
|
|
|
case EncounterTrade t: return VerifyEncounterTrade(pkm, t);
|
|
|
|
|
case EncounterSlot w: return VerifyEncounterWild(pkm, w);
|
|
|
|
|
case EncounterStatic s: return VerifyEncounterStatic(pkm, s);
|
|
|
|
|
case MysteryGift g: return VerifyEncounterEvent(pkm, g);
|
2017-08-01 00:09:16 +00:00
|
|
|
|
default:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter);
|
2017-08-01 00:09:16 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-07-29 18:54:52 +00:00
|
|
|
|
private static CheckResult VerifyEncounterG12(PKM pkm, LegalInfo info)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2018-01-11 00:16:35 +00:00
|
|
|
|
var EncounterMatch = info.EncounterMatch;
|
|
|
|
|
if (EncounterMatch.EggEncounter)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
pkm.WasEgg = true;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
return VerifyEncounterEgg(pkm);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2017-07-06 23:03:41 +00:00
|
|
|
|
if (EncounterMatch is EncounterSlot1 l)
|
|
|
|
|
{
|
|
|
|
|
if (info.Generation == 2)
|
|
|
|
|
return VerifyWildEncounterGen2(pkm, l);
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter);
|
2017-07-06 23:03:41 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (EncounterMatch is EncounterStatic s)
|
2017-08-01 00:09:16 +00:00
|
|
|
|
return VerifyEncounterStatic(pkm, s);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (EncounterMatch is EncounterTrade t)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return VerifyEncounterTrade(pkm, t);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2017-08-01 00:09:16 +00:00
|
|
|
|
|
|
|
|
|
// Gen2 Wild Encounters
|
2017-07-06 23:03:41 +00:00
|
|
|
|
private static CheckResult VerifyWildEncounterGen2(PKM pkm, EncounterSlot1 encounter)
|
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
switch (encounter.Type)
|
|
|
|
|
{
|
2017-07-08 00:40:23 +00:00
|
|
|
|
// Fishing in the beta gen 2 Safari Zone
|
2017-08-01 00:09:16 +00:00
|
|
|
|
case SlotType.Old_Rod_Safari:
|
|
|
|
|
case SlotType.Good_Rod_Safari:
|
|
|
|
|
case SlotType.Super_Rod_Safari:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG2InvalidTileSafari, CheckIdentifier.Encounter);
|
2017-08-01 00:09:16 +00:00
|
|
|
|
}
|
2017-07-06 23:03:41 +00:00
|
|
|
|
|
|
|
|
|
if (encounter.Version == GameVersion.C)
|
|
|
|
|
return VerifyWildEncounterCrystal(pkm, encounter);
|
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter);
|
2017-07-06 23:03:41 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-10-23 06:26:37 +00:00
|
|
|
|
private static CheckResult VerifyWildEncounterCrystal(PKM pkm, EncounterSlot encounter)
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
switch (encounter.Type)
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
case SlotType.Headbutt:
|
|
|
|
|
case SlotType.Headbutt_Special:
|
|
|
|
|
return VerifyWildEncounterCrystalHeadbutt(pkm, encounter);
|
|
|
|
|
|
|
|
|
|
case SlotType.Old_Rod:
|
|
|
|
|
case SlotType.Good_Rod:
|
|
|
|
|
case SlotType.Super_Rod:
|
|
|
|
|
switch (encounter.Location)
|
|
|
|
|
{
|
|
|
|
|
case 19: // National Park
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG2InvalidTilePark, CheckIdentifier.Encounter);
|
2017-08-01 00:09:16 +00:00
|
|
|
|
case 76: // Route 14
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG2InvalidTileR14, CheckIdentifier.Encounter);
|
2017-08-01 00:09:16 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2017-07-06 23:03:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter);
|
2017-07-06 23:03:41 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2018-04-30 01:26:36 +00:00
|
|
|
|
private static CheckResult VerifyWildEncounterCrystalHeadbutt(ITrainerID tr, EncounterSlot encounter)
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2018-06-10 17:44:05 +00:00
|
|
|
|
var tree = Encounters2.GetGSCHeadbuttAvailability(encounter, tr.TID);
|
2018-04-30 01:26:36 +00:00
|
|
|
|
switch (tree)
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
|
|
|
|
case TreeEncounterAvailable.ValidTree:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LG2TreeID, CheckIdentifier.Encounter);
|
2017-07-06 23:03:41 +00:00
|
|
|
|
case TreeEncounterAvailable.InvalidTree:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG2InvalidTileTreeID, CheckIdentifier.Encounter);
|
2017-08-01 00:09:16 +00:00
|
|
|
|
default: // Impossible
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG2InvalidTileTreeNotFound, CheckIdentifier.Encounter);
|
2017-07-29 18:54:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
// Eggs
|
2018-08-03 03:11:42 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2018-03-09 05:18:32 +00:00
|
|
|
|
pkm.WasEgg = true;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
// Check Species
|
|
|
|
|
if (Legal.NoHatchFromEgg.Contains(pkm.Species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggSpecies, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
switch (pkm.GenNumber)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
case 2: return new CheckResult(CheckIdentifier.Encounter); // no met location info
|
2017-06-18 01:37:19 +00:00
|
|
|
|
case 3: return pkm.Format != 3 ? VerifyEncounterEgg3Transfer(pkm) : VerifyEncounterEgg3(pkm);
|
|
|
|
|
case 4: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, 02002) : VerifyEncounterEgg4(pkm);
|
2017-09-06 03:32:07 +00:00
|
|
|
|
case 5: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, 30003) : VerifyEncounterEgg5(pkm);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
case 6: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, 30002) : VerifyEncounterEgg6(pkm);
|
|
|
|
|
case 7: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, 30002) : VerifyEncounterEgg7(pkm);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
default: // none of the above
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg3(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return pkm.Format == 3 ? VerifyEncounterEgg3Native(pkm) : VerifyEncounterEgg3Transfer(pkm);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg3Native(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Met_Level != 0)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(LEggFMetLevel_0, 0), CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
{
|
|
|
|
|
var loc = pkm.FRLG ? Legal.ValidEggMet_FRLG : Legal.ValidEggMet_RSE;
|
|
|
|
|
if (!loc.Contains(pkm.Met_Location))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggMetLocationFail, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var locs = pkm.FRLG ? Legal.ValidMet_FRLG : pkm.E ? Legal.ValidMet_E : Legal.ValidMet_RS;
|
|
|
|
|
if (locs.Contains(pkm.Met_Location))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (Legal.ValidMet_FRLG.Contains(pkm.Met_Location) || Legal.ValidMet_E.Contains(pkm.Met_Location) || Legal.ValidMet_RS.Contains(pkm.Met_Location))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocationTrade, CheckIdentifier.Encounter);
|
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg3Transfer(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.IsEgg)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEgg, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Met_Level < 5)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEggMetLevel, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Egg_Location != 0)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationNone, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Format == 4 && pkm.Met_Location != 0x37) // Pal Park
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationPalPark, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Format != 4 && pkm.Met_Location != 30001)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEggLocationTransporter, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg4(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Format == 4)
|
2017-10-20 05:00:31 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 0, Legal.Met_HGSS_Hatch);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.IsEgg)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEgg, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
// transferred
|
|
|
|
|
if (pkm.Met_Level < 1)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEggMetLevel, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Met_Location != 30001)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEggLocationTransporter, CheckIdentifier.Encounter);
|
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg5(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, pkm.B2W2 ? Legal.ValidMet_B2W2 : Legal.ValidMet_BW);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg6(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.AO)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_AO);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Egg_Location == 318)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggMetLocationFail, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_XY);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg7(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.SM)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_SM);
|
2017-09-20 04:35:30 +00:00
|
|
|
|
if (pkm.USUM)
|
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_USUM);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
// no other games
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-09-30 21:08:35 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEggLevelLoc(PKM pkm, int eggLevel, ICollection<int> MetLocations)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Met_Level != eggLevel)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(LEggFMetLevel_0, eggLevel), CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
return MetLocations.Contains(pkm.Met_Location)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter)
|
|
|
|
|
: new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyUnhatchedEgg(PKM pkm, int tradeLoc)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-06-28 05:08:16 +00:00
|
|
|
|
var eggLevel = pkm.Format < 5 ? 0 : 1;
|
|
|
|
|
if (pkm.Met_Level != eggLevel)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(LEggFMetLevel_0, eggLevel), CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
if (pkm.Egg_Location == tradeLoc)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationTradeFail, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Met_Location == tradeLoc)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocationTrade, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
return pkm.Met_Location == 0
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? new CheckResult(Severity.Valid, LEggUnhatched, CheckIdentifier.Encounter)
|
|
|
|
|
: new CheckResult(Severity.Invalid, LEggLocationNone, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-29 18:54:52 +00:00
|
|
|
|
// Other
|
2017-08-01 00:09:16 +00:00
|
|
|
|
private static CheckResult VerifyEncounterWild(PKM pkm, EncounterSlot slot)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
// Check for Unreleased Encounters / Collisions
|
|
|
|
|
switch (pkm.GenNumber)
|
|
|
|
|
{
|
|
|
|
|
case 4:
|
2017-08-01 00:09:16 +00:00
|
|
|
|
if (slot.Location == 193 && slot.Type == SlotType.Surf) // surfing in Johto Route 45
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (slot.Permissions.IsNormalLead)
|
2018-08-03 03:11:42 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return slot.Permissions.Pressure
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? new CheckResult(Severity.Valid, LEncConditionLead, CheckIdentifier.Encounter)
|
|
|
|
|
: new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter);
|
2018-08-03 03:11:42 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
// Decreased Level Encounters
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (slot.Permissions.WhiteFlute)
|
2018-08-03 03:11:42 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return slot.Permissions.Pressure
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? new CheckResult(Severity.Valid, LEncConditionWhiteLead, CheckIdentifier.Encounter)
|
|
|
|
|
: new CheckResult(Severity.Valid, LEncConditionWhite, CheckIdentifier.Encounter);
|
2018-08-03 03:11:42 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
// Increased Level Encounters
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (slot.Permissions.BlackFlute)
|
2018-08-03 03:11:42 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return slot.Permissions.Pressure
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? new CheckResult(Severity.Valid, LEncConditionBlackLead, CheckIdentifier.Encounter)
|
|
|
|
|
: new CheckResult(Severity.Valid, LEncConditionBlack, CheckIdentifier.Encounter);
|
2018-08-03 03:11:42 +00:00
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
if (slot.Permissions.Pressure)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncConditionLead, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncConditionDexNav, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-08-01 00:09:16 +00:00
|
|
|
|
private static CheckResult VerifyEncounterStatic(PKM pkm, EncounterStatic s)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
// Check for Unreleased Encounters / Collisions
|
|
|
|
|
switch (pkm.GenNumber)
|
|
|
|
|
{
|
|
|
|
|
case 3:
|
2018-06-10 17:44:05 +00:00
|
|
|
|
if (s is EncounterStaticShadow w && w.EReader && pkm.Language != (int)LanguageID.Japanese) // Non-JP E-reader Pokemon
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG3EReader, CheckIdentifier.Encounter);
|
2017-10-23 04:01:08 +00:00
|
|
|
|
if (pkm.Species == 151 && s.Location == 201 && pkm.Language != (int)LanguageID.Japanese) // Non-JP Mew (Old Sea Map)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedEMewJP, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2017-12-12 00:01:24 +00:00
|
|
|
|
switch (pkm.Species)
|
|
|
|
|
{
|
|
|
|
|
case 491 when s.Location == 079 && !pkm.Pt: // DP Darkrai
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedPtDarkrai, CheckIdentifier.Encounter);
|
2017-12-12 00:01:24 +00:00
|
|
|
|
case 492 when s.Location == 063 && !pkm.Pt:// DP Shaymin
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedPtShaymin, CheckIdentifier.Encounter);
|
2017-12-12 00:01:24 +00:00
|
|
|
|
case 493 when s.Location == 086: // Azure Flute Arceus
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedHoOArceus, CheckIdentifier.Encounter);
|
2017-12-12 00:01:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (s.Location == 193 && s is EncounterStaticTyped t && t.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfing in Johto Route 45
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 7:
|
2017-05-29 22:21:39 +00:00
|
|
|
|
if (s.EggLocation == 60002 && pkm.RelearnMoves.Any(m => m != 0))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncStaticRelearn, CheckIdentifier.RelearnMove); // not gift egg
|
2017-05-28 04:17:53 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-10-08 21:48:35 +00:00
|
|
|
|
if (s.EggEncounter && !pkm.IsEgg) // hatched
|
|
|
|
|
{
|
2018-08-03 03:11:42 +00:00
|
|
|
|
var hatchCheck = VerifyEncounterEgg(pkm);
|
2017-10-08 21:48:35 +00:00
|
|
|
|
if (!hatchCheck.Valid)
|
|
|
|
|
return hatchCheck;
|
|
|
|
|
}
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncStaticMatch, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterTrade(PKM pkm, EncounterTrade trade)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
if (trade.Species == pkm.Species && trade.EvolveOnTrade)
|
|
|
|
|
{
|
|
|
|
|
// Pokemon that evolve on trade can not be in the phase evolution after the trade
|
|
|
|
|
// If the trade holds an everstone EvolveOnTrade will be false for the encounter
|
2017-06-18 01:37:19 +00:00
|
|
|
|
var species = LegalityAnalysis.SpeciesStrings;
|
2017-05-28 04:17:53 +00:00
|
|
|
|
var unevolved = species[pkm.Species];
|
|
|
|
|
var evolved = species[pkm.Species + 1];
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(LEvoTradeReq, unevolved, evolved), CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEncTradeMatch, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterLink(PKM pkm, EncounterLink enc)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
// Should NOT be Fateful, and should be in Database
|
|
|
|
|
if (enc == null)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LLinkNone, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2018-03-30 23:31:40 +00:00
|
|
|
|
if (pkm.XY && !enc.CanBeReceivedBy(GameVersion.XY))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LLinkXY, CheckIdentifier.Encounter);
|
2018-03-30 23:31:40 +00:00
|
|
|
|
if (pkm.AO && !enc.CanBeReceivedBy(GameVersion.ORAS))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LLinkAO, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2018-03-10 02:58:00 +00:00
|
|
|
|
if (pkm.IsShiny)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LLinkShiny, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
|
|
|
|
return pkm.FatefulEncounter
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? new CheckResult(Severity.Invalid, LLinkFateful, CheckIdentifier.Encounter)
|
|
|
|
|
: new CheckResult(Severity.Valid, LLinkValid, CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEvent(PKM pkm, MysteryGift MatchedGift)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2017-06-18 06:09:00 +00:00
|
|
|
|
switch (MatchedGift)
|
|
|
|
|
{
|
|
|
|
|
case PCD pcd:
|
|
|
|
|
if (!pcd.CanBeReceivedBy(pkm.Version))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(L_XMatches0_1, MatchedGift.CardHeader, $"-- {LEncGiftVersionNotDistributed}"), CheckIdentifier.Encounter);
|
2017-06-18 06:09:00 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-10-06 06:13:48 +00:00
|
|
|
|
if (!pkm.IsEgg && MatchedGift.IsEgg) // hatched
|
|
|
|
|
{
|
2018-08-03 03:11:42 +00:00
|
|
|
|
var hatchCheck = VerifyEncounterEgg(pkm);
|
2017-10-06 06:13:48 +00:00
|
|
|
|
if (!hatchCheck.Valid)
|
|
|
|
|
return hatchCheck;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
// Strict matching already performed by EncounterGenerator. May be worth moving some checks here to better flag invalid gifts.
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, string.Format(L_XMatches0_1, MatchedGift.CardHeader, string.Empty), CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|