Allow seed of mastery toggling mastered flag

oops
This commit is contained in:
Kurt
2022-05-06 16:11:52 -07:00
parent 59ceec3c65
commit 124bbf98ad
3 changed files with 12 additions and 24 deletions

View File

@@ -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()

View File

@@ -122,16 +122,17 @@ public bool IsForcedMasteryCorrect(PKM pkm)
if (pkm is not IMoveShop8Mastery p)
return true;
Span<int> m = stackalloc int[4];
Span<int> 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)

View File

@@ -21,7 +21,7 @@ public interface IMoveShop8Mastery : IMoveShop8
public static class MoveShop8MasteryExtensions
{
public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span<int> moves, Learnset mastery, int level, ushort alpha)
public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span<int> 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<in
if (masteryLevel > 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<in
return true;
}
private static bool IsPurchasedEncounterMove(IMoveShop8 p, Span<int> 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;
}
}