Disallow HOME move share w/ battleversion & <=Gen7

HOME's SWSH moveset is disqualified from having <=Gen7 moveset permissions if the battle version was applied in SW/SH.
This commit is contained in:
Kurt 2024-04-05 14:49:46 -05:00
parent f0b127e13e
commit 9c1538f503

View file

@ -54,6 +54,10 @@ public sealed class LearnGroupHOME : ILearnGroup
if (CleanPurge(result, current, pk, types, local, evos))
return true;
}
// Ignore Battle Version generally; can be transferred back to SW/SH and wiped after the moves have been shared from HOME.
// Battle Version is only relevant while in PK8 format, as a wiped moveset can no longer harbor external moves for that format.
// SW/SH is the only game that can ever harbor external moves, and is the only game that uses Battle Version.
if (TryAddOriginalMoves(result, current, pk, enc))
{
if (CleanPurge(result, current, pk, types, local, evos))
@ -67,10 +71,9 @@ public sealed class LearnGroupHOME : ILearnGroup
return true;
}
// Ignore Battle Version; can be transferred back to SW/SH and wiped after the moves have been shared from HOME
if (history.HasVisitedLGPE)
{
// PK8 w/ Battle Version can be ignored, as LGP/E has separate HOME data.
var instance = LearnGroup7b.Instance;
instance.Check(result, current, pk, history, enc, types, option);
if (CleanPurge(result, current, pk, types, local, evos))
@ -78,6 +81,8 @@ public sealed class LearnGroupHOME : ILearnGroup
}
else if (history.HasVisitedGen7)
{
if (IsWipedPK8(pk))
return false; // Battle Version wiped Gen7 and below moves.
ILearnGroup instance = LearnGroup7.Instance;
while (true)
{
@ -93,6 +98,8 @@ public sealed class LearnGroupHOME : ILearnGroup
return false;
}
private static bool IsWipedPK8(PKM pk) => pk is PK8 { BattleVersion: GameVersion.SW or GameVersion.SH };
/// <summary>
/// Scan the results and remove any that are not valid for the game <see cref="local"/> game.
/// </summary>
@ -178,6 +185,8 @@ public sealed class LearnGroupHOME : ILearnGroup
{
if (enc is IMoveset { Moves: { HasMoves: true } x })
{
if (enc is { Generation: <= 7, Context: not EntityContext.Gen7b } && IsWipedPK8(pk))
return false; // Battle Version wiped Gen7 and below moves.
Span<ushort> moves = stackalloc ushort[4];
x.CopyTo(moves);
var ls = GameData.GetLearnSource(enc.Version);
@ -185,6 +194,8 @@ public sealed class LearnGroupHOME : ILearnGroup
}
if (enc is EncounterSlot8GO { OriginFormat: PogoImportFormat.PK7 or PogoImportFormat.PB7 } g8)
{
if (g8.OriginFormat is PogoImportFormat.PK7 && IsWipedPK8(pk))
return false; // Battle Version wiped Gen7 and below moves.
Span<ushort> moves = stackalloc ushort[4];
g8.GetInitialMoves(pk.MetLevel, moves);
return AddOriginalMoves(result, current, moves, g8.OriginFormat == PogoImportFormat.PK7 ? LearnEnvironment.USUM : LearnEnvironment.GG);