From b63e53af951f8be8ecde37248f279414c8aceb5d Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 19 Sep 2017 23:19:22 -0700 Subject: [PATCH] misc tweaks no functional changes --- .../Legality/Encounters/EncounterGenerator.cs | 18 +++++++++++++++--- .../Legality/Encounters/PeekEnumerator.cs | 14 ++++++++++++++ .../Controls/PKM Editor/PKMEditor.cs | 8 ++++---- .../Subforms/Save Editors/Gen4/SAV_Misc4.cs | 4 ++-- .../Subforms/Save Editors/Gen5/SAV_Misc5.cs | 2 +- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs index 75179d840..668697c8a 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs @@ -5,8 +5,21 @@ namespace PKHeX.Core { + /// + /// Generates matching data and relevant for a . + /// Logic for generating possible in-game encounter data. + /// public static class EncounterGenerator { + /// + /// Generates possible data according to the input PKM data and legality info. + /// + /// PKM data + /// Legality information + /// Possible encounters + /// + /// The iterator lazily finds possible encounters. If no encounters are possible, the enumerable will be empty. + /// public static IEnumerable GetEncounters(PKM pkm, LegalInfo info) { switch (info.Generation) @@ -318,8 +331,7 @@ private static IEnumerable GenerateRawEncounters3(PKM pkm) // EncounterStatic private static bool IsEncounterTypeMatch(IEncounterable e, int type) { - return type == 0 && !(e is EncounterStaticTyped) - || e is EncounterStaticTyped t && t.TypeEncounter.Contains(type); + return e is EncounterStaticTyped t ? t.TypeEncounter.Contains(type) : type == 0; } private static bool IsValidCatchRatePK1(EncounterStatic e, PK1 pk1) { @@ -858,7 +870,7 @@ private static IEnumerable GetValidEncounterTradesVC1(PKM pkm, D // Even if the in game trade uses the tables with source pokemon allowing generation 2 games, the traded pokemon could be a non-tradeback pokemon var rate = (pkm as PK1)?.Catch_Rate; - if (z is EncounterTradeCatchRate r ) + if (z is EncounterTradeCatchRate r) { if (rate != r.Catch_Rate) continue; diff --git a/PKHeX.Core/Legality/Encounters/PeekEnumerator.cs b/PKHeX.Core/Legality/Encounters/PeekEnumerator.cs index 348558232..993cb7884 100644 --- a/PKHeX.Core/Legality/Encounters/PeekEnumerator.cs +++ b/PKHeX.Core/Legality/Encounters/PeekEnumerator.cs @@ -33,6 +33,11 @@ public void Reset() public PeekEnumerator(IEnumerator enumerator) => Enumerator = enumerator ?? throw new ArgumentNullException(nameof(enumerator)); + /// + /// Fetch the next element, if not already performed. + /// + /// True/False that a Next element exists + /// Advances the enumerator if Next has not been peeked already private bool TryFetchPeek() { if (!didPeek && (didPeek = Enumerator.MoveNext())) @@ -40,6 +45,11 @@ private bool TryFetchPeek() return didPeek; } + /// + /// Peeks to the next element + /// + /// Next element + /// Throws an exception if no element exists public T Peek() { if (!TryFetchPeek()) @@ -51,6 +61,10 @@ public T PeekOrDefault() { return !TryFetchPeek() ? default(T) : peek; } + /// + /// Checks if a Next element exists + /// + /// True/False that a Next element exists public bool PeekIsNext() { return TryFetchPeek(); diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 2ac5219af..b47f38a8e 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -894,10 +894,10 @@ private void UpdateIVs(object sender, EventArgs e) changingFields = false; // Potential Reading - L_Potential.Text = (Unicode - ? new[] { "★☆☆☆", "★★☆☆", "★★★☆", "★★★★" } - : new[] { "+", "++", "+++", "++++" } - )[pkm.PotentialRating]; + var arr = Unicode + ? new[] {"★☆☆☆", "★★☆☆", "★★★☆", "★★★★"} + : new[] {"+", "++", "+++", "++++"}; + L_Potential.Text = arr[pkm.PotentialRating]; TB_IVTotal.Text = pkm.IVs.Sum().ToString(); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs index e34cd71bd..e19c4bdc3 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen4/SAV_Misc4.cs @@ -490,8 +490,8 @@ private void ReadBattleFrontier() } private void SaveBattleFrontier() { - if(ofsPrints > 0) - for(int i = 0; i < Prints.Length; i++) + if (ofsPrints > 0) + for (int i = 0; i < Prints.Length; i++) { if (Prints[i] == 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + (i << 1)) >> 1) - 1)) continue; BitConverter.GetBytes(Prints[i] << 1).CopyTo(SAV.Data, ofsPrints + (i << 1)); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs index 5d67b583c..e5adf6a3d 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs @@ -308,7 +308,7 @@ private void ReadEntralink() }; ComboItem[] PassPowerB = PassPowerA.Zip(PassPowerC, (f, s) => new ComboItem { Text = f, Value = s }).ToArray(); cba = new[] { CB_PassPower1, CB_PassPower2, CB_PassPower3 }; - for(int i = 0; i < cba.Length; i++) + for (int i = 0; i < cba.Length; i++) { cba[i].Items.Clear(); cba[i].DisplayMember = "Text";