diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 8db0452b2..b3c1025f5 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -1284,7 +1284,7 @@ private void verifyAbility() } private bool? verifyAbilityPreCapsule(int[] abilities, int abilval) { - // Shadow Colosseum pokemon could habe any PID without maching PID + // CXD pokemon could have any ability without maching PID if (pkm.Version == (int)GameVersion.CXD && pkm.Format == 3) return null; @@ -1374,7 +1374,7 @@ private void verifyAbility7(int[] abilities) if (!valid) AddLine(Severity.Invalid, V111, CheckIdentifier.Ability); } - else if(EncounterIsMysteryGift) + else if (EncounterIsMysteryGift) verifyAbilityMG456(abilities, ((WC7)EncounterMatch).AbilityType); else if (Legal.Ban_NoHidden7.Contains(pkm.SpecForm) && pkm.AbilityNumber == 4) AddLine(Severity.Invalid, V112, CheckIdentifier.Ability); @@ -2285,12 +2285,12 @@ private void verifyMisc() { AddLine(Severity.Invalid, V319, CheckIdentifier.Misc); } if (pkm.CNTs.Any(stat => stat > 0)) { AddLine(Severity.Invalid, V320, CheckIdentifier.Misc); } - if( pkm.Format == 2 && (pkm.PKRS_Cured || pkm.PKRS_Infected)) + if (pkm.Format == 2 && (pkm.PKRS_Cured || pkm.PKRS_Infected)) { AddLine(Severity.Invalid, V368, CheckIdentifier.Misc); } var HatchCycles = (EncounterMatch as EncounterStatic)?.EggCycles; if (HatchCycles == 0) HatchCycles = pkm.PersonalInfo.HatchCycles; - if( pkm.CurrentFriendship > HatchCycles) + if (pkm.CurrentFriendship > HatchCycles) { AddLine(Severity.Invalid, V374, CheckIdentifier.Misc); } } @@ -2641,7 +2641,6 @@ private CheckResult[] parseMovesWasEggPreRelearn(int[] Moves, List[] validL Games = new[] { GameVersion.B2W2 }; break; } - int splitctr = Legal.SplitBreed.Contains(pkm.Species) ? 1 : 0; var issplitbreed = Legal.SplitBreed.Contains(pkm.Species); foreach (var ver in Games) { @@ -2649,7 +2648,7 @@ private CheckResult[] parseMovesWasEggPreRelearn(int[] Moves, List[] validL var BaseLvlMoves = 489 <= pkm.Species && pkm.Species <= 490 ? 1 : 100; var LvlupEggMoves = Legal.getBaseEggMoves(pkm, ver, BaseLvlMoves); // Level up, TMHM or tutor moves exclusive to the incense egg species, like Azurill, incompatible with the non-incense species egg moves - var ExclusiveIncenseMoves = issplitbreed ? Legal.getExclusiveEvolutionMoves(pkm,Legal.getBaseEggSpecies(pkm,0), EvoChainsAllGens, ver) : null; + var ExclusiveIncenseMoves = issplitbreed ? Legal.getExclusiveEvolutionMoves(pkm, Legal.getBaseEggSpecies(pkm), EvoChainsAllGens, ver) : null; var EggMoves = Legal.getEggMoves(pkm, ver); bool volt = (gen > 3 || ver == GameVersion.E) && Legal.LightBall.Contains(pkm.Species); @@ -2742,7 +2741,7 @@ private CheckResult[] parseMovesRelearn(int[] Moves, List[] validLevelMoves var issplitbreed = pkm.WasEgg && Legal.SplitBreed.Contains(pkm.Species); var EggMoves = pkm.WasEgg? Legal.getEggMoves(pkm, game): emptyegg; // Level up, TMHM or tutor moves exclusive to the incense egg species, like Azurill, incompatible with the non-incense species egg moves - var ExclusiveIncenseMoves = issplitbreed ? Legal.getExclusiveEvolutionMoves(pkm, Legal.getBaseEggSpecies(pkm, 0), EvoChainsAllGens, game) : empty; + var ExclusiveIncenseMoves = issplitbreed ? Legal.getExclusiveEvolutionMoves(pkm, Legal.getBaseEggSpecies(pkm), EvoChainsAllGens, game) : empty; int[] RelearnMoves = pkm.RelearnMoves; int[] SpecialMoves = (EncounterMatch as IMoveset)?.Moves ?? new int[0]; @@ -2767,7 +2766,7 @@ private CheckResult[] parseMoves(int[] moves, List[] learn, int[] relearn, var LvlupEggMovesSplitLearned = new List[egg.Length]; var EggMovesSplitLearned = new List[egg.Length]; var IncenseMovesLearned = new List(); - for (int i=0;i < egg.Length; i++ ) + for (int i= 0; i < egg.Length; i++) { LvlupEggMovesSplitLearned[i] = new List(); EggMovesSplitLearned[i] = new List(); @@ -2855,7 +2854,7 @@ private CheckResult[] parseMoves(int[] moves, List[] learn, int[] relearn, else res[m] = new CheckResult(Severity.Valid, V345, CheckIdentifier.Move); LvlupEggMovesLearned.Add(m); - if(issplitbreed) + if (issplitbreed) { // Only add to split breed lists learned moves that can be from one of the egg species, ignore common moves if (lvlupegg[0].Contains(moves[m]) && !lvlupegg[1].Contains(moves[m])) @@ -2936,7 +2935,7 @@ private CheckResult[] parseMoves(int[] moves, List[] learn, int[] relearn, { foreach (int m in RegularEggMovesLearned) { - if(EggMovesLearned.Contains(m)) + if (EggMovesLearned.Contains(m)) res[m] = new CheckResult(Severity.Invalid, pkm.WasGiftEgg ? V377 : V341, CheckIdentifier.Move); else if (LvlupEggMovesLearned.Contains(m)) res[m] = new CheckResult(Severity.Invalid, pkm.WasGiftEgg ? V378 : V347, CheckIdentifier.Move); @@ -2948,7 +2947,7 @@ private CheckResult[] parseMoves(int[] moves, List[] learn, int[] relearn, if ((EggMovesSplitLearned[0].Any() || IncenseMovesLearned.Any()) && EggMovesSplitLearned[1].Any()) { var species = specieslist; - var splitbreedspecies0 = species[Legal.getBaseEggSpecies(pkm, 0)]; + var splitbreedspecies0 = species[Legal.getBaseEggSpecies(pkm)]; // 0 var splitbreedspecies1 = species[Legal.getBaseEggSpecies(pkm, 1)]; foreach (int m in EggMovesSplitLearned[0]) // Example: Azurill Egg move, incompatible with Marill egg moves @@ -3340,7 +3339,7 @@ private CheckResult[] verifyRelearnEggBase(int[] RelearnMoves, int skipOption, b res[i] = new CheckResult(Severity.Invalid, V182, CheckIdentifier.RelearnMove); } - if(splitbreedinvalid) + if (splitbreedinvalid) { var species = specieslist; var splitbreedspecies0 = species[Legal.getBaseEggSpecies(pkm, skipOption)]; diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index df0b7bddd..edd89d91f 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -1063,7 +1063,7 @@ internal static IEnumerable getExclusiveEvolutionMoves(PKM pkm, int Species var preevomoves = new List(); var evomoves = new List(); var index = Array.FindIndex(evoChain, e => e.Species == Species); - for(int i =0; i < evoChain.Length; i++) + for (int i = 0; i < evoChain.Length; i++) { var evo = evoChain[i]; var moves = getMoves(pkm, evo.Species, 1, evo.Level, pkm.AltForm, moveTutor: true, Version: Version, LVL: true, specialTutors: true, Machine: true, MoveReminder: false, RemoveTransferHM: false, Generation: Generation); @@ -3414,7 +3414,7 @@ internal static IEnumerable getTutorMoves(PKM pkm, int species, int form, b case 6: info = PersonalTable.AO[species]; moves.AddRange(TypeTutor6.Where((t, i) => info.TypeTutors[i])); - if ( pkm.InhabitedGeneration(6) && specialTutors && (pkm.AO || !pkm.IsUntraded)) + if (pkm.InhabitedGeneration(6) && specialTutors && (pkm.AO || !pkm.IsUntraded)) { PersonalInfo pi = PersonalTable.AO.getFormeEntry(species, form); for (int i = 0; i < Tutors_AO.Length; i++) diff --git a/PKHeX/Legality/Structures/EvolutionTree.cs b/PKHeX/Legality/Structures/EvolutionTree.cs index ae6902f8a..600410979 100644 --- a/PKHeX/Legality/Structures/EvolutionTree.cs +++ b/PKHeX/Legality/Structures/EvolutionTree.cs @@ -168,7 +168,7 @@ private int getIndex(EvolutionMethod evo) public IEnumerable getValidPreEvolutions(PKM pkm, int lvl, int maxSpeciesOrigin =-1 ,bool skipChecks = false) { int index = getIndex(pkm); - if(maxSpeciesOrigin <= 0) + if (maxSpeciesOrigin <= 0) maxSpeciesOrigin = Legal.getMaxSpeciesOrigin(pkm); return Lineage[index].getExplicitLineage(pkm, lvl, skipChecks, MaxSpeciesTree, maxSpeciesOrigin); } @@ -314,7 +314,7 @@ public static List getArray(byte[] data) for (int j = 0; j < 5; j++) { EvolutionMethod m = getMethod(data, offset); - if(m!=null) + if (m != null) m_list.Add(m); else break; diff --git a/PKHeX/Legality/Structures/GBEncounterData.cs b/PKHeX/Legality/Structures/GBEncounterData.cs index 52e38c192..95197f1c9 100644 --- a/PKHeX/Legality/Structures/GBEncounterData.cs +++ b/PKHeX/Legality/Structures/GBEncounterData.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; namespace PKHeX.Core { @@ -35,6 +31,7 @@ public GBEncounterData(int species) Type = GBEncounterType.EggEncounter; Level = 5; WasEgg = true; + Species = species; } public GBEncounterData(PKM pkm, int gen, object enc) @@ -42,7 +39,7 @@ public GBEncounterData(PKM pkm, int gen, object enc) Generation = gen; Encounter = enc; WasEgg = false; - if (Encounter as EncounterTrade != null) + if (Encounter is EncounterTrade) { var trade = (EncounterTrade)Encounter; Species = trade.Species; @@ -50,12 +47,12 @@ public GBEncounterData(PKM pkm, int gen, object enc) Level = pkm.Met_Level; // Crystal else Level = trade.Level; - if ( Generation == 2) + if (Generation == 2) Type = GBEncounterType.TradeEncounterG2; else Type = GBEncounterType.TradeEncounterG1; } - else if (Encounter as EncounterStatic != null) + else if (Encounter is EncounterStatic) { var statc = (EncounterStatic)Encounter; Species = statc.Species; @@ -65,7 +62,7 @@ public GBEncounterData(PKM pkm, int gen, object enc) else Type = GBEncounterType.StaticEncounter; } - else if (Encounter as EncounterSlot1 != null) + else if (Encounter is EncounterSlot1) { var slot = (EncounterSlot1)Encounter; Species = slot.Species; diff --git a/PKHeX/Legality/Structures/Learnset.cs b/PKHeX/Legality/Structures/Learnset.cs index bd1b33a64..90dd489da 100644 --- a/PKHeX/Legality/Structures/Learnset.cs +++ b/PKHeX/Legality/Structures/Learnset.cs @@ -18,7 +18,7 @@ public abstract class Learnset /// Array of Move IDs public int[] getMoves(int maxLevel, int minLevel = 0) { - if (minLevel <=1 && maxLevel >= 100) + if (minLevel <= 1 && maxLevel >= 100) return Moves; int start = Array.FindIndex(Levels, z => z >= minLevel); if (start < 0) diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index 553442767..badf0db78 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -993,7 +993,7 @@ public static partial class Legal private static readonly EncounterArea SlotsD_HoneyTree = new EncounterArea { - Slots = SlotsPt_HoneyTree.Slots.Concat( new[] + Slots = SlotsPt_HoneyTree.Slots.Concat(new[] { new EncounterSlot { Species = 266, LevelMin = 5, LevelMax = 15, Type = SlotType.HoneyTree }, // Silcoon }).ToArray() diff --git a/PKHeX/PKHeX.Core.csproj b/PKHeX/PKHeX.Core.csproj index 945f69d34..cccb4872e 100644 --- a/PKHeX/PKHeX.Core.csproj +++ b/PKHeX/PKHeX.Core.csproj @@ -165,7 +165,7 @@ - + diff --git a/PKHeX/PKM/PK3.cs b/PKHeX/PKM/PK3.cs index 7381562e1..4f87fb3f3 100644 --- a/PKHeX/PKM/PK3.cs +++ b/PKHeX/PKM/PK3.cs @@ -116,7 +116,7 @@ public PK3(byte[] decryptedData = null, string ident = null) public override int IV_SPA { get { return (int)(IV32 >> 20) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } } public override int IV_SPD { get { return (int)(IV32 >> 25) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } } public override bool IsEgg { get { return ((IV32 >> 30) & 1) == 1; } set { IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } } - public bool AbilityBit { get { return (IV32 >> 31) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (uint)(value ? 1 << 31 : 0 ); } } + public bool AbilityBit { get { return (IV32 >> 31) == 1; } set { IV32 = (IV32 & 0x7FFFFFFF) | (uint)(value ? 1 << 31 : 0); } } private uint RIB0 { get { return BitConverter.ToUInt32(Data, 0x4C); } set { BitConverter.GetBytes(value).CopyTo(Data, 0x4C); } } public int RibbonCountG3Cool { get { return (int)(RIB0 >> 00) & 7; } set { RIB0 = (uint)((RIB0 & ~(7 << 00)) | (uint)(value & 7) << 00); } } diff --git a/PKHeX/Saves/SAV3GCMemoryCard.cs b/PKHeX/Saves/SAV3GCMemoryCard.cs index ce8a32610..71961a6f9 100644 --- a/PKHeX/Saves/SAV3GCMemoryCard.cs +++ b/PKHeX/Saves/SAV3GCMemoryCard.cs @@ -251,7 +251,7 @@ public GameVersion SelectedGameVersion { get { - if(EntryCOLO > -1 && EntrySelected == EntryCOLO) + if (EntryCOLO > -1 && EntrySelected == EntryCOLO) return GameVersion.COLO; if (EntryXD > -1 && EntrySelected == EntryXD) return GameVersion.XD; diff --git a/PKHeX/Saves/SAV4.cs b/PKHeX/Saves/SAV4.cs index 57f46c9c3..e25987750 100644 --- a/PKHeX/Saves/SAV4.cs +++ b/PKHeX/Saves/SAV4.cs @@ -1142,7 +1142,7 @@ public byte[] PoketchDotArtist get { byte[] ret = new byte[120]; // 2bit*24px*20px - int ofs = 0; + int ofs; switch (Version) { case GameVersion.DP: ofs = 0x1176; break; @@ -1155,14 +1155,14 @@ public byte[] PoketchDotArtist } set { - int ofs = 0; + int ofs; switch (Version) { case GameVersion.DP: ofs = 0x1176; break; default: return; } ofs += GBO; - for(int i = 0; i < 120; i++) + for (int i = 0; i < 120; i++) Data[ofs + i] = value[i]; Data[ofs - 0x2A] |= 0x04; // 0x114C "Touch!" } diff --git a/PKHeX/Saves/SaveUtil.cs b/PKHeX/Saves/SaveUtil.cs index 51381fedd..85bf6d8e1 100644 --- a/PKHeX/Saves/SaveUtil.cs +++ b/PKHeX/Saves/SaveUtil.cs @@ -276,7 +276,7 @@ public static GameVersion getIsG3XDSAV(byte[] data) // Check the intro bytes for each save slot byte[] slotintroXD = { 0x01, 0x01, 0x01, 0x00 }; int offset = data.Length - SIZE_G3XD; - // For XD savegames inside a memory card only the firs sequence is equal to slotintroXD + // For XD savegames inside a memory card only the first sequence is equal to slotintroXD bool valid = false; for (int i = 0; i < 2; i++) { @@ -284,9 +284,7 @@ public static GameVersion getIsG3XDSAV(byte[] data) if (ident.SequenceEqual(slotintroXD)) valid = true; } - if(!valid) - return GameVersion.Invalid; - return GameVersion.XD; + return valid ? GameVersion.XD : GameVersion.Invalid; } /// Determines the type of 4th gen save /// Save data of which to determine the type