2017-07-29 18:54:52 +00:00
|
|
|
|
using System;
|
2017-09-30 21:08:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
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>
|
2021-03-31 01:51:53 +00:00
|
|
|
|
/// <param name="generation">Source generation to verify</param>
|
2017-08-01 00:09:16 +00:00
|
|
|
|
/// <returns>Returns the verification method appropriate for the input PKM</returns>
|
2021-03-31 01:51:53 +00:00
|
|
|
|
public static Func<PKM, IEncounterable, CheckResult> GetEncounterVerifierMethod(int generation) => generation switch
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
1 or 2 => VerifyEncounterG12,
|
|
|
|
|
_ => VerifyEncounter,
|
|
|
|
|
};
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2021-07-14 00:33:23 +00:00
|
|
|
|
private static CheckResult VerifyEncounter(PKM pkm, IEncounterTemplate enc) => enc switch
|
2017-08-01 00:09:16 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
EncounterEgg e => VerifyEncounterEgg(pkm, e.Generation),
|
|
|
|
|
EncounterTrade t => VerifyEncounterTrade(pkm, t),
|
|
|
|
|
EncounterSlot w => VerifyEncounterWild(w),
|
|
|
|
|
EncounterStatic s => VerifyEncounterStatic(pkm, s),
|
|
|
|
|
MysteryGift g => VerifyEncounterEvent(pkm, g),
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter),
|
2021-01-02 01:08:49 +00:00
|
|
|
|
};
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-14 00:33:23 +00:00
|
|
|
|
private static CheckResult VerifyEncounterG12(PKM pkm, IEncounterTemplate enc)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2021-01-11 02:15:33 +00:00
|
|
|
|
if (enc.EggEncounter)
|
|
|
|
|
return VerifyEncounterEgg(pkm, enc.Generation);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
return enc switch
|
2020-07-19 18:32:40 +00:00
|
|
|
|
{
|
2020-12-22 07:37:07 +00:00
|
|
|
|
EncounterSlot1 => new CheckResult(Severity.Valid, LEncCondition, CheckIdentifier.Encounter),
|
2020-07-19 18:32:40 +00:00
|
|
|
|
EncounterSlot2 s2 => VerifyWildEncounterGen2(pkm, s2),
|
|
|
|
|
EncounterStatic s => VerifyEncounterStatic(pkm, s),
|
|
|
|
|
EncounterTrade t => VerifyEncounterTrade(pkm, t),
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter),
|
2020-07-19 18:32:40 +00:00
|
|
|
|
};
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
2017-08-01 00:09:16 +00:00
|
|
|
|
|
|
|
|
|
// Gen2 Wild Encounters
|
2020-07-19 18:32:40 +00:00
|
|
|
|
private static CheckResult VerifyWildEncounterGen2(PKM pkm, EncounterSlot2 encounter)
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2021-07-30 21:05:23 +00:00
|
|
|
|
switch (encounter.GetSlotType())
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2017-08-01 00:09:16 +00:00
|
|
|
|
case SlotType.Headbutt:
|
|
|
|
|
return VerifyWildEncounterCrystalHeadbutt(pkm, encounter);
|
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case SlotType.Old_Rod or SlotType.Good_Rod or SlotType.Super_Rod:
|
2017-08-01 00:09:16 +00:00
|
|
|
|
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
|
|
|
|
|
2021-02-02 05:22:58 +00:00
|
|
|
|
private static CheckResult VerifyWildEncounterCrystalHeadbutt(ITrainerID tr, EncounterSlot2 s2)
|
2017-07-06 23:03:41 +00:00
|
|
|
|
{
|
2021-02-02 05:22:58 +00:00
|
|
|
|
return s2.IsTreeAvailable(tr.TID)
|
2021-01-23 03:20:18 +00:00
|
|
|
|
? new CheckResult(Severity.Valid, LG2TreeID, 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
|
2021-01-02 03:45:40 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg(PKM pkm, int gen) => gen switch
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2021-01-02 03:45:40 +00:00
|
|
|
|
2 => new CheckResult(CheckIdentifier.Encounter), // valid -- no met location info
|
2021-01-20 20:37:51 +00:00
|
|
|
|
3 => pkm.IsEgg ? VerifyUnhatchedEgg3(pkm) : VerifyEncounterEgg3(pkm),
|
2021-01-02 03:45:40 +00:00
|
|
|
|
4 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade4) : VerifyEncounterEgg4(pkm),
|
|
|
|
|
5 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade5) : VerifyEncounterEgg5(pkm),
|
|
|
|
|
6 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg6(pkm),
|
|
|
|
|
7 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg7(pkm),
|
2021-11-20 02:23:49 +00:00
|
|
|
|
8 when GameVersion.BDSP.Contains((GameVersion)pkm.Version) => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6NPC, Locations.Default8bNone) : VerifyEncounterEgg8BDSP(pkm),
|
2021-01-02 03:45:40 +00:00
|
|
|
|
8 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg8(pkm),
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter),
|
2021-01-02 03:45:40 +00:00
|
|
|
|
};
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-01-20 20:37:51 +00:00
|
|
|
|
private static CheckResult VerifyUnhatchedEgg3(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2021-01-20 20:37:51 +00:00
|
|
|
|
if (pkm.Met_Level != 0)
|
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(LEggFMetLevel_0, 0), CheckIdentifier.Encounter);
|
|
|
|
|
|
|
|
|
|
// Only EncounterEgg should reach here.
|
|
|
|
|
var loc = pkm.FRLG ? Locations.HatchLocationFRLG : Locations.HatchLocationRSE;
|
|
|
|
|
if (pkm.Met_Location != loc)
|
|
|
|
|
return new CheckResult(Severity.Invalid, LEggMetLocationFail, 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
|
|
|
|
|
2021-01-20 20:37:51 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg3(PKM pkm)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2021-01-20 20:37:51 +00:00
|
|
|
|
if (pkm.Format != 3)
|
|
|
|
|
return VerifyEncounterEgg3Transfer(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);
|
2021-01-20 20:37:51 +00:00
|
|
|
|
|
|
|
|
|
// Check the origin game list.
|
|
|
|
|
var met = pkm.Met_Location;
|
|
|
|
|
var locs = pkm.FRLG ? Legal.ValidMet_FRLG : pkm.E ? Legal.ValidMet_E : Legal.ValidMet_RS;
|
|
|
|
|
if (locs.Contains(met))
|
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
|
|
|
|
|
|
|
|
|
|
// Version isn't updated when hatching on a different game. Check any game.
|
|
|
|
|
if (Legal.ValidMet_FRLG.Contains(met) || Legal.ValidMet_E.Contains(met) || Legal.ValidMet_RS.Contains(met))
|
|
|
|
|
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-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);
|
2021-01-20 20:37:51 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Format != 4)
|
|
|
|
|
{
|
|
|
|
|
if (pkm.Met_Location != Locations.Transfer4)
|
|
|
|
|
return new CheckResult(Severity.Invalid, LTransferEggLocationTransporter, CheckIdentifier.Encounter);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pkm.Met_Location != Locations.Transfer3)
|
|
|
|
|
return new CheckResult(Severity.Invalid, LEggLocationPalPark, 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)
|
2020-01-25 20:19:59 +00:00
|
|
|
|
{
|
|
|
|
|
// Traded eggs don't update Version, like in future games.
|
|
|
|
|
var locations = pkm.WasTradedEgg ? Legal.ValidMet_4 :
|
|
|
|
|
pkm.HGSS ? Legal.ValidMet_HGSS :
|
|
|
|
|
pkm.Pt ? Legal.ValidMet_Pt :
|
|
|
|
|
Legal.ValidMet_DP;
|
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 0, locations);
|
|
|
|
|
}
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-20 02:23:49 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEgg8BDSP(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (pkm.BDSP)
|
2021-12-25 02:39:54 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, 1, Legal.IsValidEggHatchLocation8b);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
|
|
|
|
|
// 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)
|
2021-12-25 02:39:54 +00:00
|
|
|
|
{
|
2022-02-05 06:19:04 +00:00
|
|
|
|
return VerifyEncounterEggLevelLoc(pkm, eggLevel, (location, _) => MetLocations.Contains(location));
|
2021-12-25 02:39:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// (hatch location, hatch version, bool result)
|
|
|
|
|
private static CheckResult VerifyEncounterEggLevelLoc(PKM pkm, int eggLevel, Func<int, GameVersion, bool> isValid)
|
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);
|
2021-12-25 02:39:54 +00:00
|
|
|
|
return isValid(pkm.Met_Location, (GameVersion)pkm.Version)
|
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
|
|
|
|
|
2021-11-20 02:23:49 +00:00
|
|
|
|
private static CheckResult VerifyUnhatchedEgg(PKM pkm, int tradeLoc, short noneLoc = 0)
|
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
|
|
|
|
|
2021-01-20 20:37:51 +00:00
|
|
|
|
var met = pkm.Met_Location;
|
|
|
|
|
if (met == tradeLoc)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, LEggLocationTrade, CheckIdentifier.Encounter);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
return (short)met == noneLoc
|
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
|
2020-08-21 23:35:49 +00:00
|
|
|
|
private static CheckResult VerifyEncounterWild(EncounterSlot slot)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2020-08-21 23:35:49 +00:00
|
|
|
|
var summary = slot.GetConditionString(out bool valid);
|
|
|
|
|
return new CheckResult(valid ? Severity.Valid : Severity.Invalid, summary, 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
|
2020-10-24 18:11:53 +00:00
|
|
|
|
switch (s.Generation)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
|
|
|
|
case 3:
|
2020-12-22 06:33:48 +00:00
|
|
|
|
if (s is EncounterStaticShadow {EReader: true} && 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);
|
2020-10-26 04:42:14 +00:00
|
|
|
|
|
2021-01-01 23:01:22 +00:00
|
|
|
|
switch (pkm.Species)
|
|
|
|
|
{
|
|
|
|
|
case (int)Species.Mew when s.Location == 201 && pkm.Language != (int)LanguageID.Japanese: // Non-JP Mew (Old Sea Map)
|
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleasedEMewJP, CheckIdentifier.Encounter);
|
|
|
|
|
case (int)Species.Deoxys when s.Location == 200 && pkm.Language == (int)LanguageID.Japanese: // JP Deoxys (Birth Island)
|
|
|
|
|
return new CheckResult(Severity.Invalid, LEncUnreleased, CheckIdentifier.Encounter);
|
|
|
|
|
}
|
2020-10-26 04:42:14 +00:00
|
|
|
|
|
2017-05-28 04:17:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2020-12-23 20:15:49 +00:00
|
|
|
|
if (pkm.Met_Location == 193 && s is EncounterStatic4 {Roaming: true}) // 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:
|
2022-03-13 01:06:03 +00:00
|
|
|
|
if (s.EggLocation == Locations.Daycare5 && pkm.RelearnMove1 != 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
|
|
|
|
|
{
|
2020-10-24 18:11:53 +00:00
|
|
|
|
var hatchCheck = VerifyEncounterEgg(pkm, s.Generation);
|
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
|
|
|
|
|
2021-01-01 23:01:22 +00:00
|
|
|
|
private static CheckResult VerifyEncounterTrade(ISpeciesForm pkm, EncounterTrade trade)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2022-03-13 01:06:03 +00:00
|
|
|
|
var species = pkm.Species;
|
|
|
|
|
if (trade.EvolveOnTrade && trade.Species == 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
|
2022-03-13 01:06:03 +00:00
|
|
|
|
var names = ParseSettings.SpeciesStrings;
|
|
|
|
|
var evolved = names[species + 1];
|
|
|
|
|
var unevolved = names[species];
|
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
|
|
|
|
|
2021-01-01 23:01:22 +00:00
|
|
|
|
private static CheckResult VerifyEncounterEvent(PKM pkm, MysteryGift gift)
|
2017-05-28 04:17:53 +00:00
|
|
|
|
{
|
2021-01-01 23:01:22 +00:00
|
|
|
|
switch (gift)
|
2017-06-18 06:09:00 +00:00
|
|
|
|
{
|
|
|
|
|
case PCD pcd:
|
2018-09-05 23:09:30 +00:00
|
|
|
|
if (!pcd.CanBeReceivedBy(pkm.Version) && pcd.Gift.PK.Version == 0)
|
2021-01-01 23:01:22 +00:00
|
|
|
|
return new CheckResult(Severity.Invalid, string.Format(L_XMatches0_1, gift.CardHeader, $"-- {LEncGiftVersionNotDistributed}"), CheckIdentifier.Encounter);
|
2017-06-18 06:09:00 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2021-01-01 23:01:22 +00:00
|
|
|
|
if (!pkm.IsEgg && gift.IsEgg) // hatched
|
2017-10-06 06:13:48 +00:00
|
|
|
|
{
|
2021-01-02 03:45:40 +00:00
|
|
|
|
var hatchCheck = VerifyEncounterEgg(pkm, gift.Generation);
|
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.
|
2021-01-01 23:01:22 +00:00
|
|
|
|
return new CheckResult(Severity.Valid, string.Format(L_XMatches0_1, gift.CardHeader, string.Empty), CheckIdentifier.Encounter);
|
2017-05-28 04:17:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|