diff --git a/PKHeX.Core/Editing/PKM/LegalMoveSource.cs b/PKHeX.Core/Editing/PKM/LegalMoveSource.cs index c4524e81f..d12428c42 100644 --- a/PKHeX.Core/Editing/PKM/LegalMoveSource.cs +++ b/PKHeX.Core/Editing/PKM/LegalMoveSource.cs @@ -15,7 +15,7 @@ namespace PKHeX.Core public IReadOnlyList DataSource => (ComboItem[])MoveDataAllowed.Clone(); /// - /// Checks if the requested is in the valid learnable list of moves. + /// Checks if the requested is legally able to be learned. /// /// Move to check if can be learned /// True if can learn the move diff --git a/PKHeX.Core/Game/GameStrings/GameInfo.cs b/PKHeX.Core/Game/GameStrings/GameInfo.cs index 775897361..64700b05c 100644 --- a/PKHeX.Core/Game/GameStrings/GameInfo.cs +++ b/PKHeX.Core/Game/GameStrings/GameInfo.cs @@ -32,7 +32,7 @@ namespace PKHeX.Core } public static GameDataSource Sources { get; private set; } = new(_strings); - public static FilteredGameDataSource FilteredSources { get; set; } = new(FakeSaveFile.Default, Sources, false); + public static FilteredGameDataSource FilteredSources { get; set; } = new(FakeSaveFile.Default, Sources); public static string GetVersionName(GameVersion version) { diff --git a/PKHeX.Core/Legality/Moves/MoveLevelUp.cs b/PKHeX.Core/Legality/Moves/MoveLevelUp.cs index fafa266da..71412483a 100644 --- a/PKHeX.Core/Legality/Moves/MoveLevelUp.cs +++ b/PKHeX.Core/Legality/Moves/MoveLevelUp.cs @@ -94,7 +94,7 @@ namespace PKHeX.Core private static LearnVersion GetIsLevelUp3(int species, int form, int move, int lvlLevel, GameVersion ver = Any) { if (species == (int)Species.Deoxys) - return GetIsLevelUp3Deoxys(form, move, lvlLevel); + return GetIsLevelUp3Deoxys(form, move, lvlLevel, ver); // Emerald level up tables are equal to R/S level up tables switch (ver) @@ -217,9 +217,9 @@ namespace PKHeX.Core return LearnNONE; } - private static LearnVersion GetIsLevelUp3Deoxys(int form, int move, int lvl) + private static LearnVersion GetIsLevelUp3Deoxys(int form, int move, int lvl, GameVersion ver = Any) { - var moveset = GetDeoxysLearn3(form); + var moveset = GetDeoxysLearn3(form, ver); if (moveset == null) return LearnNONE; var lv = moveset.GetLevelLearnMove(move); @@ -240,22 +240,17 @@ namespace PKHeX.Core private static Learnset? GetDeoxysLearn3(int form, GameVersion ver = Any) { const int index = (int)Species.Deoxys; - if (ver == Any) - { - return form switch - { - 0 => LevelUpRS[index], // Normal - 1 => LevelUpFR[index], // Attack - 2 => LevelUpLG[index], // Defense - 3 => LevelUpE[index], // Speed - _ => null, - }; - } + if (ver != Any && Gen3.Contains(ver)) + return GameData.GetLearnsets(ver)[index]; - var gen = ver.GetGeneration(); - if (gen != 3) - return GetDeoxysLearn3(form); - return GameData.GetLearnsets(ver)[index]; + return form switch + { + 0 => LevelUpRS[index], // Normal + 1 => LevelUpFR[index], // Attack + 2 => LevelUpLG[index], // Defense + 3 => LevelUpE[index], // Speed + _ => null, + }; } public static IEnumerable GetMovesLevelUp(PKM pkm, int species, int form, int maxLevel, int minlvlG1, int minlvlG2, GameVersion version, bool MoveReminder, int generation) diff --git a/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs b/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs index adbfd576d..854ec2143 100644 --- a/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs +++ b/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs @@ -336,9 +336,7 @@ namespace PKHeX.Core if ((s >> 16 & 1) == 0) continue; // only swap if 1 - var temp = natures[i]; - natures[i] = natures[j]; - natures[j] = temp; + (natures[i], natures[j]) = (natures[j], natures[i]); } } diff --git a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs index cb488d1e7..7d6c46934 100644 --- a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs @@ -248,7 +248,7 @@ namespace PKHeX.Core data.AddLine(GetValid(LNickMatchLanguageEgg, CheckIdentifier.Egg)); } - private void VerifyNicknameTrade(LegalityAnalysis data, EncounterTrade t) + private static void VerifyNicknameTrade(LegalityAnalysis data, EncounterTrade t) { switch (data.Info.Generation) { diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs index bf69b9882..0fc5642b5 100644 --- a/PKHeX.Core/MysteryGifts/PGF.cs +++ b/PKHeX.Core/MysteryGifts/PGF.cs @@ -52,7 +52,7 @@ namespace PKHeX.Core public string Nickname { get => StringConverter.GetString5(Data, 0x1E, 11 * 2); - set => StringConverter.SetString5(value, 11, 11, (char)0xFFFF).CopyTo(Data, 0x1E); + set => StringConverter.SetString5(value, 11, 11, '\uFFFF').CopyTo(Data, 0x1E); } public int Nature { get => (sbyte)Data[0x34]; set => Data[0x34] = (byte)value; } @@ -78,7 +78,7 @@ namespace PKHeX.Core public override string OT_Name { get => StringConverter.GetString5(Data, 0x4A, 8 * 2); - set => StringConverter.SetString5(value, 8, 8, (char)0xFFFF).CopyTo(Data, 0x4A); + set => StringConverter.SetString5(value, 8, 8, '\uFFFF').CopyTo(Data, 0x4A); } public int OTGender { get => Data[0x5A]; set => Data[0x5A] = (byte)value; } @@ -88,7 +88,7 @@ namespace PKHeX.Core public override string CardTitle { get => StringConverter.GetString5(Data, 0x60, 37 * 2); - set => StringConverter.SetString5(value + '\uFFFF', 37, 37, 0).CopyTo(Data, 0x60); + set => StringConverter.SetString5(value, 37, 37, 0).CopyTo(Data, 0x60); } // Card Attributes diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index e0be10d79..e34d5acfc 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -326,12 +326,7 @@ namespace PKHeX.Core public override MysteryGiftAlbum GiftAlbum { - get - { - var album = new MysteryGiftAlbum(MysteryGiftCards, MysteryGiftReceivedFlags); - album.Flags[2047] = false; - return album; - } + get => new(MysteryGiftCards, MysteryGiftReceivedFlags) {Flags = {[2047] = false}}; set { bool available = IsMysteryGiftAvailable(value.Gifts); diff --git a/PKHeX.Core/Saves/Substructures/OPower/OPower6.cs b/PKHeX.Core/Saves/Substructures/OPower/OPower6.cs index 760ce4c3c..16ac5c0fc 100644 --- a/PKHeX.Core/Saves/Substructures/OPower/OPower6.cs +++ b/PKHeX.Core/Saves/Substructures/OPower/OPower6.cs @@ -7,40 +7,31 @@ namespace PKHeX.Core { private static readonly OPowerFlagSet[] Mapping = { - new(5, Hatching), - new(5, Bargain), - new(5, Prize_Money), - new(5, Exp_Point), - new(5, Capture), + // Skip unused byte + new(5, Hatching) {Offset = 1}, + new(5, Bargain) {Offset = 6}, + new(5, Prize_Money) {Offset = 11}, + new(5, Exp_Point) {Offset = 16}, + new(5, Capture) {Offset = 21}, - new(3, Encounter), - new(3, Stealth), - new(3, HP_Restoring), - new(3, PP_Restoring), + new(3, Encounter) {Offset = 26}, + new(3, Stealth) {Offset = 29}, + new(3, HP_Restoring) {Offset = 32}, + new(3, PP_Restoring) {Offset = 35}, - new(1, Full_Recovery), + new(1, Full_Recovery) {Offset = 38}, - new(5, Befriending), + new(5, Befriending) {Offset = 39}, - new(3, Attack), - new(3, Defense), - new(3, Sp_Attack), - new(3, Sp_Defense), - new(3, Speed), - new(3, Critical), - new(3, Accuracy), + new(3, Attack) {Offset = 44}, + new(3, Defense) {Offset = 47}, + new(3, Sp_Attack) {Offset = 50}, + new(3, Sp_Defense) {Offset = 53}, + new(3, Speed) {Offset = 56}, + new(3, Critical) {Offset = 59}, + new(3, Accuracy) {Offset = 62}, }; - static OPower6() - { - int index = 1; // Skip unused byte - foreach (var m in Mapping) - { - m.Offset = index; - index += m.Count; - } - } - public OPower6(SaveFile sav, int offset) : base(sav) => Offset = offset; private static OPowerFlagSet Get(OPower6Type type) => Array.Find(Mapping, t => t.Identifier == type); diff --git a/PKHeX.Core/Util/BigEndian.cs b/PKHeX.Core/Util/BigEndian.cs index a57e8f4f2..e9d208d2d 100644 --- a/PKHeX.Core/Util/BigEndian.cs +++ b/PKHeX.Core/Util/BigEndian.cs @@ -102,9 +102,7 @@ namespace PKHeX.Core int j = 0 + data.Length - 1; while (i < j) { - var temp = data[i]; - data[i] = data[j]; - data[j] = temp; + (data[i], data[j]) = (data[j], data[i]); i++; j--; } @@ -119,13 +117,8 @@ namespace PKHeX.Core { for (int i = 0; i < data.Length; i += 4) { - byte tmp = data[0 + i]; - data[0 + i] = data[3 + i]; - data[3 + i] = tmp; - - byte tmp1 = data[1 + i]; - data[1 + i] = data[2 + i]; - data[2 + i] = tmp1; + (data[0 + i], data[3 + i]) = (data[3 + i], data[0 + i]); + (data[1 + i], data[2 + i]) = (data[2 + i], data[1 + i]); } } } diff --git a/PKHeX.Core/Util/RandUtil.cs b/PKHeX.Core/Util/RandUtil.cs index 75cf47541..9bef56e00 100644 --- a/PKHeX.Core/Util/RandUtil.cs +++ b/PKHeX.Core/Util/RandUtil.cs @@ -34,9 +34,7 @@ namespace PKHeX.Core for (int i = start; i < end; i++) { int index = i + rnd.Next(end - i); - T t = items[index]; - items[index] = items[i]; - items[i] = t; + (items[index], items[i]) = (items[i], items[index]); } } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs index a18953ad6..59e436589 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs @@ -50,7 +50,7 @@ namespace PKHeX.WinForms private const int cellscollected = 169; private const int celloffset = 0xC6; private int CellCount => SAV is SAV7USUM ? 100 : 95; - private readonly string[] states = {"None", "Available", "Received"}; + private static readonly string[] states = {"None", "Available", "Received"}; private void B_Save_Click(object sender, EventArgs e) { @@ -100,7 +100,7 @@ namespace PKHeX.WinForms #region locations -- lazy - private readonly string[] locationsSM = + private static readonly string[] locationsSM = { "Verdant Cave - Trial Site", "Ruins of Conflict - Outside", @@ -199,7 +199,7 @@ namespace PKHeX.WinForms "Aether Foundation 1F - Main Building", }; - private readonly string[] locationsUSUM = + private static readonly string[] locationsUSUM = { "Hau'oli City (Shopping) - Salon (Outside)", "Hau'oli City (Shopping) - Malasada Shop (Outside)", diff --git a/PKHeX.WinForms/Subforms/Save Editors/TrainerStat.cs b/PKHeX.WinForms/Subforms/Save Editors/TrainerStat.cs index 9cfa65697..01e41ff68 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/TrainerStat.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/TrainerStat.cs @@ -29,7 +29,7 @@ namespace PKHeX.WinForms.Controls if (!records.TryGetValue(i, out var name)) name = $"{i:D3}"; - CB_Stats.Items.Add(name!); + CB_Stats.Items.Add(name); } CB_Stats.SelectedIndex = records.First().Key; }