From 4399a4f4b4a9812b2123fe8aba1daee6bc4fee7a Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 22 Sep 2017 19:59:28 -0700 Subject: [PATCH] Allow first learned move to be non-stab only forced if STAB is checked --- pk3DS.Core/Randomizers/LearnsetRandomizer.cs | 7 ++++--- pk3DS/Subforms/Gen6/LevelUpEditor6.cs | 1 + pk3DS/Subforms/Gen7/LevelUpEditor7.cs | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pk3DS.Core/Randomizers/LearnsetRandomizer.cs b/pk3DS.Core/Randomizers/LearnsetRandomizer.cs index 8da74c5..b38cca7 100644 --- a/pk3DS.Core/Randomizers/LearnsetRandomizer.cs +++ b/pk3DS.Core/Randomizers/LearnsetRandomizer.cs @@ -20,16 +20,18 @@ public LearnsetRandomizer(GameConfig config, Learnset[] sets) Config = config; moverand = new MoveRandomizer(config); Learnsets = sets; + rSTABPercent = 52.3m; } public bool Expand = true; public int ExpandTo = 25; public bool Spread = true; public int SpreadTo = 75; + public bool STABFirst = true; public bool STAB { set => moverand.rSTAB = value; } public int[] BannedMoves { set => moverand.BannedMoves = value; } - public decimal rSTABPercent = 52.3m; + public decimal rSTABPercent { set => moverand.rSTABPercent = value; } public void Execute() { @@ -72,12 +74,11 @@ private int[] GetRandomLevels(Learnset set, int count) private int[] GetRandomMoves(int count, int index) { count = Expand ? ExpandTo : count; - moverand.rSTABPercent = rSTABPercent; int[] moves = new int[count]; if (count == 0) return moves; - moves[0] = moverand.GetRandomFirstMove(index); + moves[0] = STABFirst ? moverand.GetRandomFirstMove(index) : moverand.GetRandomFirstMoveAny(); moverand.GetRandomLearnset(index, count - 1).CopyTo(moves, 1); return moves; } diff --git a/pk3DS/Subforms/Gen6/LevelUpEditor6.cs b/pk3DS/Subforms/Gen6/LevelUpEditor6.cs index d956dd9..acf5eb5 100644 --- a/pk3DS/Subforms/Gen6/LevelUpEditor6.cs +++ b/pk3DS/Subforms/Gen6/LevelUpEditor6.cs @@ -145,6 +145,7 @@ private void B_RandAll_Click(object sender, EventArgs e) SpreadTo = (int)NUD_Level.Value, STAB = CHK_STAB.Checked, rSTABPercent = NUD_STAB.Value, + STABFirst = CHK_STAB.Checked, BannedMoves = banned.ToArray() }; rand.Execute(); diff --git a/pk3DS/Subforms/Gen7/LevelUpEditor7.cs b/pk3DS/Subforms/Gen7/LevelUpEditor7.cs index c87f128..d900358 100644 --- a/pk3DS/Subforms/Gen7/LevelUpEditor7.cs +++ b/pk3DS/Subforms/Gen7/LevelUpEditor7.cs @@ -140,6 +140,7 @@ private void B_RandAll_Click(object sender, EventArgs e) SpreadTo = (int) NUD_Level.Value, STAB = CHK_STAB.Checked, rSTABPercent = NUD_STAB.Value, + STABFirst = CHK_STAB.Checked, BannedMoves = new[] { 165, 621, 464 }.Concat(Legal.Z_Moves).ToArray(), // Struggle, Hyperspace Fury, Dark Void }; rand.Execute();