diff --git a/PKHeX.Core/Editing/PKM/LegalMoveSource.cs b/PKHeX.Core/Editing/PKM/LegalMoveSource.cs index d12428c42..b6c0d8957 100644 --- a/PKHeX.Core/Editing/PKM/LegalMoveSource.cs +++ b/PKHeX.Core/Editing/PKM/LegalMoveSource.cs @@ -47,11 +47,13 @@ public void ReloadMoves(IReadOnlyList moves) private int Compare(ComboItem i1, ComboItem i2) { // split into 2 groups: Allowed & Not, and sort each sublist - var c1 = AllowedMoves.Contains(i1.Value); - var c2 = AllowedMoves.Contains(i2.Value); + var (strA, value1) = i1; + var (strB, value2) = i2; + var c1 = AllowedMoves.Contains(value1); + var c2 = AllowedMoves.Contains(value2); if (c1) - return c2 ? string.CompareOrdinal(i1.Text, i2.Text) : -1; - return c2 ? 1 : string.CompareOrdinal(i1.Text, i2.Text); + return c2 ? string.CompareOrdinal(strA, strB) : -1; + return c2 ? 1 : string.CompareOrdinal(strA, strB); } public void ReloadMoves(IReadOnlyList moves) diff --git a/PKHeX.Core/Editing/Program/StartupArguments.cs b/PKHeX.Core/Editing/Program/StartupArguments.cs index 8cd555c95..ca4bea303 100644 --- a/PKHeX.Core/Editing/Program/StartupArguments.cs +++ b/PKHeX.Core/Editing/Program/StartupArguments.cs @@ -74,15 +74,12 @@ public void ReadTemplateIfNoEntity(string path) Entity = pk; } - private static SaveFile? ReadSettingsDefinedPKM(IStartupSettings startup, PKM pkm) + private static SaveFile? ReadSettingsDefinedPKM(IStartupSettings startup, PKM pkm) => startup.AutoLoadSaveOnStartup switch { - var opt = startup.AutoLoadSaveOnStartup; - if (opt is AutoLoadSetting.LastLoaded) - return GetMostRecentlyLoaded(startup.RecentlyLoaded).FirstOrDefault(z => z.IsCompatiblePKM(pkm)); - if (opt is AutoLoadSetting.RecentBackup) - return SaveFinder.DetectSaveFiles().FirstOrDefault(z => z.IsCompatiblePKM(pkm)); - return null; - } + AutoLoadSetting.RecentBackup => SaveFinder.DetectSaveFiles().FirstOrDefault(z => z.IsCompatiblePKM(pkm)), + AutoLoadSetting.LastLoaded => GetMostRecentlyLoaded(startup.RecentlyLoaded).FirstOrDefault(z => z.IsCompatiblePKM(pkm)), + _ => null, + }; private static SaveFile? ReadSettingsAnyPKM(IStartupSettings startup) => startup.AutoLoadSaveOnStartup switch { diff --git a/PKHeX.Core/Editing/Showdown/ShowdownSet.cs b/PKHeX.Core/Editing/Showdown/ShowdownSet.cs index 76eb89a05..d23e48ca5 100644 --- a/PKHeX.Core/Editing/Showdown/ShowdownSet.cs +++ b/PKHeX.Core/Editing/Showdown/ShowdownSet.cs @@ -107,17 +107,20 @@ private void LoadLines(IEnumerable lines) // Handle edge case with fixed-gender forms. if (Species is (int) Meowstic or (int) Indeedee) + ReviseGenderedForms(); + } + + private void ReviseGenderedForms() + { + if (Gender == 1) // Recognized with (F) { - if (Gender == 1) // Recognized with (F) - { - FormName = "F"; - Form = 1; - } - else - { - FormName = Form == 1 ? "F" : "M"; - Gender = Form; - } + FormName = "F"; + Form = 1; + } + else + { + FormName = Form == 1 ? "F" : "M"; + Gender = Form; } } diff --git a/PKHeX.Core/Legality/Areas/EncounterArea.cs b/PKHeX.Core/Legality/Areas/EncounterArea.cs index e8668a589..8b2e8400a 100644 --- a/PKHeX.Core/Legality/Areas/EncounterArea.cs +++ b/PKHeX.Core/Legality/Areas/EncounterArea.cs @@ -6,15 +6,12 @@ namespace PKHeX.Core /// /// Represents an Area where can be encountered, which contains a Location ID and data. /// - public abstract record EncounterArea : IVersion + public abstract record EncounterArea(GameVersion Version) : IVersion { - public GameVersion Version { get; } public int Location { get; protected init; } public SlotType Type { get; protected init; } = SlotType.Any; protected abstract IReadOnlyList Raw { get; } - protected EncounterArea(GameVersion game) => Version = game; - /// /// Gets the slots contained in the area that match the provided data. /// diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs index 61154e8cf..4eea9fce3 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs @@ -336,7 +336,7 @@ static Encounters4() Location = 214, Moves = new[] { 344, 270, 207, 220 }, GroundTile = Max_Pt, - Shiny = Shiny.Never + Shiny = Shiny.Never, }, // Stationary Legendary diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs index 1f4ad90ff..aff7dca7d 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs @@ -536,7 +536,7 @@ static Encounters5() new(0xFF01007F) { Species = 595, Level = 28, Location = 037, Ability = 2, Nature = Nature.Docile }, // Joltik @ Chargestone Cave new(0xFF00007F) { Species = 597, Level = 28, Location = 037, Ability = 1, Nature = Nature.Bashful }, // Ferroseed @ Chargestone Cave new(0xFF000000) { Species = 599, Level = 28, Location = 037, Ability = 1, Nature = Nature.Rash }, // Klink @ Chargestone Cave - new(0xFF00001F) { Species = 570, Level = 25, Location = 010, Ability = 1, Nature = Nature.Hasty, Gift = true } // N's Zorua @ Driftveil City + new(0xFF00001F) { Species = 570, Level = 25, Location = 010, Ability = 1, Nature = Nature.Hasty, Gift = true }, // N's Zorua @ Driftveil City }; private static readonly EncounterStatic5[] Encounter_B2W2 = ArrayUtil.ConcatAll(Encounter_B2W2_Regular, Encounter_B2W2_N, Encounter_DreamRadar); diff --git a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs index 415e3d15a..463c3a1e9 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterSlot/EncounterSlot6XY.cs @@ -28,10 +28,7 @@ public override string GetConditionString(out bool valid) return Pressure ? LegalityCheckStrings.LEncConditionLead : LegalityCheckStrings.LEncCondition; } - public EncounterSlot6XY CreatePressureFormCopy(int evoForm) - { - return new((EncounterArea6XY) Area, Species, evoForm, LevelMin, LevelMax) {Pressure = true}; - } + public EncounterSlot6XY CreatePressureFormCopy(int evoForm) => new((EncounterArea6XY) Area, Species, evoForm, LevelMin, LevelMax) {Pressure = true}; protected override HiddenAbilityPermission IsHiddenAbilitySlot() => IsHorde ? HiddenAbilityPermission.Possible : HiddenAbilityPermission.Never; } diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs index 9627d996d..a79e5a776 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/DreamWorldEntry.cs @@ -37,20 +37,17 @@ private void AddTo(GameVersion game, EncounterStatic5[] result, ref int ctr) result[ctr++] = Create(game, a, Move3); } - private EncounterStatic5 Create(GameVersion game, int ability, int move) + private EncounterStatic5 Create(GameVersion game, int ability, int move) => new(game) { - return new(game) - { - Species = Species, - Form = Form, - Gender = Gender, - Level = Level, - Ability = ability, - Location = 075, - Shiny = Shiny.Never, - Moves = new[] { move }, - }; - } + Species = Species, + Form = Form, + Gender = Gender, + Level = Level, + Ability = ability, + Location = 075, + Shiny = Shiny.Never, + Moves = new[] { move }, + }; public static EncounterStatic5[] GetArray(GameVersion game, IReadOnlyList t) { diff --git a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs index a9cd8a668..d077311df 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterStatic/EncounterStatic.cs @@ -9,7 +9,7 @@ namespace PKHeX.Core /// /// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions. /// - public abstract record EncounterStatic : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber + public abstract record EncounterStatic(GameVersion Version) : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber { public int Species { get; init; } public int Form { get; init; } @@ -17,7 +17,6 @@ public abstract record EncounterStatic : IEncounterable, IMoveset, ILocation, IE public virtual int LevelMin => Level; public virtual int LevelMax => Level; public abstract int Generation { get; } - public GameVersion Version { get; } public virtual int Location { get; init; } public int Ability { get; init; } @@ -50,8 +49,6 @@ public abstract record EncounterStatic : IEncounterable, IMoveset, ILocation, IE internal const int FormVivillon = 30; //protected const int FormRandom = 31; - protected EncounterStatic(GameVersion game) => Version = game; - protected virtual PKM GetBlank(ITrainerInfo tr) => PKMConverter.GetBlank(Generation, Version); public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPKM(sav, EncounterCriteria.Unrestricted); diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs index 9dca45b65..09d516743 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade.cs @@ -10,7 +10,7 @@ namespace PKHeX.Core /// /// Trade data is fixed level in all cases except for the first few generations of games. /// - public abstract record EncounterTrade : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber + public abstract record EncounterTrade(GameVersion Version) : IEncounterable, IMoveset, ILocation, IEncounterMatch, IFixedBall, IFixedAbilityNumber { public int Species { get; init; } public int Form { get; init; } @@ -19,7 +19,6 @@ public abstract record EncounterTrade : IEncounterable, IMoveset, ILocation, IEn public int LevelMax => 100; public IReadOnlyList Moves { get; init; } = Array.Empty(); public abstract int Generation { get; } - public GameVersion Version { get; } public int CurrentLevel { get; init; } = -1; public abstract int Location { get; } @@ -63,8 +62,6 @@ public int TID7 public bool HasNickname => Nicknames.Count != 0 && IsNicknamed; public bool HasTrainerName => TrainerNames.Count != 0; - protected EncounterTrade(GameVersion game) => Version = game; - public PKM ConvertToPKM(ITrainerInfo sav) => ConvertToPKM(sav, EncounterCriteria.Unrestricted); public PKM ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria) diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionMethod.cs b/PKHeX.Core/Legality/Evolutions/EvolutionMethod.cs index 47e68580a..abc72eb05 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionMethod.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionMethod.cs @@ -136,14 +136,11 @@ private bool HasMetLevelIncreased(PKM pkm, int lvl) }; } - public EvoCriteria GetEvoCriteria(int species, int form, int lvl) + public EvoCriteria GetEvoCriteria(int species, int form, int lvl) => new(species, form) { - return new(species, form) - { - Level = lvl, - Method = Method, - }; - } + Level = lvl, + Method = Method, + }; public static int GetAmpLowKeyResult(int n) { diff --git a/PKHeX.Core/MysteryGifts/WC3.cs b/PKHeX.Core/MysteryGifts/WC3.cs index 7ea622da0..858ccf250 100644 --- a/PKHeX.Core/MysteryGifts/WC3.cs +++ b/PKHeX.Core/MysteryGifts/WC3.cs @@ -160,7 +160,7 @@ private void SetMoves(PK3 pk) Moves = MoveList.GetBaseEggMoves(pk, Species, Form, (GameVersion)pk.Version, Level); if (Moves.Count != 4) { - var moves = Moves.ToArray(); + int[] moves = Moves.ToArray(); Array.Resize(ref moves, 4); Moves = moves; } diff --git a/PKHeX.Core/PKM/PK2.cs b/PKHeX.Core/PKM/PK2.cs index e60e6938f..98ef77bb6 100644 --- a/PKHeX.Core/PKM/PK2.cs +++ b/PKHeX.Core/PKM/PK2.cs @@ -223,43 +223,40 @@ public PK7 ConvertToPK7() return pk7; } - public SK2 ConvertToSK2() + public SK2 ConvertToSK2() => new(Japanese) { - return new(Japanese) - { - Species = Species, - HeldItem = HeldItem, - Move1 = Move1, - Move2 = Move2, - Move3 = Move3, - Move4 = Move4, - TID = TID, - EXP = EXP, - EV_HP = EV_HP, - EV_ATK = EV_ATK, - EV_DEF = EV_DEF, - EV_SPE = EV_SPE, - EV_SPC = EV_SPC, - DV16 = DV16, - Move1_PP = Move1_PP, - Move2_PP = Move2_PP, - Move3_PP = Move3_PP, - Move4_PP = Move4_PP, - Move1_PPUps = Move1_PPUps, - Move2_PPUps = Move2_PPUps, - Move3_PPUps = Move3_PPUps, - Move4_PPUps = Move4_PPUps, - CurrentFriendship = CurrentFriendship, - IsEgg = IsEgg, - Stat_Level = Stat_Level, - PKRS_Days = PKRS_Days, - PKRS_Strain = PKRS_Strain, - CaughtData = CaughtData, + Species = Species, + HeldItem = HeldItem, + Move1 = Move1, + Move2 = Move2, + Move3 = Move3, + Move4 = Move4, + TID = TID, + EXP = EXP, + EV_HP = EV_HP, + EV_ATK = EV_ATK, + EV_DEF = EV_DEF, + EV_SPE = EV_SPE, + EV_SPC = EV_SPC, + DV16 = DV16, + Move1_PP = Move1_PP, + Move2_PP = Move2_PP, + Move3_PP = Move3_PP, + Move4_PP = Move4_PP, + Move1_PPUps = Move1_PPUps, + Move2_PPUps = Move2_PPUps, + Move3_PPUps = Move3_PPUps, + Move4_PPUps = Move4_PPUps, + CurrentFriendship = CurrentFriendship, + IsEgg = IsEgg, + Stat_Level = Stat_Level, + PKRS_Days = PKRS_Days, + PKRS_Strain = PKRS_Strain, + CaughtData = CaughtData, - // Only copies until first 0x50 terminator, but just copy everything - Nickname = Nickname, - OT_Name = OT_Name, - }; - } + // Only copies until first 0x50 terminator, but just copy everything + Nickname = Nickname, + OT_Name = OT_Name, + }; } } diff --git a/PKHeX.Core/PKM/SK2.cs b/PKHeX.Core/PKM/SK2.cs index 1a61f5b45..27b4810e8 100644 --- a/PKHeX.Core/PKM/SK2.cs +++ b/PKHeX.Core/PKM/SK2.cs @@ -147,44 +147,41 @@ public override void SetNotNicknamed(int language) public override int MaxAbilityID => Legal.MaxAbilityID_2; public override int MaxItemID => Legal.MaxItemID_2; - public PK2 ConvertToPK2() + public PK2 ConvertToPK2() => new(Japanese) { - return new(Japanese) - { - Species = Species, - HeldItem = HeldItem, - Move1 = Move1, - Move2 = Move2, - Move3 = Move3, - Move4 = Move4, - TID = TID, - EXP = EXP, - EV_HP = EV_HP, - EV_ATK = EV_ATK, - EV_DEF = EV_DEF, - EV_SPE = EV_SPE, - EV_SPC = EV_SPC, - DV16 = DV16, - Move1_PP = Move1_PP, - Move2_PP = Move2_PP, - Move3_PP = Move3_PP, - Move4_PP = Move4_PP, - Move1_PPUps = Move1_PPUps, - Move2_PPUps = Move2_PPUps, - Move3_PPUps = Move3_PPUps, - Move4_PPUps = Move4_PPUps, - CurrentFriendship = CurrentFriendship, - Stat_Level = Stat_Level, - IsEgg = IsEgg, - PKRS_Days = PKRS_Days, - PKRS_Strain = PKRS_Strain, - CaughtData = CaughtData, + Species = Species, + HeldItem = HeldItem, + Move1 = Move1, + Move2 = Move2, + Move3 = Move3, + Move4 = Move4, + TID = TID, + EXP = EXP, + EV_HP = EV_HP, + EV_ATK = EV_ATK, + EV_DEF = EV_DEF, + EV_SPE = EV_SPE, + EV_SPC = EV_SPC, + DV16 = DV16, + Move1_PP = Move1_PP, + Move2_PP = Move2_PP, + Move3_PP = Move3_PP, + Move4_PP = Move4_PP, + Move1_PPUps = Move1_PPUps, + Move2_PPUps = Move2_PPUps, + Move3_PPUps = Move3_PPUps, + Move4_PPUps = Move4_PPUps, + CurrentFriendship = CurrentFriendship, + Stat_Level = Stat_Level, + IsEgg = IsEgg, + PKRS_Days = PKRS_Days, + PKRS_Strain = PKRS_Strain, + CaughtData = CaughtData, - // Only copies until first 0x50 terminator, but just copy everything - Nickname = Nickname, - OT_Name = IsRental ? Japanese ? "1337" : "PKHeX" : OT_Name, - }; - } + // Only copies until first 0x50 terminator, but just copy everything + Nickname = Nickname, + OT_Name = IsRental ? Japanese ? "1337" : "PKHeX" : OT_Name, + }; private static bool IsJapanese(ReadOnlySpan data) { diff --git a/PKHeX.Core/PKM/Shared/G3PKM.cs b/PKHeX.Core/PKM/Shared/G3PKM.cs index f483a4888..85f50e78a 100644 --- a/PKHeX.Core/PKM/Shared/G3PKM.cs +++ b/PKHeX.Core/PKM/Shared/G3PKM.cs @@ -100,89 +100,86 @@ protected static int SwapBits(int value, int p1, int p2) /// /// Generation 3 format to convert to /// New object with transferred properties. - protected T ConvertTo() where T : G3PKM, new() + protected T ConvertTo() where T : G3PKM, new() => new() { - return new() - { - Species = Species, - Language = Language, - PID = PID, - TID = TID, - SID = SID, - EXP = EXP, - HeldItem = HeldItem, - AbilityBit = AbilityBit, - IsEgg = IsEgg, - FatefulEncounter = FatefulEncounter, + Species = Species, + Language = Language, + PID = PID, + TID = TID, + SID = SID, + EXP = EXP, + HeldItem = HeldItem, + AbilityBit = AbilityBit, + IsEgg = IsEgg, + FatefulEncounter = FatefulEncounter, - Met_Location = Met_Location, - Met_Level = Met_Level, - Version = Version, - Ball = Ball, + Met_Location = Met_Location, + Met_Level = Met_Level, + Version = Version, + Ball = Ball, - Nickname = Nickname, - OT_Name = OT_Name, - OT_Gender = OT_Gender, - OT_Friendship = OT_Friendship, + Nickname = Nickname, + OT_Name = OT_Name, + OT_Gender = OT_Gender, + OT_Friendship = OT_Friendship, - Move1_PPUps = Move1_PPUps, - Move2_PPUps = Move2_PPUps, - Move3_PPUps = Move3_PPUps, - Move4_PPUps = Move4_PPUps, - Move1 = Move1, - Move2 = Move2, - Move3 = Move3, - Move4 = Move4, - Move1_PP = Move1_PP, - Move2_PP = Move2_PP, - Move3_PP = Move3_PP, - Move4_PP = Move4_PP, + Move1_PPUps = Move1_PPUps, + Move2_PPUps = Move2_PPUps, + Move3_PPUps = Move3_PPUps, + Move4_PPUps = Move4_PPUps, + Move1 = Move1, + Move2 = Move2, + Move3 = Move3, + Move4 = Move4, + Move1_PP = Move1_PP, + Move2_PP = Move2_PP, + Move3_PP = Move3_PP, + Move4_PP = Move4_PP, - IV_HP = IV_HP, - IV_ATK = IV_ATK, - IV_DEF = IV_DEF, - IV_SPE = IV_SPE, - IV_SPA = IV_SPA, - IV_SPD = IV_SPD, - EV_HP = EV_HP, - EV_ATK = EV_ATK, - EV_DEF = EV_DEF, - EV_SPE = EV_SPE, - EV_SPA = EV_SPA, - EV_SPD = EV_SPD, - CNT_Cool = CNT_Cool, - CNT_Beauty = CNT_Beauty, - CNT_Cute = CNT_Cute, - CNT_Smart = CNT_Smart, - CNT_Tough = CNT_Tough, - CNT_Sheen = CNT_Sheen, + IV_HP = IV_HP, + IV_ATK = IV_ATK, + IV_DEF = IV_DEF, + IV_SPE = IV_SPE, + IV_SPA = IV_SPA, + IV_SPD = IV_SPD, + EV_HP = EV_HP, + EV_ATK = EV_ATK, + EV_DEF = EV_DEF, + EV_SPE = EV_SPE, + EV_SPA = EV_SPA, + EV_SPD = EV_SPD, + CNT_Cool = CNT_Cool, + CNT_Beauty = CNT_Beauty, + CNT_Cute = CNT_Cute, + CNT_Smart = CNT_Smart, + CNT_Tough = CNT_Tough, + CNT_Sheen = CNT_Sheen, - PKRS_Days = PKRS_Days, - PKRS_Strain = PKRS_Strain, + PKRS_Days = PKRS_Days, + PKRS_Strain = PKRS_Strain, - // Transfer Ribbons - RibbonCountG3Cool = RibbonCountG3Cool, - RibbonCountG3Beauty = RibbonCountG3Beauty, - RibbonCountG3Cute = RibbonCountG3Cute, - RibbonCountG3Smart = RibbonCountG3Smart, - RibbonCountG3Tough = RibbonCountG3Tough, - RibbonChampionG3 = RibbonChampionG3, - RibbonWinning = RibbonWinning, - RibbonVictory = RibbonVictory, - RibbonArtist = RibbonArtist, - RibbonEffort = RibbonEffort, - RibbonChampionBattle = RibbonChampionBattle, - RibbonChampionRegional = RibbonChampionRegional, - RibbonChampionNational = RibbonChampionNational, - RibbonCountry = RibbonCountry, - RibbonNational = RibbonNational, - RibbonEarth = RibbonEarth, - RibbonWorld = RibbonWorld, - Unused1 = Unused1, - Unused2 = Unused2, - Unused3 = Unused3, - Unused4 = Unused4, - }; - } + // Transfer Ribbons + RibbonCountG3Cool = RibbonCountG3Cool, + RibbonCountG3Beauty = RibbonCountG3Beauty, + RibbonCountG3Cute = RibbonCountG3Cute, + RibbonCountG3Smart = RibbonCountG3Smart, + RibbonCountG3Tough = RibbonCountG3Tough, + RibbonChampionG3 = RibbonChampionG3, + RibbonWinning = RibbonWinning, + RibbonVictory = RibbonVictory, + RibbonArtist = RibbonArtist, + RibbonEffort = RibbonEffort, + RibbonChampionBattle = RibbonChampionBattle, + RibbonChampionRegional = RibbonChampionRegional, + RibbonChampionNational = RibbonChampionNational, + RibbonCountry = RibbonCountry, + RibbonNational = RibbonNational, + RibbonEarth = RibbonEarth, + RibbonWorld = RibbonWorld, + Unused1 = Unused1, + Unused2 = Unused2, + Unused3 = Unused3, + Unused4 = Unused4, + }; } } diff --git a/PKHeX.Core/PKM/Shared/PokeListGB.cs b/PKHeX.Core/PKM/Shared/PokeListGB.cs index ad975a8ec..fd2ce849b 100644 --- a/PKHeX.Core/PKM/Shared/PokeListGB.cs +++ b/PKHeX.Core/PKM/Shared/PokeListGB.cs @@ -40,7 +40,7 @@ protected PokeListGB(byte[]? d, PokeListType c = PokeListType.Single, bool jp = Capacity = (byte)c; Entry_Size = GetEntrySize(); StringLength = GetStringLength(jp); - var data = d ?? GetEmptyList(c, jp); + byte[] data = d ?? GetEmptyList(c, jp); var dataSize = 1 + 1 + (Capacity * (Entry_Size + 1 + (2 * StringLength))); Array.Resize(ref data, dataSize); diff --git a/PKHeX.Core/PersonalInfo/PersonalTable.cs b/PKHeX.Core/PersonalInfo/PersonalTable.cs index 83cbe9fc7..e94832a16 100644 --- a/PKHeX.Core/PersonalInfo/PersonalTable.cs +++ b/PKHeX.Core/PersonalInfo/PersonalTable.cs @@ -112,10 +112,7 @@ public class PersonalTable /// public static readonly PersonalTable Y = GetTable("y", GameVersion.YW); - private static PersonalTable GetTable(string game, GameVersion format) - { - return new(Util.GetBinaryResource($"personal_{game}"), format); - } + private static PersonalTable GetTable(string game, GameVersion format) => new(Util.GetBinaryResource($"personal_{game}"), format); private static Func GetConstructor(GameVersion format) => format switch { diff --git a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs index 39e9cc829..76bd55ada 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs @@ -34,21 +34,18 @@ public byte[] Write() return Data; } - private SecretBase3PKM GetPKM(int index) + private SecretBase3PKM GetPKM(int index) => new() { - return new() - { - PID = BitConverter.ToUInt32(Data, GetOffsetPID(index)), - Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(index)), - HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(index)), - Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 0)), - Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 1)), - Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 2)), - Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 3)), - Level = Data[O_Level + index], - EVAll = Data[O_EV + index], - }; - } + PID = BitConverter.ToUInt32(Data, GetOffsetPID(index)), + Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(index)), + HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(index)), + Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 0)), + Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 1)), + Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 2)), + Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 3)), + Level = Data[O_Level + index], + EVAll = Data[O_EV + index], + }; private void SetPKM(int index) { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs index 8ad2331dd..71bb036c1 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs @@ -122,7 +122,7 @@ private InventoryPouch8b MakePouch(InventoryType type, Func? isLeg InventoryType.Balls => 999, InventoryType.BattleItems => 999, InventoryType.Treasure => 999, - _ => throw new ArgumentOutOfRangeException(nameof(type)) + _ => throw new ArgumentOutOfRangeException(nameof(type)), }; private static ushort[] GetLegal(InventoryType type) => type switch @@ -135,7 +135,7 @@ private InventoryPouch8b MakePouch(InventoryType type, Func? isLeg InventoryType.Balls => Legal.Pouch_Ball_BS, InventoryType.BattleItems => Legal.Pouch_Battle_BS, InventoryType.Treasure => Legal.Pouch_Treasure_BS, - _ => throw new ArgumentOutOfRangeException(nameof(type)) + _ => throw new ArgumentOutOfRangeException(nameof(type)), }; } } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/UgItemUtil.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/UgItemUtil.cs index 75e58baac..54f12449b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/UgItemUtil.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/UgItemUtil.cs @@ -19,6 +19,7 @@ public static UgItemType GetType(int ugItemID) _ => UndergroundItemList8b.ItemMaxCount, }; + // ReSharper disable once NotAccessedPositionalProperty.Local private record UgItemDef(int UgItemID, int ItemID, int SphereID, int PedestalID, int StatueID) { private bool IsSphere => SphereID > 0; diff --git a/PKHeX.Core/Saves/Util/SaveFinder.cs b/PKHeX.Core/Saves/Util/SaveFinder.cs index 6ac2634b0..f9b45fcd4 100644 --- a/PKHeX.Core/Saves/Util/SaveFinder.cs +++ b/PKHeX.Core/Saves/Util/SaveFinder.cs @@ -126,11 +126,11 @@ public static IEnumerable GetFoldersToCheck(IReadOnlyList drives { var foldersToCheck = extra.Where(f => !string.IsNullOrWhiteSpace(f)).Concat(CustomBackupPaths); - string path3DS = Path.GetPathRoot(Get3DSLocation(drives)); + string? path3DS = Path.GetPathRoot(Get3DSLocation(drives)); if (!string.IsNullOrEmpty(path3DS)) // check for Homebrew/CFW backups foldersToCheck = foldersToCheck.Concat(Get3DSBackupPaths(path3DS)); - string pathNX = Path.GetPathRoot(GetSwitchLocation(drives)); + string? pathNX = Path.GetPathRoot(GetSwitchLocation(drives)); if (!string.IsNullOrEmpty(pathNX)) // check for Homebrew/CFW backups foldersToCheck = foldersToCheck.Concat(GetSwitchBackupPaths(pathNX)); diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 2c52808fe..06f49afeb 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -727,7 +727,8 @@ private void ClickMoves(object? sender, EventArgs e) UpdateLegality(skipMoveRepop: true); if (sender == GB_CurrentMoves) { - if (!SetSuggestedMoves(random: ModifierKeys == Keys.Control)) + bool random = ModifierKeys == Keys.Control; + if (!SetSuggestedMoves(random)) return; } else if (sender == GB_RelearnMoves) diff --git a/PKHeX.WinForms/Controls/Slots/PokeGrid.cs b/PKHeX.WinForms/Controls/Slots/PokeGrid.cs index d32745a46..990bd9421 100644 --- a/PKHeX.WinForms/Controls/Slots/PokeGrid.cs +++ b/PKHeX.WinForms/Controls/Slots/PokeGrid.cs @@ -72,19 +72,16 @@ private void Generate(int width, int height) public void SetBackground(Image img) => BackgroundImage = img; - public static PictureBox GetControl(int width, int height) + public static PictureBox GetControl(int width, int height) => new() { - return new() - { - AutoSize = false, - SizeMode = PictureBoxSizeMode.CenterImage, - BackColor = Color.Transparent, - Width = width + (2 * 1), - Height = height + (2 * 1), - Padding = Padding.Empty, - Margin = Padding.Empty, - BorderStyle = BorderStyle.FixedSingle, - }; - } + AutoSize = false, + SizeMode = PictureBoxSizeMode.CenterImage, + BackColor = Color.Transparent, + Width = width + (2 * 1), + Height = height + (2 * 1), + Padding = Padding.Empty, + Margin = Padding.Empty, + BorderStyle = BorderStyle.FixedSingle, + }; } } diff --git a/PKHeX.WinForms/Controls/Slots/SlotChangeInfo.cs b/PKHeX.WinForms/Controls/Slots/SlotChangeInfo.cs index fe03ac381..f0e58652c 100644 --- a/PKHeX.WinForms/Controls/Slots/SlotChangeInfo.cs +++ b/PKHeX.WinForms/Controls/Slots/SlotChangeInfo.cs @@ -21,6 +21,13 @@ public void Reset() } public bool SameLocation => (Destination != null) && (Source?.Equals(Destination) ?? false); - public bool DragIsParty => Source?.Slot is SlotInfoParty || Destination?.Slot is SlotInfoParty; + + private bool SourceIsParty => Source?.Slot is SlotInfoParty; + private bool DestinationIsParty => Destination?.Slot is SlotInfoParty; + + /// + /// Used to indicate if the changes will alter the player's party data state. + /// + public bool DragIsParty => SourceIsParty || DestinationIsParty; } } \ No newline at end of file diff --git a/PKHeX.WinForms/Controls/Slots/SlotList.cs b/PKHeX.WinForms/Controls/Slots/SlotList.cs index 4430a7830..dfd2262bb 100644 --- a/PKHeX.WinForms/Controls/Slots/SlotList.cs +++ b/PKHeX.WinForms/Controls/Slots/SlotList.cs @@ -119,19 +119,16 @@ private void AddSlots(int count) private const int PadPixels = 2; - private static PictureBox GetPictureBox(int index, SpriteBuilder s) + private static PictureBox GetPictureBox(int index, SpriteBuilder s) => new() { - return new() - { - BorderStyle = BorderStyle.FixedSingle, - Width = s.Width + 2, - Height = s.Height + 2, - AllowDrop = true, - Margin = new Padding(PadPixels), - SizeMode = PictureBoxSizeMode.CenterImage, - Name = $"bpkm{index}", - }; - } + BorderStyle = BorderStyle.FixedSingle, + Width = s.Width + 2, + Height = s.Height + 2, + AllowDrop = true, + Margin = new Padding(PadPixels), + SizeMode = PictureBoxSizeMode.CenterImage, + Name = $"bpkm{index}", + }; private sealed class LabelType : Label { diff --git a/PKHeX.WinForms/Subforms/SAV_FolderList.cs b/PKHeX.WinForms/Subforms/SAV_FolderList.cs index f3dab7d67..76c5738cd 100644 --- a/PKHeX.WinForms/Subforms/SAV_FolderList.cs +++ b/PKHeX.WinForms/Subforms/SAV_FolderList.cs @@ -113,15 +113,12 @@ private void AddButton(string name, string path) button.MouseHover += (_, _) => hover.Show(path, button); } - private static Button GetCustomButton(string name) + private static Button GetCustomButton(string name) => new() { - return new() - { - Size = new Size { Height = ButtonHeight, Width = ButtonWidth }, - Text = name, - Name = $"B_{name}", - }; - } + Size = new Size { Height = ButtonHeight, Width = ButtonWidth }, + Text = name, + Name = $"B_{name}", + }; private static IEnumerable GetUserPaths() { diff --git a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs index c4c678e78..b02957135 100644 --- a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs +++ b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs @@ -304,11 +304,13 @@ private void B_Search_Click(object sender, EventArgs e) if (move3 != -1) res = res.Where(mg => mg.HasMove(move3)); if (move4 != -1) res = res.Where(mg => mg.HasMove(move4)); - if (CHK_Shiny.CheckState == CheckState.Checked) res = res.Where(pk => pk.IsShiny); - else if (CHK_Shiny.CheckState == CheckState.Unchecked) res = res.Where(pk => !pk.IsShiny); + var shiny = CHK_Shiny.CheckState; + if (shiny == CheckState.Checked) res = res.Where(pk => pk.IsShiny); + else if (shiny == CheckState.Unchecked) res = res.Where(pk => !pk.IsShiny); - if (CHK_IsEgg.CheckState == CheckState.Checked) res = res.Where(pk => pk.IsEgg); - else if (CHK_IsEgg.CheckState == CheckState.Unchecked) res = res.Where(pk => !pk.IsEgg); + var egg = CHK_IsEgg.CheckState; + if (egg == CheckState.Checked) res = res.Where(pk => pk.IsEgg); + else if (egg == CheckState.Unchecked) res = res.Where(pk => !pk.IsEgg); slotSelected = -1; // reset the slot last viewed diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs index 29419a9ff..2fe48f061 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen5/SAV_Misc5.cs @@ -172,16 +172,13 @@ private void ReadMain() } } - private static List GetStates() + private static List GetStates() => new() { - return new() - { - new ComboItem("Not roamed", 0), - new ComboItem("Roaming", 1), - new ComboItem("Defeated", 2), - new ComboItem("Captured", 3), - }; - } + new ComboItem("Not roamed", 0), + new ComboItem("Roaming", 1), + new ComboItem("Defeated", 2), + new ComboItem("Captured", 3), + }; private void SaveMain() { diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs index ee97d5d59..dc56ffbd0 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.cs @@ -105,29 +105,26 @@ private DataGridView GetDGV(InventoryPouch pouch) return dgv; } - private static DataGridView GetBaseDataGrid(InventoryPouch pouch) + private static DataGridView GetBaseDataGrid(InventoryPouch pouch) => new() { - return new() - { - Dock = DockStyle.Fill, - Text = pouch.Type.ToString(), - Name = "DGV_" + pouch.Type, + Dock = DockStyle.Fill, + Text = $"{pouch.Type}", + Name = $"DGV_{pouch.Type}", - AllowUserToAddRows = false, - AllowUserToDeleteRows = false, - AllowUserToResizeRows = false, - AllowUserToResizeColumns = false, - RowHeadersVisible = false, - MultiSelect = false, - ShowEditingIcon = false, + AllowUserToAddRows = false, + AllowUserToDeleteRows = false, + AllowUserToResizeRows = false, + AllowUserToResizeColumns = false, + RowHeadersVisible = false, + MultiSelect = false, + ShowEditingIcon = false, - EditMode = DataGridViewEditMode.EditOnEnter, - ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single, - ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize, - SelectionMode = DataGridViewSelectionMode.CellSelect, - CellBorderStyle = DataGridViewCellBorderStyle.None, - }; - } + EditMode = DataGridViewEditMode.EditOnEnter, + ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single, + ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize, + SelectionMode = DataGridViewSelectionMode.CellSelect, + CellBorderStyle = DataGridViewCellBorderStyle.None, + }; private static DataGridViewComboBoxColumn GetItemColumn(int c, string name = "Item") => new() { diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs index 6f5301439..8972b4d97 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs @@ -586,42 +586,33 @@ private List PopulateViewGiftsG567() return pb; } - private static FlowLayoutPanel GetFlowLayoutPanel() + private static FlowLayoutPanel GetFlowLayoutPanel() => new() { - return new() - { - Width = 480, - Height = 60, - Padding = new Padding(0), - Margin = new Padding(0), - }; - } + Width = 480, + Height = 60, + Padding = new Padding(0), + Margin = new Padding(0), + }; - private static Label GetLabel(string text) + private static Label GetLabel(string text) => new() { - return new() - { - Size = new Size(40, 60), - AutoSize = false, - TextAlign = ContentAlignment.MiddleRight, - Text = text, - Padding = new Padding(0), - Margin = new Padding(0), - }; - } + Size = new Size(40, 60), + AutoSize = false, + TextAlign = ContentAlignment.MiddleRight, + Text = text, + Padding = new Padding(0), + Margin = new Padding(0), + }; - private static PictureBox GetPictureBox() + private static PictureBox GetPictureBox() => new() { - return new() - { - Size = new Size(70, 58), - SizeMode = PictureBoxSizeMode.CenterImage, - BorderStyle = BorderStyle.FixedSingle, - BackColor = Color.Transparent, - Padding = new Padding(0), - Margin = new Padding(1), - }; - } + Size = new Size(70, 58), + SizeMode = PictureBoxSizeMode.CenterImage, + BorderStyle = BorderStyle.FixedSingle, + BackColor = Color.Transparent, + Padding = new Padding(0), + Margin = new Padding(1), + }; private void B_ModifyAll_Click(object sender, EventArgs e) {