Minor clean

no functional change
This commit is contained in:
Kurt 2020-06-27 23:36:53 -05:00
parent a7ba178005
commit 993673f0de
28 changed files with 77 additions and 75 deletions

View file

@ -3,7 +3,7 @@
public static class HiddenPowerApplicator
{
/// <summary>
/// Sets the <see cref="PKM.IVs"/> to match a provided <see cref="hptype"/>.
/// Sets the <see cref="PKM.IVs"/> to match a provided <see cref="hiddenPowerType"/>.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
/// <param name="hptype">Desired Hidden Power typing.</param>
@ -15,7 +15,7 @@
}
/// <summary>
/// Sets the <see cref="PKM.IVs"/> to match a provided <see cref="hptype"/>.
/// Sets the <see cref="PKM.IVs"/> to match a provided <see cref="hiddenPowerType"/>.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
/// <param name="hiddenPowerType">Desired Hidden Power typing.</param>

View file

@ -37,8 +37,8 @@ namespace PKHeX.Core
var vers = versions.Length >= 1 ? versions : GameUtil.GetVersionsWithinRange(pk, pk.Format);
foreach (var ver in vers)
{
var encs = GenerateVersionEncounters(pk, m, ver);
foreach (var enc in encs)
var encounters = GenerateVersionEncounters(pk, m, ver);
foreach (var enc in encounters)
{
var result = enc.ConvertToPKM(info);
#if VERIFY_GEN
@ -233,8 +233,8 @@ namespace PKHeX.Core
/// <returns>A consumable <see cref="IEncounterable"/> list of possible encounters.</returns>
private static IEnumerable<EncounterStatic> GetStatic(PKM pk, IReadOnlyCollection<int> needs)
{
var encs = EncounterStaticGenerator.GetPossible(pk);
foreach (var enc in encs)
var encounters = EncounterStaticGenerator.GetPossible(pk);
foreach (var enc in encounters)
{
if (enc.IsUnobtainable(pk))
continue;

View file

@ -34,8 +34,10 @@ namespace PKHeX.Core
if (gameSource == GameVersion.Any)
gameSource = (GameVersion)pkm.Version;
var encs = GetStaticEncounters(pkm, chain, gameSource);
return encs.Where(e => ParseSettings.AllowGBCartEra || !GameVersion.GBCartEraOnly.Contains(e.Version));
var encounters = GetStaticEncounters(pkm, chain, gameSource);
if (ParseSettings.AllowGBCartEra)
return encounters;
return encounters.Where(e => !GameVersion.GBCartEraOnly.Contains(e.Version));
}
public static IEnumerable<EncounterStatic> GetValidStaticEncounter(PKM pkm, GameVersion gameSource = GameVersion.Any)

View file

@ -22,8 +22,8 @@ namespace PKHeX.Core
/// </summary>
public static bool CanLearn(string species, IEnumerable<string> moves, string lang = GameLanguage.DefaultLanguage)
{
var encs = GetLearn(species, moves, lang);
return encs.Any();
var encounters = GetLearn(species, moves, lang);
return encounters.Any();
}
/// <summary>
@ -31,8 +31,8 @@ namespace PKHeX.Core
/// </summary>
public static IEnumerable<string> GetLearnSummary(string species, IEnumerable<string> moves, string lang = GameLanguage.DefaultLanguage)
{
var encs = GetLearn(species, moves, lang);
var msg = Summarize(encs).ToList();
var encounters = GetLearn(species, moves, lang);
var msg = Summarize(encounters).ToList();
if (msg.Count == 0)
msg.Add(NoMatches);
return msg;

View file

@ -294,8 +294,7 @@ namespace PKHeX.Core
for (int m = 0; m < 4; m++)
{
if (res[m] == null)
res[m] = new CheckMoveResult(Unknown, info.Generation, Invalid, LMoveSourceInvalid, Move);
res[m] ??= new CheckMoveResult(Unknown, info.Generation, Invalid, LMoveSourceInvalid, Move);
}
return res;
}

View file

@ -13,7 +13,7 @@ namespace PKHeX.Core
public readonly int GenderLow;
public readonly bool DPPt;
public readonly bool AllowLeads;
public readonly FrameType FrameType = FrameType.None;
public readonly FrameType FrameType;
public readonly RNG RNG = RNG.LCRNG;
public readonly bool Safari3;

View file

@ -420,7 +420,7 @@ namespace PKHeX
if (!matchAny)
return TradebackType.WasTradeback;
if (catch_rate == 0 || HeldItems_GSC.Contains((ushort)catch_rate))
if (HeldItems_GSC.Contains((ushort)catch_rate))
return TradebackType.Any;
return TradebackType.Gen1_NotTradeback;

View file

@ -392,10 +392,7 @@ namespace PKHeX.Core
};
internal static readonly HashSet<int> Ban_NoHidden8 = new HashSet<int>
{
// none as of DLC 1!
};
internal static readonly HashSet<int> Ban_NoHidden8 = new HashSet<int>(); // none as of DLC 1!
internal static readonly HashSet<int> Ban_NoHidden8Apricorn = new HashSet<int>
{

View file

@ -73,7 +73,7 @@ namespace PKHeX.Core
if (WordFilter.IsFiltered(pkm.HT_Name, out bad))
data.AddLine(GetInvalid($"Wordfilter: {bad}"));
if (ContainsTooManyNumbers(ot, data.Info.Generation))
data.AddLine(GetInvalid($"Wordfilter: Too many numbers."));
data.AddLine(GetInvalid("Wordfilter: Too many numbers."));
}
}

View file

@ -86,8 +86,7 @@ namespace PKHeX.Core
t.HyperTrainFlags = 0;
return;
}
if (IVs == null)
IVs = pkm.IVs;
IVs ??= pkm.IVs;
t.HT_HP = IVs[0] != 31;
t.HT_ATK = IVs[1] != 31 && IVs[1] > 2;

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core
{

View file

@ -153,20 +153,18 @@ namespace PKHeX.Core
var result = (byte[])sav7.Clone();
using (var sha256 = SHA256.Create())
{
// Store current signature
var oldSig = new byte[MemeCryptoSignatureLength];
Buffer.BlockCopy(sav7, MemeCryptoOffset, oldSig, 0, MemeCryptoSignatureLength);
using var sha256 = SHA256.Create();
// Store current signature
var oldSig = new byte[MemeCryptoSignatureLength];
Buffer.BlockCopy(sav7, MemeCryptoOffset, oldSig, 0, MemeCryptoSignatureLength);
var newSig = sha256.ComputeHash(sav7, ChecksumTableOffset, ChecksumSignatureLength);
Array.Resize(ref newSig, MemeCryptoSignatureLength);
var newSig = sha256.ComputeHash(sav7, ChecksumTableOffset, ChecksumSignatureLength);
Array.Resize(ref newSig, MemeCryptoSignatureLength);
if (VerifyMemeData(oldSig, out var memeSig, MemeKeyIndex.PokedexAndSaveFile))
Buffer.BlockCopy(memeSig, 0x20, newSig, 0x20, 0x60);
if (VerifyMemeData(oldSig, out var memeSig, MemeKeyIndex.PokedexAndSaveFile))
Buffer.BlockCopy(memeSig, 0x20, newSig, 0x20, 0x60);
SignMemeData(newSig).CopyTo(result, MemeCryptoOffset);
}
SignMemeData(newSig).CopyTo(result, MemeCryptoOffset);
return result;
}
}

