From ceb14c8468ea3221c6ffd740f408532edd1baedf Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 20 Jan 2021 22:09:25 -0800 Subject: [PATCH] Add consistent ctrl/alt modifiers for IV/EV/AV Closes #3132 --- .../Controls/PKM Editor/StatEditor.cs | 32 ++++++++++++++++--- PKHeX.WinForms/Resources/text/shortcuts.txt | 4 ++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs index 8e8bb7ff0..ac82d4a20 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs @@ -213,10 +213,30 @@ private void UpdateAVs(object sender, EventArgs e) private void UpdateRandomEVs(object sender, EventArgs e) { - bool zero = (ModifierKeys & Keys.Control) != 0; - var evs = zero ? new int[6] : PKX.GetRandomEVs(Entity.Format); + var evs = ModifierKeys switch + { + Keys.Control => SetMaxEVs(Entity), + Keys.Alt => new int[6], + _ => PKX.GetRandomEVs(Entity.Format), + }; LoadEVs(evs); UpdateEVs(sender, EventArgs.Empty); + + static int[] SetMaxEVs(PKM entity) + { + if (entity.Format < 3) + return Enumerable.Repeat((int) ushort.MaxValue, 6).ToArray(); + + var stats = entity.PersonalInfo.Stats; + var ordered = stats.Select((z, i) => new {Stat = z, Index = i}).OrderByDescending(z => z.Stat).ToArray(); + + var result = new int[6]; + result[ordered[0].Index] = 252; + result[ordered[1].Index] = 252; + result[ordered[2].Index] = 6; + + return result; + } } private void UpdateHackedStats(object sender, EventArgs e) @@ -354,8 +374,12 @@ private void LoadBST(PersonalInfo pi) public void UpdateRandomIVs(object sender, EventArgs e) { - var flawless = (ModifierKeys & Keys.Control) != 0; - var IVs = flawless ? Entity.SetRandomIVs(6) : Entity.SetRandomIVs(); + var IVs = ModifierKeys switch + { + Keys.Control => Entity.SetRandomIVs(6), + Keys.Alt => new int[6], + _ => Entity.SetRandomIVs(), + }; LoadIVs(IVs); } diff --git a/PKHeX.WinForms/Resources/text/shortcuts.txt b/PKHeX.WinForms/Resources/text/shortcuts.txt index 726fef54e..2f8363c60 100644 --- a/PKHeX.WinForms/Resources/text/shortcuts.txt +++ b/PKHeX.WinForms/Resources/text/shortcuts.txt @@ -27,7 +27,7 @@ Control + Click on... - Individual EVs: Set EV to max. - Randomize IVs: Set all IVs to max. - Randomize AVs: Set all AVs to max. -- Randomize EVs: Set all EVs to 0. +- Randomize EVs: Set all EVs to max (if appropriate). - PP Ups Label: Set all PP Ups to 0. (Click = 3) - Friendship Label: Set Friendship to 0. (Click = 255 or Base) - Level box: Set Level to 100. @@ -36,7 +36,9 @@ Control + Click on... Alt + Click on... - Preview Sprite to load from a QR url on your clipboard. - Species: Export Showdown/Smogon set to Clipboard. +- Randomize IVs: Set all IVs to 0. - Randomize AVs: Set all AVs to 0. +- Randomize EVs: Set all EVs to 0. - Individual IVs: Set IV to 0. - Individual AVs: Set AV to 0. - Individual EVs: Set EV to 0.