diff --git a/pk3DS.Core/Randomizers/LearnsetRandomizer.cs b/pk3DS.Core/Randomizers/LearnsetRandomizer.cs index 1539060..7e59ae1 100644 --- a/pk3DS.Core/Randomizers/LearnsetRandomizer.cs +++ b/pk3DS.Core/Randomizers/LearnsetRandomizer.cs @@ -32,11 +32,7 @@ public LearnsetRandomizer(GameConfig config, Learnset[] sets) public bool Learn4Level1 = false; public bool STAB { set => moverand.rSTAB = value; } - public IList BannedMoves - { - get => moverand.BannedMoves; - set => moverand.BannedMoves = value; - } + public IList BannedMoves { set => moverand.BannedMoves = value; } public decimal rSTABPercent { set => moverand.rSTABPercent = value; } public void Execute() diff --git a/pk3DS.Core/Randomizers/MoveRandomizer.cs b/pk3DS.Core/Randomizers/MoveRandomizer.cs index 42a5be8..5225763 100644 --- a/pk3DS.Core/Randomizers/MoveRandomizer.cs +++ b/pk3DS.Core/Randomizers/MoveRandomizer.cs @@ -125,5 +125,19 @@ public int GetRandomFirstMove(int[] types) } while (!types.Contains(MoveData[move].Type)); return move; } + + public bool SanitizeMovesetForBannedMoves(int[] moves, int index) + { + bool updated = false; + for (int m = 0; m < moves.Length; m++) + { + if (!BannedMoves.Contains(moves[m])) + continue; + updated = true; + moves[m] = GetRandomFirstMove(index); + } + + return updated; + } } } diff --git a/pk3DS/Subforms/Gen7/SMTE.cs b/pk3DS/Subforms/Gen7/SMTE.cs index 42f6044..1d18688 100644 --- a/pk3DS/Subforms/Gen7/SMTE.cs +++ b/pk3DS/Subforms/Gen7/SMTE.cs @@ -676,17 +676,8 @@ private void B_Randomize_Click(object sender, EventArgs e) // sanitize moves if (CB_Moves.SelectedIndex > 1) // learn source { - bool update = false; var moves = pk.Moves; - for (int m = 0; m < moves.Length; m++) - { - if (!learn.BannedMoves.Contains(moves[m])) - continue; - update = true; - moves[m] = move.GetRandomFirstMove(pk.Species); - } - - if (update) + if (move.SanitizeMovesetForBannedMoves(moves, pk.Species)) pk.Moves = moves; } }