View file

@ -17,12 +17,12 @@ namespace PKHeX.Core
protected readonly int Offset;
protected readonly int PouchDataSize;
protected InventoryPouch(InventoryType type, ushort[] legal, int maxcount, int offset, int size = -1)
protected InventoryPouch(InventoryType type, ushort[] legal, int maxCount, int offset, int size = -1)
{
Items = Array.Empty<InventoryItem>();
Type = type;
LegalItems = legal;
MaxCount = maxcount;
MaxCount = maxCount;
Offset = offset;
PouchDataSize = size > -1 ? size : legal.Length;
}

View file

@ -6,8 +6,8 @@ namespace PKHeX.Core
{
public uint SecurityKey { private get; set; } // = 0 // Gen3 Only
public InventoryPouch3(InventoryType type, ushort[] legal, int maxcount, int offset, int size)
: base(type, legal, maxcount, offset, size)
public InventoryPouch3(InventoryType type, ushort[] legal, int maxCount, int offset, int size)
: base(type, legal, maxCount, offset, size)
{
}

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core
{
public sealed class InventoryPouch3GC : InventoryPouch
{
public InventoryPouch3GC(InventoryType type, ushort[] legal, int maxcount, int offset, int size)
: base(type, legal, maxcount, offset, size)
public InventoryPouch3GC(InventoryType type, ushort[] legal, int maxCount, int offset, int size)
: base(type, legal, maxCount, offset, size)
{
}

View file

@ -7,8 +7,8 @@ namespace PKHeX.Core
/// </summary>
public sealed class InventoryPouch4 : InventoryPouch
{
public InventoryPouch4(InventoryType type, ushort[] legal, int maxcount, int offset)
: base(type, legal, maxcount, offset)
public InventoryPouch4(InventoryType type, ushort[] legal, int maxCount, int offset)
: base(type, legal, maxCount, offset)
{
}

View file

@ -5,8 +5,8 @@ namespace PKHeX.Core
{
public sealed class InventoryPouch7 : InventoryPouch
{
public InventoryPouch7(InventoryType type, ushort[] legal, int maxcount, int offset)
: base(type, legal, maxcount, offset)
public InventoryPouch7(InventoryType type, ushort[] legal, int maxCount, int offset)
: base(type, legal, maxCount, offset)
{
OriginalItems = Array.Empty<InventoryItem>();
}

View file

@ -8,8 +8,8 @@ namespace PKHeX.Core
/// </summary>
public sealed class InventoryPouch7b : InventoryPouch
{
public InventoryPouch7b(InventoryType type, ushort[] legal, int maxcount, int offset, int size)
: base(type, legal, maxcount, offset, size)
public InventoryPouch7b(InventoryType type, ushort[] legal, int maxCount, int offset, int size)
: base(type, legal, maxCount, offset, size)
{
}

View file

@ -8,8 +8,8 @@ namespace PKHeX.Core
/// </summary>
public sealed class InventoryPouch8 : InventoryPouch
{
public InventoryPouch8(InventoryType type, ushort[] legal, int maxcount, int offset, int size)
: base(type, legal, maxcount, offset, size)
public InventoryPouch8(InventoryType type, ushort[] legal, int maxCount, int offset, int size)
: base(type, legal, maxCount, offset, size)
{
}

View file

@ -4,8 +4,8 @@ namespace PKHeX.Core
{
public sealed class InventoryPouchGB : InventoryPouch
{
public InventoryPouchGB(InventoryType type, ushort[] legal, int maxcount, int offset, int size)
: base(type, legal, maxcount, offset, size)
public InventoryPouchGB(InventoryType type, ushort[] legal, int maxCount, int offset, int size)
: base(type, legal, maxCount, offset, size)
{
}

View file

@ -21,8 +21,8 @@ namespace PKHeX.Drawing
if (baseLayer is null)
return (Bitmap)overLayer;
Bitmap img = new Bitmap(baseLayer);
using (Graphics gr = Graphics.FromImage(img))
gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height);
using Graphics gr = Graphics.FromImage(img);
gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height);
return img;
}

View file

@ -34,17 +34,15 @@ namespace PKHeX.Drawing
private static Bitmap ExtendImage(Font font, Image qr, int width, int height, Image pic, string[] lines, string extraText)
{
var newpic = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(newpic))
{
g.FillRectangle(new SolidBrush(Color.White), 0, 0, newpic.Width, newpic.Height);
g.DrawImage(pic, 0, 0);
using Graphics g = Graphics.FromImage(newpic);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, newpic.Width, newpic.Height);
g.DrawImage(pic, 0, 0);
g.DrawString(GetLine(lines, 0), font, Brushes.Black, new PointF(18, qr.Height - 5));
g.DrawString(GetLine(lines, 1), font, Brushes.Black, new PointF(18, qr.Height + 8));
g.DrawString(GetLine(lines, 2).Replace(Environment.NewLine, "/").Replace("//", " ").Replace(":/", ": "), font,
Brushes.Black, new PointF(18, qr.Height + 20));
g.DrawString(GetLine(lines, 3) + extraText, font, Brushes.Black, new PointF(18, qr.Height + 32));
}
g.DrawString(GetLine(lines, 0), font, Brushes.Black, new PointF(18, qr.Height - 5));
g.DrawString(GetLine(lines, 1), font, Brushes.Black, new PointF(18, qr.Height + 8));
g.DrawString(GetLine(lines, 2).Replace(Environment.NewLine, "/").Replace("//", " ").Replace(":/", ": "), font,
Brushes.Black, new PointF(18, qr.Height + 20));
g.DrawString(GetLine(lines, 3) + extraText, font, Brushes.Black, new PointF(18, qr.Height + 32));
return newpic;
}

View file

@ -1,4 +1,5 @@
using System.IO;
using System.Diagnostics;
using System.IO;
using System.Media;
using PKHeX.Core;
using PKHeX.Drawing;
@ -20,7 +21,7 @@ namespace PKHeX.WinForms.Controls
Sounds.SoundLocation = path;
try { Sounds.Play(); }
catch { }
catch { Debug.WriteLine("Failed to play sound."); }
}
public void Stop() => Sounds.Stop();

View file

@ -95,11 +95,12 @@ namespace PKHeX.WinForms
{
try
{
if (e.ColumnIndex != 1) return;
if (e.ColumnIndex != 1)
return;
ComboBox comboBox = (ComboBox)dataGridView1.EditingControl;
comboBox.DroppedDown = true;
}
catch { }
catch { Console.WriteLine("Failed to modify item."); }
}
private bool loading = true;

View file

@ -54,8 +54,12 @@ namespace PKHeX.WinForms
{
for (int i = 0; i < sav.BoxCount; i++)
{
var boxEditor = new BoxEditor { Name = $"BE_Box{i:00}", Margin = new Padding(1) };
boxEditor.Editor = new BoxEdit(sav);
var boxEditor = new BoxEditor
{
Name = $"BE_Box{i:00}",
Margin = new Padding(1),
Editor = new BoxEdit(sav),
};
boxEditor.Setup(m);
boxEditor.InitializeGrid();
boxEditor.Reset();

View file

@ -88,7 +88,7 @@ namespace PKHeX.WinForms
return control switch
{
CheckBox cb => cb.Checked,
_ => (object)null
_ => null
};
}

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
@ -173,7 +174,10 @@ namespace PKHeX.WinForms
{
var _ = (Form)System.Activator.CreateInstance(t, new object[argCount]);
}
catch { }
catch
{
Debug.Write($"Failed to create a new form {t}");
}
}
}

View file

@ -30,11 +30,11 @@ namespace PKHeX.Tests.Simulator
{
var set = new ShowdownSet(SetGlaceonUSUMTutor);
var pk7 = new PK7 {Species = set.Species, AltForm = set.FormIndex, Moves = set.Moves};
var encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
Assert.True(!encs.Any());
var encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
Assert.True(!encounters.Any());
pk7.HT_Name = "PKHeX";
encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
var first = encs.FirstOrDefault();
encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
var first = encounters.FirstOrDefault();
Assert.NotNull(first);
var egg = (EncounterEgg)first;