From 124bbf98adccd712df5ce6f93f99bbd628177a77 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 6 May 2022 16:11:52 -0700 Subject: [PATCH] Allow seed of mastery toggling mastered flag oops --- .../EncounterSlot/EncounterSlot8a.cs | 2 +- .../EncounterStatic/EncounterStatic8a.cs | 9 ++++--- PKHeX.Core/PKM/Interfaces/IMoveShop8.cs | 25 +++++-------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs index 5ac2ed621..95aaa599a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot8a.cs @@ -157,7 +157,7 @@ public bool IsForcedMasteryCorrect(PKM pkm) learn.SetEncounterMoves(level, moves); } - return p.IsValidMasteredEncounter(moves, mastery, level, alpha); + return p.IsValidMasteredEncounter(moves, learn, mastery, level, alpha); } private OverworldParam8a GetParams() diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8a.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8a.cs index dd26210a4..2a7bc8dc9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8a.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic8a.cs @@ -122,16 +122,17 @@ public bool IsForcedMasteryCorrect(PKM pkm) if (pkm is not IMoveShop8Mastery p) return true; - Span m = stackalloc int[4]; + Span moves = stackalloc int[4]; var level = pkm.Met_Level; var index = PersonalTable.LA.GetFormIndex(Species, Form); + var learn = Legal.LevelUpLA[index]; var mastery = Legal.MasteryLA[index]; if (Moves.Count != 0) - m = (int[])Moves; + moves = (int[])Moves; else - Legal.LevelUpLA[index].SetEncounterMoves(level, m); + learn.SetEncounterMoves(level, moves); - return p.IsValidMasteredEncounter(m, mastery, level, alpha); + return p.IsValidMasteredEncounter(moves, learn, mastery, level, alpha); } protected override void SetEncounterMoves(PKM pk, GameVersion version, int level) diff --git a/PKHeX.Core/PKM/Interfaces/IMoveShop8.cs b/PKHeX.Core/PKM/Interfaces/IMoveShop8.cs index c0fb3250a..f794658d7 100644 --- a/PKHeX.Core/PKM/Interfaces/IMoveShop8.cs +++ b/PKHeX.Core/PKM/Interfaces/IMoveShop8.cs @@ -21,7 +21,7 @@ public interface IMoveShop8Mastery : IMoveShop8 public static class MoveShop8MasteryExtensions { - public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span moves, Learnset mastery, int level, ushort alpha) + public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span moves, Learnset learn, Learnset mastery, int level, ushort alpha) { foreach (var move in moves) { @@ -38,7 +38,11 @@ public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span level && move != alpha) // no master flag set { if (!p && m) - return false; + { + // Check for seed of mastery usage + if (learn.GetMoveLevel(move) > level) + return false; + } } else { @@ -49,21 +53,4 @@ public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span moves) - { - foreach (var move in moves) - { - if (move == 0) - continue; - var index = p.MoveShopPermitIndexes.IndexOf((ushort)move); - if (index == -1) - continue; // manually mastered for encounter, not a tutor - - if (p.GetPurchasedRecordFlag(index)) - return true; - } - - return false; - } }