2018-06-24 05:00:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
2021-01-31 03:15:39 +00:00
|
|
|
|
using static PKHeX.Core.MemoryPermissions;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// <summary>
|
2020-08-01 00:25:14 +00:00
|
|
|
|
/// Verifies the <see cref="IMemoryOT.OT_Memory"/>, <see cref="IMemoryHT.HT_Memory"/>, and associated values.
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class MemoryVerifier : Verifier
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Memory;
|
|
|
|
|
|
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
VerifyOTMemory(data);
|
|
|
|
|
VerifyHTMemory(data);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-07-19 02:57:15 +00:00
|
|
|
|
private CheckResult VerifyCommonMemory(PKM pkm, int handler, int gen, LegalInfo info)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var memory = MemoryVariableSet.Read((ITrainerMemories)pkm, handler);
|
2019-12-08 07:36:39 +00:00
|
|
|
|
|
|
|
|
|
// Actionable HM moves
|
2019-05-11 07:59:07 +00:00
|
|
|
|
int matchingMoveMemory = Array.IndexOf(Memories.MoveSpecificMemories[0], memory.MemoryID);
|
2019-12-08 07:36:39 +00:00
|
|
|
|
if (matchingMoveMemory != -1)
|
|
|
|
|
{
|
|
|
|
|
// Gen8 has no HMs, so this memory can never exist.
|
2021-02-03 19:33:09 +00:00
|
|
|
|
if (gen != 6 || (pkm.Species != (int)Species.Smeargle && !GetCanLearnMachineMove(pkm, Memories.MoveSpecificMemories[1][matchingMoveMemory], 6)))
|
2019-12-08 07:36:39 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler));
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-05-11 07:59:07 +00:00
|
|
|
|
switch (memory.MemoryID)
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
|
|
|
|
// {0} saw {2} carrying {1} on its back. {4} that {3}.
|
2021-02-03 19:33:09 +00:00
|
|
|
|
case 21 when gen != 6 || !GetCanLearnMachineMove(new PK6 {Species = memory.Variable, EXP = Experience.GetEXP(100, PersonalTable.XY.GetFormIndex(memory.Variable, 0))}, 19, 6):
|
2019-05-11 07:59:07 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2020-12-26 17:27:41 +00:00
|
|
|
|
case 16 or 48 when !CanKnowMove(pkm, memory, gen, info, memory.MemoryID == 16):
|
2019-05-11 07:59:07 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2021-02-03 19:33:09 +00:00
|
|
|
|
case 49 when memory.Variable == 0 || !GetCanRelearnMove(pkm, memory.Variable, gen, info.EvoChainsAllGens[gen]):
|
2019-05-11 07:59:07 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadMove, memory.Handler));
|
2020-12-21 22:22:24 +00:00
|
|
|
|
|
|
|
|
|
// Dynamaxing
|
|
|
|
|
// {0} battled at {1}’s side against {2} that Dynamaxed. {4} that {3}.
|
2021-06-30 22:55:32 +00:00
|
|
|
|
case 71 when !GetCanDynamaxTrainer(memory.Variable, 8, handler == 0 ? (GameVersion)pkm.Version : GameVersion.Any):
|
2020-12-21 22:22:24 +00:00
|
|
|
|
// {0} battled {2} and Dynamaxed upon {1}’s instruction. {4} that {3}.
|
|
|
|
|
case 72 when !((PersonalInfoSWSH)PersonalTable.SWSH[memory.Variable]).IsPresentInGame:
|
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadSpecies, handler == 0 ? L_XOT : L_XHT));
|
|
|
|
|
|
|
|
|
|
// Move
|
|
|
|
|
// {0} studied about how to use {2} in a Box, thinking about {1}. {4} that {3}.
|
|
|
|
|
// {0} practiced its cool pose for the move {2} in a Box, wishing to be praised by {1}. {4} that {3}.
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case 80 or 81 when !CanKnowMove(pkm, memory, gen, info):
|
2020-12-22 03:50:56 +00:00
|
|
|
|
return Get(string.Format(LMemoryArgBadMove, memory.Handler), gen == 8 ? Severity.Fishy : Severity.Invalid);
|
2020-12-21 22:22:24 +00:00
|
|
|
|
|
|
|
|
|
// Species
|
|
|
|
|
// {0} had a great chat about {1} with the {2} that it was in a Box with. {4} that {3}.
|
|
|
|
|
// {0} became good friends with the {2} in a Box, practiced moves with it, and talked about the day that {0} would be praised by {1}. {4} that {3}.
|
|
|
|
|
// {0} got in a fight with the {2} that it was in a Box with about {1}. {4} that {3}.
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case 82 or 83 or 87 when !((PersonalInfoSWSH)PersonalTable.SWSH[memory.Variable]).IsPresentInGame:
|
2020-12-21 22:22:24 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadSpecies, handler == 0 ? L_XOT : L_XHT));
|
|
|
|
|
|
|
|
|
|
// Item
|
2021-01-31 03:15:39 +00:00
|
|
|
|
// {0} went to a Pokémon Center with {1} to buy {2}. {4} that {3}.
|
|
|
|
|
case 5 when !CanBuyItem(gen, memory.Variable):
|
|
|
|
|
// {1} used {2} when {0} was in trouble. {4} that {3}.
|
|
|
|
|
case 15 when !CanUseItem(gen, memory.Variable, pkm.Species):
|
|
|
|
|
// {0} saw {1} using {2}. {4} that {3}.
|
|
|
|
|
case 26 when !CanUseItemGeneric(gen, memory.Variable):
|
|
|
|
|
// {0} planted {2} with {1} and imagined a big harvest. {4} that {3}.
|
|
|
|
|
case 34 when !CanPlantBerry(gen, memory.Variable):
|
|
|
|
|
// {1} had {0} hold items like {2} to help it along. {4} that {3}.
|
|
|
|
|
case 40 when !CanHoldItem(gen, memory.Variable):
|
|
|
|
|
// {0} was excited when {1} won prizes like {2} through Loto-ID. {4} that {3}.
|
|
|
|
|
case 51 when !CanWinRotoLoto(gen, memory.Variable):
|
2021-01-29 21:47:31 +00:00
|
|
|
|
// {0} was worried if {1} was looking for the {2} that it was holding in a Box. {4} that {3}.
|
|
|
|
|
// When {0} was in a Box, it thought about the reason why {1} had it hold the {2}. {4} that {3}.
|
|
|
|
|
case 84 or 88 when !Legal.HeldItems_SWSH.Contains((ushort)memory.Variable) || pkm.IsEgg:
|
2020-12-21 22:22:24 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryArgBadItem, memory.Handler));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2020-02-12 06:25:50 +00:00
|
|
|
|
if (gen == 6 && !Memories.CanHaveIntensity(memory.MemoryID, memory.Intensity))
|
2019-11-26 19:01:09 +00:00
|
|
|
|
{
|
2019-11-28 00:01:12 +00:00
|
|
|
|
if (pkm.Gen6 || (pkm.Gen7 && memory.MemoryID != 0)) // todo: memory intensity checks for gen8
|
2019-11-26 19:01:09 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryIndexIntensityMin, memory.Handler, Memories.GetMinimumIntensity(memory.MemoryID)));
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2020-02-12 06:25:50 +00:00
|
|
|
|
if (gen == 6 && memory.MemoryID != 4 && !Memories.CanHaveFeeling(memory.MemoryID, memory.Feeling))
|
2019-11-26 19:01:09 +00:00
|
|
|
|
{
|
2019-11-28 00:01:12 +00:00
|
|
|
|
if (pkm.Gen6 || (pkm.Gen7 && memory.MemoryID != 0)) // todo: memory feeling checks for gen8
|
2019-11-26 19:01:09 +00:00
|
|
|
|
return GetInvalid(string.Format(LMemoryFeelInvalid, memory.Handler));
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-05-11 07:59:07 +00:00
|
|
|
|
return GetValid(string.Format(LMemoryF_0_Valid, memory.Handler));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 02:12:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used for enforcing a fixed memory detail.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="data">Output storage</param>
|
|
|
|
|
/// <param name="m">Memory ID</param>
|
|
|
|
|
/// <param name="i">Intensity</param>
|
|
|
|
|
/// <param name="t">Text Variable</param>
|
|
|
|
|
/// <param name="f">Feeling</param>
|
2018-06-24 05:00:01 +00:00
|
|
|
|
private void VerifyOTMemoryIs(LegalityAnalysis data, int m, int i, int t, int f)
|
|
|
|
|
{
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var pkm = (ITrainerMemories)data.pkm;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.OT_Memory != m)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryIndexID, L_XOT, m)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.OT_Intensity != i)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryIndexIntensity, L_XOT, i)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.OT_TextVar != t)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryIndexVar, L_XOT, t)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.OT_Feeling != f)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryIndexFeel, L_XOT, f)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-08-01 00:25:14 +00:00
|
|
|
|
private void VerifyHTMemoryNone(LegalityAnalysis data, ITrainerMemories pkm)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.HT_Memory != 0 || pkm.HT_TextVar != 0 || pkm.HT_Intensity != 0 || pkm.HT_Feeling != 0)
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryCleared, L_XHT)));
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 02:17:37 +00:00
|
|
|
|
private void VerifyOTMemory(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var mem = (ITrainerMemories)pkm;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
var Info = data.Info;
|
|
|
|
|
|
|
|
|
|
switch (data.EncounterMatch)
|
|
|
|
|
{
|
2020-12-22 06:33:48 +00:00
|
|
|
|
case WC6 {IsEgg: false} g when g.OTGender != 3:
|
2018-06-24 05:00:01 +00:00
|
|
|
|
VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
|
|
|
|
|
return;
|
2020-12-22 06:33:48 +00:00
|
|
|
|
case WC7 {IsEgg: false} g when g.OTGender != 3:
|
2018-06-30 22:01:16 +00:00
|
|
|
|
VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
2020-12-22 06:33:48 +00:00
|
|
|
|
case WC8 {IsEgg: false} g when g.OTGender != 3:
|
2019-11-26 19:22:01 +00:00
|
|
|
|
VerifyOTMemoryIs(data, g.OT_Memory, g.OT_Intensity, g.OT_TextVar, g.OT_Feeling);
|
|
|
|
|
return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2020-12-29 08:58:08 +00:00
|
|
|
|
case IMemoryOT t when t is not MysteryGift: // Ignore Mystery Gift cases (covered above)
|
2019-11-26 19:01:09 +00:00
|
|
|
|
VerifyOTMemoryIs(data, t.OT_Memory, t.OT_Intensity, t.OT_TextVar, t.OT_Feeling);
|
|
|
|
|
return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
int memoryGen = Info.Generation;
|
2020-08-01 00:25:14 +00:00
|
|
|
|
int memory = mem.OT_Memory;
|
2019-12-08 07:36:39 +00:00
|
|
|
|
|
2020-03-26 02:18:52 +00:00
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
{
|
|
|
|
|
// Traded unhatched eggs in Gen8 have OT link trade memory applied erroneously.
|
2021-01-29 22:34:45 +00:00
|
|
|
|
// They can also have the box-inspect memory!
|
|
|
|
|
if (memoryGen != 8 || !((pkm.Met_Location == Locations.LinkTrade6 && memory == 4) || memory == 85))
|
2020-03-26 02:18:52 +00:00
|
|
|
|
{
|
|
|
|
|
VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-21 22:22:24 +00:00
|
|
|
|
else if (!CanHaveMemoryForOT(pkm, memoryGen, memory))
|
2019-12-12 03:37:51 +00:00
|
|
|
|
{
|
|
|
|
|
VerifyOTMemoryIs(data, 0, 0, 0, 0); // empty
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// Bounds checking
|
|
|
|
|
switch (memoryGen)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-12-08 07:36:39 +00:00
|
|
|
|
case 6 when pkm.XY && (memory > Memories.MAX_MEMORY_ID_XY || Memories.Memory_NotXY.Contains(memory)):
|
|
|
|
|
case 6 when pkm.AO && (memory > Memories.MAX_MEMORY_ID_AO || Memories.Memory_NotAO.Contains(memory)):
|
|
|
|
|
case 8 when pkm.SWSH && (memory > Memories.MAX_MEMORY_ID_SWSH || Memories.Memory_NotSWSH.Contains(memory)):
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XOT)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
break;
|
2019-12-08 07:36:39 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// Verify memory if specific to OT
|
|
|
|
|
switch (memory)
|
|
|
|
|
{
|
|
|
|
|
// No Memory
|
|
|
|
|
case 0: // SWSH trades don't set HT memories immediately, which is hilarious.
|
|
|
|
|
data.AddLine(Get(LMemoryMissingOT, memoryGen == 8 ? Severity.Fishy : Severity.Invalid));
|
|
|
|
|
VerifyOTMemoryIs(data, 0, 0, 0, 0);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
|
|
|
|
|
case 2 when !Info.EncounterMatch.EggEncounter:
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadHatch, L_XOT)));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// {0} became {1}’s friend when it arrived via Link Trade at... {2}. {4} that {3}.
|
|
|
|
|
case 4 when pkm.Gen6:
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadOTEgg, L_XOT)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
|
2020-08-01 00:25:14 +00:00
|
|
|
|
case 6 when memoryGen == 6 && !Memories.GetHasPokeCenterLocation((GameVersion)pkm.Version, mem.OT_TextVar):
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XOT)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
2020-08-01 00:25:14 +00:00
|
|
|
|
case 6 when memoryGen == 8 && mem.OT_TextVar != 0:
|
2020-01-11 00:08:34 +00:00
|
|
|
|
data.AddLine(Get(string.Format(LMemoryArgBadLocation, L_XOT), ParseSettings.Gen8MemoryLocationTextVariable));
|
|
|
|
|
return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// {0} was with {1} when {1} caught {2}. {4} that {3}.
|
2018-06-24 05:00:01 +00:00
|
|
|
|
case 14:
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var result = GetCanBeCaptured(mem.OT_TextVar, Info.Generation, (GameVersion)pkm.Version) // Any Game in the Handling Trainer's generation
|
2019-12-08 07:36:39 +00:00
|
|
|
|
? GetValid(string.Format(LMemoryArgSpecies, L_XOT))
|
|
|
|
|
: GetInvalid(string.Format(LMemoryArgBadSpecies, L_XOT));
|
|
|
|
|
data.AddLine(result);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-19 02:57:15 +00:00
|
|
|
|
data.AddLine(VerifyCommonMemory(pkm, 0, Info.Generation, Info));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-12-21 22:22:24 +00:00
|
|
|
|
private static bool CanHaveMemoryForOT(PKM pkm, int origin, int memory)
|
2019-12-12 03:37:51 +00:00
|
|
|
|
{
|
2020-12-21 22:22:24 +00:00
|
|
|
|
switch (origin)
|
|
|
|
|
{
|
2020-12-25 18:58:33 +00:00
|
|
|
|
// Bank Memories only: Gen7 does not set memories.
|
|
|
|
|
case 1 or 2 or 7 when memory != 4: // VC transfers
|
2020-12-21 22:22:24 +00:00
|
|
|
|
|
|
|
|
|
// Memories don't exist
|
|
|
|
|
case 7 when pkm.GG: // LGPE does not set memories.
|
|
|
|
|
case 8 when pkm.GO_HOME: // HOME does not set memories.
|
|
|
|
|
case 8 when pkm.Met_Location == Locations.HOME8: // HOME does not set memories.
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Eggs cannot have memories
|
|
|
|
|
// Cannot have memories if the OT was from a generation prior to Gen6.
|
|
|
|
|
default:
|
|
|
|
|
return origin >= 6 && !pkm.IsEgg;
|
|
|
|
|
}
|
2019-12-12 03:37:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 02:17:37 +00:00
|
|
|
|
private void VerifyHTMemory(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var mem = (ITrainerMemories)pkm;
|
2019-12-08 07:36:39 +00:00
|
|
|
|
var Info = data.Info;
|
|
|
|
|
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var memory = mem.HT_Memory;
|
2019-12-10 00:23:29 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
if (pkm.IsUntraded)
|
|
|
|
|
{
|
2019-12-10 00:23:29 +00:00
|
|
|
|
if (memory == 4 && WasTradedSWSHEgg(pkm))
|
|
|
|
|
{
|
|
|
|
|
// Untraded link trade eggs in Gen8 have HT link trade memory applied erroneously.
|
|
|
|
|
// Verify the link trade memory later.
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-08-01 00:25:14 +00:00
|
|
|
|
VerifyHTMemoryNone(data, mem);
|
2019-12-10 00:23:29 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-12-08 07:36:39 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-11-26 19:01:09 +00:00
|
|
|
|
if (pkm.Format == 7)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-12-08 07:36:39 +00:00
|
|
|
|
VerifyHTMemoryTransferTo7(data, pkm, Info);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
var memoryGen = pkm.Format >= 8 ? 8 : 6;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// Bounds checking
|
|
|
|
|
switch (memoryGen)
|
|
|
|
|
{
|
|
|
|
|
case 6 when memory > Memories.MAX_MEMORY_ID_AO:
|
|
|
|
|
case 8 when memory > Memories.MAX_MEMORY_ID_SWSH || Memories.Memory_NotSWSH.Contains(memory):
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadID, L_XHT)));
|
|
|
|
|
break;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// Verify memory if specific to HT
|
|
|
|
|
switch (memory)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// No Memory
|
|
|
|
|
case 0: // SWSH trades don't set HT memories immediately, which is hilarious.
|
|
|
|
|
data.AddLine(Get(LMemoryMissingHT, memoryGen == 8 ? Severity.Fishy : Severity.Invalid));
|
2020-08-01 00:25:14 +00:00
|
|
|
|
VerifyHTMemoryNone(data, mem);
|
2019-12-08 07:36:39 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// {0} met {1} at... {2}. {1} threw a Poké Ball at it, and they started to travel together. {4} that {3}.
|
|
|
|
|
case 1:
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadCatch, L_XHT)));
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
|
|
|
|
|
case 2:
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadHatch, L_XHT)));
|
|
|
|
|
return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
|
2020-08-01 00:25:14 +00:00
|
|
|
|
case 6 when memoryGen == 6 && !Memories.GetHasPokeCenterLocation(GameVersion.Gen6, mem.HT_TextVar):
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LMemoryArgBadLocation, L_XOT)));
|
|
|
|
|
return;
|
2020-08-01 00:25:14 +00:00
|
|
|
|
case 6 when memoryGen == 8 && mem.HT_TextVar != 0:
|
2020-01-11 00:08:34 +00:00
|
|
|
|
data.AddLine(Get(string.Format(LMemoryArgBadLocation, L_XOT), ParseSettings.Gen8MemoryLocationTextVariable));
|
|
|
|
|
return;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// {0} was with {1} when {1} caught {2}. {4} that {3}.
|
2018-06-24 05:00:01 +00:00
|
|
|
|
case 14:
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var result = GetCanBeCaptured(mem.HT_TextVar, memoryGen, GameVersion.Any) // Any Game in the Handling Trainer's generation
|
2019-12-08 07:36:39 +00:00
|
|
|
|
? GetValid(string.Format(LMemoryArgSpecies, L_XHT))
|
|
|
|
|
: GetInvalid(string.Format(LMemoryArgBadSpecies, L_XHT));
|
|
|
|
|
data.AddLine(result);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-12-08 07:36:39 +00:00
|
|
|
|
|
2020-07-19 02:57:15 +00:00
|
|
|
|
var commonResult = VerifyCommonMemory(pkm, 1, memoryGen, Info);
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(commonResult);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 06:30:40 +00:00
|
|
|
|
private static bool WasTradedSWSHEgg(PKM pkm) => pkm.SWSH && (!pkm.IsEgg ? pkm.Egg_Location : pkm.Met_Location) is Locations.LinkTrade6;
|
2019-12-10 00:23:29 +00:00
|
|
|
|
|
2019-12-08 07:36:39 +00:00
|
|
|
|
private void VerifyHTMemoryTransferTo7(LegalityAnalysis data, PKM pkm, LegalInfo Info)
|
|
|
|
|
{
|
2020-08-01 00:25:14 +00:00
|
|
|
|
var mem = (ITrainerMemories)pkm;
|
2019-12-08 07:36:39 +00:00
|
|
|
|
// Bank Transfer adds in the Link Trade Memory.
|
|
|
|
|
// Trading 7<->7 between games (not Bank) clears this data.
|
2020-08-01 00:25:14 +00:00
|
|
|
|
if (mem.HT_Memory == 0)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
{
|
2020-08-01 00:25:14 +00:00
|
|
|
|
VerifyHTMemoryNone(data, mem);
|
2019-12-08 07:36:39 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Transfer 6->7 & withdraw to same HT => keeps past gen memory
|
|
|
|
|
// Don't require link trade memory for these past gen cases
|
|
|
|
|
int gen = Info.Generation;
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (gen is >= 3 and < 7 && pkm.CurrentHandler == 1)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-08-01 00:25:14 +00:00
|
|
|
|
if (mem.HT_Memory != 4)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(Severity.Invalid, LMemoryIndexLinkHT, CheckIdentifier.Memory);
|
2020-08-01 00:25:14 +00:00
|
|
|
|
if (mem.HT_TextVar != 0)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(Severity.Invalid, LMemoryIndexArgHT, CheckIdentifier.Memory);
|
2020-08-01 00:25:14 +00:00
|
|
|
|
if (mem.HT_Intensity != 1)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(Severity.Invalid, LMemoryIndexIntensityHT1, CheckIdentifier.Memory);
|
2020-08-01 00:25:14 +00:00
|
|
|
|
if (mem.HT_Feeling > 10)
|
2019-12-08 07:36:39 +00:00
|
|
|
|
data.AddLine(Severity.Invalid, LMemoryIndexFeelHT09, CheckIdentifier.Memory);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|