Allow move crossover from GO initial movesets

GO imports that are created with their PK7 and PB7 movesets can bleed from their initial moves.

Example: Muk-Alola level 20 with Minimize can bleed into SV at level 20 (below the normal learn at level 21).
This commit is contained in:
Kurt 2023-07-07 19:32:38 -07:00
parent 00b3e111f8
commit 164d517ef1
3 changed files with 34 additions and 2 deletions

View file

@ -39,7 +39,7 @@ public sealed record EncounterSlot8GO : EncounterSlotGO, IFixedOTFriendship
protected override PKM GetBlank() => OriginFormat switch
{
PogoImportFormat.PK7 => new PK9(),
PogoImportFormat.PK7 => new PK7(),
PogoImportFormat.PB7 => new PB7(),
PogoImportFormat.PK8 => new PK8(),
PogoImportFormat.PA8 => new PA8(),
@ -57,7 +57,7 @@ public sealed record EncounterSlot8GO : EncounterSlotGO, IFixedOTFriendship
_ => throw new ArgumentOutOfRangeException(nameof(OriginFormat)),
};
internal GameVersion OriginGroup => OriginFormat switch
private GameVersion OriginGroup => OriginFormat switch
{
PogoImportFormat.PK7 => GameVersion.USUM,
PogoImportFormat.PB7 => GameVersion.GG,
@ -72,6 +72,7 @@ public sealed record EncounterSlot8GO : EncounterSlotGO, IFixedOTFriendship
PogoImportFormat.PK7 or PogoImportFormat.PB7 =>
PersonalTable.BDSP.IsPresentInGame(Species, Form) ? EntityContext.Gen8b
: PersonalTable.LA.IsPresentInGame(Species, Form) ? EntityContext.Gen8a
: PersonalTable.SV.IsPresentInGame(Species, Form) ? EntityContext.Gen9
: EntityContext.Gen8, // don't throw an exception, just give them a context.
PogoImportFormat.PK8 => EntityContext.Gen8,
PogoImportFormat.PA8 => EntityContext.Gen8a,

View file

@ -55,6 +55,12 @@ public class LearnGroupHOME : ILearnGroup
return true;
}
if (!history.HasVisitedSWSH && enc is EncounterSlot8GO { OriginFormat: PogoImportFormat.PK7 or PogoImportFormat.PB7 } g8)
{
if (TryAddOriginalMovesGO(g8, result, current, pk.Met_Level))
return true;
}
if (TryAddSpecialCaseMoves(pk.Species, result, current))
return true;
@ -82,6 +88,21 @@ public class LearnGroupHOME : ILearnGroup
return false;
}
private static bool TryAddOriginalMovesGO(EncounterSlot8GO enc, Span<MoveResult> result, ReadOnlySpan<ushort> current, int met)
{
Span<ushort> moves = stackalloc ushort[4];
enc.GetInitialMoves(met, moves);
foreach (var move in moves)
{
if (move == 0)
break;
var index = current.IndexOf(move);
if (index != -1)
result[index] = new MoveResult(LearnMethod.Shared, LearnEnvironment.HOME);
}
return MoveResult.AllParsed(result);
}
/// <summary>
/// Scan the results and remove any that are not valid for the game <see cref="local"/> game.
/// </summary>
@ -148,6 +169,8 @@ public class LearnGroupHOME : ILearnGroup
RentLoopGetAll(LearnGroup8a.Instance, result, pk, history, enc, types, option, evos, local);
if (history.HasVisitedBDSP && pk is not PB8)
RentLoopGetAll(LearnGroup8b.Instance, result, pk, history, enc, types, option, evos, local);
if (enc is EncounterSlot8GO { OriginFormat: PogoImportFormat.PK7 or PogoImportFormat.PB7 } g8)
AddOriginalMovesGO(g8, result, enc.LevelMin);
AddSpecialCaseMoves(pk.Species, result);
@ -235,5 +258,13 @@ public class LearnGroupHOME : ILearnGroup
result[(int)Move.VoltTackle] = true;
}
private static void AddOriginalMovesGO(EncounterSlot8GO enc, Span<bool> result, int met)
{
Span<ushort> moves = stackalloc ushort[4];
enc.GetInitialMoves(met, moves);
foreach (var move in moves)
result[move] = true;
}
private static bool IsPikachuLine(ushort species) => species is (int)Species.Raichu or (int)Species.Pikachu or (int)Species.Pichu;
}