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)
|
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
return info.EncounterMatch switch
|
2017-08-01 00:09:16 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
EncounterEgg _ => VerifyEncounterEgg(pkm),
|
|
|
|
|
EncounterTrade t => VerifyEncounterTrade(pkm, t),
|
|
|
|
|
EncounterSlot w => VerifyEncounterWild(pkm, w),
|
|
|
|
|
EncounterStatic s => VerifyEncounterStatic(pkm, s),
|
|
|
|
|
MysteryGift g => VerifyEncounterEvent(pkm, g),
|
|
|
|
|
_ => new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter)
|
|
|
|
|
};
|
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
|
|
|
|
{
|
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);
|
2019-10-08 01:40:09 +00:00
|
|
|
|
return tree switch
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
TreeEncounterAvailable.ValidTree => new CheckResult(Severity.Valid, LG2TreeID, CheckIdentifier.Encounter),
|
|
|
|
|
TreeEncounterAvailable.InvalidTree => new CheckResult(Severity.Invalid, LG2InvalidTileTreeID, CheckIdentifier.Encounter),
|
|
|
|
|
_ => new CheckResult(Severity.Invalid, LG2InvalidTileTreeNotFound, CheckIdentifier.Encounter)
|
|
|
|
|
};
|
2017-07-29 18:54:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
// Eggs
|
2020-01-13 07:00:32 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg(PKM pkm, bool checkSpecies = true)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
// Check Species
|
2020-01-13 07:00:32 +00:00
|
|
|
|
if (checkSpecies && Legal.NoHatchFromEgg.Contains(pkm.Species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggSpecies, CheckIdentifier.Encounter);
|
2019-09-10 07:21:51 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
switch (pkm.GenNumber)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
2019-09-10 07:21:51 +00:00
|
|
|
|
case 2: return new CheckResult(CheckIdentifier.Encounter); // valid -- no met location info
|
2017-06-18 01:37:19 +00:00
|
|
|
|
case 3: return pkm.Format != 3 ? VerifyEncounterEgg3Transfer(pkm) : VerifyEncounterEgg3(pkm);
|
2019-05-11 03:46:49 +00:00
|
|
|
|
case 4: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade4) : VerifyEncounterEgg4(pkm);
|
|
|
|
|
case 5: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade5) : VerifyEncounterEgg5(pkm);
|
|
|
|
|
case 6: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg6(pkm);
|
|
|
|
|
case 7: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg7(pkm);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
case 8: return pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg8(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);
|
2019-05-11 03:46:49 +00:00
|
|
|
|
if (pkm.Format == 4 && pkm.Met_Location != Locations.Transfer3)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationPalPark, CheckIdentifier.Encounter);
|
2019-05-11 03:46:49 +00:00
|
|
|
|
if (pkm.Format != 4 && pkm.Met_Location != Locations.Transfer4)
|
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);
|
2019-05-11 03:46:49 +00:00
|
|
|
|
|
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);
|
2019-05-11 03:46:49 +00:00
|
|
|
|
if (pkm.Met_Location != Locations.Transfer4)
|
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
|
|
|
|
|
2019-09-23 23:56:47 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg8(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (pkm.SWSH)
|
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, Legal.ValidMet_SWSH);
|
|
|
|
|
|
|
|
|
|
// no other games
|
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2019-06-01 17:22:49 +00:00
|
|
|
|
if (pkm.Species == (int)Species.Mew && 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)
|
|
|
|
|
{
|
2019-06-01 17:22:49 +00:00
|
|
|
|
case (int)Species.Darkrai when s.Location == 079 && !pkm.Pt: // DP Darkrai
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedPtDarkrai, CheckIdentifier.Encounter);
|
2019-06-01 17:22:49 +00:00
|
|
|
|
case (int)Species.Shaymin when s.Location == 063 && !pkm.Pt:// DP Shaymin
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedPtShaymin, CheckIdentifier.Encounter);
|
2019-06-01 17:22:49 +00:00
|
|
|
|
case (int)Species.Arceus 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:
|
2019-05-11 03:46:49 +00:00
|
|
|
|
if (s.EggLocation == Locations.Daycare5 && pkm.RelearnMoves.Any(m => m != 0)) // eevee gift egg
|
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
|
|
|
|
{
|
2019-05-11 07:59:07 +00:00
|
|
|
|
if (trade.EvolveOnTrade && trade.Species == pkm.Species)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
// 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 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:
|
2018-09-05 23:09:30 +00:00
|
|
|
|
if (!pcd.CanBeReceivedBy(pkm.Version) && pcd.Gift.PK.Version == 0)
|
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
|
|
|
|
|
{
|
2020-01-13 07:00:32 +00:00
|
|
|
|
var hatchCheck = VerifyEncounterEgg(pkm, false);
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|