From d47bb1d2974438e8ad8b73a3cbc6f2872bf19e53 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 3 Dec 2023 20:13:20 -0800 Subject: [PATCH] Update .NET Runtime to .NET 8.0 (#4082) With the new version of Visual Studio bringing C# 12, we can revise our logic for better readability as well as use new methods/APIs introduced in the .NET 8.0 BCL. --- Directory.Build.props | 2 +- .../Editing/Applicators/BallApplicator.cs | 35 +- .../Applicators/CatchRateApplicator.cs | 15 +- .../Editing/Applicators/MemoryApplicator.cs | 9 +- .../Editing/Applicators/MoveApplicator.cs | 4 +- .../Applicators/MoveShopRecordApplicator.cs | 2 +- PKHeX.Core/Editing/Bulk/BatchEditing.cs | 20 +- PKHeX.Core/Editing/Bulk/BatchEditor.cs | 2 +- PKHeX.Core/Editing/Bulk/BatchFilters.cs | 12 +- PKHeX.Core/Editing/Bulk/BatchMods.cs | 13 +- .../Editing/Bulk/ComplexSet/ComplexFilter.cs | 22 +- .../Editing/Bulk/ComplexSet/ComplexSet.cs | 15 +- .../Editing/Bulk/ComplexSet/MetaFilter.cs | 18 +- PKHeX.Core/Editing/Bulk/StringInstruction.cs | 23 +- .../Bulk/Suggestion/ComplexSuggestion.cs | 23 +- .../Editing/Bulk/Suggestion/TypeSuggestion.cs | 16 +- PKHeX.Core/Editing/CommonEdits.cs | 12 +- .../Editing/Database/TrainerDatabase.cs | 6 +- PKHeX.Core/Editing/HiddenPower.cs | 23 +- PKHeX.Core/Editing/NatureAmp.cs | 60 +- .../Editing/PKM/LegalMoveComboSource.cs | 9 +- PKHeX.Core/Editing/PKM/LegalMoveInfo.cs | 4 +- PKHeX.Core/Editing/PKM/LegalMoveSource.cs | 6 +- PKHeX.Core/Editing/PKM/QR/QRPK7.cs | 6 +- PKHeX.Core/Editing/PKM/QR/QRPKM.cs | 6 +- PKHeX.Core/Editing/Pokerus.cs | 6 +- PKHeX.Core/Editing/Program/AutoLoadSetting.cs | 4 +- .../Editing/Program/StartupArguments.cs | 2 +- .../Editing/Saves/BoxManip/BoxManipClear.cs | 13 +- .../Saves/BoxManip/BoxManipClearComplex.cs | 13 +- .../Saves/BoxManip/BoxManipClearDuplicate.cs | 12 +- .../Editing/Saves/BoxManip/BoxManipModify.cs | 9 +- .../Saves/BoxManip/BoxManipModifyComplex.cs | 9 +- .../Editing/Saves/BoxManip/BoxManipSort.cs | 13 +- .../Editing/Saves/BoxManip/BoxManipUtil.cs | 8 +- .../Editors/EventOld/EventLabelParsing.cs | 17 +- .../Editors/EventUnlock/EventUnlocker8b.cs | 4 +- .../Editors/EventWork/Diff/EventWorkDiff.cs | 8 +- .../Editors/EventWork/Diff/EventWorkDiff7b.cs | 11 +- .../Editors/EventWork/Diff/EventWorkDiff8b.cs | 15 +- .../Saves/Editors/EventWork/EventFlag.cs | 8 +- .../Saves/Editors/EventWork/EventVarGroup.cs | 10 +- .../Editors/EventWork/SplitEventEditor.cs | 4 +- .../Editing/Saves/Editors/FakePKMEditor.cs | 8 +- PKHeX.Core/Editing/Saves/Slots/BoxEdit.cs | 13 +- PKHeX.Core/Editing/Saves/Slots/Extensions.cs | 40 +- .../Editing/Saves/Slots/Info/ISlotInfo.cs | 4 +- .../Editing/Saves/Slots/Info/SlotInfoFile.cs | 2 +- .../Editing/Saves/Slots/Info/SlotOrigin.cs | 2 +- .../Editing/Saves/Slots/SlotChangelog.cs | 23 +- PKHeX.Core/Editing/Saves/Slots/SlotEditor.cs | 14 +- .../Editing/Saves/Slots/SlotPublisher.cs | 4 +- .../Editing/Saves/Slots/SlotViewInfo.cs | 13 +- .../Editing/Showdown/ShowdownParsing.cs | 4 +- PKHeX.Core/Editing/Showdown/ShowdownSet.cs | 18 +- .../GameStrings/FilteredGameDataSource.cs | 5 +- PKHeX.Core/Game/GameStrings/GameDataSource.cs | 54 +- PKHeX.Core/Game/GameStrings/GameLanguage.cs | 4 +- PKHeX.Core/Game/GameStrings/GameStrings.cs | 28 +- PKHeX.Core/Game/GameStrings/GeoLocation.cs | 2 +- .../GameStrings/LocationSet/LocationSet0.cs | 2 +- .../GameStrings/LocationSet/LocationSet4.cs | 2 +- .../GameStrings/LocationSet/LocationSet6.cs | 2 +- PKHeX.Core/Game/GameStrings/MetDataSource.cs | 50 +- PKHeX.Core/Game/GameUtil.cs | 4 +- PKHeX.Core/Game/Locations/Locations4.cs | 18 +- PKHeX.Core/Game/Locations/Locations5.cs | 22 +- PKHeX.Core/Game/Locations/Locations6.cs | 24 +- PKHeX.Core/Game/Locations/Locations7.cs | 20 +- PKHeX.Core/Game/Locations/Locations7b.cs | 20 +- PKHeX.Core/Game/Locations/Locations8.cs | 34 +- PKHeX.Core/Game/Locations/Locations8a.cs | 36 +- PKHeX.Core/Game/Locations/Locations8b.cs | 20 +- PKHeX.Core/Game/Locations/Locations9.cs | 20 +- PKHeX.Core/Game/Locations/LocationsHOME.cs | 6 +- PKHeX.Core/Items/HeldItemLumpImage.cs | 6 +- PKHeX.Core/Items/ItemStorage1.cs | 6 +- PKHeX.Core/Items/ItemStorage2.cs | 34 +- PKHeX.Core/Items/ItemStorage3Colo.cs | 14 +- PKHeX.Core/Items/ItemStorage3E.cs | 18 +- PKHeX.Core/Items/ItemStorage3FRLG.cs | 18 +- PKHeX.Core/Items/ItemStorage3RS.cs | 45 +- PKHeX.Core/Items/ItemStorage3XD.cs | 45 +- PKHeX.Core/Items/ItemStorage4.cs | 124 ++-- PKHeX.Core/Items/ItemStorage4DP.cs | 5 +- PKHeX.Core/Items/ItemStorage4HGSS.cs | 24 +- PKHeX.Core/Items/ItemStorage4Pt.cs | 17 +- PKHeX.Core/Items/ItemStorage5.cs | 82 ++- PKHeX.Core/Items/ItemStorage5B2W2.cs | 6 +- PKHeX.Core/Items/ItemStorage5BW.cs | 6 +- PKHeX.Core/Items/ItemStorage6AO.cs | 36 +- PKHeX.Core/Items/ItemStorage6XY.cs | 41 +- PKHeX.Core/Items/ItemStorage7GG.cs | 48 +- PKHeX.Core/Items/ItemStorage7SM.cs | 53 +- PKHeX.Core/Items/ItemStorage7USUM.cs | 37 +- PKHeX.Core/Items/ItemStorage8BDSP.cs | 77 ++- PKHeX.Core/Items/ItemStorage8LA.cs | 18 +- PKHeX.Core/Items/ItemStorage8SWSH.cs | 78 +-- PKHeX.Core/Items/ItemStorage9SV.cs | 78 +-- PKHeX.Core/Legality/BinLinkerAccessor.cs | 6 +- PKHeX.Core/Legality/Breeding.cs | 4 +- PKHeX.Core/Legality/Bulk/BulkAnalysis.cs | 12 +- .../Bulk/DuplicateEncryptionChecker.cs | 2 +- .../Legality/Bulk/DuplicatePIDChecker.cs | 2 +- .../Legality/Bulk/DuplicateTrainerChecker.cs | 2 +- PKHeX.Core/Legality/Core.cs | 6 +- .../Encounters/Data/EncounterEvent.cs | 24 +- .../Legality/Encounters/Data/EncounterUtil.cs | 6 +- .../Encounters/Data/Gen1/Encounters1.cs | 30 +- .../Encounters/Data/Gen1/Encounters1GBEra.cs | 10 +- .../Encounters/Data/Gen1/Encounters1VC.cs | 4 +- .../Encounters/Data/Gen2/Encounters2.cs | 28 +- .../Encounters/Data/Gen2/Encounters2GBEra.cs | 14 +- .../Encounters/Data/Gen3/Encounters3Colo.cs | 18 +- .../Data/Gen3/Encounters3ColoShadow.cs | 34 +- .../Data/Gen3/Encounters3ColoTeams.cs | 19 +- .../Encounters/Data/Gen3/Encounters3FRLG.cs | 37 +- .../Encounters/Data/Gen3/Encounters3RSE.cs | 61 +- .../Encounters/Data/Gen3/Encounters3XD.cs | 20 +- .../Data/Gen3/Encounters3XDShadow.cs | 455 +++++++------ .../Data/Gen3/Encounters3XDTeams.cs | 145 +++-- .../Encounters/Data/Gen3/EncountersWC3.cs | 22 +- .../Encounters/Data/Gen4/Encounters4DPPt.cs | 32 +- .../Encounters/Data/Gen4/Encounters4HGSS.cs | 20 +- .../Encounters/Data/Gen5/Encounters5B2W2.cs | 40 +- .../Encounters/Data/Gen5/Encounters5BW.cs | 30 +- .../Encounters/Data/Gen5/Encounters5DR.cs | 10 +- .../Encounters/Data/Gen6/Encounters6AO.cs | 16 +- .../Encounters/Data/Gen6/Encounters6XY.cs | 18 +- .../Encounters/Data/Gen7/Encounters7GG.cs | 40 +- .../Encounters/Data/Gen7/Encounters7SM.cs | 18 +- .../Encounters/Data/Gen7/Encounters7USUM.cs | 18 +- .../Encounters/Data/Gen8/Encounters8.cs | 26 +- .../Encounters/Data/Gen8/Encounters8Nest.cs | 476 +++++++------- .../Encounters/Data/Gen8/Encounters8a.cs | 4 +- .../Encounters/Data/Gen8/Encounters8b.cs | 20 +- .../Encounters/Data/Gen9/Encounters9.cs | 16 +- .../Encounters/Data/Live/EncountersGO.cs | 3 +- .../ByGeneration/EncounterGenerator1.cs | 2 +- .../ByGeneration/EncounterGenerator2.cs | 2 +- .../ByGeneration/EncounterGenerator4.cs | 2 +- .../ByGeneration/EncounterGenerator5.cs | 2 +- .../ByGeneration/EncounterGenerator9.cs | 3 +- .../Lump/EncounterGeneratorDummy.cs | 18 +- .../ByGeneration/Lump/EncounterGeneratorGO.cs | 3 +- .../Encounters/Generator/EncounterCriteria.cs | 4 +- .../Encounters/Generator/EncounterFinder.cs | 4 +- .../Moveset/EncounterMovesetGenerator.cs | 6 +- .../Generator/Possible/EncounterPossible3.cs | 12 +- .../Generator/Search/EncounterEnumerator3.cs | 12 +- .../Encounters/Information/EncounterDate.cs | 2 +- .../Encounters/Information/EncounterLearn.cs | 8 +- .../Information/EncounterSuggestion.cs | 2 +- .../Information/EncounterSummary.cs | 2 +- .../Templates/Enums/AbilityPermission.cs | 2 +- .../Templates/GO/EncounterSlot7GO.cs | 4 +- .../Templates/Gen1/EncounterGift1.cs | 3 +- .../Templates/Gen2/EncounterArea2.cs | 6 +- .../Templates/Gen2/EncounterGift2.cs | 3 +- .../Templates/Gen2/EncounterSlot2.cs | 12 +- .../Templates/Gen3/XD/EncounterArea3XD.cs | 6 +- .../Templates/Gen3/XD/EncounterTrade3XD.cs | 2 +- .../Templates/Gen4/EncounterArea4.cs | 6 +- .../Templates/Gen4/EncounterSlot4.cs | 3 +- .../Templates/Gen4/EncounterTrade4PID.cs | 10 +- .../Gen4/EncounterTrade4RanchGift.cs | 2 +- .../Templates/Gen4/GroundTileAllowed.cs | 2 +- .../Templates/Gen5/EncounterStatic5.cs | 2 +- .../Templates/Gen5/EncounterStatic5Entree.cs | 2 +- .../Templates/Gen5/EncounterTrade5B2W2.cs | 2 +- .../Templates/Gen6/EncounterArea6XY.cs | 6 +- .../Templates/Gen6/EncounterSlot6XY.cs | 2 +- .../Encounters/Templates/Gen8/AreaWeather8.cs | 2 +- .../Templates/Gen8/EncounterArea8.cs | 236 +++---- .../Templates/Gen8/EncounterStatic8N.cs | 14 +- .../Templates/Gen8/EncounterTrade8.cs | 2 +- .../Templates/Gen8a/EncounterStatic8a.cs | 2 +- .../Templates/Gen8b/EncounterArea8b.cs | 6 +- .../Templates/Gen8b/EncounterSlot8b.cs | 2 +- .../Templates/Gen8b/EncounterStatic8b.cs | 6 +- .../Templates/Gen9/EncounterOutbreak9.cs | 4 - .../Templates/Gen9/EncounterSlot9.cs | 116 ++-- .../Encounters/Templates/Gen9/IGemType.cs | 3 +- .../Templates/Interfaces/IEncounterInfo.cs | 6 +- .../Properties/IEncounterFormRandom.cs | 2 +- .../Encounters/Templates/Shared/Moveset.cs | 2 +- .../Encounters/Verifiers/EggHatchLocation3.cs | 8 +- .../Encounters/Verifiers/EggHatchLocation4.cs | 6 +- .../Encounters/Verifiers/EggHatchLocation5.cs | 8 +- .../Encounters/Verifiers/EggHatchLocation7.cs | 6 +- .../Encounters/Verifiers/EggHatchLocation8.cs | 6 +- .../Verifiers/EggHatchLocation8b.cs | 6 +- .../Encounters/Verifiers/EggHatchLocation9.cs | 6 +- .../Encounters/Verifiers/EncounterVerifier.cs | 4 +- .../Encounters/Verifiers/EvolutionVerifier.cs | 2 +- .../Legality/Evolutions/EvolutionChain.cs | 2 +- .../EvolutionGroup/EvolutionGroupUtil.cs | 2 +- .../EvolutionGroup/EvolutionUtil.cs | 2 +- .../Legality/Evolutions/EvolutionHistory.cs | 2 +- .../Legality/Evolutions/EvolutionSet.cs | 2 +- .../Legality/Evolutions/EvolutionTree.cs | 3 +- .../Forward/EvolutionForwardPersonal.cs | 11 +- .../Forward/EvolutionForwardSpecies.cs | 13 +- .../Evolutions/Methods/EvolutionMethod.cs | 2 +- .../Reversal/EvolutionReverseLookup.cs | 17 +- .../Reversal/EvolutionReversePersonal.cs | 5 +- .../Reversal/EvolutionReverseSpecies.cs | 5 +- .../Formatting/BaseLegalityFormatter.cs | 4 +- .../Legality/Formatting/LegalityFormatting.cs | 2 +- .../Legality/LearnSource/Group/LearnGroup5.cs | 2 +- .../Legality/LearnSource/Group/LearnGroup8.cs | 4 +- .../Legality/LearnSource/Group/LearnGroup9.cs | 4 +- .../LearnSource/Group/LearnGroupHOME.cs | 8 +- .../Legality/LearnSource/LearnEnvironment.cs | 2 +- .../LearnSource/Sources/LearnSource2C.cs | 2 +- .../LearnSource/Sources/LearnSource2GS.cs | 2 +- .../LearnSource/Sources/LearnSource3E.cs | 8 +- .../LearnSource/Sources/LearnSource3FR.cs | 2 +- .../LearnSource/Sources/LearnSource3LG.cs | 2 +- .../LearnSource/Sources/LearnSource3RS.cs | 26 +- .../LearnSource/Sources/LearnSource4DP.cs | 2 +- .../LearnSource/Sources/LearnSource4HGSS.cs | 2 +- .../LearnSource/Sources/LearnSource4Pt.cs | 2 +- .../LearnSource/Sources/LearnSource5B2W2.cs | 2 +- .../LearnSource/Sources/LearnSource5BW.cs | 2 +- .../LearnSource/Sources/LearnSource6AO.cs | 8 +- .../LearnSource/Sources/LearnSource6XY.cs | 8 +- .../LearnSource/Sources/LearnSource7GG.cs | 18 +- .../LearnSource/Sources/LearnSource7SM.cs | 2 +- .../LearnSource/Sources/LearnSource7USUM.cs | 2 +- .../LearnSource/Sources/LearnSource8BDSP.cs | 14 +- .../LearnSource/Sources/LearnSource8SWSH.cs | 2 +- .../LearnSource/Sources/LearnSource9SV.cs | 4 +- .../Sources/Shared/ILearnSource.cs | 4 +- .../Sources/Shared/LearnSource1.cs | 6 +- .../Sources/Shared/LearnSource2.cs | 8 +- .../Sources/Shared/LearnSource3.cs | 8 +- .../Sources/Shared/LearnSource4.cs | 34 +- .../Sources/Shared/LearnSource5.cs | 12 +- .../Sources/Shared/LearnSource7.cs | 6 +- .../LearnSource/Verify/LearnPossible.cs | 2 +- .../Verify/LearnVerifierRelearn.cs | 4 +- PKHeX.Core/Legality/Learnset/EggMoves.cs | 23 +- PKHeX.Core/Legality/Learnset/Learnset.cs | 14 +- .../Legality/Learnset/LearnsetReader.cs | 2 +- PKHeX.Core/Legality/MoveListSuggest.cs | 4 +- .../Legality/Moves/Breeding/BreedInfo.cs | 22 +- .../Legality/Moves/Breeding/EggSource.cs | 6 +- .../Legality/Moves/Breeding/MoveBreed.cs | 2 +- .../Algorithms/Xoroshiro128PlusReversal.cs | 4 +- PKHeX.Core/Legality/RNG/CXD/TeamLock.cs | 17 +- PKHeX.Core/Legality/RNG/CXD/TeamLockResult.cs | 14 +- PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs | 4 +- PKHeX.Core/Legality/RNG/Frame/SlotNumber.cs | 61 +- PKHeX.Core/Legality/RNG/MethodFinder.cs | 14 +- .../RNG/Methods/Gen4/PokewalkerRNG.cs | 6 +- .../RNG/Methods/Gen8/Overworld8RNG.cs | 4 +- .../RNG/Methods/Gen8a/Overworld8aRNG.cs | 4 +- .../RNG/Methods/Gen8b/Roaming8bRNG.cs | 6 +- .../Legality/RNG/Methods/Gen8b/Wild8bRNG.cs | 2 +- .../RNG/Methods/Gen9/Encounter9RNG.cs | 4 +- .../Legality/RNG/Methods/Gen9/Tera9RNG.cs | 16 +- PKHeX.Core/Legality/RNG/PIDGenerator.cs | 2 +- PKHeX.Core/Legality/RNG/PIDType.cs | 2 +- .../Legality/RNG/Util/ToxtricityUtil.cs | 4 +- .../Restrictions/EvolutionRestrictions.cs | 10 +- .../Legality/Restrictions/GBRestrictions.cs | 14 +- .../Legality/Restrictions/ItemRestrictions.cs | 4 +- .../Restrictions/Memories/Memories.cs | 6 +- .../Restrictions/Memories/MemoryContext6.cs | 8 +- .../Memories/MemoryContext6Data.cs | 96 +-- .../Restrictions/Memories/MemoryContext8.cs | 8 +- .../Memories/MemoryContext8Data.cs | 99 ++- .../Memories/MemoryPermissions.cs | 239 +++---- .../Memories/MemoryVariableSet.cs | 8 +- .../Legality/Restrictions/Vivillon3DS.cs | 28 +- PKHeX.Core/Legality/Structures/LegalInfo.cs | 4 +- PKHeX.Core/Legality/Structures/Severity.cs | 2 +- PKHeX.Core/Legality/Tables/FormChangeUtil.cs | 41 +- PKHeX.Core/Legality/Tables/FormInfo.cs | 64 +- PKHeX.Core/Legality/Tables/FormItem.cs | 4 +- PKHeX.Core/Legality/Tables/MystryMew.cs | 6 +- PKHeX.Core/Legality/Tables/SpeciesCategory.cs | 76 +-- .../Verifiers/Ability/AbilityBreedLegality.cs | 6 +- .../Verifiers/Ability/AbilityVerifier.cs | 4 +- .../Legality/Verifiers/Ball/BallContext6.cs | 6 +- .../Legality/Verifiers/Ball/BallContext7.cs | 6 +- .../Verifiers/Ball/BallContextHOME.cs | 6 +- .../Verifiers/Ball/BallUseLegality.cs | 5 +- .../Legality/Verifiers/Ball/BallVerifier.cs | 9 +- .../Legality/Verifiers/EffortValueVerifier.cs | 10 +- .../Verifiers/FormArgumentVerifier.cs | 4 +- PKHeX.Core/Legality/Verifiers/FormVerifier.cs | 6 +- .../Legality/Verifiers/GenderVerifier.cs | 2 +- .../Legality/Verifiers/HistoryVerifier.cs | 6 +- .../Legality/Verifiers/LevelVerifier.cs | 4 +- PKHeX.Core/Legality/Verifiers/MarkVerifier.cs | 2 +- .../Legality/Verifiers/MemoryVerifier.cs | 2 +- .../Verifiers/Misc/ContestStatInfo.cs | 63 +- PKHeX.Core/Legality/Verifiers/MiscVerifier.cs | 23 +- .../Legality/Verifiers/NicknameVerifier.cs | 2 +- .../Legality/Verifiers/ParseSettings.cs | 8 +- .../Legality/Verifiers/Ribbons/MarkRules.cs | 7 +- .../Verifiers/Ribbons/RibbonResult.cs | 2 +- .../Verifiers/Ribbons/RibbonResultList.cs | 7 +- .../Legality/Verifiers/Ribbons/RibbonRules.cs | 14 +- .../Verifiers/Ribbons/RibbonStrings.cs | 2 +- .../Ribbons/RibbonVerifierCommon4.cs | 6 +- .../Legality/Verifiers/TrainerNameVerifier.cs | 4 +- PKHeX.Core/Moves/MoveInfo.cs | 4 +- PKHeX.Core/Moves/MoveInfo1.cs | 12 +- PKHeX.Core/Moves/MoveInfo2.cs | 6 +- PKHeX.Core/Moves/MoveInfo3.cs | 6 +- PKHeX.Core/Moves/MoveInfo4.cs | 6 +- PKHeX.Core/Moves/MoveInfo5.cs | 12 +- PKHeX.Core/Moves/MoveInfo6.cs | 6 +- PKHeX.Core/Moves/MoveInfo7.cs | 6 +- PKHeX.Core/Moves/MoveInfo7b.cs | 12 +- PKHeX.Core/Moves/MoveInfo8.cs | 12 +- PKHeX.Core/Moves/MoveInfo8a.cs | 12 +- PKHeX.Core/Moves/MoveInfo8b.cs | 6 +- PKHeX.Core/Moves/MoveInfo9.cs | 18 +- PKHeX.Core/MysteryGifts/DataMysteryGift.cs | 10 +- PKHeX.Core/MysteryGifts/MysteryGift.cs | 21 +- PKHeX.Core/MysteryGifts/MysteryUtil.cs | 4 +- PKHeX.Core/MysteryGifts/PCD.cs | 10 +- PKHeX.Core/MysteryGifts/PGF.cs | 15 +- PKHeX.Core/MysteryGifts/PGT.cs | 11 +- PKHeX.Core/MysteryGifts/PL6.cs | 20 +- PKHeX.Core/MysteryGifts/WA8.cs | 15 +- PKHeX.Core/MysteryGifts/WB7.cs | 11 +- PKHeX.Core/MysteryGifts/WB8.cs | 19 +- PKHeX.Core/MysteryGifts/WC3.cs | 7 +- PKHeX.Core/MysteryGifts/WC6.cs | 21 +- PKHeX.Core/MysteryGifts/WC7.cs | 20 +- PKHeX.Core/MysteryGifts/WC8.cs | 17 +- PKHeX.Core/MysteryGifts/WC9.cs | 21 +- PKHeX.Core/MysteryGifts/WR7.cs | 9 +- PKHeX.Core/PKHeX.Core.csproj | 2 +- PKHeX.Core/PKM/BK4.cs | 6 +- PKHeX.Core/PKM/CK3.cs | 12 +- PKHeX.Core/PKM/Enums/GroundTileType.cs | 8 +- PKHeX.Core/PKM/HOME/GameDataPA8.cs | 4 +- PKHeX.Core/PKM/HOME/GameDataPB8.cs | 2 +- PKHeX.Core/PKM/HOME/GameDataPK8.cs | 6 +- PKHeX.Core/PKM/HOME/GameDataPK9.cs | 4 +- PKHeX.Core/PKM/HOME/HomeCrypto.cs | 2 +- PKHeX.Core/PKM/HOME/HomeOptional1.cs | 2 +- PKHeX.Core/PKM/HOME/PKH.cs | 2 +- PKHeX.Core/PKM/Interfaces/IFormArgument.cs | 10 +- PKHeX.Core/PKM/Interfaces/IGanbaru.cs | 2 +- PKHeX.Core/PKM/Interfaces/IGeoTrack.cs | 2 - PKHeX.Core/PKM/Interfaces/ITrainerMemories.cs | 4 +- .../PKM/Interfaces/Metadata/ISpeciesForm.cs | 2 +- .../Templates/IContestStatsReadOnly.cs | 2 +- PKHeX.Core/PKM/PA8.cs | 61 +- PKHeX.Core/PKM/PB7.cs | 53 +- PKHeX.Core/PKM/PB8.cs | 10 +- PKHeX.Core/PKM/PK3.cs | 5 +- PKHeX.Core/PKM/PK4.cs | 14 +- PKHeX.Core/PKM/PK5.cs | 6 +- PKHeX.Core/PKM/PK6.cs | 22 +- PKHeX.Core/PKM/PK7.cs | 16 +- PKHeX.Core/PKM/PK8.cs | 8 +- PKHeX.Core/PKM/PK9.cs | 12 +- PKHeX.Core/PKM/PKM.cs | 14 +- PKHeX.Core/PKM/RK4.cs | 12 +- PKHeX.Core/PKM/SK2.cs | 4 +- PKHeX.Core/PKM/Searching/SearchSettings.cs | 14 +- PKHeX.Core/PKM/Searching/SearchUtil.cs | 6 +- PKHeX.Core/PKM/Shared/G4PKM.cs | 4 +- PKHeX.Core/PKM/Shared/G6PKM.cs | 2 +- PKHeX.Core/PKM/Shared/G8PKM.cs | 4 +- PKHeX.Core/PKM/Shared/GBPKM.cs | 15 +- PKHeX.Core/PKM/Shared/GBPKML.cs | 3 +- PKHeX.Core/PKM/Shared/PokeListGB.cs | 4 +- PKHeX.Core/PKM/Strings/StringConverter12.cs | 12 +- .../Strings/StringConverter12Transporter.cs | 17 +- PKHeX.Core/PKM/Strings/StringConverter2KOR.cs | 74 +-- PKHeX.Core/PKM/Strings/StringConverter3.cs | 12 +- PKHeX.Core/PKM/Strings/StringConverter345.cs | 122 ++-- PKHeX.Core/PKM/Strings/StringConverter4.cs | 3 - PKHeX.Core/PKM/Strings/StringConverter4GC.cs | 2 - .../PKM/Strings/StringConverter4Util.cs | 602 +++++++----------- PKHeX.Core/PKM/Strings/StringConverter7.cs | 5 +- PKHeX.Core/PKM/Strings/StringConverter7ZH.cs | 227 +++++-- .../PKM/Util/Conversion/EntityConverter.cs | 4 +- .../PKM/Util/Conversion/FormConverter.cs | 427 +++++++------ .../PKM/Util/Conversion/IEntityRejuvenator.cs | 2 +- .../PKM/Util/Conversion/ItemConverter.cs | 15 +- .../PKM/Util/Conversion/SpeciesConverter.cs | 28 +- PKHeX.Core/PKM/Util/EntityDetection.cs | 33 +- PKHeX.Core/PKM/Util/EntityFileExtension.cs | 4 +- PKHeX.Core/PKM/Util/EntityFormat.cs | 14 +- PKHeX.Core/PKM/Util/EntitySorting.cs | 4 +- PKHeX.Core/PKM/Util/Experience.cs | 36 +- PKHeX.Core/PKM/Util/GameConsole.cs | 2 +- PKHeX.Core/PKM/Util/Language.cs | 6 +- PKHeX.Core/PKM/Util/PokeCrypto.cs | 14 +- PKHeX.Core/PKM/Util/RecentTrainerCache.cs | 4 +- PKHeX.Core/PKM/Util/SpeciesName.cs | 10 +- PKHeX.Core/PKM/XK3.cs | 6 +- PKHeX.Core/PersonalInfo/Info/PersonalInfo1.cs | 10 +- PKHeX.Core/PersonalInfo/Info/PersonalInfo2.cs | 4 +- PKHeX.Core/PersonalInfo/Info/PersonalInfo3.cs | 9 +- PKHeX.Core/PersonalInfo/Info/PersonalInfo4.cs | 6 +- .../PersonalInfo/Info/PersonalInfo5B2W2.cs | 12 +- .../PersonalInfo/Info/PersonalInfo5BW.cs | 4 +- .../PersonalInfo/Info/PersonalInfo6AO.cs | 12 +- .../PersonalInfo/Info/PersonalInfo6XY.cs | 4 +- PKHeX.Core/PersonalInfo/Info/PersonalInfo7.cs | 11 +- .../PersonalInfo/Info/PersonalInfo7GG.cs | 4 +- .../PersonalInfo/Info/PersonalInfo8BDSP.cs | 6 +- .../PersonalInfo/Info/PersonalInfo8LA.cs | 10 +- .../PersonalInfo/Info/PersonalInfo8SWSH.cs | 29 +- .../PersonalInfo/Info/PersonalInfo9SV.cs | 10 +- .../text/memories/text_Intensity_de.txt | 3 +- .../text/memories/text_Intensity_en.txt | 3 +- .../text/memories/text_Intensity_es.txt | 3 +- .../text/memories/text_Intensity_fr.txt | 3 +- .../text/memories/text_Intensity_it.txt | 3 +- .../text/memories/text_Intensity_ja.txt | 3 +- .../text/memories/text_Intensity_ko.txt | 3 +- .../text/memories/text_Intensity_zh.txt | 3 +- .../text/memories/text_Intensity_zh2.txt | 3 +- PKHeX.Core/Ribbons/IRibbonSetMark8.cs | 2 +- PKHeX.Core/Saves/Access/ISaveBlock7SM.cs | 6 +- PKHeX.Core/Saves/Access/ISaveBlock8SWSH.cs | 6 +- .../Saves/Access/SaveBlockAccessor5B2W2.cs | 60 +- .../Saves/Access/SaveBlockAccessor5BW.cs | 50 +- .../Saves/Access/SaveBlockAccessor6AO.cs | 4 +- .../Saves/Access/SaveBlockAccessor6AODemo.cs | 34 +- .../Saves/Access/SaveBlockAccessor6XY.cs | 74 +-- .../Saves/Access/SaveBlockAccessor7SM.cs | 4 +- .../Saves/Access/SaveBlockAccessor7USUM.cs | 4 +- .../Saves/Access/SaveBlockAccessor7b.cs | 4 +- .../Saves/Access/SaveBlockAccessor8SWSH.cs | 6 +- .../Saves/Access/SaveBlockAccessor9SV.cs | 2 +- PKHeX.Core/Saves/Blocks/BlockInfo.cs | 2 +- PKHeX.Core/Saves/Blocks/BlockInfo3DS.cs | 9 +- .../Saves/Encryption/MemeCrypto/MemeCrypto.cs | 10 +- .../Saves/Encryption/MemeCrypto/MemeKey.cs | 32 +- .../Saves/Encryption/SwishCrypto/SCBlock.cs | 4 +- .../Encryption/SwishCrypto/SCBlockCompare.cs | 8 +- .../Encryption/SwishCrypto/SCBlockMetadata.cs | 17 +- .../Encryption/SwishCrypto/SCXorShift32.cs | 6 +- .../Encryption/SwishCrypto/SwishCrypto.cs | 20 +- PKHeX.Core/Saves/SAV1.cs | 6 +- PKHeX.Core/Saves/SAV1Stadium.cs | 5 +- PKHeX.Core/Saves/SAV1StadiumJ.cs | 4 +- PKHeX.Core/Saves/SAV2.cs | 12 +- PKHeX.Core/Saves/SAV3.cs | 12 +- PKHeX.Core/Saves/SAV3Colosseum.cs | 6 +- PKHeX.Core/Saves/SAV3E.cs | 38 +- PKHeX.Core/Saves/SAV3FRLG.cs | 33 +- PKHeX.Core/Saves/SAV3GCMemoryCard.cs | 10 +- PKHeX.Core/Saves/SAV3RS.cs | 30 +- PKHeX.Core/Saves/SAV3RSBox.cs | 10 +- PKHeX.Core/Saves/SAV3XD.cs | 6 +- PKHeX.Core/Saves/SAV4.cs | 20 +- PKHeX.Core/Saves/SAV4DP.cs | 16 +- PKHeX.Core/Saves/SAV4HGSS.cs | 18 +- PKHeX.Core/Saves/SAV4Pt.cs | 16 +- PKHeX.Core/Saves/SAV4Sinnoh.cs | 10 +- PKHeX.Core/Saves/SAV5.cs | 4 +- PKHeX.Core/Saves/SAV6.cs | 2 +- PKHeX.Core/Saves/SAV6AO.cs | 2 +- PKHeX.Core/Saves/SAV6XY.cs | 2 +- PKHeX.Core/Saves/SAV7.cs | 4 +- PKHeX.Core/Saves/SAV7b.cs | 2 +- PKHeX.Core/Saves/SAV8LA.cs | 8 +- PKHeX.Core/Saves/SAV8SWSH.cs | 11 +- PKHeX.Core/Saves/SAV9SV.cs | 8 +- PKHeX.Core/Saves/SaveFile.cs | 18 +- PKHeX.Core/Saves/SaveFileMetadata.cs | 8 +- PKHeX.Core/Saves/Storage/SAV4Ranch.cs | 12 +- .../Saves/Substructures/Battle Videos/BV3.cs | 20 +- .../Saves/Substructures/Battle Videos/BV6.cs | 9 +- .../Saves/Substructures/Battle Videos/BV7.cs | 15 +- .../Substructures/Gen12/G1OverworldSpawner.cs | 16 +- .../Gen3/DecorationInventory3.cs | 3 +- .../Gen3/EReaderBerrySettings.cs | 58 +- .../Substructures/Gen3/Gen3MysteryData.cs | 6 +- .../Saves/Substructures/Gen3/HallFame3.cs | 28 +- .../Saves/Substructures/Gen3/PokeBlock3.cs | 6 +- PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs | 8 +- .../Saves/Substructures/Gen3/Record3.cs | 6 +- .../Saves/Substructures/Gen3/Roamer3.cs | 2 +- .../Saves/Substructures/Gen3/SecretBase3.cs | 21 +- .../Saves/Substructures/Gen3/StrategyMemo.cs | 13 +- PKHeX.Core/Saves/Substructures/Gen3/Swarm3.cs | 14 +- .../Saves/Substructures/Gen4/Dendou4.cs | 2 + .../Saves/Substructures/Gen4/Geonet4.cs | 6 +- .../Saves/Substructures/Gen4/HoneyTreeUtil.cs | 2 +- .../Substructures/Gen4/HoneyTreeValue.cs | 6 +- .../Saves/Substructures/Gen4/Poffin4.cs | 6 +- .../Substructures/Gen4/Ranch/RanchLevel.cs | 2 +- .../Substructures/Gen4/Ranch/RanchMii.cs | 6 +- .../Gen4/Ranch/RanchOwnershipType.cs | 2 +- .../Substructures/Gen4/Ranch/RanchToy.cs | 6 +- .../Substructures/Gen4/Ranch/RanchToyType.cs | 2 +- .../Gen4/Ranch/RanchTrainerMii.cs | 6 +- .../Saves/Substructures/Gen4/Roamer4.cs | 7 +- .../Substructures/Gen5/CGearBackground.cs | 28 +- .../Saves/Substructures/Gen5/Color15Bit.cs | 6 +- .../Saves/Substructures/Gen5/Daycare5.cs | 4 +- .../Saves/Substructures/Gen5/Encount5.cs | 8 +- .../Saves/Substructures/Gen5/Entralink5.cs | 8 +- .../Substructures/Gen5/Entree/EntreeForest.cs | 6 +- .../Substructures/Gen5/Entree/EntreeSlot.cs | 6 +- .../Saves/Substructures/Gen5/FestaBlock5.cs | 82 +-- PKHeX.Core/Saves/Substructures/Gen5/Medal5.cs | 4 +- PKHeX.Core/Saves/Substructures/Gen5/Misc5.cs | 14 +- .../Saves/Substructures/Gen5/MyItem5B2W2.cs | 6 +- .../Saves/Substructures/Gen5/MyItem5BW.cs | 6 +- .../Saves/Substructures/Gen5/PassPower5.cs | 4 +- .../Saves/Substructures/Gen5/Roamer5.cs | 7 +- .../Saves/Substructures/Gen5/UnityTower5.cs | 6 +- .../Saves/Substructures/Gen6/BoxLayout6.cs | 2 +- .../Saves/Substructures/Gen6/Encount6.cs | 10 +- .../Saves/Substructures/Gen6/Fashion6XY.cs | 6 +- .../Substructures/Gen6/HallFame6Entity.cs | 1 + .../Saves/Substructures/Gen6/LinkBlock6.cs | 2 +- .../Saves/Substructures/Gen6/MyItem6AO.cs | 4 +- .../Saves/Substructures/Gen6/MyItem6XY.cs | 4 +- .../Saves/Substructures/Gen6/MyStatus6XY.cs | 6 +- .../Substructures/Gen6/OPower/OPower6.cs | 6 +- .../Gen6/OPower/OPowerFlagSet.cs | 15 +- PKHeX.Core/Saves/Substructures/Gen6/PSS6.cs | 6 +- .../Saves/Substructures/Gen6/RecordBlock6.cs | 33 +- .../Gen6/SecretBase/SecretBase6.cs | 40 +- .../SecretBase/SecretBase6GoodPlacement.cs | 44 +- .../Gen6/SecretBase/SecretBase6GoodStock.cs | 22 +- .../Substructures/Gen6/SecretBase6Block.cs | 5 +- .../Saves/Substructures/Gen6/SubEventLog6.cs | 21 +- .../Substructures/Gen6/SuperTrainBlock.cs | 11 +- .../Substructures/Gen6/TrainerFashion6.cs | 12 +- .../Saves/Substructures/Gen7/BattleTree7.cs | 35 +- .../Saves/Substructures/Gen7/BoxLayout7.cs | 2 +- .../Saves/Substructures/Gen7/FashionBlock7.cs | 20 +- .../Saves/Substructures/Gen7/FestaFacility.cs | 4 +- .../Saves/Substructures/Gen7/FieldMenu7.cs | 2 +- .../Substructures/Gen7/FieldMoveModelSave7.cs | 4 +- .../Substructures/Gen7/LGPE/CaptureRecords.cs | 4 +- .../Substructures/Gen7/LGPE/EventWork7b.cs | 2 +- .../Substructures/Gen7/LGPE/Fashion7b.cs | 12 +- .../Saves/Substructures/Gen7/LGPE/GP1.cs | 15 +- .../Saves/Substructures/Gen7/LGPE/MyItem7b.cs | 4 +- .../Substructures/Gen7/LGPE/WB7Records.cs | 6 +- .../Saves/Substructures/Gen7/MyItem7SM.cs | 4 +- .../Saves/Substructures/Gen7/MyItem7USUM.cs | 4 +- .../Substructures/Gen7/PlayerBattleStyle7.cs | 4 +- PKHeX.Core/Saves/Substructures/Gen7/QR7.cs | 6 +- .../Substructures/Gen7/WormholeInfoReader.cs | 37 +- .../Gen8/BS/BattleTowerWork8b.cs | 11 +- .../Substructures/Gen8/BS/EncounterSave8b.cs | 18 +- .../Saves/Substructures/Gen8/BS/MyItem8b.cs | 6 +- .../Substructures/Gen8/BS/MysteryBlock8b.cs | 26 +- .../Substructures/Gen8/BS/RandomGroup8b.cs | 11 +- .../Saves/Substructures/Gen8/BS/Record8b.cs | 6 +- .../Substructures/Gen8/BS/RecordAddData8b.cs | 11 +- .../Saves/Substructures/Gen8/BS/SealDeco8b.cs | 21 +- .../Saves/Substructures/Gen8/BS/Zukan8b.cs | 4 +- .../Substructures/Gen8/LA/BoxLayout8a.cs | 4 +- .../Substructures/Gen8/LA/Coordinates8a.cs | 20 +- .../Substructures/Gen8/LA/Epoch1970Value.cs | 4 +- .../Substructures/Gen8/LA/LastSaved8a.cs | 3 +- .../Saves/Substructures/Gen8/LA/MyItem8a.cs | 10 +- .../Saves/Substructures/Gen8/LA/MyStatus8a.cs | 4 +- .../Saves/Substructures/Gen8/LA/Party8a.cs | 6 +- .../Saves/Substructures/Gen8/LA/PlayTime8a.cs | 6 +- .../Substructures/Gen8/LA/PlayerFashion8a.cs | 5 +- .../Gen8/LA/Pokedex/PokedexConstants8a.cs | 30 +- .../Gen8/LA/Pokedex/PokedexSave8a.cs | 36 +- .../LA/Pokedex/PokedexSaveResearchEntry.cs | 3 +- .../Gen8/LA/Spawners/AreaSpawnerSet8a.cs | 3 +- .../Gen8/LA/Spawners/MassOutbreakSet8a.cs | 3 +- .../Gen8/LA/Spawners/MassOutbreakSpawner8a.cs | 3 +- .../Gen8/LA/Spawners/MassiveOutbreakArea8a.cs | 3 +- .../Gen8/LA/Spawners/MassiveOutbreakSet8a.cs | 3 +- .../LA/Spawners/MassiveOutbreakSpawner8a.cs | 3 +- .../Gen8/LA/Spawners/Spawner8a.cs | 1 + .../Gen8/LA/Spawners/SpawnerEntry8a.cs | 5 +- .../Gen8/LA/Spawners/SpawnerMeta8a.cs | 3 +- PKHeX.Core/Saves/Substructures/Gen8/Meta8.cs | 12 +- .../Saves/Substructures/Gen8/SWSH/Box8.cs | 7 +- .../Substructures/Gen8/SWSH/BoxLayout8.cs | 4 +- .../Substructures/Gen8/SWSH/Coordinates8.cs | 4 +- .../Saves/Substructures/Gen8/SWSH/Daycare8.cs | 6 +- .../Substructures/Gen8/SWSH/FashionUnlock8.cs | 6 +- .../Gen8/SWSH/FieldMoveModelSave8.cs | 6 +- .../Saves/Substructures/Gen8/SWSH/Fused8.cs | 4 +- .../Saves/Substructures/Gen8/SWSH/Misc8.cs | 6 +- .../Saves/Substructures/Gen8/SWSH/MyItem8.cs | 8 +- .../Substructures/Gen8/SWSH/MyStatus8.cs | 4 +- .../Saves/Substructures/Gen8/SWSH/Party8.cs | 6 +- .../Substructures/Gen8/SWSH/PlayTime8.cs | 4 +- .../Substructures/Gen8/SWSH/RaidSpawnList8.cs | 23 +- .../Saves/Substructures/Gen8/SWSH/Record8.cs | 10 +- .../Substructures/Gen8/SWSH/RentalTeam8.cs | 16 +- .../Substructures/Gen8/SWSH/TeamIndexes8.cs | 6 +- .../Substructures/Gen8/SWSH/TitleScreen8.cs | 14 +- .../Substructures/Gen8/SWSH/TrainerCard8.cs | 16 +- .../Saves/Substructures/Gen9/BoxLayout9.cs | 4 +- .../Saves/Substructures/Gen9/ConfigCamera9.cs | 4 +- .../Saves/Substructures/Gen9/ConfigSave9.cs | 4 +- .../Substructures/Gen9/Epoch1900Value.cs | 4 +- .../Substructures/Gen9/FixedSpawnList9.cs | 22 +- PKHeX.Core/Saves/Substructures/Gen9/Meta9.cs | 6 +- .../Saves/Substructures/Gen9/MyItem9.cs | 10 +- .../Saves/Substructures/Gen9/MyStatus9.cs | 4 +- PKHeX.Core/Saves/Substructures/Gen9/Party9.cs | 4 +- .../Saves/Substructures/Gen9/PlayTime9.cs | 4 +- .../Substructures/Gen9/PlayerAppearance9.cs | 3 +- .../Substructures/Gen9/PlayerFashion9.cs | 3 +- .../Gen9/PlayerFashionUnlock9.cs | 46 +- .../Substructures/Gen9/RaidSevenStar9.cs | 20 +- .../Substructures/Gen9/RaidSpawnList9.cs | 5 +- .../Saves/Substructures/Gen9/RentalTeam9.cs | 10 +- .../Substructures/Gen9/RentalTeamSet9.cs | 6 +- .../Saves/Substructures/Gen9/TeamIndexes9.cs | 4 +- .../Saves/Substructures/IEventFlagArray.cs | 4 +- .../Substructures/Inventory/IItemNewFlag.cs | 4 +- .../Inventory/Item/InventoryItem8.cs | 2 +- .../Inventory/Pouch/InventoryPouch.cs | 2 +- .../Inventory/Pouch/InventoryPouch3.cs | 8 +- .../Inventory/Pouch/InventoryPouch3GC.cs | 8 +- .../Inventory/Pouch/InventoryPouch4.cs | 8 +- .../Inventory/Pouch/InventoryPouch7.cs | 7 +- .../Inventory/Pouch/InventoryPouch7b.cs | 7 +- .../Inventory/Pouch/InventoryPouch8.cs | 7 +- .../Inventory/Pouch/InventoryPouch8a.cs | 10 +- .../Inventory/Pouch/InventoryPouch8b.cs | 8 +- .../Inventory/Pouch/InventoryPouch9.cs | 13 +- .../Inventory/Pouch/InventoryPouchGB.cs | 8 +- .../Saves/Substructures/MysteryGiftAlbum.cs | 21 +- .../PokeDex/Gen9/PokeDexEntry9Kitakami.cs | 1 + .../PokeDex/Gen9/PokeDexEntry9Paldea.cs | 1 + .../PokeDex/Gen9/Zukan9Kitakami.cs | 6 +- .../PokeDex/Gen9/Zukan9Paldea.cs | 10 +- .../Saves/Substructures/PokeDex/Zukan.cs | 3 +- .../Saves/Substructures/PokeDex/Zukan4.cs | 21 +- .../Saves/Substructures/PokeDex/Zukan6.cs | 2 +- .../Saves/Substructures/PokeDex/Zukan7.cs | 2 +- .../Saves/Substructures/PokeDex/Zukan7b.cs | 12 +- PKHeX.Core/Saves/Substructures/Records.cs | 18 +- PKHeX.Core/Saves/Util/Checksums.cs | 34 +- PKHeX.Core/Saves/Util/DexFormUtil.cs | 18 +- .../Saves/Util/Recognition/SaveHandlerARDS.cs | 2 +- .../Util/Recognition/SaveHandlerBizHawk.cs | 2 +- .../Util/Recognition/SaveHandlerDeSmuME.cs | 2 +- .../Saves/Util/Recognition/SaveHandlerGCI.cs | 8 +- .../Recognition/SaveHandlerSplitResult.cs | 17 +- PKHeX.Core/Saves/Util/SaveExtensions.cs | 4 +- PKHeX.Core/Saves/Util/SaveFinder.cs | 2 +- PKHeX.Core/Saves/Util/SaveUtil.cs | 57 +- PKHeX.Core/Util/ArrayUtil.cs | 145 +---- PKHeX.Core/Util/ComboItemUtil.cs | 4 +- PKHeX.Core/Util/DateUtil.cs | 8 +- PKHeX.Core/Util/FileUtil.cs | 18 +- PKHeX.Core/Util/FlagUtil.cs | 4 +- .../LocalizedDescriptionAttribute.cs | 17 +- PKHeX.Core/Util/RandUtil.cs | 17 - PKHeX.Core/Util/ReflectUtil.cs | 2 +- PKHeX.Core/Util/ResourceUtil.cs | 40 +- PKHeX.Core/Util/UpdateUtil.cs | 2 +- PKHeX.Core/Util/Util.cs | 24 +- PKHeX.Drawing.Misc/PKHeX.Drawing.Misc.csproj | 4 +- PKHeX.Drawing.Misc/QR/QRDecode.cs | 2 +- PKHeX.Drawing.Misc/QR/QREncode.cs | 10 +- .../Util/MysteryGiftSpriteUtil.cs | 6 +- PKHeX.Drawing.Misc/Util/PlayerSpriteUtil.cs | 8 +- PKHeX.Drawing.Misc/Util/RibbonSpriteUtil.cs | 6 +- PKHeX.Drawing.Misc/Util/TypeSpriteUtil.cs | 6 +- PKHeX.Drawing.Misc/Util/WallpaperUtil.cs | 4 +- .../Builder/SpriteBuilder.cs | 38 +- .../PKHeX.Drawing.PokeSprite.csproj | 4 +- PKHeX.Drawing.PokeSprite/Util/SpriteName.cs | 12 +- PKHeX.Drawing.PokeSprite/Util/SpriteUtil.cs | 36 +- PKHeX.Drawing/ImageUtil.cs | 2 +- PKHeX.Drawing/PKHeX.Drawing.csproj | 4 +- .../Controls/PKM Editor/BallBrowser.cs | 4 +- .../Controls/PKM Editor/ContestStat.cs | 4 +- .../Controls/PKM Editor/GenderToggle.cs | 8 +- .../Controls/PKM Editor/PKMEditor.cs | 51 +- .../Controls/PKM Editor/ShinyLeaf.cs | 2 +- .../Controls/PKM Editor/StatEditor.cs | 22 +- .../Controls/PKM Editor/TrainerID.cs | 11 +- .../Controls/PKM Editor/VerticalTabControl.cs | 4 +- .../Controls/SAV Editor/BoxEditor.cs | 2 +- .../Controls/SAV Editor/BoxMenuStrip.cs | 31 +- .../Controls/SAV Editor/ContextMenuSAV.cs | 6 +- .../Controls/SAV Editor/PartyEditor.cs | 4 +- .../Controls/SAV Editor/SAVEditor.cs | 16 +- .../Controls/SAV Editor/SlotChangeManager.cs | 15 +- PKHeX.WinForms/Controls/Slots/CryPlayer.cs | 2 +- PKHeX.WinForms/Controls/Slots/PokeGrid.cs | 2 +- PKHeX.WinForms/Controls/Slots/PokePreview.cs | 4 +- PKHeX.WinForms/Controls/Slots/SlotList.cs | 4 +- PKHeX.WinForms/Controls/Slots/SlotUtil.cs | 2 +- PKHeX.WinForms/MainWindow/Main.cs | 8 +- PKHeX.WinForms/MainWindow/PluginLoader.cs | 8 +- PKHeX.WinForms/Misc/ErrorWindow.cs | 2 +- PKHeX.WinForms/PKHeX.WinForms.csproj | 2 +- PKHeX.WinForms/Program.cs | 5 +- PKHeX.WinForms/Properties/PKHeXSettings.cs | 8 +- .../Properties/Resources.Designer.cs | 192 +++++- PKHeX.WinForms/Properties/Resources.resx | 42 ++ .../img/Bag/{Bag_TMHM.png => bag_tech.png} | Bin PKHeX.WinForms/Subforms/KChart.cs | 45 +- .../Subforms/Misc/EntitySummaryImage.cs | 9 +- .../Subforms/Misc/SortableBindingList.cs | 10 +- .../Subforms/PKM Editors/MemoryAmie.cs | 43 +- .../Subforms/PKM Editors/RibbonEditor.cs | 2 +- .../PKM Editors/SuperTrainingEditor.cs | 4 +- PKHeX.WinForms/Subforms/PKM Editors/Text.cs | 94 ++- PKHeX.WinForms/Subforms/ReportGrid.cs | 4 +- PKHeX.WinForms/Subforms/SAV_Database.cs | 20 +- PKHeX.WinForms/Subforms/SAV_Encounters.cs | 8 +- PKHeX.WinForms/Subforms/SAV_FolderList.cs | 30 +- PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs | 16 +- .../Subforms/Save Editors/Gen3/SAV_Misc3.cs | 58 +- .../Subforms/Save Editors/Gen3/SAV_Roamer3.cs | 6 +- .../Save Editors/Gen4/SAV_Apricorn.cs | 2 +- .../Subforms/Save Editors/Gen4/SAV_Misc4.cs | 96 +-- .../Save Editors/Gen4/SAV_Pokedex4.cs | 4 +- .../Save Editors/Gen5/SAV_CGearSkin.cs | 2 +- .../Subforms/Save Editors/Gen5/SAV_Misc5.cs | 41 +- .../Save Editors/Gen5/SAV_Pokedex5.cs | 4 +- .../Save Editors/Gen6/SAV_BoxLayout.cs | 2 +- .../Save Editors/Gen6/SAV_HallOfFame.cs | 4 +- .../Save Editors/Gen6/SAV_PokeBlockORAS.cs | 6 +- .../Save Editors/Gen6/SAV_PokedexORAS.cs | 4 +- .../Save Editors/Gen6/SAV_PokedexXY.cs | 4 +- .../Save Editors/Gen6/SAV_Pokepuff.cs | 8 +- .../Save Editors/Gen6/SAV_SecretBase.cs | 18 +- .../Subforms/Save Editors/Gen6/SAV_Trainer.cs | 8 +- .../Save Editors/Gen7/SAV_FestivalPlaza.cs | 99 +-- .../Save Editors/Gen7/SAV_HallOfFame7.cs | 6 +- .../Save Editors/Gen7/SAV_PokedexGG.cs | 12 +- .../Save Editors/Gen7/SAV_PokedexSM.cs | 6 +- .../Save Editors/Gen7/SAV_Trainer7.cs | 26 +- .../Save Editors/Gen7/SAV_ZygardeCell.cs | 10 +- .../Gen8/PokedexResearchTask8aPanel.cs | 8 +- .../Save Editors/Gen8/SAV_BlockDump8.cs | 6 +- .../Save Editors/Gen8/SAV_FlagWork8b.cs | 8 +- .../Save Editors/Gen8/SAV_PokedexLA.cs | 14 +- .../Gen8/SAV_PokedexResearchEditorLA.cs | 22 +- .../Save Editors/Gen8/SAV_PokedexSWSH.cs | 4 +- .../Save Editors/Gen9/SAV_Trainer9.cs | 8 +- .../Subforms/Save Editors/SAV_EventFlags.cs | 4 +- .../Subforms/Save Editors/SAV_EventFlags2.cs | 4 +- .../Subforms/Save Editors/SAV_EventWork.cs | 4 +- .../Save Editors/SAV_Inventory.Designer.cs | 22 - .../Subforms/Save Editors/SAV_Inventory.cs | 68 +- .../Subforms/Save Editors/SAV_Inventory.resx | 235 ------- .../Subforms/Save Editors/SAV_MailBox.cs | 36 +- .../Save Editors/SAV_SimpleTrainer.cs | 6 +- .../Subforms/Save Editors/SAV_Wondercard.cs | 12 +- PKHeX.WinForms/Subforms/SettingsEditor.cs | 2 +- PKHeX.WinForms/Util/DevUtil.cs | 61 +- PKHeX.WinForms/Util/FontUtil.cs | 2 +- PKHeX.WinForms/Util/WinFormsTranslator.cs | 6 +- PKHeX.WinForms/Util/WinFormsUtil.cs | 25 +- .../PKHeX.Core.Tests/Legality/ShadowTests.cs | 46 +- .../PKHeX.Core.Tests/PKHeX.Core.Tests.csproj | 8 +- .../PKHeX.Core.Tests/PKM/HiddenPowerTests.cs | 12 + Tests/PKHeX.Core.Tests/PKM/PIDIVTests.cs | 138 ++-- Tests/PKHeX.Core.Tests/PKM/StringTests.cs | 18 +- Tests/PKHeX.Core.Tests/Saves/SMTests.cs | 2 +- .../Simulator/GeneratorTests.cs | 15 +- .../Simulator/ShowdownSetTests.cs | 26 +- Tests/PKHeX.Core.Tests/Util/FlagUtilTests.cs | 2 +- 773 files changed, 6267 insertions(+), 7007 deletions(-) rename PKHeX.WinForms/Resources/img/Bag/{Bag_TMHM.png => bag_tech.png} (100%) delete mode 100644 PKHeX.WinForms/Subforms/Save Editors/SAV_Inventory.resx diff --git a/Directory.Build.props b/Directory.Build.props index c8a4aa3d0..aeba89233 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ 23.10.11 - 11 + 12 enable en PKHeX diff --git a/PKHeX.Core/Editing/Applicators/BallApplicator.cs b/PKHeX.Core/Editing/Applicators/BallApplicator.cs index b6451cf45..61af4ad0c 100644 --- a/PKHeX.Core/Editing/Applicators/BallApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/BallApplicator.cs @@ -96,7 +96,7 @@ private static int GetBallListFromColor(PKM pk, Span result) // Gen1/2 don't store color in personal info var pi = pk.Format >= 3 ? pk.PersonalInfo : PersonalTable.USUM.GetFormEntry(pk.Species, 0); var color = (PersonalColor)pi.Color; - var balls = BallColors[color]; + var balls = BallColors[(int)color]; var currentBall = (Ball)pk.Ball; return GetCircularOnce(balls, currentBall, result); } @@ -122,14 +122,15 @@ private static int GetCircularOnce(ReadOnlySpan items, int startIndex, Spa static BallApplicator() { - ReadOnlySpan exclude = stackalloc Ball[] {None, Poke}; - ReadOnlySpan end = stackalloc Ball[] {Poke}; + ReadOnlySpan exclude = [None, Poke]; + ReadOnlySpan end = [Poke]; Span all = stackalloc Ball[BallList.Length - exclude.Length]; all = all[..FillExcept(all, exclude, BallList)]; var colors = (PersonalColor[])Enum.GetValues(typeof(PersonalColor)); - foreach (var c in colors) + foreach (var color in colors) { + int c = (int)color; // Replace the array reference with a new array that appends non-matching values, followed by the end values. var defined = BallColors[c]; Span match = (BallColors[c] = new Ball[all.Length + end.Length]); @@ -164,20 +165,20 @@ static bool Contains(ReadOnlySpan arr, Ball b) /// /// Priority Match ball IDs that match the color ID in descending order /// - private static readonly Dictionary BallColors = new() - { - [PersonalColor.Red] = new[] { Cherish, Repeat, Fast, Heal, Great, Dream, Lure }, - [PersonalColor.Blue] = new[] { Dive, Net, Great, Beast, Lure }, - [PersonalColor.Yellow] = new[] { Level, Ultra, Repeat, Quick, Moon }, - [PersonalColor.Green] = new[] { Safari, Friend, Nest, Dusk }, - [PersonalColor.Black] = new[] { Luxury, Heavy, Ultra, Moon, Net, Beast }, + private static readonly Ball[][] BallColors = + [ + /* Red */ [Cherish, Repeat, Fast, Heal, Great, Dream, Lure], + /* Blue */ [Dive, Net, Great, Beast, Lure], + /* Yellow */ [Level, Ultra, Repeat, Quick, Moon], + /* Green */ [Safari, Friend, Nest, Dusk], + /* Black */ [Luxury, Heavy, Ultra, Moon, Net, Beast], - [PersonalColor.Brown] = new[] { Level, Heavy }, - [PersonalColor.Purple] = new[] { Master, Love, Dream, Heal }, - [PersonalColor.Gray] = new[] { Heavy, Premier, Luxury }, - [PersonalColor.White] = new[] { Premier, Timer, Luxury, Ultra }, - [PersonalColor.Pink] = new[] { Love, Dream, Heal }, - }; + /* Brown */ [Level, Heavy], + /* Purple */ [Master, Love, Dream, Heal], + /* Gray */ [Heavy, Premier, Luxury], + /* White */ [Premier, Timer, Luxury, Ultra], + /* Pink */ [Love, Dream, Heal], + ]; /// /// Personal Data color IDs diff --git a/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs b/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs index 0e54bccf4..d9e1b26e9 100644 --- a/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/CatchRateApplicator.cs @@ -34,17 +34,22 @@ public static byte GetSuggestedCatchRate(PK1 pk, SaveFile sav, LegalityAnalysis case EncounterGift1 { Version: GameVersion.Stadium, Species: (int)Species.Psyduck }: return pk.Japanese ? (byte)167 : (byte)168; // Amnesia Psyduck has different catch rates depending on language default: - var pt = GetPersonalTable(sav, enc); + var pt = GetPersonalTable(sav, enc.Version); var pi = pt[enc.Species]; return (byte)pi.CatchRate; } } - private static PersonalTable1 GetPersonalTable(SaveFile sav, IEncounterable v) + private static PersonalTable1 GetPersonalTable(SaveFile sav, GameVersion ver) { - if (sav.Personal is PersonalTable1 pt && (sav.Version.Contains(v.Version) || v.Version.Contains(sav.Version))) - return pt; - if (!GameVersion.RB.Contains(v.Version)) + if (sav.Personal is PersonalTable1 pt) + { + var other = sav.Version; + if (other.Contains(ver) || ver.Contains(other)) + return pt; + } + + if (!GameVersion.RB.Contains(ver)) return PersonalTable.Y; return PersonalTable.RB; } diff --git a/PKHeX.Core/Editing/Applicators/MemoryApplicator.cs b/PKHeX.Core/Editing/Applicators/MemoryApplicator.cs index 1cfedaecf..bd5a00617 100644 --- a/PKHeX.Core/Editing/Applicators/MemoryApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/MemoryApplicator.cs @@ -1,4 +1,4 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Logic for modifying the Memory parameters of a . @@ -43,8 +43,9 @@ public static void SetHatchMemory6(this PKM pk) public static void SetRandomMemory6(this PK6 pk) { // for lack of better randomization :) - pk.OT_Memory = 63; - pk.OT_Intensity = 6; - pk.OT_Feeling = MemoryContext6.GetRandomFeeling6(pk.OT_Memory); + const byte memory = 63; // almost got lost when it explored a forest with {Trainer} + pk.OT_Memory = memory; + pk.OT_Feeling = MemoryContext6.GetRandomFeeling6(memory); + pk.OT_Intensity = MemoryContext6.MaxIntensity; } } diff --git a/PKHeX.Core/Editing/Applicators/MoveApplicator.cs b/PKHeX.Core/Editing/Applicators/MoveApplicator.cs index f5b122450..cddd017eb 100644 --- a/PKHeX.Core/Editing/Applicators/MoveApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/MoveApplicator.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; public static class MoveApplicator { /// - /// Sets the individual PP Up count values depending if a Move is present in the move's slot or not. + /// Sets the individual PP Up count values depending on if a Move is present in the move's slot or not. /// /// Pokémon to modify. /// to use. @@ -29,7 +29,7 @@ static int GetPPUpCount(ushort moveID) } /// - /// Sets the individual PP Up count values depending if a Move is present in the move slot or not. + /// Sets the individual PP Up count values depending on if a Move is present in the move slot or not. /// /// Pokémon to modify. public static void SetMaximumPPUps(this PKM pk) diff --git a/PKHeX.Core/Editing/Applicators/MoveShopRecordApplicator.cs b/PKHeX.Core/Editing/Applicators/MoveShopRecordApplicator.cs index 66ca9f521..fb6b7b875 100644 --- a/PKHeX.Core/Editing/Applicators/MoveShopRecordApplicator.cs +++ b/PKHeX.Core/Editing/Applicators/MoveShopRecordApplicator.cs @@ -129,7 +129,7 @@ public static void SetEncounterMasteryFlags(this IMoveShop8Mastery shop, ReadOnl if (!permit.IsRecordPermitted(index)) continue; - // If the Pokémon is caught with any move shop move in its learnset + // If the Pokémon is caught with any move shop move in its learnset, // and it is high enough level to master it, the game will automatically // give it the "Mastered" flag but not the "Purchased" flag // For moves that are not in the learnset, it returns -1 which is true, thus set as mastered. diff --git a/PKHeX.Core/Editing/Bulk/BatchEditing.cs b/PKHeX.Core/Editing/Bulk/BatchEditing.cs index 815be3371..9da6d7721 100644 --- a/PKHeX.Core/Editing/Bulk/BatchEditing.cs +++ b/PKHeX.Core/Editing/Bulk/BatchEditing.cs @@ -16,24 +16,24 @@ namespace PKHeX.Core; public static class BatchEditing { public static readonly Type[] Types = - { + [ typeof (PK9), typeof (PK8), typeof (PA8), typeof (PB8), typeof (PB7), typeof (PK7), typeof (PK6), typeof (PK5), typeof (PK4), typeof(BK4), typeof(RK4), typeof (PK3), typeof (XK3), typeof (CK3), typeof (PK2), typeof (SK2), typeof (PK1), - }; + ]; /// /// Extra properties to show in the list of selectable properties (GUI) /// - public static readonly List CustomProperties = new() - { + public static readonly List CustomProperties = + [ PROP_LEGAL, PROP_TYPENAME, PROP_RIBBONS, PROP_CONTESTSTATS, PROP_MOVEMASTERY, PROP_TYPE1, PROP_TYPE2, PROP_TYPEEITHER, IdentifierContains, nameof(ISlotInfo.Slot), nameof(SlotInfoBox.Box), - }; + ]; /// /// Property names, indexed by . @@ -122,7 +122,7 @@ private static string[][] GetPropArray(IReadOnlyList types, IReadOnlyList< /// Pokémon to check /// Property Name to check /// Property Info retrieved (if any). - /// True if has property, false if does not. + /// True if it has property, false if it does not. public static bool TryGetHasProperty(PKM pk, string name, [NotNullWhen(true)] out PropertyInfo? pi) { var type = pk.GetType(); @@ -135,7 +135,7 @@ public static bool TryGetHasProperty(PKM pk, string name, [NotNullWhen(true)] ou /// Type to check /// Property Name to check /// Property Info retrieved (if any). - /// True if has property, false if does not. + /// True if it has property, false if it does not. public static bool TryGetHasProperty(Type type, string name, [NotNullWhen(true)] out PropertyInfo? pi) { var index = Array.IndexOf(Types, type); @@ -167,7 +167,7 @@ public static IEnumerable GetTypesImplementing(string property) /// Gets the type of the property using the saved cache of properties. /// /// Property Name to fetch the type for - /// Type index (within . Leave empty (0) for a nonspecific format. + /// Type index (within ). Leave empty (0) for a nonspecific format. /// Short name of the property's type. public static string? GetPropertyType(string propertyName, int typeIndex = 0) { @@ -385,13 +385,13 @@ internal static ModifyResult TryModifyPKM(PKM pk, IEnumerable } /// - /// Sets the if the should be filtered due to the provided. + /// Sets the property if the should be filtered due to the provided. /// /// Command Filter /// Pokémon to check. /// PropertyInfo cache (optional) /// True if filtered, else false. - private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info, IReadOnlyDictionary props) + private static ModifyResult SetPKMProperty(StringInstruction cmd, BatchInfo info, Dictionary props) { var pk = info.Entity; if (cmd.PropertyValue.StartsWith(CONST_BYTES, StringComparison.Ordinal)) diff --git a/PKHeX.Core/Editing/Bulk/BatchEditor.cs b/PKHeX.Core/Editing/Bulk/BatchEditor.cs index 3ad6dbd10..bcebc62c2 100644 --- a/PKHeX.Core/Editing/Bulk/BatchEditor.cs +++ b/PKHeX.Core/Editing/Bulk/BatchEditor.cs @@ -69,7 +69,7 @@ public string GetEditorResults(IReadOnlyCollection sets) /// /// Batch instruction line(s) /// Entities to modify - /// Editor object if follow up modifications are desired. + /// Editor object if follow-up modifications are desired. public static BatchEditor Execute(ReadOnlySpan lines, IEnumerable data) { var editor = new BatchEditor(); diff --git a/PKHeX.Core/Editing/Bulk/BatchFilters.cs b/PKHeX.Core/Editing/Bulk/BatchFilters.cs index 3d1904c86..39f1bfffe 100644 --- a/PKHeX.Core/Editing/Bulk/BatchFilters.cs +++ b/PKHeX.Core/Editing/Bulk/BatchFilters.cs @@ -11,8 +11,8 @@ public static class BatchFilters /// /// Filters to use for that are derived from the data. /// - public static readonly List FilterMods = new() - { + public static readonly List FilterMods = + [ new ComplexFilter(PROP_LEGAL, (pk, cmd) => bool.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == new LegalityAnalysis(pk).Valid), (info, cmd) => bool.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(b == info.Legality.Valid)), @@ -32,13 +32,13 @@ public static class BatchFilters new ComplexFilter(PROP_TYPEEITHER, (pk, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(pk.PersonalInfo.IsType(b)), (info, cmd) => byte.TryParse(cmd.PropertyValue, out var b) && cmd.Comparer.IsCompareEquivalence(info.Entity.PersonalInfo.IsType(b))), - }; + ]; /// /// Filters to use for that are derived from the source. /// - public static readonly List FilterMeta = new() - { + public static readonly List FilterMeta = + [ new MetaFilter(IdentifierContains, (obj, cmd) => obj is SlotCache s && cmd.Comparer.IsCompareEquivalence(s.Identify().Contains(cmd.PropertyValue))), @@ -47,5 +47,5 @@ public static class BatchFilters new MetaFilter(nameof(ISlotInfo.Slot), (obj, cmd) => obj is SlotCache s && int.TryParse(cmd.PropertyValue, out var slot) && cmd.Comparer.IsCompareOperator((s.Source.Slot + 1).CompareTo(slot))), - }; + ]; } diff --git a/PKHeX.Core/Editing/Bulk/BatchMods.cs b/PKHeX.Core/Editing/Bulk/BatchMods.cs index a42fe5218..87ae6f208 100644 --- a/PKHeX.Core/Editing/Bulk/BatchMods.cs +++ b/PKHeX.Core/Editing/Bulk/BatchMods.cs @@ -10,8 +10,8 @@ namespace PKHeX.Core; /// public static class BatchMods { - public static readonly List SuggestionMods = new() - { + public static readonly List SuggestionMods = + [ // Interface Specific new TypeSuggestion(nameof(ICombatPower.Stat_CP), p => p.ResetCP()), new TypeSuggestion(nameof(IScaledSizeValue.HeightAbsolute), p => p.ResetHeight()), @@ -49,13 +49,12 @@ public static class BatchMods new ComplexSuggestion(nameof(PKM.CurrentLevel), (_, _, info) => BatchModifications.SetMinimumCurrentLevel(info)), new ComplexSuggestion(PROP_CONTESTSTATS, p => p is IContestStats, (_, value, info) => BatchModifications.SetContestStats(info.Entity, info.Legality, value)), new ComplexSuggestion(PROP_MOVEMASTERY, (_, value, info) => BatchModifications.SetSuggestedMasteryData(info, value)), - }; + ]; private static DateOnly ParseDate(ReadOnlySpan val) => DateOnly.ParseExact(val, "yyyyMMdd", CultureInfo.InvariantCulture); - public static readonly List ComplexMods = new() - { - // Date + public static readonly List ComplexMods = + [ new ComplexSet(nameof(PKM.MetDate), (pk, cmd) => pk.MetDate = ParseDate(cmd.PropertyValue)), new ComplexSet(nameof(PKM.EggMetDate), (pk, cmd) => pk.EggMetDate = ParseDate(cmd.PropertyValue)), @@ -84,7 +83,7 @@ public static class BatchMods // Complicated new ComplexSet(nameof(PKM.EncryptionConstant), value => value.StartsWith(CONST_RAND), (pk, cmd) => pk.EncryptionConstant = CommonEdits.GetComplicatedEC(pk, option: cmd.PropertyValue[^1])), - }; + ]; private static void SetRandomTeraType(PKM pk) { diff --git a/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexFilter.cs b/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexFilter.cs index b16f7e445..f07b37151 100644 --- a/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexFilter.cs +++ b/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexFilter.cs @@ -1,24 +1,14 @@ -using System; +using System; namespace PKHeX.Core; /// -public sealed class ComplexFilter : IComplexFilter +public sealed class ComplexFilter( + string Property, + Func FilterPKM, + Func FilterBulk) + : IComplexFilter { - private readonly string Property; - private readonly Func FilterPKM; - private readonly Func FilterBulk; - - public ComplexFilter( - string property, - Func filterPkm, - Func filterBulk) - { - Property = property; - FilterPKM = filterPkm; - FilterBulk = filterBulk; - } - public bool IsMatch(string prop) => prop == Property; public bool IsFiltered(PKM pk, StringInstruction value) => FilterPKM(pk, value); public bool IsFiltered(BatchInfo info, StringInstruction value) => FilterBulk(info, value); diff --git a/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexSet.cs b/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexSet.cs index a388862d2..20fdb7825 100644 --- a/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexSet.cs +++ b/PKHeX.Core/Editing/Bulk/ComplexSet/ComplexSet.cs @@ -1,21 +1,14 @@ -using System; +using System; namespace PKHeX.Core; /// -public sealed class ComplexSet : IComplexSet +public sealed class ComplexSet(string PropertyName, Action Action) : IComplexSet { - public readonly string PropertyName; + public readonly string PropertyName = PropertyName; public readonly Func IsValueCompatible = _ => true; - private readonly Action Action; - public ComplexSet(string propertyName, Action modify) - { - PropertyName = propertyName; - Action = modify; - } - - public ComplexSet(string propertyName, Func criteria, Action modify) : this(propertyName, modify) => IsValueCompatible = criteria; + public ComplexSet(string PropertyName, Func criteria, Action Action) : this(PropertyName, Action) => IsValueCompatible = criteria; public bool IsMatch(string name, string value) => name == PropertyName && IsValueCompatible(value); diff --git a/PKHeX.Core/Editing/Bulk/ComplexSet/MetaFilter.cs b/PKHeX.Core/Editing/Bulk/ComplexSet/MetaFilter.cs index c6d0da6a3..eb294fb72 100644 --- a/PKHeX.Core/Editing/Bulk/ComplexSet/MetaFilter.cs +++ b/PKHeX.Core/Editing/Bulk/ComplexSet/MetaFilter.cs @@ -1,21 +1,13 @@ -using System; +using System; namespace PKHeX.Core; /// -public sealed class MetaFilter : IComplexFilterMeta +public sealed class MetaFilter( + string Property, + Func FilterPKM) + : IComplexFilterMeta { - private readonly string Property; - private readonly Func FilterPKM; - - public MetaFilter( - string property, - Func filterPkm) - { - Property = property; - FilterPKM = filterPkm; - } - public bool IsMatch(string prop) => prop == Property; public bool IsFiltered(object pk, StringInstruction value) => FilterPKM(pk, value); } diff --git a/PKHeX.Core/Editing/Bulk/StringInstruction.cs b/PKHeX.Core/Editing/Bulk/StringInstruction.cs index 0be2fba31..284ac8680 100644 --- a/PKHeX.Core/Editing/Bulk/StringInstruction.cs +++ b/PKHeX.Core/Editing/Bulk/StringInstruction.cs @@ -16,21 +16,17 @@ namespace PKHeX.Core; /// /// /// -public sealed class StringInstruction +public sealed class StringInstruction(string PropertyName, string PropertyValue) { /// Property to modify. - public string PropertyName { get; } + public string PropertyName { get; } = PropertyName; + /// Value to set to the property. - public string PropertyValue { get; private set; } + public string PropertyValue { get; private set; } = PropertyValue; + /// Filter Comparison Type public InstructionComparer Comparer { get; private init; } - public StringInstruction(string name, string value) - { - PropertyName = name; - PropertyValue = value; - } - public void SetScreenedValue(ReadOnlySpan arr) { int index = arr.IndexOf(PropertyValue); @@ -41,7 +37,12 @@ public void SetScreenedValue(ReadOnlySpan arr) /// /// Valid prefixes that are recognized for value comparison types. /// - public static ReadOnlySpan Prefixes => new[] { Apply, FilterEqual, FilterNotEqual, FilterGreaterThan, FilterGreaterThanOrEqual, FilterLessThan, FilterLessThanOrEqual }; + public static ReadOnlySpan Prefixes => + [ + Apply, + FilterEqual, FilterNotEqual, FilterGreaterThan, FilterGreaterThanOrEqual, FilterLessThan, FilterLessThanOrEqual, + ]; + private const char Apply = '.'; private const char SplitRange = ','; @@ -292,8 +293,6 @@ public static bool TryParseSplitTuple(ReadOnlySpan tuple, out ReadOnlySpan /// /// Gets the from the input . /// - /// - /// public static InstructionComparer GetComparer(char opCode) => opCode switch { FilterEqual => IsEqual, diff --git a/PKHeX.Core/Editing/Bulk/Suggestion/ComplexSuggestion.cs b/PKHeX.Core/Editing/Bulk/Suggestion/ComplexSuggestion.cs index 93330bf4e..9b07fb0af 100644 --- a/PKHeX.Core/Editing/Bulk/Suggestion/ComplexSuggestion.cs +++ b/PKHeX.Core/Editing/Bulk/Suggestion/ComplexSuggestion.cs @@ -1,30 +1,25 @@ -using System; +using System; namespace PKHeX.Core; /// -public sealed class ComplexSuggestion : ISuggestModification +public sealed class ComplexSuggestion( + string Keyword, + Func Action) + : ISuggestModification { - public readonly string Keyword; + public readonly string Keyword = Keyword; public readonly Func Criteria = _ => true; - public readonly Func Action; + public readonly Func Action = Action; public ComplexSuggestion( - string keyword, + string Keyword, Func criteria, - Func action) : this(keyword, action) + Func action) : this(Keyword, action) { Criteria = criteria; } - public ComplexSuggestion( - string keyword, - Func action) - { - Keyword = keyword; - Action = action; - } - public bool IsMatch(string name, string value, BatchInfo info) { return name == Keyword && Criteria(info.Entity); diff --git a/PKHeX.Core/Editing/Bulk/Suggestion/TypeSuggestion.cs b/PKHeX.Core/Editing/Bulk/Suggestion/TypeSuggestion.cs index 47a943daf..beb031ebf 100644 --- a/PKHeX.Core/Editing/Bulk/Suggestion/TypeSuggestion.cs +++ b/PKHeX.Core/Editing/Bulk/Suggestion/TypeSuggestion.cs @@ -1,22 +1,16 @@ -using System; +using System; namespace PKHeX.Core; /// /// Specific (or not) type -public sealed class TypeSuggestion : ISuggestModification +public sealed class TypeSuggestion(string Keyword, Action Action) : ISuggestModification { - public readonly string Keyword; - public readonly Action Action; + public readonly string Keyword = Keyword; + public readonly Action Action = (pk, _) => Action(pk); public readonly Func Criteria = _ => true; - public TypeSuggestion(string keyword, Action action) - { - Keyword = keyword; - Action = (pk, _) => action(pk); - } - - public TypeSuggestion(string keyword, Func criteria, Action action) : this(keyword, action) + public TypeSuggestion(string Keyword, Func criteria, Action action) : this(Keyword, action) { Criteria = criteria; } diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs index 9b508d2aa..0385a2ed8 100644 --- a/PKHeX.Core/Editing/CommonEdits.cs +++ b/PKHeX.Core/Editing/CommonEdits.cs @@ -172,18 +172,18 @@ public static void ApplySetDetails(this PKM pk, IBattleTemplate Set) { // In Generation 1/2 Format sets, when IVs are not specified with a Hidden Power set, we might not have the hidden power type. // Under this scenario, just force the Hidden Power type. - if (Array.IndexOf(Set.Moves, (ushort)Move.HiddenPower) != -1 && pk.HPType != Set.HiddenPowerType) + if (Array.IndexOf(Set.Moves, (ushort)Move.HiddenPower) != -1 && gb.HPType != Set.HiddenPowerType) { - if (Set.IVs.AsSpan().IndexOfAny(30, 31) >= 0) - pk.SetHiddenPower(Set.HiddenPowerType); + if (Set.IVs.AsSpan().ContainsAny(30, 31)) + gb.SetHiddenPower(Set.HiddenPowerType); } // In Generation 1/2 Format sets, when EVs are not specified at all, it implies maximum EVs instead! // Under this scenario, just apply maximum EVs (65535). - if (Set.EVs.AsSpan().IndexOfAnyExcept(0) == -1) + if (!Set.EVs.AsSpan().ContainsAnyExcept(0)) gb.MaxEVs(); else - pk.SetEVs(Set.EVs); + gb.SetEVs(Set.EVs); } else { @@ -191,7 +191,7 @@ public static void ApplySetDetails(this PKM pk, IBattleTemplate Set) } // IVs have no side effects such as hidden power type in gen 8 - // therefore all specified IVs are deliberate and should not be Hyper Trained for pokemon met in gen 8 + // therefore all specified IVs are deliberate and should not be Hyper Trained for Pokémon met in gen 8 if (pk.Generation < 8) pk.SetSuggestedHyperTrainingData(Set.IVs); diff --git a/PKHeX.Core/Editing/Database/TrainerDatabase.cs b/PKHeX.Core/Editing/Database/TrainerDatabase.cs index 7f227eec8..b7b4c3033 100644 --- a/PKHeX.Core/Editing/Database/TrainerDatabase.cs +++ b/PKHeX.Core/Editing/Database/TrainerDatabase.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; /// public sealed class TrainerDatabase { - private readonly Dictionary> Database = new(); + private readonly Dictionary> Database = []; /// /// Fetches an appropriate trainer based on the requested . @@ -104,7 +104,7 @@ public void Register(ITrainerInfo trainer) ver = s.Version; if (!Database.TryGetValue(ver, out var list)) { - Database.Add(ver, new List { trainer }); + Database.Add(ver, [trainer]); return; } @@ -127,7 +127,7 @@ public void Register(ITrainerInfo trainer) /// A copy of the object will be made to prevent modifications, just in case. public void RegisterCopy(ITrainerInfo info) => Register(new SimpleTrainerInfo(info)); - private static ITrainerInfo GetTrainerReference(PKM pk) + private static SimpleTrainerInfo GetTrainerReference(PKM pk) { var result = new SimpleTrainerInfo((GameVersion)pk.Version) { diff --git a/PKHeX.Core/Editing/HiddenPower.cs b/PKHeX.Core/Editing/HiddenPower.cs index a7d2ec862..318543e00 100644 --- a/PKHeX.Core/Editing/HiddenPower.cs +++ b/PKHeX.Core/Editing/HiddenPower.cs @@ -33,8 +33,8 @@ public static int GetType(ReadOnlySpan IVs) return SixBitType[hp]; } - private static ReadOnlySpan SixBitType => new byte[] - { + private static ReadOnlySpan SixBitType => + [ // (low-bit mash) * 15 / 63 00, 00, 00, 00, 00, 01, 01, 01, 01, 02, 02, 02, 02, 03, 03, 03, @@ -44,7 +44,7 @@ public static int GetType(ReadOnlySpan IVs) 09, 09, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, - }; + ]; /// /// Gets the current Hidden Power Type of the input for Generations 1 & 2 @@ -58,6 +58,9 @@ public static int GetTypeGB(ReadOnlySpan IVs) return ((atk & 3) << 2) | (def & 3); } + /// + public static int GetTypeGB(ushort u16) => ((u16 >> 12) & 0b1100) | ((u16 >> 8) & 0b11); + /// /// Modifies the provided to have the requested for Generations 1 & 2 /// @@ -71,6 +74,14 @@ public static bool SetTypeGB(int hiddenPowerType, Span IVs) return true; } + /// + public static ushort SetTypeGB(int hiddenPowerType, ushort current) + { + // Extract bits from ATK and DEF. + var u16 = ((hiddenPowerType & 0b1100) << 12) | ((hiddenPowerType & 0b11) << 8); + return (ushort)((current & 0b1100_1100_1111_1111) | u16); + } + /// /// Modifies the provided to have the requested . /// @@ -190,8 +201,8 @@ private static void ForceLowBits(Span ivs, byte bits) /// These are just precomputed for fast modification. /// Individual Values (H/A/B/S/C/D) /// - public static ReadOnlySpan DefaultLowBits => new byte[] - { + public static ReadOnlySpan DefaultLowBits => + [ 0b000011, // Fighting 0b001000, // Flying 0b001011, // Poison @@ -208,5 +219,5 @@ private static void ForceLowBits(Span ivs, byte bits) 0b111001, // Ice 0b111101, // Dragon 0b111111, // Dark - }; + ]; } diff --git a/PKHeX.Core/Editing/NatureAmp.cs b/PKHeX.Core/Editing/NatureAmp.cs index 900600c18..f093afe8b 100644 --- a/PKHeX.Core/Editing/NatureAmp.cs +++ b/PKHeX.Core/Editing/NatureAmp.cs @@ -17,7 +17,7 @@ public static class NatureAmp /// New nature value public static int GetNewNature(this NatureAmpRequest type, int statIndex, int currentNature) { - if (currentNature > (int)Nature.Quirky) + if (currentNature >= NatureCount) return -1; var (up, dn) = GetNatureModification(currentNature); @@ -105,6 +105,64 @@ public static void ModifyStatsForNature(Span stats, int nature) upStat = (ushort)((upStat * 11) / 10); dnStat = (ushort)((dnStat * 9) / 10); } + + /// + /// Nature Amplification Table + /// + /// -1 is 90%, 0 is 100%, 1 is 110%. + public static ReadOnlySpan Table => + [ + 0, 0, 0, 0, 0, // Hardy + 1,-1, 0, 0, 0, // Lonely + 1, 0, 0, 0,-1, // Brave + 1, 0,-1, 0, 0, // Adamant + 1, 0, 0,-1, 0, // Naughty + -1, 1, 0, 0, 0, // Bold + 0, 0, 0, 0, 0, // Docile + 0, 1, 0, 0,-1, // Relaxed + 0, 1,-1, 0, 0, // Impish + 0, 1, 0,-1, 0, // Lax + -1, 0, 0, 0, 1, // Timid + 0,-1, 0, 0, 1, // Hasty + 0, 0, 0, 0, 0, // Serious + 0, 0,-1, 0, 1, // Jolly + 0, 0, 0,-1, 1, // Naive + -1, 0, 1, 0, 0, // Modest + 0,-1, 1, 0, 0, // Mild + 0, 0, 1, 0,-1, // Quiet + 0, 0, 0, 0, 0, // Bashful + 0, 0, 1,-1, 0, // Rash + -1, 0, 0, 1, 0, // Calm + 0,-1, 0, 1, 0, // Gentle + 0, 0, 0, 1,-1, // Sassy + 0, 0,-1, 1, 0, // Careful + 0, 0, 0, 0, 0, // Quirky + ]; + + private const int NatureCount = 25; + private const int AmpWidth = 5; + + public static int AmplifyStat(int nature, int index, int initial) => GetNatureAmp(nature, index) switch + { + 1 => 110 * initial / 100, // 110% + -1 => 90 * initial / 100, // 90% + _ => initial, + }; + + private static sbyte GetNatureAmp(int nature, int index) + { + if ((uint)nature >= NatureCount) + return -1; + var amps = GetAmps(nature); + return amps[index]; + } + + public static ReadOnlySpan GetAmps(int nature) + { + if ((uint)nature >= NatureCount) + nature = 0; + return Table.Slice(AmpWidth * nature, AmpWidth); + } } public enum NatureAmpRequest diff --git a/PKHeX.Core/Editing/PKM/LegalMoveComboSource.cs b/PKHeX.Core/Editing/PKM/LegalMoveComboSource.cs index 9dac6a12e..866e2d4d1 100644 --- a/PKHeX.Core/Editing/PKM/LegalMoveComboSource.cs +++ b/PKHeX.Core/Editing/PKM/LegalMoveComboSource.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; namespace PKHeX.Core; @@ -10,16 +9,16 @@ namespace PKHeX.Core; public sealed class LegalMoveComboSource : ILegalMoveDisplaySource { private readonly bool[] IsMoveBoxOrdered = new bool[4]; - private ComboItem[] MoveDataAllowed = Array.Empty(); + private ComboItem[] MoveDataAllowed = []; - public IReadOnlyList DataSource => (ComboItem[])MoveDataAllowed.Clone(); + public IReadOnlyList DataSource => [.. MoveDataAllowed]; // copy /// /// Resets the data source with an updated collection. /// public void ReloadMoves(IReadOnlyList moves) { - MoveDataAllowed = moves.ToArray(); + MoveDataAllowed = [.. moves]; // copy ClearUpdateCheck(); } @@ -35,7 +34,7 @@ public void ReloadMoves(LegalMoveInfo info) private void SortMoves(LegalMoveInfo info) => Array.Sort(MoveDataAllowed, (i1, i2) => Compare(i1, i2, info.CanLearn)); // defer re-population until dropdown is opened; handled by dropdown event - private void ClearUpdateCheck() => Array.Clear(IsMoveBoxOrdered, 0, IsMoveBoxOrdered.Length); + private void ClearUpdateCheck() => IsMoveBoxOrdered.AsSpan().Clear(); private static int Compare(ComboItem i1, ComboItem i2, Func check) { diff --git a/PKHeX.Core/Editing/PKM/LegalMoveInfo.cs b/PKHeX.Core/Editing/PKM/LegalMoveInfo.cs index 04acab6c0..fd7cf799d 100644 --- a/PKHeX.Core/Editing/PKM/LegalMoveInfo.cs +++ b/PKHeX.Core/Editing/PKM/LegalMoveInfo.cs @@ -15,8 +15,8 @@ public sealed class LegalMoveInfo /// /// Checks if the requested is legally able to be learned. /// - /// Move to check if can be learned - /// True if can learn the move + /// Move to check if it can be learned + /// True if it can learn the move public bool CanLearn(ushort move) => AllowedMoves[move]; /// diff --git a/PKHeX.Core/Editing/PKM/LegalMoveSource.cs b/PKHeX.Core/Editing/PKM/LegalMoveSource.cs index 3ca864b6a..f625a66fe 100644 --- a/PKHeX.Core/Editing/PKM/LegalMoveSource.cs +++ b/PKHeX.Core/Editing/PKM/LegalMoveSource.cs @@ -5,12 +5,10 @@ namespace PKHeX.Core; /// /// Legal Move information for a single , for indicating if a move is legal or not. /// -public sealed class LegalMoveSource +public sealed class LegalMoveSource(ILegalMoveDisplaySource Display) { public LegalMoveInfo Info { get; } = new(); - public readonly ILegalMoveDisplaySource Display; - - public LegalMoveSource(ILegalMoveDisplaySource display) => Display = display; + public readonly ILegalMoveDisplaySource Display = Display; public void ReloadMoves(LegalityAnalysis source) { diff --git a/PKHeX.Core/Editing/PKM/QR/QRPK7.cs b/PKHeX.Core/Editing/PKM/QR/QRPK7.cs index 3a8ff890f..865e13755 100644 --- a/PKHeX.Core/Editing/PKM/QR/QRPK7.cs +++ b/PKHeX.Core/Editing/PKM/QR/QRPK7.cs @@ -6,8 +6,10 @@ namespace PKHeX.Core; /// /// Generation 7 PGL QR Code encoded entities. /// -public sealed class QRPK7 : IEncounterInfo +public sealed class QRPK7(byte[] Data) : IEncounterInfo { + private readonly byte[] Data = (byte[])Data.Clone(); + public GameVersion Version => (GameVersion)CassetteVersion; public bool EggEncounter => false; public byte LevelMin => Level; @@ -16,9 +18,7 @@ public sealed class QRPK7 : IEncounterInfo public EntityContext Context => EntityContext.Gen7; public bool IsShiny => false; - private readonly byte[] Data; public const int SIZE = 0x30; - public QRPK7(byte[] d) => Data = (byte[])d.Clone(); public uint EncryptionConstant => ReadUInt32LittleEndian(Data.AsSpan(0)); public byte HT_Flags => Data[4]; diff --git a/PKHeX.Core/Editing/PKM/QR/QRPKM.cs b/PKHeX.Core/Editing/PKM/QR/QRPKM.cs index e9cf034f1..578a57114 100644 --- a/PKHeX.Core/Editing/PKM/QR/QRPKM.cs +++ b/PKHeX.Core/Editing/PKM/QR/QRPKM.cs @@ -33,12 +33,12 @@ public static string[] GetQRLines(this PKM pk) string IVs = $"IVs: {pk.IV_HP:00}/{pk.IV_ATK:00}/{pk.IV_DEF:00}/{pk.IV_SPA:00}/{pk.IV_SPD:00}/{pk.IV_SPE:00}"; string EVs = $"EVs: {pk.EV_HP:00}/{pk.EV_ATK:00}/{pk.EV_DEF:00}/{pk.EV_SPA:00}/{pk.EV_SPD:00}/{pk.EV_SPE:00}"; - return new[] - { + return + [ string.Join(" ", header), sb.ToString(), IVs + " " + EVs, - }; + ]; } private static IEnumerable GetHeader(PKM pk, GameStrings s) diff --git a/PKHeX.Core/Editing/Pokerus.cs b/PKHeX.Core/Editing/Pokerus.cs index 7aff49a57..12e33292b 100644 --- a/PKHeX.Core/Editing/Pokerus.cs +++ b/PKHeX.Core/Editing/Pokerus.cs @@ -63,7 +63,7 @@ public static bool IsStrainValid(PKM pk, int strain, int days) /// /// /// Gen3 R/S have a 30/255 chance of giving strain 0, and a 1/255 chance of giving strain 8. - /// Transfers will retain strain 0/8 and they're still able to infect others. + /// Transfers will retain strain 0/8, and they're still able to infect others. /// public static bool IsStrainValid(int strain) => strain <= 0xF; @@ -102,11 +102,11 @@ public static bool IsDurationValid(int strain, int days, out int max) /// /// Strain number /// Duration remaining - /// True if can be infected by another infectious individual. + /// True if it can be infected by another infectious individual. public static bool IsSusceptible(int strain, int days) => strain == 0 && days == 0; /// - /// Vaccinates the Pokémon so it will never be infectious in the format it exists in. + /// Vaccinates the Pokémon, so it will never be infectious in the format it exists in. /// /// Entity to modify. /// Overwrites all Pokérus values even if already legal. diff --git a/PKHeX.Core/Editing/Program/AutoLoadSetting.cs b/PKHeX.Core/Editing/Program/AutoLoadSetting.cs index ae3940656..3c1ccdaa7 100644 --- a/PKHeX.Core/Editing/Program/AutoLoadSetting.cs +++ b/PKHeX.Core/Editing/Program/AutoLoadSetting.cs @@ -1,4 +1,4 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Option to load a save file automatically to an editing environment. @@ -6,7 +6,7 @@ public enum AutoLoadSetting { /// - /// Doesn't auto load a save file, and instead uses a fake save file data. + /// Doesn't autoload a save file, and instead uses a fake save file data. /// Disabled, diff --git a/PKHeX.Core/Editing/Program/StartupArguments.cs b/PKHeX.Core/Editing/Program/StartupArguments.cs index 6d3beac2b..a154aac59 100644 --- a/PKHeX.Core/Editing/Program/StartupArguments.cs +++ b/PKHeX.Core/Editing/Program/StartupArguments.cs @@ -16,7 +16,7 @@ public sealed class StartupArguments // ReSharper disable once UnassignedGetOnlyAutoProperty public Exception? Error { get; } // ReSharper disable once CollectionNeverQueried.Global - public readonly List Extra = new(); + public readonly List Extra = []; /// /// Step 1: Reads in command line arguments. diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClear.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClear.cs index ca4b1bab5..4539c7488 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClear.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClear.cs @@ -1,15 +1,13 @@ -using System; +using System; namespace PKHeX.Core; /// -/// Clears contents of boxes by deleting all that satisfy a . +/// Clears contents of boxes by deleting all that satisfy a criteria. /// -public sealed class BoxManipClear : BoxManipBase +public sealed class BoxManipClear(BoxManipType Type, Func criteria, Func Usable) : BoxManipBase(Type, Usable) { - private readonly Func Criteria; - public BoxManipClear(BoxManipType type, Func criteria) : this(type, criteria, _ => true) { } - public BoxManipClear(BoxManipType type, Func criteria, Func usable) : base(type, usable) => Criteria = criteria; + public BoxManipClear(BoxManipType Type, Func Criteria) : this(Type, Criteria, _ => true) { } public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxClearAll : MessageStrings.MsgSaveBoxClearCurrent; public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxClearAllFailBattle : MessageStrings.MsgSaveBoxClearCurrentFailBattle; @@ -18,7 +16,8 @@ public sealed class BoxManipClear : BoxManipBase public override int Execute(SaveFile sav, BoxManipParam param) { var (start, stop, reverse) = param; - bool Method(PKM p) => reverse ^ Criteria(p); return sav.ClearBoxes(start, stop, Method); + + bool Method(PKM p) => reverse ^ criteria(p); } } diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearComplex.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearComplex.cs index 61acf2dad..370c057f2 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearComplex.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearComplex.cs @@ -1,15 +1,13 @@ -using System; +using System; namespace PKHeX.Core; /// -/// Clears contents of boxes by deleting all that satisfy a based on a . +/// Clears contents of boxes by deleting all that satisfy a criteria based on a . /// -public sealed class BoxManipClearComplex : BoxManipBase +public sealed class BoxManipClearComplex(BoxManipType Type, Func criteria, Func Usable) : BoxManipBase(Type, Usable) { - private readonly Func Criteria; - public BoxManipClearComplex(BoxManipType type, Func criteria) : this(type, criteria, _ => true) { } - public BoxManipClearComplex(BoxManipType type, Func criteria, Func usable) : base(type, usable) => Criteria = criteria; + public BoxManipClearComplex(BoxManipType Type, Func Criteria) : this(Type, Criteria, _ => true) { } public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxClearAll : MessageStrings.MsgSaveBoxClearCurrent; public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxClearAllFailBattle : MessageStrings.MsgSaveBoxClearCurrentFailBattle; @@ -18,7 +16,8 @@ public sealed class BoxManipClearComplex : BoxManipBase public override int Execute(SaveFile sav, BoxManipParam param) { var (start, stop, reverse) = param; - bool Method(PKM p) => reverse ^ Criteria(p, sav); return sav.ClearBoxes(start, stop, Method); + + bool Method(PKM p) => reverse ^ criteria(p, sav); } } diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearDuplicate.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearDuplicate.cs index 537d31c08..5817e21ed 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearDuplicate.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipClearDuplicate.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace PKHeX.Core; @@ -9,7 +9,7 @@ namespace PKHeX.Core; /// Base type of the "is duplicate" hash for the duplicate detection. public sealed class BoxManipClearDuplicate : BoxManipBase { - private readonly HashSet HashSet = new(); + private readonly HashSet HashSet = []; private readonly Func Criteria; public BoxManipClearDuplicate(BoxManipType type, Func criteria) : this(type, criteria, _ => true) { } @@ -18,10 +18,7 @@ public BoxManipClearDuplicate(BoxManipType type, Func criteria, Func { var result = criteria(pk); - if (HashSet.Contains(result)) - return true; - HashSet.Add(result); - return false; + return !HashSet.Add(result); }; } @@ -33,7 +30,8 @@ public override int Execute(SaveFile sav, BoxManipParam param) { HashSet.Clear(); var (start, stop, reverse) = param; - bool Method(PKM p) => reverse ^ Criteria(p); return sav.ClearBoxes(start, stop, Method); + + bool Method(PKM p) => reverse ^ Criteria(p); } } diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModify.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModify.cs index aec92cd23..e725ed15e 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModify.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModify.cs @@ -1,15 +1,14 @@ -using System; +using System; namespace PKHeX.Core; /// /// Modifies contents of boxes by using an to change data. /// -public sealed class BoxManipModify : BoxManipBase +public sealed class BoxManipModify(BoxManipType type, Action Action, Func Usable) + : BoxManipBase(type, Usable) { - private readonly Action Action; - public BoxManipModify(BoxManipType type, Action action) : this(type, action, _ => true) { } - public BoxManipModify(BoxManipType type, Action action, Func usable) : base(type, usable) => Action = action; + public BoxManipModify(BoxManipType type, Action Action) : this(type, Action, _ => true) { } public override string GetPrompt(bool all) => string.Empty; public override string GetFail(bool all) => string.Empty; diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModifyComplex.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModifyComplex.cs index c9d0d6853..7e4b2ad79 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModifyComplex.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipModifyComplex.cs @@ -1,15 +1,14 @@ -using System; +using System; namespace PKHeX.Core; /// /// Modifies contents of boxes by using an (referencing a Save File) to change data. /// -public sealed class BoxManipModifyComplex : BoxManipBase +public sealed class BoxManipModifyComplex(BoxManipType Type, Action Action, Func Usable) + : BoxManipBase(Type, Usable) { - private readonly Action Action; - public BoxManipModifyComplex(BoxManipType type, Action action) : this(type, action, _ => true) { } - public BoxManipModifyComplex(BoxManipType type, Action action, Func usable) : base(type, usable) => Action = action; + public BoxManipModifyComplex(BoxManipType Type, Action Action) : this(Type, Action, _ => true) { } public override string GetPrompt(bool all) => string.Empty; public override string GetFail(bool all) => string.Empty; diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipSort.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipSort.cs index 3e5965aee..5295d5cf2 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipSort.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipSort.cs @@ -1,16 +1,14 @@ -using System; +using System; using System.Collections.Generic; namespace PKHeX.Core; /// -/// Sorts contents of boxes by using a to determine the order. +/// Sorts contents of boxes by using a Sorter to determine the order. /// -public sealed class BoxManipSort : BoxManipBase +public sealed class BoxManipSort(BoxManipType Type, Func, IEnumerable> Sorter, Func Usable) : BoxManipBase(Type, Usable) { - private readonly Func, IEnumerable> Sorter; - public BoxManipSort(BoxManipType type, Func, IEnumerable> sorter) : this(type, sorter, _ => true) { } - public BoxManipSort(BoxManipType type, Func, IEnumerable> sorter, Func usable) : base(type, usable) => Sorter = sorter; + public BoxManipSort(BoxManipType Type, Func, IEnumerable> Sorter) : this(Type, Sorter, _ => true) { } public override string GetPrompt(bool all) => all ? MessageStrings.MsgSaveBoxSortAll : MessageStrings.MsgSaveBoxSortCurrent; public override string GetFail(bool all) => all ? MessageStrings.MsgSaveBoxSortAllFailBattle: MessageStrings.MsgSaveBoxSortCurrentFailBattle; @@ -18,8 +16,9 @@ public sealed class BoxManipSort : BoxManipBase public override int Execute(SaveFile sav, BoxManipParam param) { - IEnumerable Method(IEnumerable p, int index) => Sorter(p); var (start, stop, reverse) = param; return sav.SortBoxes(start, stop, Method, reverse); + + IEnumerable Method(IEnumerable p, int index) => Sorter(p); } } diff --git a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipUtil.cs b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipUtil.cs index 1cbb9f638..ebe318eab 100644 --- a/PKHeX.Core/Editing/Saves/BoxManip/BoxManipUtil.cs +++ b/PKHeX.Core/Editing/Saves/BoxManip/BoxManipUtil.cs @@ -12,12 +12,12 @@ public static class BoxManipUtil /// Grouped categories of different . /// public static readonly IReadOnlyList[] ManipCategories = - { + [ BoxManipDefaults.ClearCommon, BoxManipDefaults.SortCommon, BoxManipDefaults.SortAdvanced, BoxManipDefaults.ModifyCommon, - }; + ]; /// /// Manipulation Group Names to be used for uniquely naming groups of GUI controls. @@ -26,12 +26,12 @@ public static class BoxManipUtil /// Order should match that of . /// public static readonly string[] ManipCategoryNames = - { + [ "Delete", "Sort", "SortAdvanced", "Modify", - }; + ]; /// /// Gets a reference that carries out the action of the requested . diff --git a/PKHeX.Core/Editing/Saves/Editors/EventOld/EventLabelParsing.cs b/PKHeX.Core/Editing/Saves/Editors/EventOld/EventLabelParsing.cs index 0c9df61b4..b9f57870a 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventOld/EventLabelParsing.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventOld/EventLabelParsing.cs @@ -13,7 +13,7 @@ public static class EventLabelParsing private const char Split = '\t'; private static readonly NamedEventConst Custom = new("Custom", NamedEventConst.CustomMagicValue); - private static readonly NamedEventConst[] Empty = { Custom }; + private static readonly NamedEventConst[] Empty = [Custom]; public static List GetFlags(ReadOnlySpan strings, int maxValue = int.MaxValue) { @@ -45,14 +45,13 @@ public static List GetWork(ReadOnlySpan strings, int max return result; } - private static void SanityCheck(NamedEventValue item, ISet processed, int maxValue) + private static void SanityCheck(NamedEventValue item, ISet processed, int maxValue) => SanityCheck(processed, maxValue, item.Index); + + private static void SanityCheck(ISet processed, int maxValue, int index) { - var index = item.Index; - if (index >= maxValue) - throw new ArgumentOutOfRangeException(nameof(index), index, "Value too high."); - if (processed.Contains(index)) + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, maxValue); + if (!processed.Add(index)) throw new ArgumentOutOfRangeException(nameof(index), index, "Already have an entry for this!"); - processed.Add(index); } public static bool TryParseValue(ReadOnlySpan value, [NotNullWhen(true)] out NamedEventValue? result) @@ -115,9 +114,9 @@ private static (string Description, IReadOnlyList Named) GetDes return (desc, predefined); } - private static IReadOnlyList GetPredefinedArray(ReadOnlySpan combined) + private static List GetPredefinedArray(ReadOnlySpan combined) { - var result = new List(Empty); + List result = [..Empty]; // x:y tuples separated by , while (true) diff --git a/PKHeX.Core/Editing/Saves/Editors/EventUnlock/EventUnlocker8b.cs b/PKHeX.Core/Editing/Saves/Editors/EventUnlock/EventUnlocker8b.cs index 33ee8a63c..6d6b8e419 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventUnlock/EventUnlocker8b.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventUnlock/EventUnlocker8b.cs @@ -1,9 +1,7 @@ namespace PKHeX.Core; -public sealed class EventUnlocker8b : EventUnlocker +public sealed class EventUnlocker8b(SAV8BS sav) : EventUnlocker(sav) { - public EventUnlocker8b(SAV8BS sav) : base(sav) { } - public bool UnlockReadySpiritomb => SAV.UgSaveData.TalkedNPC < 32; public bool UnlockReadyBoxLegend => SAV.FlagWork.GetFlag(308) && SAV.FlagWork.GetWork(84) != 5; // FE_D05R0114_SPPOKE_GET, WK_SCENE_D05R0114 (1-3 story related, 4 = captured, 5 = can retry) public bool UnlockReadyShaymin => SAV.FlagWork.GetFlag(545) || !(SAV.FlagWork.GetWork(276) == 1 && SAV.Zukan.HasNationalDex && SAV.Items.GetItemQuantity(452) == 1 && SAV.FlagWork.GetSystemFlag(5)); // HAIHUEVENT_ID_D30, Oak's Letter diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs index 58fdffd5c..22938a01a 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff.cs @@ -11,10 +11,10 @@ namespace PKHeX.Core; /// public sealed class EventBlockDiff : IEventWorkDiff where T : class, IEventFlagArray, IEventWorkArray where T2 : unmanaged, IEquatable { - public List SetFlags { get; } = new(); - public List ClearedFlags { get; } = new(); - public List WorkChanged { get; } = new(); - public List WorkDiff { get; } = new(); + public List SetFlags { get; } = []; + public List ClearedFlags { get; } = []; + public List WorkChanged { get; } = []; + public List WorkDiff { get; } = []; public EventWorkDiffCompatibility Message { get; private set; } private const int MAX_SAVEFILE_SIZE = 0x10_0000; // 1 MB diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs index 58d183e5d..1122bf122 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff7b.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using static PKHeX.Core.EventWorkUtil; @@ -10,10 +9,10 @@ namespace PKHeX.Core; public sealed class EventWorkDiff7b : IEventWorkDiff { private SAV7b? S1; - public List SetFlags { get; } = new(); - public List ClearedFlags { get; } = new(); - public List WorkChanged { get; } = new(); - public List WorkDiff { get; } = new(); + public List SetFlags { get; } = []; + public List ClearedFlags { get; } = []; + public List WorkChanged { get; } = []; + public List WorkDiff { get; } = []; public EventWorkDiffCompatibility Message { get; private set; } private const int MAX_SAVEFILE_SIZE = 0x10_0000; // 1 MB @@ -53,7 +52,7 @@ private void Diff(SAV7b s1, SAV7b s2) public IReadOnlyList Summarize() { if (S1 == null) - return Array.Empty(); + return []; var ew = S1.Blocks.EventWork; var fOn = SetFlags.Select(z => FlagSummary.Get(z, ew).ToString()); diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs index bae7b9303..ec083fe01 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/Diff/EventWorkDiff8b.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using static PKHeX.Core.EventWorkUtil; @@ -10,12 +9,12 @@ namespace PKHeX.Core; public sealed class EventWorkDiff8b : IEventWorkDiff { private SAV8BS? S1; - public List SetSystem { get; } = new(); - public List SetFlags { get; } = new(); - public List ClearedSystem { get; } = new(); - public List ClearedFlags { get; } = new(); - public List WorkChanged { get; } = new(); - public List WorkDiff { get; } = new(); + public List SetSystem { get; } = []; + public List SetFlags { get; } = []; + public List ClearedSystem { get; } = []; + public List ClearedFlags { get; } = []; + public List WorkChanged { get; } = []; + public List WorkDiff { get; } = []; public EventWorkDiffCompatibility Message { get; private set; } private const int MAX_SAVEFILE_SIZE = 0x10_0000; // 1 MB @@ -55,7 +54,7 @@ private void Diff(SAV8BS s1, SAV8BS s2) public IReadOnlyList Summarize() { if (S1 == null) - return Array.Empty(); + return []; var fOn = SetFlags.Select(z => new FlagSummary(z).ToString()); var fOff = ClearedFlags.Select(z => new FlagSummary(z).ToString()); diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/EventFlag.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/EventFlag.cs index ec1405428..25f7eca79 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/EventFlag.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/EventFlag.cs @@ -1,15 +1,11 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; /// /// Event Flag that toggles certain features / entities on and off. /// -public sealed class EventFlag : EventVar +public sealed class EventFlag(int index, EventVarType t, IReadOnlyList pieces) : EventVar(index, t, pieces[1]) { public bool Flag; - - public EventFlag(int index, EventVarType t, IReadOnlyList pieces) : base(index, t, pieces[1]) - { - } } diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/EventVarGroup.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/EventVarGroup.cs index 92f1c6f74..2c5e0ce25 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/EventVarGroup.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/EventVarGroup.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; -public sealed class EventVarGroup +public sealed class EventVarGroup(EventVarType type) { - public readonly EventVarType Type; - public readonly List Vars = new(); - - public EventVarGroup(EventVarType type) => Type = type; + public readonly EventVarType Type = type; + public readonly List Vars = []; } diff --git a/PKHeX.Core/Editing/Saves/Editors/EventWork/SplitEventEditor.cs b/PKHeX.Core/Editing/Saves/Editors/EventWork/SplitEventEditor.cs index c94386fae..f3ba81810 100644 --- a/PKHeX.Core/Editing/Saves/Editors/EventWork/SplitEventEditor.cs +++ b/PKHeX.Core/Editing/Saves/Editors/EventWork/SplitEventEditor.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace PKHeX.Core; @@ -42,7 +42,7 @@ public SplitEventEditor(IEventVar block, IEnumerable work, IEnumerabl } /// - /// Writes all of the updated event values back to the block. + /// Writes all the updated event values back to the block. /// public void Save() { diff --git a/PKHeX.Core/Editing/Saves/Editors/FakePKMEditor.cs b/PKHeX.Core/Editing/Saves/Editors/FakePKMEditor.cs index b7bf4083f..30b990ccf 100644 --- a/PKHeX.Core/Editing/Saves/Editors/FakePKMEditor.cs +++ b/PKHeX.Core/Editing/Saves/Editors/FakePKMEditor.cs @@ -1,13 +1,11 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Fakes the interface interactions. /// -public sealed class FakePKMEditor : IPKMView +public sealed class FakePKMEditor(PKM template) : IPKMView { - public FakePKMEditor(PKM template) => Data = template; - - public PKM Data { get; private set; } + public PKM Data { get; private set; } = template; public bool Unicode => true; public bool HaX => false; public bool ChangingFields { get; set; } diff --git a/PKHeX.Core/Editing/Saves/Slots/BoxEdit.cs b/PKHeX.Core/Editing/Saves/Slots/BoxEdit.cs index 9d8a937d6..3e8c4ce97 100644 --- a/PKHeX.Core/Editing/Saves/Slots/BoxEdit.cs +++ b/PKHeX.Core/Editing/Saves/Slots/BoxEdit.cs @@ -1,20 +1,13 @@ -using System; +using System; namespace PKHeX.Core; /// /// Represents a Box Editor that loads the contents for easy manipulation. /// -public sealed class BoxEdit +public sealed class BoxEdit(SaveFile SAV) { - private readonly SaveFile SAV; - private readonly PKM[] CurrentContents; - - public BoxEdit(SaveFile sav) - { - SAV = sav; - CurrentContents = new PKM[sav.BoxSlotCount]; - } + private readonly PKM[] CurrentContents = new PKM[SAV.BoxSlotCount]; public void Reload() => LoadBox(CurrentBox); diff --git a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs index 795e41434..5955e476b 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs @@ -29,7 +29,7 @@ public static PKM[] GetExtraPKM(this SaveFile sav, IReadOnlyList s return arr; } - private static readonly List None = new(); + private static readonly List None = []; public static List GetExtraSlots(this SaveFile sav, bool all = false) => sav switch { @@ -50,20 +50,20 @@ public static PKM[] GetExtraPKM(this SaveFile sav, IReadOnlyList s private static List GetExtraSlots2(SAV2 sav) { - return new List - { + return + [ new(sav.Data.AsMemory(sav.GetDaycareSlotOffset(0, 2)), 0) {Type = StorageSlotType.Daycare }, // egg - }; + ]; } private static List GetExtraSlots3(SAV3 sav) { if (sav is not SAV3FRLG) return None; - return new List - { + return + [ new(sav.Large.AsMemory(0x3C98), 0) {Type = StorageSlotType.Daycare}, - }; + ]; } private static List GetExtraSlots4(SAV4 sav) @@ -99,8 +99,8 @@ private static List GetExtraSlots5(SAV5 sav) private static List GetExtraSlots6XY(SAV6XY sav) { - return new List - { + return + [ new(sav.Data, 0, sav.GTS) {Type = StorageSlotType.GTS}, new(sav.Data, 0, sav.Fused) {Type = StorageSlotType.Fused}, new(sav.Data, 0, sav.SUBE.Give) {Type = StorageSlotType.Misc}, // Old Man @@ -111,13 +111,13 @@ private static List GetExtraSlots6XY(SAV6XY sav) new(sav.Data, 3, sav.GetBattleBoxSlot(3)) {Type = StorageSlotType.BattleBox}, new(sav.Data, 4, sav.GetBattleBoxSlot(4)) {Type = StorageSlotType.BattleBox}, new(sav.Data, 5, sav.GetBattleBoxSlot(5)) {Type = StorageSlotType.BattleBox}, - }; + ]; } private static List GetExtraSlots6AO(SAV6AO sav) { - return new List - { + return + [ new(sav.Data, 0, SAV6AO.GTS) {Type = StorageSlotType.GTS}, new(sav.Data, 0, SAV6AO.Fused) {Type = StorageSlotType.Fused}, new(sav.Data, 0, sav.SUBE.Give) {Type = StorageSlotType.Misc}, @@ -128,7 +128,7 @@ private static List GetExtraSlots6AO(SAV6AO sav) new(sav.Data, 3, sav.GetBattleBoxSlot(3)) {Type = StorageSlotType.BattleBox}, new(sav.Data, 4, sav.GetBattleBoxSlot(4)) {Type = StorageSlotType.BattleBox}, new(sav.Data, 5, sav.GetBattleBoxSlot(5)) {Type = StorageSlotType.BattleBox}, - }; + ]; } private static List GetExtraSlots7(SAV7 sav, bool all) @@ -164,10 +164,10 @@ private static List GetExtraSlots7(SAV7 sav, bool all) private static List GetExtraSlots7b(SAV7b sav) { - return new List - { + return + [ new(sav.Data, 0, sav.Blocks.GetBlockOffset(BelugaBlockIndex.Daycare) + 8, true) {Type = StorageSlotType.Daycare}, - }; + ]; } private static List GetExtraSlots8(ISaveBlock8Main sav) @@ -198,8 +198,8 @@ private static List GetExtraSlots8(ISaveBlock8Main sav) private static List GetExtraSlots8b(SAV8BS sav) { - return new List - { + return + [ new(sav.Data, 0, sav.UgSaveData.GetSlotOffset(0), true) { Type = StorageSlotType.Misc }, new(sav.Data, 1, sav.UgSaveData.GetSlotOffset(1), true) { Type = StorageSlotType.Misc }, new(sav.Data, 2, sav.UgSaveData.GetSlotOffset(2), true) { Type = StorageSlotType.Misc }, @@ -209,12 +209,12 @@ private static List GetExtraSlots8b(SAV8BS sav) new(sav.Data, 6, sav.UgSaveData.GetSlotOffset(6), true) { Type = StorageSlotType.Misc }, new(sav.Data, 7, sav.UgSaveData.GetSlotOffset(7), true) { Type = StorageSlotType.Misc }, new(sav.Data, 8, sav.UgSaveData.GetSlotOffset(8), true) { Type = StorageSlotType.Misc }, - }; + ]; } private static List GetExtraSlots8a(SAV8LA _) { - return new List(); + return []; } private static List GetExtraSlots9(SAV9SV sav) diff --git a/PKHeX.Core/Editing/Saves/Slots/Info/ISlotInfo.cs b/PKHeX.Core/Editing/Saves/Slots/Info/ISlotInfo.cs index c97057a34..8b1e20661 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Info/ISlotInfo.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Info/ISlotInfo.cs @@ -19,7 +19,7 @@ public interface ISlotInfo /// Indicates if this slot can write to the requested . /// /// Save file to try writing to. - /// True if can write to + /// True if the slot can be written to bool CanWriteTo(SaveFile sav); /// @@ -27,7 +27,7 @@ public interface ISlotInfo /// /// Save file to try writing to. /// Entity data to try writing. - /// True if can write to + /// True if the slot can be written to WriteBlockedMessage CanWriteTo(SaveFile sav, PKM pk); /// diff --git a/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoFile.cs b/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoFile.cs index ddff8d764..2f633e735 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoFile.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Info/SlotInfoFile.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Records data for an that originates from an external file. +/// Records data for that originates from an external file. /// /// public sealed record SlotInfoFile(string Path) : ISlotInfo diff --git a/PKHeX.Core/Editing/Saves/Slots/Info/SlotOrigin.cs b/PKHeX.Core/Editing/Saves/Slots/Info/SlotOrigin.cs index a85773928..6e894c61b 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Info/SlotOrigin.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Info/SlotOrigin.cs @@ -8,7 +8,7 @@ public enum SlotOrigin : byte /// /// Slot data originated from the Party, or follows "party format" data rules. /// - /// Some games do not permit forms to exist outside of the party. + /// Some games do not permit forms to exist outside the party. Party = 0, /// diff --git a/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs b/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs index 5f579611b..9135bc00d 100644 --- a/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs +++ b/PKHeX.Core/Editing/Saves/Slots/SlotChangelog.cs @@ -1,18 +1,15 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; /// /// Tracks slot changes and provides the ability to revert a change. /// -public sealed class SlotChangelog +public sealed class SlotChangelog(SaveFile SAV) { - private readonly SaveFile SAV; private readonly Stack UndoStack = new(); private readonly Stack RedoStack = new(); - public SlotChangelog(SaveFile sav) => SAV = sav; - public bool CanUndo => UndoStack.Count != 0; public bool CanRedo => RedoStack.Count != 0; @@ -57,26 +54,22 @@ private void AddUndo(SlotReversion change) _ => new SingleSlotReversion(info, sav), }; - private abstract class SlotReversion + private abstract class SlotReversion(ISlotInfo Info) { - internal readonly ISlotInfo Info; - protected SlotReversion(ISlotInfo info) => Info = info; - + internal readonly ISlotInfo Info = Info; public abstract void Revert(SaveFile sav); } - private sealed class PartyReversion : SlotReversion + private sealed class PartyReversion(ISlotInfo info, IList Party) : SlotReversion(info) { - private readonly IList Party; - public PartyReversion(ISlotInfo info, SaveFile s) : base(info) => Party = s.PartyData; + public PartyReversion(ISlotInfo info, SaveFile s) : this(info, s.PartyData) { } public override void Revert(SaveFile sav) => sav.PartyData = Party; } - private sealed class SingleSlotReversion : SlotReversion + private sealed class SingleSlotReversion(ISlotInfo info, PKM Entity) : SlotReversion(info) { - private readonly PKM Entity; - public SingleSlotReversion(ISlotInfo info, SaveFile sav) : base(info) => Entity = info.Read(sav); + public SingleSlotReversion(ISlotInfo info, SaveFile sav) : this(info, info.Read(sav)) { } public override void Revert(SaveFile sav) => Info.WriteTo(sav, Entity, PKMImportSetting.Skip); } diff --git a/PKHeX.Core/Editing/Saves/Slots/SlotEditor.cs b/PKHeX.Core/Editing/Saves/Slots/SlotEditor.cs index 1e66e63a8..9df69b017 100644 --- a/PKHeX.Core/Editing/Saves/Slots/SlotEditor.cs +++ b/PKHeX.Core/Editing/Saves/Slots/SlotEditor.cs @@ -3,18 +3,10 @@ namespace PKHeX.Core; /// /// Facilitates interaction with a or other data location's slot data. /// -public sealed class SlotEditor +public sealed class SlotEditor(SaveFile SAV) { - private readonly SaveFile SAV; - public readonly SlotChangelog Changelog; - public readonly SlotPublisher Publisher; - - public SlotEditor(SaveFile sav) - { - SAV = sav; - Changelog = new SlotChangelog(sav); - Publisher = new SlotPublisher(); - } + public readonly SlotChangelog Changelog = new(SAV); + public readonly SlotPublisher Publisher = new(); private void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pk) => Publisher.NotifySlotChanged(slot, type, pk); diff --git a/PKHeX.Core/Editing/Saves/Slots/SlotPublisher.cs b/PKHeX.Core/Editing/Saves/Slots/SlotPublisher.cs index c82178050..51b94058d 100644 --- a/PKHeX.Core/Editing/Saves/Slots/SlotPublisher.cs +++ b/PKHeX.Core/Editing/Saves/Slots/SlotPublisher.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace PKHeX.Core; @@ -10,7 +10,7 @@ public sealed class SlotPublisher /// /// All instances that provide a view on individual content. /// - public List> Subscribers { get; } = new(); + public List> Subscribers { get; } = []; public ISlotInfo? Previous { get; private set; } public SlotTouchType PreviousType { get; private set; } = SlotTouchType.None; diff --git a/PKHeX.Core/Editing/Saves/Slots/SlotViewInfo.cs b/PKHeX.Core/Editing/Saves/Slots/SlotViewInfo.cs index 124a13b51..48625fc83 100644 --- a/PKHeX.Core/Editing/Saves/Slots/SlotViewInfo.cs +++ b/PKHeX.Core/Editing/Saves/Slots/SlotViewInfo.cs @@ -6,22 +6,17 @@ namespace PKHeX.Core; /// Tuple containing data for a and the originating /// /// -public sealed class SlotViewInfo : IEquatable where T : class +public sealed class SlotViewInfo(ISlotInfo Slot, ISlotViewer View) : IEquatable + where T : class { - public readonly ISlotInfo Slot; - public readonly ISlotViewer View; + public readonly ISlotInfo Slot = Slot; + public readonly ISlotViewer View = View; public PKM ReadCurrent() => Slot.Read(View.SAV); public bool CanWriteTo() => Slot.CanWriteTo(View.SAV); public bool IsEmpty() => Slot.IsEmpty(View.SAV); public WriteBlockedMessage CanWriteTo(PKM pk) => Slot.CanWriteTo(View.SAV, pk); - public SlotViewInfo(ISlotInfo slot, ISlotViewer view) - { - Slot = slot; - View = view; - } - private bool Equals(SlotViewInfo other) { if (other.View.SAV != View.SAV) diff --git a/PKHeX.Core/Editing/Showdown/ShowdownParsing.cs b/PKHeX.Core/Editing/Showdown/ShowdownParsing.cs index f082e061b..48ea50d75 100644 --- a/PKHeX.Core/Editing/Showdown/ShowdownParsing.cs +++ b/PKHeX.Core/Editing/Showdown/ShowdownParsing.cs @@ -9,7 +9,7 @@ namespace PKHeX.Core; /// public static class ShowdownParsing { - private static readonly string[] genderForms = { "", "F", "" }; + private static readonly string[] genderForms = ["", "F", ""]; /// /// Gets the Form ID from the input . @@ -193,7 +193,7 @@ private static int GetLength(ReadOnlySpan text) { // Find the end of the Showdown Set lines. // The end is implied when: - // - we see a completely whitespace or empty line, or + // - we see a complete whitespace or empty line, or // - we witness four 'move' definition lines. int length = 0; int moveCount = 4; diff --git a/PKHeX.Core/Editing/Showdown/ShowdownSet.cs b/PKHeX.Core/Editing/Showdown/ShowdownSet.cs index eb5661544..424be6e53 100644 --- a/PKHeX.Core/Editing/Showdown/ShowdownSet.cs +++ b/PKHeX.Core/Editing/Showdown/ShowdownSet.cs @@ -10,20 +10,20 @@ namespace PKHeX.Core; /// public sealed class ShowdownSet : IBattleTemplate { - private static readonly string[] StatNames = { "HP", "Atk", "Def", "Spe", "SpA", "SpD" }; + private static readonly string[] StatNames = ["HP", "Atk", "Def", "Spe", "SpA", "SpD"]; private const string LineSplit = ": "; private const string ItemSplit = " @ "; private const int MAX_SPECIES = (int)MAX_COUNT - 1; internal const string DefaultLanguage = GameLanguage.DefaultLanguage; private static readonly GameStrings DefaultStrings = GameInfo.GetStrings(DefaultLanguage); - private static ReadOnlySpan DashedSpecies => new ushort[] - { + private static ReadOnlySpan DashedSpecies => + [ (int)NidoranF, (int)NidoranM, (int)HoOh, (int)Jangmoo, (int)Hakamoo, (int)Kommoo, (int)TingLu, (int)ChienPao, (int)WoChien, (int)ChiYu, - }; + ]; /// public ushort Species { get; private set; } @@ -62,10 +62,10 @@ public sealed class ShowdownSet : IBattleTemplate public byte Form { get; private set; } /// - public int[] EVs { get; } = {00, 00, 00, 00, 00, 00}; + public int[] EVs { get; } = [00, 00, 00, 00, 00, 00]; /// - public int[] IVs { get; } = {31, 31, 31, 31, 31, 31}; + public int[] IVs { get; } = [31, 31, 31, 31, 31, 31]; /// public int HiddenPowerType { get; private set; } = -1; @@ -73,7 +73,7 @@ public sealed class ShowdownSet : IBattleTemplate public MoveType TeraType { get; private set; } = MoveType.Any; /// - public ushort[] Moves { get; } = {0, 0, 0, 0}; + public ushort[] Moves { get; } = [0, 0, 0, 0]; /// public bool CanGigantamax { get; private set; } @@ -429,7 +429,7 @@ private string GetSpeciesNickname(string specForm) { var count = stats.Length - stats.Count(ignoreValue); if (count == 0) - return Array.Empty(); + return []; var result = new string[count]; int ctr = 0; @@ -676,7 +676,7 @@ private void ParseSpeciesNickname(ReadOnlySpan line) else // (Species), or garbage { species = tmp; - nickname = ReadOnlySpan.Empty; + nickname = []; } } diff --git a/PKHeX.Core/Game/GameStrings/FilteredGameDataSource.cs b/PKHeX.Core/Game/GameStrings/FilteredGameDataSource.cs index 3ab00f929..0cbb76559 100644 --- a/PKHeX.Core/Game/GameStrings/FilteredGameDataSource.cs +++ b/PKHeX.Core/Game/GameStrings/FilteredGameDataSource.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; @@ -23,7 +22,7 @@ public FilteredGameDataSource(SaveFile sav, GameDataSource source, bool HaX = fa } else { - Items = Array.Empty(); + Items = []; } var gamelist = GameUtil.GetVersionsWithinRange(sav, sav.Generation).ToList(); @@ -123,5 +122,5 @@ public IReadOnlyList GetAbilityList(IPersonalAbility pi) return list; } - private static readonly string[] AbilityIndexSuffixes = { " (1)", " (2)", " (H)" }; + private static readonly string[] AbilityIndexSuffixes = [" (1)", " (2)", " (H)"]; } diff --git a/PKHeX.Core/Game/GameStrings/GameDataSource.cs b/PKHeX.Core/Game/GameStrings/GameDataSource.cs index aab19c1ef..7b970d2c4 100644 --- a/PKHeX.Core/Game/GameStrings/GameDataSource.cs +++ b/PKHeX.Core/Game/GameStrings/GameDataSource.cs @@ -24,8 +24,8 @@ public sealed class GameDataSource /// /// List of values to display. /// - private static readonly List LanguageList = new() - { + private static readonly List LanguageList = + [ new ComboItem("JPN (日本語)", (int)LanguageID.Japanese), new ComboItem("ENG (English)", (int)LanguageID.English), new ComboItem("FRE (Français)", (int)LanguageID.French), @@ -35,7 +35,7 @@ public sealed class GameDataSource new ComboItem("KOR (한국어)", (int)LanguageID.Korean), new ComboItem("CHS (简体中文)", (int)LanguageID.ChineseS), new ComboItem("CHT (繁體中文)", (int)LanguageID.ChineseT), - }; + ]; public GameDataSource(GameStrings s) { @@ -87,37 +87,37 @@ public GameDataSource(GameStrings s) /// Preferentially ordered list of values to display in a list. /// /// Most recent games are at the top, loosely following Generation groups. - private static ReadOnlySpan OrderedVersionArray => new byte[] - { - 50, 51, // 9 sv - 47, // 8 legends arceus - 48, 49, // 8 bdsp - 44, 45, // 8 swsh - 42, 43, // 7 gg - 30, 31, // 7 sm - 32, 33, // 7 usum - 24, 25, // 6 xy - 27, 26, // 6 oras - 21, 20, // 5 bw - 23, 22, // 5 b2w2 - 10, 11, 12, // 4 dppt - 07, 08, // 4 hgss - 02, 01, 03, // 3 rse - 04, 05, // 3 frlg - 15, // 3 cxd + private static ReadOnlySpan OrderedVersionArray => + [ + 50, 51, // 9 S/V + 47, // 8 PLA + 48, 49, // 8 BD/SP + 44, 45, // 8 SW/SH + 42, 43, // 7 LGP/E + 30, 31, // 7 S/M + 32, 33, // 7 US/UM + 24, 25, // 6 X/Y + 27, 26, // 6 OR/AS + 21, 20, // 5 B/W + 23, 22, // 5 B2/W2 + 10, 11, 12, // 4 D/P/Pt + 07, 08, // 4 HG/SS + 02, 01, 03, // 3 R/S/E + 04, 05, // 3 FR/LG + 15, // 3 Colosseum & XD - 39, 40, 41, // 7vc2 - 35, 36, 37, 38, // 7vc1 + 39, 40, 41, // 7vc2 (Gen2 VC) + 35, 36, 37, 38, // 7vc1 (Gen1 VC) 34, // 7go 00, - }; + ]; - private static IReadOnlyList GetBalls(ReadOnlySpan itemList) => Util.GetVariedCBListBall(itemList, BallStoredIndexes, BallItemIDs); + private static ComboItem[] GetBalls(ReadOnlySpan itemList) => Util.GetVariedCBListBall(itemList, BallStoredIndexes, BallItemIDs); // Since Poké Ball (and Great Ball / Ultra Ball) are most common, any list should have them at the top. The rest can be sorted alphabetically. - private static ReadOnlySpan BallStoredIndexes => new byte[] { 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037 }; - private static ReadOnlySpan BallItemIDs => new ushort[] { 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 576, 851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771 }; + private static ReadOnlySpan BallStoredIndexes => [ 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037 ]; + private static ReadOnlySpan BallItemIDs => [ 004, 003, 002, 001, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 576, 851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771 ]; private static ComboItem[] GetVersionList(GameStrings s) { diff --git a/PKHeX.Core/Game/GameStrings/GameLanguage.cs b/PKHeX.Core/Game/GameStrings/GameLanguage.cs index 3a179bffa..b169f6347 100644 --- a/PKHeX.Core/Game/GameStrings/GameLanguage.cs +++ b/PKHeX.Core/Game/GameStrings/GameLanguage.cs @@ -28,12 +28,12 @@ public static int GetLanguageIndex(string lang) /// Language codes supported for loading string resources /// /// - private static readonly string[] LanguageCodes = { "ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2" }; + private static readonly string[] LanguageCodes = ["ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2"]; /// /// Pokétransporter location names, ordered per index of /// - private static readonly string[] ptransp = { "ポケシフター", "Poké Transfer", "Poké Fret", "Pokétrasporto", "Poképorter", "Pokétransfer", "포케시프터", "宝可传送", "寶可傳送" }; + private static readonly string[] ptransp = ["ポケシフター", "Poké Transfer", "Poké Fret", "Pokétrasporto", "Poképorter", "Pokétransfer", "포케시프터", "宝可传送", "寶可傳送"]; /// /// Gets the Met Location display name for the Pokétransporter. diff --git a/PKHeX.Core/Game/GameStrings/GameStrings.cs b/PKHeX.Core/Game/GameStrings/GameStrings.cs index 2bc229153..372d8aa69 100644 --- a/PKHeX.Core/Game/GameStrings/GameStrings.cs +++ b/PKHeX.Core/Game/GameStrings/GameStrings.cs @@ -42,14 +42,14 @@ public sealed class GameStrings : IBasicStrings /// /// Item IDs that correspond to the value. /// - private static ReadOnlySpan Items_Ball => new ushort[] - { + private static ReadOnlySpan Items_Ball => + [ 0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 0010, 0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494, 0495, 0496, 0497, 0498, 0499, 0576, 0851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771, - }; + ]; internal GameStrings(string l) { @@ -398,11 +398,11 @@ private void SanitizeMetLocations() private void SanitizeMetGen4(LocationSet4 set) { - set.Met0[054] += " (DP/Pt)"; // Victory Road + set.Met0[054] += " (D/P/Pt)"; // Victory Road set.Met0[221] += " (HG/SS)"; // Victory Road // German language duplicate; handle for all since it can be confused. - set.Met0[104] += " (DP/Pt)"; // Vista Lighthouse + set.Met0[104] += " (D/P/Pt)"; // Vista Lighthouse set.Met0[212] += " (HG/SS)"; // Lighthouse set.Met2[1] += $" ({NPC})"; // Anything from an NPC @@ -411,10 +411,10 @@ private void SanitizeMetGen4(LocationSet4 set) private void SanitizeMetGen5(LocationSet6 set) { - set.Met0[36] = $"{set.Met0[84]}/{set.Met0[36]}"; // Cold Storage in BW = PWT in BW2 - set.Met0[40] += " (B/W)"; // Victory Road in BW - set.Met0[134] += " (B2/W2)"; // Victory Road in B2W2 - // BW2 Entries from 76 to 105 are for Entralink in BW + set.Met0[36] = $"{set.Met0[84]}/{set.Met0[36]}"; // Cold Storage in B/W = PWT in B2/W2 + set.Met0[40] += " (B/W)"; // Victory Road in B/W + set.Met0[134] += " (B2/W2)"; // Victory Road in B2/W2 + // B2/W2 Entries from 76 to 105 are for Entralink in B/W for (int i = 76; i < 106; i++) set.Met0[i] += "●"; @@ -513,7 +513,7 @@ private void SanitizeMetGen8(LocationSet6 set) for (int i = 55; i < 61; i++) // distinguish Event year duplicates set.Met4[i] += " (-)"; - set.Met4[30] += " (-)"; // a Video game Event (in spanish etc) -- duplicate with line 39 + set.Met4[30] += " (-)"; // a Video game Event (in spanish etc.) -- duplicate with line 39 set.Met4[53] += " (-)"; // a Pokémon event -- duplicate with line 37 set.Met4[81] += " (-)"; // Pokémon GO -- duplicate with 30000's entry @@ -542,7 +542,7 @@ private void SanitizeMetGen8a(LocationSet6 set) set.Met3[i] += " (-)"; set.Met3[19] += " (?)"; // Kanto for the third time - set.Met4[30] += " (-)"; // a Video game Event (in spanish etc) -- duplicate with line 39 + set.Met4[30] += " (-)"; // a Video game Event (in spanish etc.) -- duplicate with line 39 set.Met4[53] += " (-)"; // a Pokémon event -- duplicate with line 37 set.Met4[81] += " (-)"; // Pokémon GO -- duplicate with 30000's entry @@ -622,7 +622,7 @@ private void SanitizeMetGen9(LocationSet6 set) for (int i = 49; i <= 54; i++) // distinguish Event year duplicates set.Met4[i] += " (-)"; - set.Met4[27] += " (-)"; // a Video game Event (in spanish etc) -- duplicate with line 36 + set.Met4[27] += " (-)"; // a Video game Event (in spanish etc.) -- duplicate with line 36 set.Met4[48] += " (-)"; // a Pokémon event -- duplicate with line 34 set.Met4[73] += " (-)"; // Pokémon GO -- duplicate with 30000's entry @@ -736,7 +736,7 @@ private string[] GetItemStrings3(GameVersion game) /// Current /// of origin /// Current GameVersion (only applicable for differentiation) - /// Location name. May be an empty string if no location name is known for that location value. + /// Location name. Potentially an empty string if no location name is known for that location value. public string GetLocationName(bool isEggLocation, int location, int format, int generation, GameVersion version) { if (format == 1) @@ -803,7 +803,7 @@ public ReadOnlySpan GetLocationNames(int gen, GameVersion version, int b { var set = GetLocations(gen, version); if (set is null) - return Array.Empty(); + return []; return set.GetLocationNames(bankID); } } diff --git a/PKHeX.Core/Game/GameStrings/GeoLocation.cs b/PKHeX.Core/Game/GameStrings/GeoLocation.cs index 83e5e720f..a30f391c7 100644 --- a/PKHeX.Core/Game/GameStrings/GeoLocation.cs +++ b/PKHeX.Core/Game/GameStrings/GeoLocation.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; public static class GeoLocation { private static readonly string[]?[] CountryList = GetCountryList(); - private static readonly string[] lang_geo = { "ja", "en", "fr", "de", "it", "es", "zh", "ko", "zh2" }; + private static readonly string[] lang_geo = ["ja", "en", "fr", "de", "it", "es", "zh", "ko", "zh2"]; private static readonly string[]?[]?[] RegionList = new string[CountryList.Length][][]; /// diff --git a/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet0.cs b/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet0.cs index 0c2d4b0d8..4a143c6ff 100644 --- a/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet0.cs +++ b/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet0.cs @@ -8,7 +8,7 @@ public sealed record LocationSet0(string[] Met0) : ILocationSet public ReadOnlySpan GetLocationNames(int bankID) => bankID switch { 0 => Met0, - _ => Array.Empty(), + _ => [], }; public string GetLocationName(int locationID) diff --git a/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet4.cs b/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet4.cs index a4135e223..4f195e280 100644 --- a/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet4.cs +++ b/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet4.cs @@ -10,7 +10,7 @@ public sealed record LocationSet4(string[] Met0, string[] Met2, string[] Met3) : 0 => Met0, 2 => Met2, 3 => Met3, - _ => Array.Empty(), + _ => [], }; public string GetLocationName(int locationID) => locationID switch diff --git a/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet6.cs b/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet6.cs index bbb26c223..4e9015f29 100644 --- a/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet6.cs +++ b/PKHeX.Core/Game/GameStrings/LocationSet/LocationSet6.cs @@ -11,7 +11,7 @@ public sealed record LocationSet6(string[] Met0, string[] Met3, string[] Met4, s 3 => Met3, 4 => Met4, 6 => Met6, - _ => Array.Empty(), + _ => [], }; public string GetLocationName(int locationID) => locationID switch diff --git a/PKHeX.Core/Game/GameStrings/MetDataSource.cs b/PKHeX.Core/Game/GameStrings/MetDataSource.cs index e41f51433..d682b90da 100644 --- a/PKHeX.Core/Game/GameStrings/MetDataSource.cs +++ b/PKHeX.Core/Game/GameStrings/MetDataSource.cs @@ -9,40 +9,24 @@ namespace PKHeX.Core; /// /// Cached copies of Met Location lists /// -public sealed class MetDataSource +public sealed class MetDataSource(GameStrings s) { - private readonly List MetGen2; - private readonly List MetGen3; - private readonly List MetGen3CXD; - private readonly List MetGen4; - private readonly List MetGen5; - private readonly List MetGen6; - private readonly List MetGen7; - private readonly List MetGen7GG; - private readonly List MetGen8; - private readonly List MetGen8a; - private readonly List MetGen8b; - private readonly List MetGen9; + private readonly List MetGen2 = CreateGen2(s); + private readonly List MetGen3 = CreateGen3(s); + private readonly List MetGen3CXD = CreateGen3CXD(s); + private readonly List MetGen4 = CreateGen4(s); + private readonly List MetGen5 = CreateGen5(s); + private readonly List MetGen6 = CreateGen6(s); + private readonly List MetGen7 = CreateGen7(s); + private readonly List MetGen7GG = CreateGen7GG(s); + private readonly List MetGen8 = CreateGen8(s); + private readonly List MetGen8a = CreateGen8a(s); + private readonly List MetGen8b = CreateGen8b(s); + private readonly List MetGen9 = CreateGen9(s); private IReadOnlyList? MetGen4Transfer; private IReadOnlyList? MetGen5Transfer; - public MetDataSource(GameStrings s) - { - MetGen2 = CreateGen2(s); - MetGen3 = CreateGen3(s); - MetGen3CXD = CreateGen3CXD(s); - MetGen4 = CreateGen4(s); - MetGen5 = CreateGen5(s); - MetGen6 = CreateGen6(s); - MetGen7 = CreateGen7(s); - MetGen7GG = CreateGen7GG(s); - MetGen8 = CreateGen8(s); - MetGen8a = CreateGen8a(s); - MetGen8b = CreateGen8b(s); - MetGen9 = CreateGen9(s); - } - private static List CreateGen2(GameStrings s) { var locations = Util.GetCBList(s.Gen2.Met0.AsSpan(0, 0x5F)); @@ -76,7 +60,7 @@ private static List CreateGen4(GameStrings s) return locations; } - private IReadOnlyList CreateGen4Transfer() + private ComboItem[] CreateGen4Transfer() { // Pal Park to front var met = MetGen4.ToArray(); @@ -99,7 +83,7 @@ private static List CreateGen5(GameStrings s) return locations; } - private IReadOnlyList CreateGen5Transfer() + private ComboItem[] CreateGen5Transfer() { // PokéTransfer to front var index = MetGen5.FindIndex(static z => z.Value == Locations.Transfer4); @@ -231,7 +215,7 @@ public IReadOnlyList GetLocationList(GameVersion version, EntityConte else result = GetLocationListInternal(version, context); - // Insert the BDSP none location if the format requires it. + // Insert the BD/SP none location if the format requires it. if (context is EntityContext.Gen8b && !BDSP.Contains(version)) { var bdsp = new ComboItem[result.Count + 1]; @@ -323,6 +307,6 @@ static void ReorderList(Span list, Span result, Func MetGen4Transfer ??= CreateGen4Transfer(), < X when context.Generation() >= 5 => MetGen5Transfer ??= CreateGen5Transfer(), - _ => Array.Empty(), + _ => [], }; } diff --git a/PKHeX.Core/Game/GameUtil.cs b/PKHeX.Core/Game/GameUtil.cs index aef1582a4..b6f2f91bf 100644 --- a/PKHeX.Core/Game/GameUtil.cs +++ b/PKHeX.Core/Game/GameUtil.cs @@ -224,7 +224,7 @@ public static bool Contains(this GameVersion g1, GameVersion g2) public static GameVersion[] GetVersionsInGeneration(int generation, int pkVersion) { if (Gen7b.Contains(pkVersion)) - return new[] {GO, GP, GE}; + return [GO, GP, GE]; return Array.FindAll(GameVersions, z => z.GetGeneration() == generation); } @@ -232,7 +232,7 @@ public static GameVersion[] GetVersionsInGeneration(int generation, int pkVersio /// List of possible values within the provided criteria. /// /// Criteria for retrieving versions - /// Generation format minimum (necessary for the CXD/Gen4 swap etc) + /// Generation format minimum (necessary for the CXD/Gen4 swap etc.) public static IEnumerable GetVersionsWithinRange(IGameValueLimit obj, int generation = -1) { var max = obj.MaxGameID; diff --git a/PKHeX.Core/Game/Locations/Locations4.cs b/PKHeX.Core/Game/Locations/Locations4.cs index df7779bd8..6b72a537e 100644 --- a/PKHeX.Core/Game/Locations/Locations4.cs +++ b/PKHeX.Core/Game/Locations/Locations4.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class Locations4 { - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, @@ -30,17 +30,17 @@ internal static class Locations4 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, - }; + ]; // Ignore the --- met location at index 7. - public static ReadOnlySpan Met2 => new ushort[] - { + public static ReadOnlySpan Met2 => + [ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013, 2014, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, @@ -49,5 +49,5 @@ internal static class Locations4 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, - }; + ]; } diff --git a/PKHeX.Core/Game/Locations/Locations5.cs b/PKHeX.Core/Game/Locations/Locations5.cs index c173aa561..1ce69735a 100644 --- a/PKHeX.Core/Game/Locations/Locations5.cs +++ b/PKHeX.Core/Game/Locations/Locations5.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class Locations5 { - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 001, 002, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, @@ -22,17 +22,17 @@ internal static class Locations5 130, 131, 132, 133, 134, 135, 136, 137, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30002, 30004, 30005, 30006, 30007, 30008, 30010, 30011, 30012, 30013, 30014, 30015, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { - 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, + public static ReadOnlySpan Met4 => + [ + 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, @@ -43,7 +43,7 @@ internal static class Locations5 40080, 40081, 40082, 40083, 40084, 40085, 40086, 40087, 40088, 40089, 40090, 40091, 40092, 40093, 40094, 40095, 40096, 40097, 40098, 40099, 40100, 40101, 40102, 40103, 40104, 40105, 40106, 40107, 40108, 40109, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] { 60001, 60003 }; + public static ReadOnlySpan Met6 => [60001, 60003]; } diff --git a/PKHeX.Core/Game/Locations/Locations6.cs b/PKHeX.Core/Game/Locations/Locations6.cs index 5d467a0a1..e70d36356 100644 --- a/PKHeX.Core/Game/Locations/Locations6.cs +++ b/PKHeX.Core/Game/Locations/Locations6.cs @@ -4,9 +4,9 @@ namespace PKHeX.Core; internal static class Locations6 { - public static ReadOnlySpan Met0 => new ushort[] - { - /* XY */ + public static ReadOnlySpan Met0 => + [ + /* X/Y */ 002, 006, 008, 010, 012, 014, 016, 018, 020, 022, 024, 026, 028, @@ -25,7 +25,7 @@ internal static class Locations6 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, - /* ORAS */ + /* OR/AS */ 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, @@ -45,16 +45,16 @@ internal static class Locations6 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { + public static ReadOnlySpan Met4 => + [ 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, @@ -63,7 +63,7 @@ internal static class Locations6 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004]; } diff --git a/PKHeX.Core/Game/Locations/Locations7.cs b/PKHeX.Core/Game/Locations/Locations7.cs index 66a74cd32..c713ebcd6 100644 --- a/PKHeX.Core/Game/Locations/Locations7.cs +++ b/PKHeX.Core/Game/Locations/Locations7.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class Locations7 { - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 002, 004, 006, 008, 010, 012, 014, 016, 018, 020, 022, 024, 026, 028, @@ -30,16 +30,16 @@ internal static class Locations7 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { + public static ReadOnlySpan Met4 => + [ 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, @@ -49,7 +49,7 @@ internal static class Locations7 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081, 40082, 40083, 40084, 40085, 40086, 40087, 40088, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004]; } diff --git a/PKHeX.Core/Game/Locations/Locations7b.cs b/PKHeX.Core/Game/Locations/Locations7b.cs index 6d09f2575..c8c7d96ec 100644 --- a/PKHeX.Core/Game/Locations/Locations7b.cs +++ b/PKHeX.Core/Game/Locations/Locations7b.cs @@ -4,24 +4,24 @@ namespace PKHeX.Core; internal static class Locations7b { - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { + public static ReadOnlySpan Met4 => + [ 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, @@ -30,7 +30,7 @@ internal static class Locations7b 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004]; } diff --git a/PKHeX.Core/Game/Locations/Locations8.cs b/PKHeX.Core/Game/Locations/Locations8.cs index c55cdbdd5..cf005fee1 100644 --- a/PKHeX.Core/Game/Locations/Locations8.cs +++ b/PKHeX.Core/Game/Locations/Locations8.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class Locations8 { - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 002, 004, 006, 008, 012, 014, 016, 018, 020, 022, 024, 028, @@ -31,26 +31,26 @@ internal static class Locations8 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { - 40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009, - 40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019, - 40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029, + public static ReadOnlySpan Met4 => + [ + 40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009, + 40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019, + 40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, - 40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049, - 40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059, - 40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069, - 40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079, + 40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049, + 40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059, + 40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069, + 40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081, 40082, 40083, 40084, 40085, 40086, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004]; } diff --git a/PKHeX.Core/Game/Locations/Locations8a.cs b/PKHeX.Core/Game/Locations/Locations8a.cs index 8214f89f3..e1f871f32 100644 --- a/PKHeX.Core/Game/Locations/Locations8a.cs +++ b/PKHeX.Core/Game/Locations/Locations8a.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class Locations8a { - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 000, 002, 004, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, @@ -22,27 +22,27 @@ internal static class Locations8a 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30002, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30021, 30022, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { - 40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009, - 40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019, - 40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029, - 40030, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, - 40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049, - 40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059, - 40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069, - 40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079, + public static ReadOnlySpan Met4 => + [ + 40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009, + 40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019, + 40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029, + 40030, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, + 40040, 40041, 40042, 40043, 40044, 40045, 40047, 40048, 40049, + 40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059, + 40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069, + 40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081, 40082, 40083, 40084, 40085, 40086, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004]; } diff --git a/PKHeX.Core/Game/Locations/Locations8b.cs b/PKHeX.Core/Game/Locations/Locations8b.cs index 5a2c6d8d2..60306e0bd 100644 --- a/PKHeX.Core/Game/Locations/Locations8b.cs +++ b/PKHeX.Core/Game/Locations/Locations8b.cs @@ -7,8 +7,8 @@ internal static class Locations8b public static bool IsUnderground(ushort location) => location is (>= 508 and <= 617); public static bool IsMarsh(ushort location) => location is (>= 219 and <= 224); - public static ReadOnlySpan Met0 => new ushort[] - { + public static ReadOnlySpan Met0 => + [ 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, @@ -77,17 +77,17 @@ internal static class Locations8b // Ramanas Park rooms with lights out 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30003, 30004, 30005, 30006, 30007, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30022, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { + public static ReadOnlySpan Met4 => + [ 40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029, @@ -96,7 +96,7 @@ internal static class Locations8b 40050, 40051, 40052, 40053, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40074, 40075, 40076, 40077, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004, /* BDSP */ 60005, 60006, 60007, 60010 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004, /* BD/SP */ 60005, 60006, 60007, 60010]; } diff --git a/PKHeX.Core/Game/Locations/Locations9.cs b/PKHeX.Core/Game/Locations/Locations9.cs index 5b3d2518b..039f1dc22 100644 --- a/PKHeX.Core/Game/Locations/Locations9.cs +++ b/PKHeX.Core/Game/Locations/Locations9.cs @@ -14,8 +14,8 @@ internal static class Locations9 /// public static bool IsKitakami(ushort location) => location is (>= 132 and <= 170); - public static ReadOnlySpan Met0 => new byte[] - { + public static ReadOnlySpan Met0 => + [ 002, 004, 006, 008, 010, 012, 014, 016, 018, 020, 022, 024, 026, 028, @@ -37,17 +37,17 @@ internal static class Locations9 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, - }; + ]; - public static ReadOnlySpan Met3 => new ushort[] - { + public static ReadOnlySpan Met3 => + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30021, 30022, 30023, 30024, - }; + ]; - public static ReadOnlySpan Met4 => new ushort[] - { + public static ReadOnlySpan Met4 => + [ 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40024, 40024, 40025, 40026, 40027, 40028, 40029, @@ -56,7 +56,7 @@ internal static class Locations9 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, - }; + ]; - public static ReadOnlySpan Met6 => new ushort[] {/* XY */ 60001, 60003, /* ORAS */ 60004, /* SV */ 60005 }; + public static ReadOnlySpan Met6 => [/* X/Y */ 60001, 60003, /* OR/AS */ 60004, /* S/V */ 60005]; } diff --git a/PKHeX.Core/Game/Locations/LocationsHOME.cs b/PKHeX.Core/Game/Locations/LocationsHOME.cs index 47a69cc43..1223db80e 100644 --- a/PKHeX.Core/Game/Locations/LocationsHOME.cs +++ b/PKHeX.Core/Game/Locations/LocationsHOME.cs @@ -18,7 +18,7 @@ public static class LocationsHOME public const ushort SWSHEgg = 65534; // -2 = 8bNone-1.. /// - /// Gets the external entity version needs to be remapped into a SW/SH location. + /// Gets the external entity version needs to be remapped into a location for SW/SH. /// /// /// True if a known remap exists. @@ -100,7 +100,7 @@ public static ushort GetLocationSWSHEgg(int ver, ushort egg) /// /// Checks if the met location is a valid location for the input . /// - /// Relevant when a BD/SP entity is transferred to SW/SH. + /// Relevant when an entity from BD/SP is transferred to SW/SH. public static bool IsValidMetBDSP(ushort loc, int ver) => loc switch { SHSP when ver == (int)GameVersion.SH => true, @@ -111,7 +111,7 @@ public static ushort GetLocationSWSHEgg(int ver, ushort egg) /// /// Checks if the met location is a valid location for the input . /// - /// Relevant when a S/V entity is transferred to SW/SH. + /// Relevant when an entity from S/V is transferred to SW/SH. public static bool IsValidMetSV(ushort loc, int ver) => loc switch { SHVL when ver == (int)GameVersion.SH => true, diff --git a/PKHeX.Core/Items/HeldItemLumpImage.cs b/PKHeX.Core/Items/HeldItemLumpImage.cs index 60f7442c6..87e89c955 100644 --- a/PKHeX.Core/Items/HeldItemLumpImage.cs +++ b/PKHeX.Core/Items/HeldItemLumpImage.cs @@ -22,7 +22,7 @@ public enum HeldItemLumpImage } /// -/// Logic to check if a held item should how a lumped image sprite. +/// Logic to check if a held item should show a lumped image sprite. /// public static class HeldItemLumpUtil { @@ -41,8 +41,8 @@ public static class HeldItemLumpUtil /// Evaluation result. public static HeldItemLumpImage GetIsLump(int item, EntityContext context) => context.Generation() switch { - <= 4 when item is (>= 0328 and <= 0419) => HeldItemLumpImage.TechnicalMachine, // gen2/3/4 TM - 8 when item is (>= 0328 and <= 0427) => HeldItemLumpImage.TechnicalMachine, // BDSP TMs + <= 4 when item is (>= 0328 and <= 0419) => HeldItemLumpImage.TechnicalMachine, // Gen2/3/4 TM + 8 when item is (>= 0328 and <= 0427) => HeldItemLumpImage.TechnicalMachine, // BD/SP TMs 8 when item is (>= 1130 and <= 1229) => HeldItemLumpImage.TechnicalRecord, // Gen8 TR 9 when item is (>= 0328 and <= 0419) // TM01-TM92 or (>= 0618 and <= 0620) // TM093-TM095 diff --git a/PKHeX.Core/Items/ItemStorage1.cs b/PKHeX.Core/Items/ItemStorage1.cs index 3881b4a1a..806d043b7 100644 --- a/PKHeX.Core/Items/ItemStorage1.cs +++ b/PKHeX.Core/Items/ItemStorage1.cs @@ -7,8 +7,8 @@ public sealed class ItemStorage1 : IItemStorage public static readonly ItemStorage1 Instance = new(); private ItemStorage1() { } - private static ReadOnlySpan Pouch_Items_RBY => new ushort[] - { + private static ReadOnlySpan Pouch_Items_RBY => + [ 000,001,002,003,004,005,006, 010,011,012,013,014,015, 016,017,018,019,020, 029,030,031, 032,033,034,035,036,037,038,039,040,041,042,043, 045,046,047, @@ -22,7 +22,7 @@ public sealed class ItemStorage1 : IItemStorage 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, 240,241,242,243,244,245,246,247,248,249,250, - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage2.cs b/PKHeX.Core/Items/ItemStorage2.cs index b845048d4..bc0861cb1 100644 --- a/PKHeX.Core/Items/ItemStorage2.cs +++ b/PKHeX.Core/Items/ItemStorage2.cs @@ -10,8 +10,8 @@ public sealed class ItemStorage2 : IItemStorage private readonly bool Crystal; private ItemStorage2(bool crystal) => Crystal = crystal; - private static ReadOnlySpan Pouch_Items_GSC => new ushort[] - { + private static ReadOnlySpan Pouch_Items_GSC => + [ 003, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 026, 027, 028, 029, @@ -31,39 +31,39 @@ public sealed class ItemStorage2 : IItemStorage 163, 167, 168, 169, 170, 172, 173, 174, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, - }; + ]; - private static ReadOnlySpan Pouch_Ball_GSC => new ushort[] - { + private static ReadOnlySpan Pouch_Ball_GSC => + [ 1, 2, 4, 5, 157, 159, 160, 161, 164, 165, 166, - }; + ]; - private static ReadOnlySpan Pouch_Key_GS => new ushort[] - { + private static ReadOnlySpan Pouch_Key_GS => + [ 007, 054, 055, 058, 059, 061, 066, 067, 068, 069, 071, 127, 128, 130, 133, 134, 175, 178, - }; + ]; private const int ExtraKeyCrystal = 4; - private static ReadOnlySpan Pouch_Key_C => new ushort[] - { + private static ReadOnlySpan Pouch_Key_C => + [ 007, 054, 055, 058, 059, 061, 066, 067, 068, 069, 071, 127, 128, 130, 133, 134, 175, 178, 070, 115, 116, 129, - }; + ]; - private static ReadOnlySpan Pouch_TMHM_GSC => new ushort[] - { + private static ReadOnlySpan Pouch_TMHM_GSC => + [ 191, 192, 193, 194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - }; + ]; - public static ushort[] GetAllHeld() => ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC); + public static ushort[] GetAllHeld() => [..Pouch_Items_GSC, ..Pouch_Ball_GSC, ..Pouch_TMHM_GSC]; - private static readonly ushort[] PCItemsC = ArrayUtil.ConcatAll(Pouch_Items_GSC, Pouch_Ball_GSC, Pouch_TMHM_GSC, Pouch_Key_C); + private static readonly ushort[] PCItemsC = [..Pouch_Items_GSC, ..Pouch_Ball_GSC, ..Pouch_TMHM_GSC, ..Pouch_Key_C]; private static ReadOnlySpan PCItemsGS => PCItemsC.AsSpan(..^ExtraKeyCrystal); diff --git a/PKHeX.Core/Items/ItemStorage3Colo.cs b/PKHeX.Core/Items/ItemStorage3Colo.cs index 0d97fa101..a2d527e13 100644 --- a/PKHeX.Core/Items/ItemStorage3Colo.cs +++ b/PKHeX.Core/Items/ItemStorage3Colo.cs @@ -6,23 +6,23 @@ public sealed class ItemStorage3Colo : IItemStorage { public static readonly ItemStorage3Colo Instance = new(); - private static ReadOnlySpan Pouch_Cologne_COLO => new ushort[] { 543, 544, 545 }; + private static ReadOnlySpan Pouch_Cologne_COLO => [543, 544, 545]; - private static ReadOnlySpan Pouch_Items_COLO => new ushort[] - { + private static ReadOnlySpan Pouch_Items_COLO => + [ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, 537, // Time Flute - }; + ]; - private static ReadOnlySpan Pouch_Key_COLO => new ushort[] - { + private static ReadOnlySpan Pouch_Key_COLO => + [ 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 538, 539, 540, 541, 542, 546, 547, - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage3E.cs b/PKHeX.Core/Items/ItemStorage3E.cs index c628ee15f..eff87c479 100644 --- a/PKHeX.Core/Items/ItemStorage3E.cs +++ b/PKHeX.Core/Items/ItemStorage3E.cs @@ -1,4 +1,5 @@ using System; +using static PKHeX.Core.ItemStorage3RS; namespace PKHeX.Core; @@ -6,28 +7,27 @@ public sealed class ItemStorage3E : IItemStorage { public static readonly ItemStorage3E Instance = new(); - private static ReadOnlySpan Pouch_Key_E => new ushort[] - { + private static ReadOnlySpan Pouch_Key_E => + [ // R/S 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, // FR/LG 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, // E 375, 376, - }; + ]; - private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(ItemStorage3RS.Pouch_Items_RS, Pouch_Key_E, - ItemStorage3RS.Pouch_Ball_RS, ItemStorage3RS.Pouch_TMHM_RS, ItemStorage3RS.Pouch_Berries_RS); + private static readonly ushort[] PCItems = [..Pouch_Items_RS, ..Pouch_Key_E, ..Pouch_Ball_RS, ..Pouch_TMHM_RS, ..Pouch_Berries_RS]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; public ReadOnlySpan GetItems(InventoryType type) => type switch { - InventoryType.Items => ItemStorage3RS.Pouch_Items_RS, + InventoryType.Items => Pouch_Items_RS, InventoryType.KeyItems => Pouch_Key_E, - InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, - InventoryType.TMHMs => ItemStorage3RS.Pouch_TMHM_RS, - InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS, + InventoryType.Balls => Pouch_Ball_RS, + InventoryType.TMHMs => Pouch_TMHM_RS, + InventoryType.Berries => Pouch_Berries_RS, InventoryType.PCItems => PCItems, _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), }; diff --git a/PKHeX.Core/Items/ItemStorage3FRLG.cs b/PKHeX.Core/Items/ItemStorage3FRLG.cs index 03ea39770..e037f9867 100644 --- a/PKHeX.Core/Items/ItemStorage3FRLG.cs +++ b/PKHeX.Core/Items/ItemStorage3FRLG.cs @@ -1,4 +1,5 @@ using System; +using static PKHeX.Core.ItemStorage3RS; namespace PKHeX.Core; @@ -6,26 +7,25 @@ public sealed class ItemStorage3FRLG : IItemStorage { public static readonly ItemStorage3FRLG Instance = new(); - private static ReadOnlySpan Pouch_Key_FRLG => new ushort[] - { + private static ReadOnlySpan Pouch_Key_FRLG => + [ // R/S 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, // FR/LG 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - }; + ]; - private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(ItemStorage3RS.Pouch_Items_RS, Pouch_Key_FRLG, - ItemStorage3RS.Pouch_Ball_RS, ItemStorage3RS.Pouch_TMHM_RS, ItemStorage3RS.Pouch_Berries_RS); + private static readonly ushort[] PCItems = [..Pouch_Items_RS, ..Pouch_Key_FRLG, ..Pouch_Ball_RS, ..Pouch_TMHM_RS, ..Pouch_Berries_RS]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; public ReadOnlySpan GetItems(InventoryType type) => type switch { - InventoryType.Items => ItemStorage3RS.Pouch_Items_RS, + InventoryType.Items => Pouch_Items_RS, InventoryType.KeyItems => Pouch_Key_FRLG, - InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, - InventoryType.TMHMs => ItemStorage3RS.Pouch_TMHM_RS, - InventoryType.Berries => ItemStorage3RS.Pouch_Berries_RS, + InventoryType.Balls => Pouch_Ball_RS, + InventoryType.TMHMs => Pouch_TMHM_RS, + InventoryType.Berries => Pouch_Berries_RS, InventoryType.PCItems => PCItems, _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), }; diff --git a/PKHeX.Core/Items/ItemStorage3RS.cs b/PKHeX.Core/Items/ItemStorage3RS.cs index ee9e60d09..09f8ef165 100644 --- a/PKHeX.Core/Items/ItemStorage3RS.cs +++ b/PKHeX.Core/Items/ItemStorage3RS.cs @@ -6,21 +6,21 @@ public sealed class ItemStorage3RS : IItemStorage { public static readonly ItemStorage3RS Instance = new(); - internal static ReadOnlySpan Pouch_Items_RS => new ushort[] - { + internal static ReadOnlySpan Pouch_Items_RS => + [ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, - }; + ]; - private static ReadOnlySpan Pouch_Key_RS => new ushort[] - { + private static ReadOnlySpan Pouch_Key_RS => + [ 259, 260, 261, 262, 263, 264, 265, 266, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, - }; + ]; private const int COUNT_TM = 50; private const int COUNT_HM = 8; - internal static ReadOnlySpan Pouch_TMHM_RS => new ushort[] - { + internal static ReadOnlySpan Pouch_TMHM_RS => + [ 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, @@ -29,7 +29,7 @@ public sealed class ItemStorage3RS : IItemStorage // HMs 339, 340, 341, 342, 343, 344, 345, 346, - }; + ]; internal static ReadOnlySpan Pouch_TM_RS => Pouch_TMHM_RS[..COUNT_TM]; @@ -37,24 +37,25 @@ public sealed class ItemStorage3RS : IItemStorage public static bool IsTM(ushort itemID) => itemID - 289u < COUNT_TM; public static bool IsHM(ushort itemID) => itemID - 339u < COUNT_HM; - internal static ReadOnlySpan Pouch_Berries_RS => new ushort[] - { - 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - }; + internal static ReadOnlySpan Pouch_Berries_RS => + [ + 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, + ]; - internal static ReadOnlySpan Pouch_Ball_RS => new ushort[] - { + internal static ReadOnlySpan Pouch_Ball_RS => + [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - }; + ]; - internal static ReadOnlySpan Unreleased => new ushort[] { 005 }; // Safari Ball + internal static ReadOnlySpan Unreleased => [005]; // Safari Ball - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Ball_RS, Pouch_Berries_RS, Pouch_TMHM_RS[..^COUNT_HM]); - } + public static ushort[] GetAllHeld() => [..Pouch_Items_RS, ..Pouch_Ball_RS, ..Pouch_Berries_RS, ..Pouch_TMHM_RS[..^COUNT_HM]]; - private static readonly ushort[] PCItems = ArrayUtil.ConcatAll(Pouch_Items_RS, Pouch_Key_RS, Pouch_Ball_RS, Pouch_TMHM_RS, Pouch_Berries_RS); + private static readonly ushort[] PCItems = [..Pouch_Items_RS, ..Pouch_Key_RS, .. Pouch_Berries_RS, ..Pouch_Ball_RS, ..Pouch_TMHM_RS]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage3XD.cs b/PKHeX.Core/Items/ItemStorage3XD.cs index 40df0d71d..6a419e6fb 100644 --- a/PKHeX.Core/Items/ItemStorage3XD.cs +++ b/PKHeX.Core/Items/ItemStorage3XD.cs @@ -6,39 +6,58 @@ public sealed class ItemStorage3XD : IItemStorage { public static readonly ItemStorage3XD Instance = new(); - private static ReadOnlySpan Pouch_Cologne_XD => new ushort[] { 513, 514, 515 }; - private static ReadOnlySpan Pouch_Items_XD => new ushort[] - { - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 84, 85, 86, 93, 94, 95, 96, 97, 98, 103, 104, 106, 107, 108, 109, 110, 111, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 254, 255, 256, 257, 258, + private static ReadOnlySpan Pouch_Cologne_XD => [513, 514, 515]; + private static ReadOnlySpan Pouch_Items_XD => + [ + 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, + 63, 64, 65, 66, 67, 68, 69, + 70, 71, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 83, 84, 85, 86, + 93, 94, 95, 96, 97, 98, + + 103, 104, 106, 107, 108, 109, + 110, 111, + 121, 122, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, + 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, + 254, 255, 256, 257, 258, // XD Additions 511, // Poké Snack - }; + ]; - private static ReadOnlySpan Pouch_Key_XD => new ushort[] - { + private static ReadOnlySpan Pouch_Key_XD => + [ 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 512, 516, 517, 518, 519, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, - }; + ]; - private static ReadOnlySpan Pouch_Disc_XD => new ushort[] - { - 534, 535, 536, 537, 538, 539, + private static ReadOnlySpan Pouch_Disc_XD => + [ + 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; public ReadOnlySpan GetItems(InventoryType type) => type switch { - InventoryType.Items => Pouch_Items_XD, InventoryType.KeyItems => Pouch_Key_XD, InventoryType.Balls => ItemStorage3RS.Pouch_Ball_RS, diff --git a/PKHeX.Core/Items/ItemStorage4.cs b/PKHeX.Core/Items/ItemStorage4.cs index 8de8f6e7c..f7b4a132b 100644 --- a/PKHeX.Core/Items/ItemStorage4.cs +++ b/PKHeX.Core/Items/ItemStorage4.cs @@ -4,24 +4,65 @@ namespace PKHeX.Core; public abstract class ItemStorage4 { - private protected static ReadOnlySpan Pouch_Items_DP => new ushort[] - { - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, - }; + private protected static ReadOnlySpan Pouch_Items_DP => + [ + 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - private protected static ReadOnlySpan Pouch_Items_Pt => new ushort[] - { - // Adds Griseous Orb - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 135, 136, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, - }; + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, + 135, 136, + 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, + ]; - private protected static ReadOnlySpan Pouch_Key_DP => new ushort[] - { - 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, - }; + private protected static ReadOnlySpan Pouch_Items_Pt => + [ + 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - private protected static ReadOnlySpan Pouch_TMHM_DP => new ushort[] - { + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, // Griseous Orb Added + 135, 136, + 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, + ]; + + private protected static ReadOnlySpan Pouch_Key_DP => + [ + 428, 429, + 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, + 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, + 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, + 460, 461, 462, 463, 464, + ]; + + private protected static ReadOnlySpan Pouch_TMHM_DP => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -35,43 +76,54 @@ public abstract class ItemStorage4 // HMs 420, 421, 422, 423, 424, 425, 426, 427, - }; + ]; - private protected static ReadOnlySpan Pouch_Mail_DP => new ushort[] - { + private protected static ReadOnlySpan Pouch_Mail_DP => + [ 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, - }; + ]; - private protected static ReadOnlySpan Pouch_Medicine_DP => new ushort[] - { - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - }; + private protected static ReadOnlySpan Pouch_Medicine_DP => + [ + 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, + ]; - private protected static ReadOnlySpan Pouch_Berries_DP => new ushort[] - { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - }; + private protected static ReadOnlySpan Pouch_Berries_DP => + [ + 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, + ]; - private protected static ReadOnlySpan Pouch_Ball_DP => new ushort[] - { + private protected static ReadOnlySpan Pouch_Ball_DP => + [ 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - }; + ]; - private protected static ReadOnlySpan Pouch_Battle_DP => new ushort[] - { + private protected static ReadOnlySpan Pouch_Battle_DP => + [ // Stat Ups 55, 56, 57, 58, 59, 60, 61, 62, // In-Battle Use 63, 64, 65, 66, 67, - }; + ]; - internal static ReadOnlySpan Unreleased => new ushort[] - { + internal static ReadOnlySpan Unreleased => + [ 005, // Safari Ball 016, // Cherish Ball 147, // Mosaic Mail 499, // Sport Ball 500, // Park Ball - }; + ]; } diff --git a/PKHeX.Core/Items/ItemStorage4DP.cs b/PKHeX.Core/Items/ItemStorage4DP.cs index 95c051cd1..178ab12e8 100644 --- a/PKHeX.Core/Items/ItemStorage4DP.cs +++ b/PKHeX.Core/Items/ItemStorage4DP.cs @@ -6,10 +6,7 @@ public sealed class ItemStorage4DP : ItemStorage4, IItemStorage { public static readonly ItemStorage4DP Instance = new(); - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Items_DP, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]); - } + public static ushort[] GetAllHeld() => [..Pouch_Items_DP, ..Pouch_Mail_DP, ..Pouch_Medicine_DP, ..Pouch_Berries_DP, ..Pouch_Ball_DP, ..Pouch_TMHM_DP[..^8]]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage4HGSS.cs b/PKHeX.Core/Items/ItemStorage4HGSS.cs index 9d64a544b..391069ba6 100644 --- a/PKHeX.Core/Items/ItemStorage4HGSS.cs +++ b/PKHeX.Core/Items/ItemStorage4HGSS.cs @@ -6,15 +6,23 @@ public sealed class ItemStorage4HGSS : ItemStorage4, IItemStorage { public static readonly ItemStorage4HGSS Instance = new(); - private static ReadOnlySpan Pouch_Key_HGSS => new ushort[] - { - 434, 435, 437, 444, 445, 446, 447, 450, 456, 464, 465, 466, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 501, 502, 503, 504, 532, 533, 534, 535, 536, - }; + private static ReadOnlySpan Pouch_Key_HGSS => + [ + 434, 435, 437, + 444, 445, 446, 447, + 450, 456, + 464, 465, 466, 468, 469, + 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, + 480, 481, 482, 483, 484, + 501, 502, 503, 504, + 532, 533, 534, 535, 536, + ]; - private static ReadOnlySpan Pouch_Ball_HGSS => new ushort[] - { - 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 499, 500, - }; + private static ReadOnlySpan Pouch_Ball_HGSS => + [ + 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 492, 493, 494, 495, 496, 497, 498, 499, 500, // Apricorn Balls + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage4Pt.cs b/PKHeX.Core/Items/ItemStorage4Pt.cs index 253a5345e..6e5b55e43 100644 --- a/PKHeX.Core/Items/ItemStorage4Pt.cs +++ b/PKHeX.Core/Items/ItemStorage4Pt.cs @@ -6,15 +6,16 @@ public sealed class ItemStorage4Pt : ItemStorage4, IItemStorage { public static readonly ItemStorage4Pt Instance = new(); - private static ReadOnlySpan Pouch_Key_Pt => new ushort[] - { - 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, - }; + private static ReadOnlySpan Pouch_Key_Pt => + [ + 428, 429, + 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, + 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, + 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, + 460, 461, 462, 463, 464, 465, 466, 467, + ]; - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Items_Pt, Pouch_Mail_DP, Pouch_Medicine_DP, Pouch_Berries_DP, Pouch_Ball_DP, Pouch_TMHM_DP[..^8]); - } + public static ushort[] GetAllHeld() => [..Pouch_Items_Pt, ..Pouch_Mail_DP, ..Pouch_Medicine_DP, ..Pouch_Berries_DP, ..Pouch_Ball_DP, ..Pouch_TMHM_DP[..^8]]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage5.cs b/PKHeX.Core/Items/ItemStorage5.cs index e7384e8b4..50fac7635 100644 --- a/PKHeX.Core/Items/ItemStorage5.cs +++ b/PKHeX.Core/Items/ItemStorage5.cs @@ -4,9 +4,9 @@ namespace PKHeX.Core; public abstract class ItemStorage5 { - private protected static ReadOnlySpan Pouch_Items_BW => new ushort[] - { - 01, 02, 03, 04, 05, 06, 07, 08, 09, + private protected static ReadOnlySpan Pouch_Items_BW => + [ + 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 55, 56, 57, 58, 59, @@ -14,11 +14,35 @@ public abstract class ItemStorage5 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 575, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, - }; + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 116, 117, 118, 119, + 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, - private protected static ReadOnlySpan Pouch_TMHM_BW => new ushort[] - { + 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, + 492, 493, 494, 495, 496, 497, 498, 499, + 500, 537, 538, 539, + 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, + 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, + 560, 561, 562, 563, 564, + 571, 572, 573, 575, 576, 577, + 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, + 590, + ]; + + private protected static ReadOnlySpan Pouch_TMHM_BW => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -33,20 +57,35 @@ public abstract class ItemStorage5 618, 619, 620, // 93-95 420, 421, 422, 423, 424, 425, - }; + ]; - private protected static ReadOnlySpan Pouch_Medicine_BW => new ushort[] - { - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 134, 504, 565, 566, 567, 568, 569, 570, 591, - }; + private protected static ReadOnlySpan Pouch_Medicine_BW => + [ + 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, - private protected static ReadOnlySpan Pouch_Berries_BW => new ushort[] - { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - }; + 134, + 504, 565, 566, 567, 568, 569, + 570, 591, + ]; - internal static ReadOnlySpan Unreleased => new ushort[] - { + private protected static ReadOnlySpan Pouch_Berries_BW => + [ + 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, + ]; + + internal static ReadOnlySpan Unreleased => + [ 005, // Safari Ball 016, // Cherish Ball 260, // Red Scarf @@ -64,10 +103,7 @@ public abstract class ItemStorage5 499, // Sport Ball 500, // Park Ball 576, // Dream Ball - }; + ]; - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Items_BW, Pouch_Medicine_BW, Pouch_Berries_BW); - } + public static ushort[] GetAllHeld() => [..Pouch_Items_BW, ..Pouch_Medicine_BW, ..Pouch_Berries_BW]; } diff --git a/PKHeX.Core/Items/ItemStorage5B2W2.cs b/PKHeX.Core/Items/ItemStorage5B2W2.cs index f9357707f..af04744b0 100644 --- a/PKHeX.Core/Items/ItemStorage5B2W2.cs +++ b/PKHeX.Core/Items/ItemStorage5B2W2.cs @@ -5,12 +5,12 @@ namespace PKHeX.Core; public sealed class ItemStorage5B2W2 : ItemStorage5, IItemStorage { public static readonly ItemStorage5B2W2 Instance = new(); - private static ReadOnlySpan Pouch_Key_B2W2 => new ushort[] - { + private static ReadOnlySpan Pouch_Key_B2W2 => + [ 437, 442, 447, 450, 453, 458, 465, 466, 471, 504, 578, 616, 617, 621, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage5BW.cs b/PKHeX.Core/Items/ItemStorage5BW.cs index 83ba18d02..9e7817f64 100644 --- a/PKHeX.Core/Items/ItemStorage5BW.cs +++ b/PKHeX.Core/Items/ItemStorage5BW.cs @@ -6,12 +6,12 @@ public sealed class ItemStorage5BW : ItemStorage5, IItemStorage { public static readonly ItemStorage5BW Instance = new(); - private static ReadOnlySpan Pouch_Key_BW => new ushort[] - { + private static ReadOnlySpan Pouch_Key_BW => + [ 437, 442, 447, 450, 465, 466, 471, 504, 533, 574, 578, 579, 616, 617, 621, 623, 624, 625, 626, - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage6AO.cs b/PKHeX.Core/Items/ItemStorage6AO.cs index d770638ff..f37890170 100644 --- a/PKHeX.Core/Items/ItemStorage6AO.cs +++ b/PKHeX.Core/Items/ItemStorage6AO.cs @@ -1,4 +1,5 @@ using System; +using static PKHeX.Core.ItemStorage6XY; namespace PKHeX.Core; @@ -6,8 +7,8 @@ public sealed class ItemStorage6AO : IItemStorage { public static readonly ItemStorage6AO Instance = new(); - internal static ReadOnlySpan Pouch_TMHM_AO => new ushort[] - { + internal static ReadOnlySpan Pouch_TMHM_AO => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -26,10 +27,10 @@ public sealed class ItemStorage6AO : IItemStorage // OR/AS 425, 737, - }; + ]; - private static ReadOnlySpan Pouch_Items_AO => new ushort[] - { + private static ReadOnlySpan Pouch_Items_AO => + [ // Flutes moved to the Medicine pouch. 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, 068, 069, 070, 071, 072, 073, 074, 075, @@ -51,17 +52,17 @@ public sealed class ItemStorage6AO : IItemStorage // OR/AS Additions 534, 535, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, - }; + ]; - private static ReadOnlySpan Pouch_Key_AO => new ushort[] - { + private static ReadOnlySpan Pouch_Key_AO => + [ 216, 445, 446, 447, 465, 466, 471, 628, 629, 631, 632, 638, 697, // Illegal // 716, 717, 723, 745, 746, 747, 748, 749, 750, 766, - // ORAS + // OR/AS 457, 474, 503, 718, 719, @@ -70,28 +71,25 @@ public sealed class ItemStorage6AO : IItemStorage 740, 741, 742, 743, 744, 751, 765, 771, 772, 774, 775, - }; + ]; - private static ReadOnlySpan Pouch_Medicine_AO => new ushort[] - { + private static ReadOnlySpan Pouch_Medicine_AO => + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709, // OR/AS -- Moved from Items pouch. 065, 066, 067, - }; + ]; - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Items_AO, Pouch_Medicine_AO, ItemStorage6XY.Pouch_Berry_XY); - } + public static ushort[] GetAllHeld() => [..Pouch_Items_AO, ..Pouch_Medicine_AO, ..Pouch_Berry_XY]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) { if (type is InventoryType.KeyItems) return true; - return ItemStorage6XY.Unreleased.BinarySearch((ushort)itemIndex) < 0; + return Unreleased.BinarySearch((ushort)itemIndex) < 0; } public ReadOnlySpan GetItems(InventoryType type) => type switch @@ -100,7 +98,7 @@ public bool IsLegal(InventoryType type, int itemIndex, int itemCount) InventoryType.KeyItems => Pouch_Key_AO, InventoryType.TMHMs => Pouch_TMHM_AO, InventoryType.Medicine => Pouch_Medicine_AO, - InventoryType.Berries => ItemStorage6XY.Pouch_Berry_XY, + InventoryType.Berries => Pouch_Berry_XY, _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), }; } diff --git a/PKHeX.Core/Items/ItemStorage6XY.cs b/PKHeX.Core/Items/ItemStorage6XY.cs index 4f2ba70ed..bbbd8a886 100644 --- a/PKHeX.Core/Items/ItemStorage6XY.cs +++ b/PKHeX.Core/Items/ItemStorage6XY.cs @@ -6,8 +6,8 @@ public sealed class ItemStorage6XY : IItemStorage { public static readonly ItemStorage6XY Instance = new(); - private static ReadOnlySpan Pouch_Items_XY => new ushort[] - { + private static ReadOnlySpan Pouch_Items_XY => + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, @@ -24,20 +24,20 @@ public sealed class ItemStorage6XY : IItemStorage 647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 699, 704, 710, 711, 715, - }; + ]; - private static ReadOnlySpan Pouch_Key_XY => new ushort[] - { + private static ReadOnlySpan Pouch_Key_XY => + [ 216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628, 629, 631, 632, 638, 641, 642, 643, 651, 689, 695, 696, 697, 698, 700, 701, 702, 703, 705, 712, 713, 714, // Illegal // 716, 717, 706, 707, - }; + ]; - private static ReadOnlySpan Pouch_TMHM_XY => new ushort[] - { + private static ReadOnlySpan Pouch_TMHM_XY => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -53,10 +53,10 @@ public sealed class ItemStorage6XY : IItemStorage 690, 691, 692, 693, 694, // 96-100 420, 421, 422, 423, 424, - }; + ]; - private static ReadOnlySpan Pouch_Medicine_XY => new ushort[] - { + private static ReadOnlySpan Pouch_Medicine_XY => + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, @@ -70,10 +70,10 @@ public sealed class ItemStorage6XY : IItemStorage 591, 645, 708, 709, - }; + ]; - public static ReadOnlySpan Pouch_Berry_XY => new ushort[] - { + public static ReadOnlySpan Pouch_Berry_XY => + [ 149, // Cheri Berry 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, @@ -86,15 +86,12 @@ public sealed class ItemStorage6XY : IItemStorage 686, // Roseli Berry 687, // Kee Berry 688, // Maranga Berry - }; + ]; - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Items_XY, Pouch_Medicine_XY, Pouch_Berry_XY); - } + public static ushort[] GetAllHeld() => [..Pouch_Items_XY, ..Pouch_Medicine_XY, ..Pouch_Berry_XY]; - internal static ReadOnlySpan Unreleased => new ushort[] - { + internal static ReadOnlySpan Unreleased => + [ 005, // Safari Ball 016, // Cherish Ball 492, // Fast Ball @@ -130,7 +127,7 @@ public static ushort[] GetAllHeld() 589, // Relic Statue 590, // Relic Crown 715, // Fairy Gem - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) { diff --git a/PKHeX.Core/Items/ItemStorage7GG.cs b/PKHeX.Core/Items/ItemStorage7GG.cs index 7efbcee35..8f4a1a17e 100644 --- a/PKHeX.Core/Items/ItemStorage7GG.cs +++ b/PKHeX.Core/Items/ItemStorage7GG.cs @@ -6,8 +6,8 @@ public sealed class ItemStorage7GG : IItemStorage { public static readonly ItemStorage7GG Instance = new(); - private static ReadOnlySpan Pouch_Candy_GG => new ushort[] - { + private static ReadOnlySpan Pouch_Candy_GG => + [ 050, // Rare Candy 960, 961, 962, 963, 964, 965, // S 966, 967, 968, 969, 970, 971, // L @@ -24,44 +24,44 @@ public sealed class ItemStorage7GG : IItemStorage 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, - }; + ]; - private static ReadOnlySpan Pouch_Medicine_GG => new ushort[] - { + private static ReadOnlySpan Pouch_Medicine_GG => + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 038, 039, 040, 041, 709, 903, - }; + ]; - private static ReadOnlySpan Pouch_TM_GG => new ushort[] - { + private static ReadOnlySpan Pouch_TM_GG => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, - }; + ]; - private static ReadOnlySpan Pouch_PowerUp_GG => new ushort[] - { + private static ReadOnlySpan Pouch_PowerUp_GG => + [ 051, 053, 081, 082, 083, 084, 085, 849, - }; + ]; - private static ReadOnlySpan Pouch_Catching_GG => new ushort[] - { + private static ReadOnlySpan Pouch_Catching_GG => + [ 001, 002, 003, 004, 012, 164, 166, 168, 861, 862, 863, 864, 865, 866, - }; + ]; - private static ReadOnlySpan Pouch_Battle_GG => new ushort[] - { + private static ReadOnlySpan Pouch_Battle_GG => + [ 055, 056, 057, 058, 059, 060, 061, 062, 656, 659, 660, 661, 662, 663, 671, 672, 675, 676, 678, 679, 760, 762, 770, 773, - }; + ]; - private static ReadOnlySpan Pouch_Regular_GG => new ushort[] - { + private static ReadOnlySpan Pouch_Regular_GG => + [ 076, 077, 078, 079, 086, 087, 088, 089, 090, 091, 092, 093, 101, 102, 103, 113, 115, 121, 122, 123, 124, 125, 126, 127, 128, @@ -70,10 +70,10 @@ public sealed class ItemStorage7GG : IItemStorage 632, 651, 795, 796, 872, 873, 874, 875, 876, 877, 878, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 900, 901, 902, - }; + ]; - internal static ReadOnlySpan Pouch_Regular_GG_Key => new ushort[] - { + internal static ReadOnlySpan Pouch_Regular_GG_Key => + [ 113, // Tea 115, // Autograph 121, // Pokémon Box @@ -107,7 +107,7 @@ public sealed class ItemStorage7GG : IItemStorage 894, // Leaf Letter (P) 895, // Leaf Letter (E) 896, // Small Bouquet - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => true; diff --git a/PKHeX.Core/Items/ItemStorage7SM.cs b/PKHeX.Core/Items/ItemStorage7SM.cs index 563a7f166..6930a0a62 100644 --- a/PKHeX.Core/Items/ItemStorage7SM.cs +++ b/PKHeX.Core/Items/ItemStorage7SM.cs @@ -6,8 +6,8 @@ public sealed class ItemStorage7SM : IItemStorage { public static readonly ItemStorage7SM Instance = new(); - internal static ReadOnlySpan Pouch_Regular_SM => new ushort[] - { + internal static ReadOnlySpan Pouch_Regular_SM => + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, 068, 069, @@ -54,18 +54,18 @@ public sealed class ItemStorage7SM : IItemStorage 851, 853, 854, 855, 856, 879, 880, 881, 882, 883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, - }; + ]; - private static ReadOnlySpan Pouch_Key_SM => new ushort[] - { + private static ReadOnlySpan Pouch_Key_SM => + [ 216, 465, 466, 628, 629, 631, 632, 638, 705, 706, 765, 773, 797, 841, 842, 843, 845, 847, 850, 857, 858, 860, - }; + ]; - internal static ReadOnlySpan Pouch_TMHM_SM => new ushort[] - { + internal static ReadOnlySpan Pouch_TMHM_SM => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -79,34 +79,34 @@ public sealed class ItemStorage7SM : IItemStorage 618, 619, 620, // 93-95 690, 691, 692, 693, 694, // 96-100 - }; + ]; - internal static ReadOnlySpan Pouch_Medicine_SM => new ushort[] - { + internal static ReadOnlySpan Pouch_Medicine_SM => + [ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 65, 66, 67, 134, 504, 565, 566, 567, 568, 569, 570, 591, 645, 708, 709, 852, - }; + ]; - internal static ReadOnlySpan Pouch_Berries_SM => new ushort[] - { + internal static ReadOnlySpan Pouch_Berries_SM => + [ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 686, 687, 688, - }; + ]; - private static ReadOnlySpan Pouch_ZCrystal_SM => new ushort[] - { + private static ReadOnlySpan Pouch_ZCrystal_SM => + [ 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, - }; + ]; - private static ReadOnlySpan Pouch_ZCrystalHeld_SM => new ushort[] - { + private static ReadOnlySpan Pouch_ZCrystalHeld_SM => + [ // SM 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836, - }; + ]; - internal static ReadOnlySpan Unreleased => new ushort[] - { + internal static ReadOnlySpan Unreleased => + [ 005, // Safari Ball 016, // Cherish Ball 064, // Fluffy Tail @@ -168,12 +168,9 @@ public sealed class ItemStorage7SM : IItemStorage 590, // Relic Crown 699, // Discount Coupon 715, // Fairy Gem - }; + ]; - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Regular_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_SM); - } + public static ushort[] GetAllHeld() => [..Pouch_Regular_SM, ..Pouch_Berries_SM, ..Pouch_Medicine_SM, ..Pouch_ZCrystalHeld_SM]; public static bool GetCrystalHeld(ushort itemKey, out ushort itemHeld) { diff --git a/PKHeX.Core/Items/ItemStorage7USUM.cs b/PKHeX.Core/Items/ItemStorage7USUM.cs index de4dd31d7..b71ffe393 100644 --- a/PKHeX.Core/Items/ItemStorage7USUM.cs +++ b/PKHeX.Core/Items/ItemStorage7USUM.cs @@ -1,4 +1,5 @@ using System; +using static PKHeX.Core.ItemStorage7SM; namespace PKHeX.Core; @@ -6,8 +7,8 @@ public sealed class ItemStorage7USUM : IItemStorage { public static readonly ItemStorage7USUM Instance = new(); - private static ReadOnlySpan Pouch_Key_USUM => new ushort[] - { + private static ReadOnlySpan Pouch_Key_USUM => + [ 216, 440, // US/UM 465, 466, 628, 629, 631, 632, 638, @@ -15,30 +16,30 @@ public sealed class ItemStorage7USUM : IItemStorage 841, 842, 843, 845, 847, 850, 857, 858, 860, // US/UM 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, - }; + ]; - private static ReadOnlySpan Pouch_Roto_USUM => new ushort[] - { + private static ReadOnlySpan Pouch_Roto_USUM => + [ 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, - }; + ]; - internal static ReadOnlySpan Pouch_ZCrystal_USUM => new ushort[] - { + internal static ReadOnlySpan Pouch_ZCrystal_USUM => + [ // SM 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, // US/UM 927, 928, 929, 930, 931, 932, - }; + ]; - private static ReadOnlySpan Pouch_ZCrystalHeld_USUM => new ushort[] - { + private static ReadOnlySpan Pouch_ZCrystalHeld_USUM => + [ // SM 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836, // US/UM Additions 921, 922, 923, 924, 925, 926, - }; + ]; - public static ushort[] GetAllHeld() => ArrayUtil.ConcatAll(ItemStorage7SM.Pouch_Regular_SM, ItemStorage7SM.Pouch_Berries_SM, ItemStorage7SM.Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM); + public static ushort[] GetAllHeld() => [..Pouch_Regular_SM, ..Pouch_Berries_SM, ..Pouch_Medicine_SM, ..Pouch_ZCrystalHeld_USUM, ..Pouch_Roto_USUM]; public static bool GetCrystalHeld(ushort itemKey, out ushort itemHeld) { @@ -72,15 +73,15 @@ public bool IsLegal(InventoryType type, int itemIndex, int itemCount) if (items.BinarySearch((ushort)itemIndex) < 0) return false; - return ItemStorage7SM.Unreleased.BinarySearch((ushort)itemIndex) < 0; + return Unreleased.BinarySearch((ushort)itemIndex) < 0; } public ReadOnlySpan GetItems(InventoryType type) => type switch { - InventoryType.Medicine => ItemStorage7SM.Pouch_Medicine_SM, - InventoryType.Items => ItemStorage7SM.Pouch_Regular_SM, - InventoryType.TMHMs => ItemStorage7SM.Pouch_TMHM_SM, - InventoryType.Berries => ItemStorage7SM.Pouch_Berries_SM, + InventoryType.Medicine => Pouch_Medicine_SM, + InventoryType.Items => Pouch_Regular_SM, + InventoryType.TMHMs => Pouch_TMHM_SM, + InventoryType.Berries => Pouch_Berries_SM, InventoryType.KeyItems => Pouch_Key_USUM, InventoryType.ZCrystals => Pouch_ZCrystal_USUM, InventoryType.BattleItems => Pouch_Roto_USUM, diff --git a/PKHeX.Core/Items/ItemStorage8BDSP.cs b/PKHeX.Core/Items/ItemStorage8BDSP.cs index 2f350e1d5..f5fdf4ec7 100644 --- a/PKHeX.Core/Items/ItemStorage8BDSP.cs +++ b/PKHeX.Core/Items/ItemStorage8BDSP.cs @@ -6,8 +6,8 @@ public sealed class ItemStorage8BDSP : IItemStorage { public static readonly ItemStorage8BDSP Instance = new(); - private static ReadOnlySpan Pouch_Regular_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Regular_BS => + [ 045, 046, 047, 048, 049, 050, 051, 052, 053, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 093, 094, 107, 108, 109, 110, 111, 112, 135, 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, @@ -21,23 +21,23 @@ public sealed class ItemStorage8BDSP : IItemStorage 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1606, - }; + ]; - private static ReadOnlySpan Pouch_Ball_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Ball_BS => + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 500, 576, 851, - }; + ]; - private static ReadOnlySpan Pouch_Battle_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Battle_BS => + [ 055, 056, 057, 058, 059, 060, 061, 062, 063, - }; + ]; - internal static ReadOnlySpan Unreleased => new ushort[] - { + internal static ReadOnlySpan Unreleased => + [ 005, // Safari Ball 016, // Cherish Ball 044, // Sacred Ash @@ -53,11 +53,11 @@ public sealed class ItemStorage8BDSP : IItemStorage 576, // Dream Ball 849, // Ice Stone 851, // Beast Ball - }; + ]; - internal static ReadOnlySpan DisallowHeldTreasure => new ushort[] - { - // new BDSP items, but they can't be held + internal static ReadOnlySpan DisallowHeldTreasure => + [ + // new BD/SP items, but they can't be held 1808, // Mysterious Shard S 1809, // Mysterious Shard L 1810, // Digger Drill @@ -72,26 +72,24 @@ public sealed class ItemStorage8BDSP : IItemStorage 1819, // Genome Slate 1820, // Discovery Slate 1821, // Distortion Slate - }; + ]; - private static ReadOnlySpan Pouch_Key_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Key_BS => + [ 428, 431, 432, 433, 438, 439, 440, 443, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 459, 460, 461, 462, 463, 464, 466, 467, 631, 632, 1267, 1278, 1822, - }; + ]; - private static ReadOnlySpan Pouch_Medicine_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Medicine_BS => + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 054, + ]; - // 134 Sweet Heart (future event item?) - }; - - private static ReadOnlySpan Pouch_Berries_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Berries_BS => + [ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, @@ -99,17 +97,17 @@ public sealed class ItemStorage8BDSP : IItemStorage 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 686, - }; + ]; - private static ReadOnlySpan Pouch_Treasure_BS => new ushort[] - { + private static ReadOnlySpan Pouch_Treasure_BS => + [ 086, 087, 088, 089, 090, 091, 092, 099, 100, 101, 102, 103, 104, 105, 106, 795, 796, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, - }; + ]; - private static ReadOnlySpan Pouch_TMHM_BS => new ushort[] // TM01-TM100 - { + private static ReadOnlySpan Pouch_TMHM_BS => // TM01-TM100 + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -120,8 +118,8 @@ public sealed class ItemStorage8BDSP : IItemStorage 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, - 420, 421, 422, 423, 424, 425, 426, 427, // Previously called HM0X, in BDSP they're now called TM93-TM100 - }; + 420, 421, 422, 423, 424, 425, 426, 427, // Previously called HM0X, in BD/SP they're now called TM93-TM100 + ]; public int GetMax(InventoryType type) => type switch { @@ -151,16 +149,13 @@ public sealed class ItemStorage8BDSP : IItemStorage _ => throw new ArgumentOutOfRangeException(nameof(type)), }; - internal static ReadOnlySpan ValidTypes => new[] - { + internal static ReadOnlySpan ValidTypes => + [ InventoryType.Items, InventoryType.KeyItems, InventoryType.TMHMs, InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure, - }; + ]; - public static ushort[] GetAll() - { - return ArrayUtil.ConcatAll(Pouch_Regular_BS, Pouch_Ball_BS, Pouch_Battle_BS, Pouch_Berries_BS, Pouch_TMHM_BS, Pouch_Medicine_BS, Pouch_Treasure_BS); - } + public static ushort[] GetAll() => [..Pouch_Regular_BS, ..Pouch_Ball_BS, ..Pouch_Battle_BS, ..Pouch_Berries_BS, ..Pouch_TMHM_BS, ..Pouch_Medicine_BS, ..Pouch_Treasure_BS]; public static InventoryType GetInventoryPouch(ushort itemIndex) { diff --git a/PKHeX.Core/Items/ItemStorage8LA.cs b/PKHeX.Core/Items/ItemStorage8LA.cs index a3eed594b..bd00eb134 100644 --- a/PKHeX.Core/Items/ItemStorage8LA.cs +++ b/PKHeX.Core/Items/ItemStorage8LA.cs @@ -6,8 +6,8 @@ public sealed class ItemStorage8LA : IItemStorage { public static readonly ItemStorage8LA Instance = new(); - private static ReadOnlySpan Pouch_Items_LA => new ushort[] - { + private static ReadOnlySpan Pouch_Items_LA => + [ 017, 023, 024, 025, 026, 027, 028, 029, 039, 041, 050, 054, 072, 073, 075, 080, 081, 082, 083, 084, 085, 090, 091, 092, 107, 108, 109, 110, 149, 150, @@ -28,10 +28,10 @@ public sealed class ItemStorage8LA : IItemStorage 1733, 1734, 1735, 1736, 1738, 1739, 1740, 1741, 1742, 1746, 1747, 1748, 1749, 1750, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1764, 1785, - }; + ]; - private static ReadOnlySpan Pouch_Recipe_LA => new ushort[] - { + private static ReadOnlySpan Pouch_Recipe_LA => + [ 1640, 1641, 1642, 1643, 1644, 1646, 1647, 1648, 1649, 1650, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, @@ -43,10 +43,10 @@ public sealed class ItemStorage8LA : IItemStorage 1751, 1752, 1753, 1783, 1784, - }; + ]; - private static ReadOnlySpan Pouch_Key_LA => new ushort[] - { + private static ReadOnlySpan Pouch_Key_LA => + [ 111, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, @@ -60,7 +60,7 @@ public sealed class ItemStorage8LA : IItemStorage 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1828, - }; + ]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) => GetItems(type).BinarySearch((ushort)itemIndex) >= 0; diff --git a/PKHeX.Core/Items/ItemStorage8SWSH.cs b/PKHeX.Core/Items/ItemStorage8SWSH.cs index de5e935ae..d6a42551d 100644 --- a/PKHeX.Core/Items/ItemStorage8SWSH.cs +++ b/PKHeX.Core/Items/ItemStorage8SWSH.cs @@ -6,8 +6,8 @@ public sealed class ItemStorage8SWSH : IItemStorage { public static readonly ItemStorage8SWSH Instance = new(); - private static ReadOnlySpan Pouch_Regular_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Regular_SWSH => + [ 045, 046, 047, 048, 049, 050, 051, 052, 053, 076, 077, 079, 080, 081, 082, 083, 084, 085, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, @@ -42,23 +42,23 @@ public sealed class ItemStorage8SWSH : IItemStorage // DLC 2 1592, 1604, 1606, - }; + ]; - private static ReadOnlySpan Pouch_Ball_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Ball_SWSH => + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 500, 576, 851, - }; + ]; - private static ReadOnlySpan Pouch_Battle_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Battle_SWSH => + [ 055, 056, 057, 058, 059, 060, 061, 062, 063, 1580, - }; + ]; - private static ReadOnlySpan Pouch_Key_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Key_SWSH => + [ 078, 628, 629, 631, 632, 638, 703, @@ -69,10 +69,10 @@ public sealed class ItemStorage8SWSH : IItemStorage // DLC 2 1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605, 1607, - }; + ]; - private static ReadOnlySpan Pouch_TMTR_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_TMTR_SWSH => + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -100,14 +100,14 @@ public sealed class ItemStorage8SWSH : IItemStorage 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, // TM00 - }; + ]; private const int COUNT_TR = 100; private static ReadOnlySpan Pouch_TR_SWSH => Pouch_TMTR_SWSH.Slice(99, COUNT_TR); public static bool IsTechRecord(ushort itemID) => itemID - 1130u < COUNT_TR; - private static ReadOnlySpan Pouch_Medicine_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Medicine_SWSH => + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 054, @@ -116,35 +116,38 @@ public sealed class ItemStorage8SWSH : IItemStorage 708, 709, 852, 903, 1579, - }; + ]; - private static ReadOnlySpan Pouch_Berries_SWSH => new ushort[] - { - 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 169, 170, 171, 172, 173, - 174, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, - 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + private static ReadOnlySpan Pouch_Berries_SWSH => + [ + 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 169, + 170, 171, 172, 173, 174, + 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 686, 687, 688, - }; + ]; - private static ReadOnlySpan Pouch_Ingredients_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Ingredients_SWSH => + [ 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, - }; + ]; - private static ReadOnlySpan Pouch_Treasure_SWSH => new ushort[] - { + private static ReadOnlySpan Pouch_Treasure_SWSH => + [ 086, 087, 088, 089, 090, 091, 092, 094, 106, 571, 580, 581, 582, 583, 795, 796, 1105, 1106, 1107, 1108, - }; + ]; - internal static ReadOnlySpan Unreleased => new ushort[] - { + internal static ReadOnlySpan Unreleased => + [ 016, // Cherish Ball 298, // Flame Plate 299, // Splash Plate @@ -165,7 +168,7 @@ public sealed class ItemStorage8SWSH : IItemStorage 500, // Park Ball // 644, // Pixie Plate - }; + ]; internal static Range DynamaxCrystalBCAT => new(DMAX_START, DMAX_END + 1); @@ -194,10 +197,7 @@ public static bool IsItemLegal(ushort item) return Unreleased.BinarySearch(item) < 0; } - public static ushort[] GetAllHeld() - { - return ArrayUtil.ConcatAll(Pouch_Regular_SWSH, Pouch_Ball_SWSH, Pouch_Battle_SWSH, Pouch_Berries_SWSH, Pouch_Medicine_SWSH, Pouch_TR_SWSH, Pouch_Treasure_SWSH, Pouch_Ingredients_SWSH); - } + public static ushort[] GetAllHeld() => [..Pouch_Regular_SWSH, ..Pouch_Ball_SWSH, ..Pouch_Battle_SWSH, ..Pouch_Berries_SWSH, ..Pouch_Medicine_SWSH, ..Pouch_TR_SWSH, ..Pouch_Treasure_SWSH, ..Pouch_Ingredients_SWSH]; public bool IsLegal(InventoryType type, int itemIndex, int itemCount) { diff --git a/PKHeX.Core/Items/ItemStorage9SV.cs b/PKHeX.Core/Items/ItemStorage9SV.cs index c7baacba0..cc4a364c8 100644 --- a/PKHeX.Core/Items/ItemStorage9SV.cs +++ b/PKHeX.Core/Items/ItemStorage9SV.cs @@ -6,37 +6,37 @@ public sealed class ItemStorage9SV : IItemStorage { public static readonly ItemStorage9SV Instance = new(); - private static ReadOnlySpan Pouch_Medicine_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Medicine_SV => + [ 0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037, 0038, 0039, 0040, 0041, 0708, 0709, - }; + ]; - private static ReadOnlySpan Pouch_Ball_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Ball_SV => + [ 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 0010, 0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494, 0495, 0496, 0497, 0498, 0499, 0500, 0576, 0851, 1785, - }; + ]; - private static ReadOnlySpan Pouch_Battle_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Battle_SV => + [ 0055, 0056, 0057, 0058, 0059, 0060, 0061, 0062, 0063, - }; + ]; - private static ReadOnlySpan Pouch_Berries_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Berries_SV => + [ 0149, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0158, 0159, 0160, 0161, 0162, 0163, 0169, 0170, 0171, 0172, 0173, 0174, 0184, 0185, 0186, 0187, 0188, 0189, 0190, 0191, 0192, 0193, 0194, 0195, 0196, 0197, 0198, 0199, 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, 0208, 0209, 0210, 0211, 0212, 0686, 0687, 0688, - }; + ]; - private static ReadOnlySpan Pouch_Other_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Other_SV => + [ 0045, 0046, 0047, 0048, 0049, 0050, 0051, 0052, 0053, 0080, 0081, 0082, 0083, 0084, 0085, 0107, 0108, 0109, 0110, 0111, 0112, 0135, 0136, 0213, 0214, 0217, 0218, 0219, 0220, 0221, @@ -61,10 +61,10 @@ public sealed class ItemStorage9SV : IItemStorage 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 2344, 2345, 2401, 2402, 2403, 2404, 2406, 2407, 2408, 2411, 2412, 2413, 2414, 2415, 2416, 2479, - }; + ]; - private static ReadOnlySpan Pouch_TM_SV => new ushort[] - { + private static ReadOnlySpan Pouch_TM_SV => + [ 0328, 0329, 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, 0338, 0339, 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, 0348, 0349, 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, @@ -86,16 +86,16 @@ public sealed class ItemStorage9SV : IItemStorage 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, - }; + ]; - private static ReadOnlySpan Pouch_Treasure_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Treasure_SV => + [ 0086, 0087, 0088, 0089, 0090, 0091, 0092, 0094, 0106, 0571, 0580, 0581, 0582, 0583, 1842, 1843, - }; + ]; - private static ReadOnlySpan Pouch_Picnic_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Picnic_SV => + [ 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, @@ -113,17 +113,17 @@ public sealed class ItemStorage9SV : IItemStorage 2399, 2400, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, - }; + ]; - private static ReadOnlySpan Pouch_Event_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Event_SV => + [ 0078, 0466, 0631, 0632, 0638, 0703, 0765, 1267, 1278, 1587, 1589, 1590, 1591, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1857, 1858, 2405, 2409, 2410, 2480, 2481, - }; + ]; - private static ReadOnlySpan Pouch_Material_SV => new ushort[] - { + private static ReadOnlySpan Pouch_Material_SV => + [ 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, @@ -147,28 +147,28 @@ public sealed class ItemStorage9SV : IItemStorage 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, - }; + ]; - internal static ReadOnlySpan ValidTypes => new[] - { + internal static ReadOnlySpan ValidTypes => + [ InventoryType.Items, InventoryType.KeyItems, InventoryType.TMHMs, InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure, InventoryType.Ingredients, InventoryType.Candy, - }; + ]; - private static ReadOnlySpan ValidHeldTypes => new[] - { + private static ReadOnlySpan ValidHeldTypes => + [ InventoryType.Items, InventoryType.TMHMs, InventoryType.Medicine, InventoryType.Berries, InventoryType.Balls, InventoryType.BattleItems, InventoryType.Treasure, - }; + ]; // [AUCTION] Porto Marinada specialty auctioneer, locked behind HOME in 2023. - public static ReadOnlySpan Unreleased => new ushort[] - { + public static ReadOnlySpan Unreleased => + [ 0005, // Safari Ball 0016, // Cherish Ball @@ -193,7 +193,7 @@ public sealed class ItemStorage9SV : IItemStorage 1592, // Galarica Wreath 1785, // Strange Ball - }; + ]; public int GetMax(InventoryType type) => type switch { diff --git a/PKHeX.Core/Legality/BinLinkerAccessor.cs b/PKHeX.Core/Legality/BinLinkerAccessor.cs index 7dcad2ecf..3aafb5de7 100644 --- a/PKHeX.Core/Legality/BinLinkerAccessor.cs +++ b/PKHeX.Core/Legality/BinLinkerAccessor.cs @@ -1,6 +1,6 @@ using System; +using System.ComponentModel.DataAnnotations; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -41,14 +41,14 @@ private ReadOnlySpan GetEntry(int index) /// /// Data reference /// Expected identifier (debug verification only) - public static BinLinkerAccessor Get(ReadOnlySpan data, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan identifier) + public static BinLinkerAccessor Get(ReadOnlySpan data, [Length(2, 2)] ReadOnlySpan identifier) { SanityCheckIdentifier(data, identifier); return new BinLinkerAccessor(data); } [Conditional("DEBUG")] - private static void SanityCheckIdentifier(ReadOnlySpan data, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan identifier) + private static void SanityCheckIdentifier(ReadOnlySpan data, [Length(2, 2)] ReadOnlySpan identifier) { Debug.Assert(data.Length > 4); Debug.Assert(identifier[0] == data[0] && identifier[1] == data[1]); diff --git a/PKHeX.Core/Legality/Breeding.cs b/PKHeX.Core/Legality/Breeding.cs index b52becb15..6d14f921d 100644 --- a/PKHeX.Core/Legality/Breeding.cs +++ b/PKHeX.Core/Legality/Breeding.cs @@ -47,7 +47,7 @@ public static class Breeding /// Checks if the can be born with inherited moves from the parents. /// /// Entity species ID - /// True if can inherit moves, false if cannot. + /// True if it can inherit moves, false if cannot. internal static bool GetCanInheritMoves(ushort species) { var pi = PKX.Personal[species]; @@ -128,7 +128,7 @@ public static bool CanHatchAsEgg(ushort species, byte form, EntityContext contex /// /// Some species can have forms that cannot exist as egg (event/special forms). Same idea as /// - /// True if can be bred. + /// True if it can be bred. private static bool IsBreedableForm(ushort species, byte form) => species switch { (int)Pikachu or (int)Eevee => false, // can't get these forms as egg diff --git a/PKHeX.Core/Legality/Bulk/BulkAnalysis.cs b/PKHeX.Core/Legality/Bulk/BulkAnalysis.cs index dfff9cd85..bd3422e0a 100644 --- a/PKHeX.Core/Legality/Bulk/BulkAnalysis.cs +++ b/PKHeX.Core/Legality/Bulk/BulkAnalysis.cs @@ -11,8 +11,8 @@ public sealed class BulkAnalysis public readonly IReadOnlyList AllData; public readonly IReadOnlyList AllAnalysis; public readonly ITrainerInfo Trainer; - public readonly List Parse = new(); - public readonly Dictionary Trackers = new(); + public readonly List Parse = []; + public readonly Dictionary Trackers = []; public readonly bool Valid; public readonly IBulkAnalysisSettings Settings; @@ -57,15 +57,15 @@ private static bool IsEmptyData(SlotCache obj) /// /// Supported checkers that will be iterated through to check all entities. /// - public static readonly List Analyzers = new() - { + public static readonly List Analyzers = + [ new StandardCloneChecker(), new DuplicateTrainerChecker(), new DuplicatePIDChecker(), new DuplicateEncryptionChecker(), new HandlerChecker(), new DuplicateGiftChecker(), - }; + ]; private void ScanAll() { @@ -95,7 +95,7 @@ public void AddLine(SlotCache first, string msg, CheckIdentifier i, Severity s = Parse.Add(chk); } - private static IReadOnlyList GetIndividualAnalysis(IReadOnlyList pkms) + private static LegalityAnalysis[] GetIndividualAnalysis(IReadOnlyList pkms) { var results = new LegalityAnalysis[pkms.Count]; for (int i = 0; i < pkms.Count; i++) diff --git a/PKHeX.Core/Legality/Bulk/DuplicateEncryptionChecker.cs b/PKHeX.Core/Legality/Bulk/DuplicateEncryptionChecker.cs index 2583520e6..358fbee70 100644 --- a/PKHeX.Core/Legality/Bulk/DuplicateEncryptionChecker.cs +++ b/PKHeX.Core/Legality/Bulk/DuplicateEncryptionChecker.cs @@ -26,7 +26,7 @@ private static void CheckECReuse(BulkAnalysis input) } } - private static void Verify(BulkAnalysis input, IDictionary dict, SlotCache cp, LegalityAnalysis ca) + private static void Verify(BulkAnalysis input, Dictionary dict, SlotCache cp, LegalityAnalysis ca) { Debug.Assert(cp.Entity.Format >= 6); var id = cp.Entity.EncryptionConstant; diff --git a/PKHeX.Core/Legality/Bulk/DuplicatePIDChecker.cs b/PKHeX.Core/Legality/Bulk/DuplicatePIDChecker.cs index e6389acc2..a1e25a5d2 100644 --- a/PKHeX.Core/Legality/Bulk/DuplicatePIDChecker.cs +++ b/PKHeX.Core/Legality/Bulk/DuplicatePIDChecker.cs @@ -25,7 +25,7 @@ private static void CheckPIDReuse(BulkAnalysis input) } } - private static void Verify(BulkAnalysis input, IDictionary dict, LegalityAnalysis ca, SlotCache cp) + private static void Verify(BulkAnalysis input, Dictionary dict, LegalityAnalysis ca, SlotCache cp) { bool g345 = ca.Info.Generation is 3 or 4 or 5; var id = g345 ? cp.Entity.EncryptionConstant : cp.Entity.PID; diff --git a/PKHeX.Core/Legality/Bulk/DuplicateTrainerChecker.cs b/PKHeX.Core/Legality/Bulk/DuplicateTrainerChecker.cs index 2964c858a..d021226ab 100644 --- a/PKHeX.Core/Legality/Bulk/DuplicateTrainerChecker.cs +++ b/PKHeX.Core/Legality/Bulk/DuplicateTrainerChecker.cs @@ -20,7 +20,7 @@ private static void CheckIDReuse(BulkAnalysis input) } } - private static void Verify(BulkAnalysis input, IDictionary dict, SlotCache cs, LegalityAnalysis ca) + private static void Verify(BulkAnalysis input, Dictionary dict, SlotCache cs, LegalityAnalysis ca) { var id = cs.Entity.ID32; diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 79ecda0dd..d0cd79776 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -143,10 +143,10 @@ public static class Legal internal static readonly ushort[] HeldItems_AO = ItemStorage6AO.GetAllHeld(); internal static readonly ushort[] HeldItems_SM = ItemStorage7SM.GetAllHeld(); internal static readonly ushort[] HeldItems_USUM = ItemStorage7USUM.GetAllHeld(); - internal static readonly ushort[] HeldItems_GG = Array.Empty(); + internal static readonly ushort[] HeldItems_GG = []; internal static readonly ushort[] HeldItems_SWSH = ItemStorage8SWSH.GetAllHeld(); internal static readonly ushort[] HeldItems_BS = ItemStorage8BDSP.GetAll(); - internal static readonly ushort[] HeldItems_LA = Array.Empty(); + internal static readonly ushort[] HeldItems_LA = []; internal static readonly ushort[] HeldItems_SV = ItemStorage9SV.GetAllHeld(); internal static int GetMaxLanguageID(int generation) => generation switch @@ -193,7 +193,7 @@ public static bool IsPPUpAvailable(PKM pk) public static bool IsPPUpAvailable(ushort moveID) => moveID switch { 0 => false, - (int)Move.Sketch => false, // BD/SP v1.0 could use PP Ups on Sketch, but not in later versions. Disallow anyways. + (int)Move.Sketch => false, // BD/SP v1.0 could use PP Ups on Sketch, but not in later versions. Disallow anyway. (int)Move.RevivalBlessing => false, _ => true, }; diff --git a/PKHeX.Core/Legality/Encounters/Data/EncounterEvent.cs b/PKHeX.Core/Legality/Encounters/Data/EncounterEvent.cs index 9a110337e..bce42f27e 100644 --- a/PKHeX.Core/Legality/Encounters/Data/EncounterEvent.cs +++ b/PKHeX.Core/Legality/Encounters/Data/EncounterEvent.cs @@ -46,31 +46,31 @@ public static class EncounterEvent #region Locally Loaded Data /// Event Database for Generation 4 - public static PCD[] EGDB_G4 { get; private set; } = Array.Empty(); + public static PCD[] EGDB_G4 { get; private set; } = []; /// Event Database for Generation 5 - public static PGF[] EGDB_G5 { get; private set; } = Array.Empty(); + public static PGF[] EGDB_G5 { get; private set; } = []; /// Event Database for Generation 6 - public static WC6[] EGDB_G6 { get; private set; } = Array.Empty(); + public static WC6[] EGDB_G6 { get; private set; } = []; /// Event Database for Generation 7 - public static WC7[] EGDB_G7 { get; private set; } = Array.Empty(); + public static WC7[] EGDB_G7 { get; private set; } = []; /// Event Database for Generation 7 - public static WB7[] EGDB_G7GG { get; private set; } = Array.Empty(); + public static WB7[] EGDB_G7GG { get; private set; } = []; /// Event Database for Generation 8 - public static WC8[] EGDB_G8 { get; private set; } = Array.Empty(); + public static WC8[] EGDB_G8 { get; private set; } = []; /// Event Database for Generation 8 - public static WA8[] EGDB_G8A { get; private set; } = Array.Empty(); + public static WA8[] EGDB_G8A { get; private set; } = []; /// Event Database for Generation 8 - public static WB8[] EGDB_G8B { get; private set; } = Array.Empty(); + public static WB8[] EGDB_G8B { get; private set; } = []; /// Event Database for Generation 9 - public static WC9[] EGDB_G9 { get; private set; } = Array.Empty(); + public static WC9[] EGDB_G9 { get; private set; } = []; #endregion private static PCD[] GetPCDDB(ReadOnlySpan bin) => Get(bin, PCD.Size, static d => new PCD(d)); @@ -143,9 +143,9 @@ public static void RefreshMGDB(params string[] paths) static bool AddOrExpand(ref HashSet? arr, ref List? extra, T obj, T[] master) { - arr ??= new(master); + arr ??= [..master]; if (arr.Add(obj)) - (extra ??= new()).Add(obj); + (extra ??= []).Add(obj); return true; } } @@ -161,7 +161,7 @@ static bool AddOrExpand(ref HashSet? arr, ref List? extra, T obj, T[] m static T[] SetArray(List? arr) { if (arr is null) - return Array.Empty(); + return []; return arr.ToArray(); } } diff --git a/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs b/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs index 40d2f7e8f..4cca9869b 100644 --- a/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs +++ b/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; +using System.ComponentModel.DataAnnotations; namespace PKHeX.Core; @@ -9,8 +9,8 @@ namespace PKHeX.Core; /// internal static class EncounterUtil { - internal static ReadOnlySpan Get([ConstantExpected] string resource) => Util.GetBinaryResource($"encounter_{resource}.pkl"); - internal static BinLinkerAccessor Get([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan ident) => BinLinkerAccessor.Get(Get(resource), ident); + internal static ReadOnlySpan Get([Length(2, 2)] string resource) => Util.GetBinaryResource($"encounter_{resource}.pkl"); + internal static BinLinkerAccessor Get([Length(2, 2)] string resource, [Length(2, 2)] ReadOnlySpan ident) => BinLinkerAccessor.Get(Get(resource), ident); internal static T? GetMinByLevel(ReadOnlySpan chain, IEnumerable possible) where T : class, IEncounterTemplate { diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1.cs b/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1.cs index 8b7a32578..2d57ed4cb 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1.cs @@ -17,8 +17,8 @@ internal static class Encounters1 private static readonly string[][] TradeNames = Util.GetLanguageStrings7(tradeRBY); internal static readonly EncounterStatic1[] StaticRBY = - { - // GameVersion is RBY for Pokemon with the same catch rate and initial moves in all games + [ + // GameVersion is RBY for Pokémon with the same catch rate and initial moves in all games // If there are any differences in moves or catch rate, they will be defined as different encounters (GameVersion) new(001, 05, RBY), // Bulbasaur new(004, 05, RBY), // Charmander @@ -65,35 +65,35 @@ internal static class Encounters1 // new(001, 10, YW), // Bulbasaur (Cerulean City) // new(004, 10, YW), // Charmander (Route 24) // new(007, 10, YW), // Squirtle (Vermillion City) - }; + ]; internal static readonly EncounterStatic1[] StaticRB = - { + [ new(030, 17, RB), // Nidorina (Red Game Corner) new(033, 17, RB), // Nidorino (Blue[EN] / Green[JP] Game Corner) new(063, 06, RB), // Abra (Blue[EN] / Green[JP] Game Corner) new(133, 25, RB), // Eevee new(127, 20, RB), // Pinsir (Blue[EN] / Green[JP] Game Corner) new(137, 18, RB), // Porygon (Blue[EN] / Green[JP] Game Corner) - }; + ]; internal static readonly EncounterStatic1[] StaticYW = - { + [ new(025, 05, YW), // Pikachu new(127, 30, YW), // Pinsir (Yellow Game Corner) (Different initial moves) new(133, 25, YW), // Eevee (Different initial moves) - }; + ]; internal static readonly EncounterStatic1[] StaticBU = - { + [ new(116, 18, BU), // Horsea (Blue[JP] Game Corner) new(036, 24, BU), // Clefable (Blue[JP] Game Corner) new(148, 30, BU), // Dragonair (Blue[JP] Game Corner) new(025, 12, BU), // Pikachu (Blue[JP] Game Corner) (Different catch rate) - }; + ]; internal static readonly EncounterTrade1[] TradeGift_RB = - { + [ new(TradeNames, 00, 122, RB, 06, 05), // Mr. Mime - Abra new(TradeNames, 01, 032, RB, 02 ), // Nidoran♂ - Nidoran♀ new(TradeNames, 02, 030, RB, 16 ), // Nidorina - Nidorino @@ -103,10 +103,10 @@ internal static class Encounters1 new(TradeNames, 06, 101, RB, 03 ), // Electrode - Raichu new(TradeNames, 07, 114, RB, 13, 05), // Tangela - Venonat new(TradeNames, 08, 086, RB, 28, 05), // Seel - Ponyta - }; + ]; public static readonly EncounterTrade1[] TradeGift_YW = - { + [ new(TradeNames, 09, 122, YW, 08, 06), // Mr. Mime - Clefairy new(TradeNames, 10, 067, YW, 16, 05) { EvolveOnTrade = true }, // Machoke - Cubone new(TradeNames, 11, 051, YW, 15, 05), // Dugtrio - Lickitung @@ -114,10 +114,10 @@ internal static class Encounters1 new(TradeNames, 13, 112, YW, 15, 10), // Rhydon - Golduck new(TradeNames, 14, 087, YW, 15, 05), // Dewgong - Growlithe new(TradeNames, 15, 089, YW, 25, 05), // Muk - Kangaskhan - }; + ]; public static readonly EncounterTrade1[] TradeGift_BU = - { + [ new(TradeNames, 16, 122, BU, 03 ), // Mr. Mime - Jigglypuff new(TradeNames, 17, 029, BU, 02 ), // Nidoran♀ - Nidoran♂ new(TradeNames, 18, 060, BU, 02 ), // Poliwag - Rattata @@ -128,5 +128,5 @@ internal static class Encounters1 new(TradeNames, 23, 075, BU, 16, 15) { EvolveOnTrade = true }, // Graveler - Abra->Kadabra new(TradeNames, 24, 079, BU, 22, 05), // Slowpoke - Seel new(TradeNames, 25, 098, BU, 15, 05), // Krabby - Growlithe - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1GBEra.cs b/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1GBEra.cs index dabcae787..49eb94651 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1GBEra.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1GBEra.cs @@ -3,13 +3,13 @@ namespace PKHeX.Core; internal static class Encounters1GBEra { private static readonly IndividualValueSet Yoshira = new(5, 10, 1, 12, 5, 5); - private static readonly string[] YoshiOT = { "YOSHIRA", "YOSHIRB", "YOSHIBA", "YOSHIBB" }; - private static readonly string[] TourOT = { "LINKE", "LINKW", "LUIGE", "LUIGW", "LUIGIC", "YOSHIC" }; - private static readonly string[] StadiumOT_Int = { "STADIUM", "STADE", "STADIO", "ESTADIO" }; + private static readonly string[] YoshiOT = ["YOSHIRA", "YOSHIRB", "YOSHIBA", "YOSHIBB"]; + private static readonly string[] TourOT = ["LINKE", "LINKW", "LUIGE", "LUIGW", "LUIGIC", "YOSHIC"]; + private static readonly string[] StadiumOT_Int = ["STADIUM", "STADE", "STADIO", "ESTADIO"]; private const string StadiumOT_JPN = "スタジアム"; internal static readonly EncounterGift1[] Gifts = - { + [ // Stadium 1 (International) new(001, 05, GameVersion.Stadium) {Moves = new(033, 045), TID16 = 2000, OT_Names = StadiumOT_Int, Language = EncounterGBLanguage.International}, // Bulbasaur new(004, 05, GameVersion.Stadium) {Moves = new(010, 043), TID16 = 2000, OT_Names = StadiumOT_Int, Language = EncounterGBLanguage.International}, // Charmander @@ -34,5 +34,5 @@ internal static class Encounters1GBEra new(151, 5, GameVersion.RB) {IVs = Yoshira, OT_Names = YoshiOT, Language = EncounterGBLanguage.International }, // Yoshira Mew Events new(151, 5, GameVersion.RB) {IVs = Yoshira, OT_Names = TourOT, Language = EncounterGBLanguage.International }, // Pokémon 2000 Stadium Tour Mew - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1VC.cs b/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1VC.cs index 5cf613bbb..1b6b0af49 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1VC.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen1/Encounters1VC.cs @@ -5,9 +5,9 @@ internal static class Encounters1VC private static readonly IndividualValueSet Flawless15 = new(15, 15, 15, 15, 15, 15); internal static readonly EncounterGift1[] Gifts = - { + [ // Event Mew new(151, 5, GameVersion.RBY) { IVs = Flawless15, TID16 = 22796, OT_Name = "GF", Language = EncounterGBLanguage.International }, new(151, 5, GameVersion.RBY) { IVs = Flawless15, TID16 = 22796, OT_Name = "ゲーフリ" }, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2.cs b/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2.cs index 37cb1ebd7..4ee955722 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2.cs @@ -16,7 +16,7 @@ internal static class Encounters2 private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeGSC); public static readonly EncounterStatic2[] StaticGSC = - { + [ new(152, 05, GSC) { Location = 001 }, // Chikorita @ New Bark Town new(155, 05, GSC) { Location = 001 }, // Cyndaquil @ New Bark Town new(158, 05, GSC) { Location = 001 }, // Totodile @ New Bark Town @@ -44,10 +44,10 @@ internal static class Encounters2 // Roamer new(243, 40, GSC) { Location = 002 }, // Raikou new(244, 40, GSC) { Location = 002 }, // Entei - }; + ]; public static readonly EncounterStatic2[] StaticGS = - { + [ new(133, 15, GS) { Location = 071 }, // Eevee @ Celadon Game Corner new(122, 15, GS) { Location = 071 }, // Mr. Mime @ Celadon Game Corner @@ -62,22 +62,22 @@ internal static class Encounters2 // Roamer new(245, 40, GS) { Location = 002 }, // Suicune - }; + ]; public static readonly EncounterStatic2[] StaticGD = - { + [ new(249, 70, GD) { Location = 031 }, // Lugia @ Whirl Islands new(250, 40, GD) { Location = 023 }, // Ho-Oh @ Tin Tower - }; + ]; public static readonly EncounterStatic2[] StaticSI = - { + [ new(249, 40, SI) { Location = 031 }, // Lugia @ Whirl Islands new(250, 70, SI) { Location = 023 }, // Ho-Oh @ Tin Tower - }; + ]; public static readonly EncounterStatic2[] StaticC = - { + [ new(245, 40, C) { Location = 023 }, // Suicune @ Tin Tower new(147, 15, C) { Location = 042, Moves = new((int)Move.ExtremeSpeed, (int)Move.Wrap, (int)Move.ThunderWave, (int)Move.Twister) }, // Dratini ExtremeSpeed @@ -91,10 +91,10 @@ internal static class Encounters2 new(063, 05, C) { Location = 016 }, // Abra @ Goldenrod City (Game Corner) new(104, 15, C) { Location = 016 }, // Cubone @ Goldenrod City (Game Corner) new(202, 15, C) { Location = 016 }, // Wobbuffet @ Goldenrod City (Game Corner) - }; + ]; public static readonly EncounterStatic2[] StaticOddEggC = - { + [ new(172, 05, C) { EggEncounter = true, Moves = new((int)Move.ThunderShock,(int)Move.Charm, (int)Move.DizzyPunch)}, // Pichu new(173, 05, C) { EggEncounter = true, Moves = new((int)Move.Pound, (int)Move.Charm, (int)Move.DizzyPunch)}, // Cleffa new(174, 05, C) { EggEncounter = true, Moves = new((int)Move.Sing, (int)Move.Charm, (int)Move.DizzyPunch)}, // Igglybuff @@ -102,12 +102,12 @@ internal static class Encounters2 new(238, 05, C) { EggEncounter = true, Moves = new((int)Move.Pound, (int)Move.Lick, (int)Move.DizzyPunch)}, // Smoochum new(239, 05, C) { EggEncounter = true, Moves = new((int)Move.QuickAttack, (int)Move.Leer, (int)Move.DizzyPunch)}, // Elekid new(240, 05, C) { EggEncounter = true, Moves = new((int)Move.Ember, (int)Move.DizzyPunch)}, // Magby - }; + ]; internal static readonly EncounterStatic2 CelebiVC = new(251, 30, C) { Location = 014 }; // Celebi @ Ilex Forest (VC) internal static readonly EncounterTrade2[] TradeGift_GSC = - { + [ new(TradeNames, 0, 095, 03, 48926) { Gender = 0, IVs = new(08, 09, 06, 06, 06, 06) }, // Onix @ Violet City for Bellsprout [wild] new(TradeNames, 1, 066, 05, 37460) { Gender = 1, IVs = new(12, 03, 07, 06, 06, 06) }, // Machop @ Goldenrod City for Drowzee [wild 9, hatched egg 5] new(TradeNames, 2, 100, 05, 29189) { Gender = 2, IVs = new(08, 09, 08, 08, 08, 08) }, // Voltorb @ Olivine City for Krabby [egg] @@ -121,5 +121,5 @@ internal static class Encounters2 new(TradeNames, 9, 021, 10, 01001), // Spearow @ Goldenrod City for free new(TradeNames, 10, 213, 15, 00518), // Shuckle @ Cianwood City for free - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2GBEra.cs b/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2GBEra.cs index 64bbce3be..32f8028f3 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2GBEra.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen2/Encounters2GBEra.cs @@ -5,11 +5,11 @@ namespace PKHeX.Core; internal static class Encounters2GBEra { - private static readonly string[] PCNYx = { "PCNYa", "PCNYb", "PCNYc", "PCNYd" }; - private static readonly string[] Stadium2 = { "Stade", "Stadion", "Stadio", "Estadio" }; + private static readonly string[] PCNYx = ["PCNYa", "PCNYb", "PCNYc", "PCNYd"]; + private static readonly string[] Stadium2 = ["Stade", "Stadion", "Stadio", "Estadio"]; internal static readonly EncounterGift2[] StaticEventsGB = - { + [ // Stadium 2 Baton Pass Farfetch'd new(083, 05, C) {Moves = new(226, 14, 97, 163), Location = 127, TID16 = 2000, OT_Name = "スタジアム"}, new(083, 05, C) {Moves = new(226, 14, 97, 163), Location = 127, TID16 = 2000, OT_Name = "Stadium", Language = International}, @@ -36,7 +36,7 @@ internal static class Encounters2GBEra new(225, 05, GS) {OT_Names = PCNYx, Moves = new(006), EggCycles = 10, Language = International}, // Pay Day Delibird new(251, 05, C) {OT_Names = PCNYx, Location = 127, Language = International}, // Celebi - // The Initial Three Set (December 28, 2001 to January 31, 2002) + // The Initial Three Set (December 28, 2001, to January 31, 2002) new(001, 05, GS) {OT_Names = PCNYx, Moves = new(246), EggCycles = 10, Language = International}, // Bulbasaur Ancientpower new(004, 05, GS) {OT_Names = PCNYx, Moves = new(242), EggCycles = 10, Language = International}, // Charmander Crunch new(007, 05, GS) {OT_Names = PCNYx, Moves = new(192), EggCycles = 10, Language = International}, // Squirtle Zap Cannon @@ -172,7 +172,7 @@ internal static class Encounters2GBEra new(086, 05, GS) {OT_Names = PCNYx, Moves = new(175), EggCycles = 10, Language = International}, // Seel Flail new(220, 05, GS) {OT_Names = PCNYx, Moves = new(018), EggCycles = 10, Language = International}, // Swinub Whirlwind - // Pokémon that Appear at Night only (December 27, 2002 to January 2, 2003) + // Pokémon that Appear at Night only (December 27, 2002, to January 2, 2003) new(163, 05, GS) {OT_Names = PCNYx, Moves = new(101), EggCycles = 10, Language = International}, // Hoothoot Night Shade new(215, 05, GS) {OT_Names = PCNYx, Moves = new(236), EggCycles = 10, Language = International}, // Sneasel Moonlight @@ -229,7 +229,7 @@ internal static class Encounters2GBEra // Gen2 Events // Egg Cycles Subject to Change. OTs for Eggs are unknown. - // Pokémon Center Mystery Egg #1 (December 15, 2001 to January 14, 2002) + // Pokémon Center Mystery Egg #1 (December 15, 2001, to January 14, 2002) new(152, 05, GSC) {Moves = new(080), EggCycles = 10}, // Chikorita Petal Dance new(172, 05, GSC) {Moves = new(047), EggCycles = 10}, // Pichu Sing new(173, 05, GSC) {Moves = new(129), EggCycles = 10}, // Cleffa Swift @@ -250,5 +250,5 @@ internal static class Encounters2GBEra new(004, 05, GSC) {Moves = new(242), EggCycles = 10}, // Charmander Crunch new(158, 05, GSC) {Moves = new(066), EggCycles = 10}, // Totodile Submission new(163, 05, GSC) {Moves = new(101), EggCycles = 10}, // Hoot-Hoot Night Shade - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs index c819de34c..d295a4cf0 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3Colo.cs @@ -5,22 +5,22 @@ namespace PKHeX.Core; internal static class Encounters3Colo { internal static readonly EncounterStatic3Colo[] Starters = - { + [ // Colosseum Starters: Gender locked to male new(196, 25) { Moves = new(093, 216, 115, 270) }, // Espeon new(197, 26) { Moves = new(044, 269, 290, 289) }, // Umbreon (Bite) - }; + ]; - internal static readonly string[] TrainerNameDuking = { string.Empty, "ギンザル", "DUKING", "DOKING", "RODRIGO", "GRAND", string.Empty, "GERMÁN" }; + internal static readonly string[] TrainerNameDuking = [string.Empty, "ギンザル", "DUKING", "DOKING", "RODRIGO", "GRAND", string.Empty, "GERMÁN"]; internal static readonly EncounterGift3Colo[] Gifts = - { + [ // In-Game without Bonus Disk new(311, 13, TrainerNameDuking, GameVersion.CXD) { Location = 254, TID16 = 37149, OT_Gender = 0, Moves = new(045, 086, 098, 270) }, // Plusle @ Ingame Trade - }; + ]; internal static readonly EncounterShadow3Colo[] Shadow = - { + [ new(01, 03000, ColoMakuhita) { Species = 296, Level = 30, Moves = new(193,116,233,238), Location = 005 }, // Makuhita: Miror B.Peon Trudly @ Phenac City new(02, 03000, First) { Species = 153, Level = 30, Moves = new(241,235,075,034), Location = 003 }, // Bayleef: Cipher Peon Verde @ Phenac City @@ -106,13 +106,13 @@ internal static class Encounters3Colo new(57, 07000, First) { Species = 213, Level = 45, Moves = new(219,227,156,117), Location = 125 }, // Shuckle: Deep King Agnol @ Deep Colosseum new(67, 05000, First) { Species = 176, Level = 20, Moves = new(118,204,186,281), Location = 001 }, // Togetic: Cipher Peon Fein @ Outskirt Stand - }; + ]; public static readonly EncounterShadow3Colo[] EReader = - { + [ // Japanese E-Reader: 0 IVs new(00, 00000, CTogepi) { Species = 175, Level = 20, Moves = new(118,204,186,281), Location = 128 }, // Togepi: Chaser ボデス @ Card e Room (Japanese games only) new(00, 00000, CMareep) { Species = 179, Level = 37, Moves = new(087,084,086,178), Location = 128 }, // Mareep: Hunter ホル @ Card e Room (Japanese games only) new(00, 00000, CScizor) { Species = 212, Level = 50, Moves = new(210,232,014,163), Location = 128 }, // Scizor: Bodybuilder ワーバン @ Card e Room (Japanese games only) - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoShadow.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoShadow.cs index f4d523fe4..3e4f909e9 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoShadow.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoShadow.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Team listings for that have a shadow Pokémon afterwards. +/// Team listings for that have a shadow Pokémon afterward. /// public static class Encounters3ColoShadow { @@ -9,41 +9,41 @@ public static class Encounters3ColoShadow public static readonly TeamLock CMakuhita = new( 296, // Makuhita - new[] { + [ new NPCLock(355, 24, 0, 127), // Duskull (M) (Quirky) new NPCLock(167, 00, 1, 127), // Spinarak (F) (Hardy) - }); + ]); public static readonly TeamLock CGligar = new( 207, // Gligar - new[] { + [ new NPCLock(216, 12, 0, 127), // Teddiursa (M) (Serious) new NPCLock(039, 06, 1, 191), // Jigglypuff (F) (Docile) new NPCLock(285, 18, 0, 127), // Shroomish (M) (Bashful) - }); + ]); public static readonly TeamLock CMurkrow = new( 198, // Murkrow - new[] { + [ new NPCLock(318, 06, 0, 127), // Carvanha (M) (Docile) new NPCLock(274, 12, 1, 127), // Nuzleaf (F) (Serious) new NPCLock(228, 18, 0, 127), // Houndour (M) (Bashful) - }); + ]); public static readonly TeamLock CHeracross = new( 214, // Heracross - new[] { + [ new NPCLock(284, 00, 0, 127), // Masquerain (M) (Hardy) new NPCLock(168, 00, 1, 127), // Ariados (F) (Hardy) - }); + ]); public static readonly TeamLock CUrsaring = new( 217, // Ursaring - new[] { + [ new NPCLock(067, 20, 1, 063), // Machoke (F) (Calm) new NPCLock(259, 16, 0, 031), // Marshtomp (M) (Mild) new NPCLock(275, 21, 1, 127), // Shiftry (F) (Gentle) - }); + ]); #endregion @@ -51,30 +51,30 @@ public static class Encounters3ColoShadow public static readonly TeamLock ETogepi = new( 175, // Togepi - new[] { + [ new NPCLock(302, 23, 0, 127), // Sableye (M) (Careful) new NPCLock(088, 08, 0, 127), // Grimer (M) (Impish) new NPCLock(316, 24, 0, 127), // Gulpin (M) (Quirky) new NPCLock(175, 22, 1, 031), // Togepi (F) (Sassy) -- itself! - }); + ]); public static readonly TeamLock EMareep = new( 179, // Mareep - new[] { + [ new NPCLock(300, 04, 1, 191), // Skitty (F) (Naughty) new NPCLock(211, 10, 1, 127), // Qwilfish (F) (Timid) new NPCLock(355, 12, 1, 127), // Duskull (F) (Serious) new NPCLock(179, 16, 1, 127), // Mareep (F) (Mild) -- itself! - }); + ]); public static readonly TeamLock EScizor = new( 212, // Scizor - new[] { + [ new NPCLock(198, 13, 1, 191), // Murkrow (F) (Jolly) new NPCLock(344, 02, 2, 255), // Claydol (-) (Brave) new NPCLock(208, 03, 0, 127), // Steelix (M) (Adamant) new NPCLock(212, 11, 0, 127), // Scizor (M) (Hasty) -- itself! - }); + ]); #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoTeams.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoTeams.cs index f40129d62..32761af05 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoTeams.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3ColoTeams.cs @@ -1,4 +1,3 @@ -using System; using static PKHeX.Core.Encounters3ColoShadow; namespace PKHeX.Core; @@ -8,17 +7,17 @@ namespace PKHeX.Core; /// public static class Encounters3ColoTeams { - public static readonly TeamLock[] First = Array.Empty(); + public static readonly TeamLock[] First = []; // Colo - public static readonly TeamLock[] ColoMakuhita = { CMakuhita }; - public static readonly TeamLock[] Gligar = { CGligar }; - public static readonly TeamLock[] Murkrow = { CMurkrow }; - public static readonly TeamLock[] Heracross = { CHeracross }; - public static readonly TeamLock[] Ursaring = { CUrsaring }; + public static readonly TeamLock[] ColoMakuhita = [CMakuhita]; + public static readonly TeamLock[] Gligar = [CGligar]; + public static readonly TeamLock[] Murkrow = [CMurkrow]; + public static readonly TeamLock[] Heracross = [CHeracross]; + public static readonly TeamLock[] Ursaring = [CUrsaring]; // E-Reader - public static readonly TeamLock[] CTogepi = {ETogepi}; - public static readonly TeamLock[] CMareep = {EMareep}; - public static readonly TeamLock[] CScizor = {EScizor}; + public static readonly TeamLock[] CTogepi = [ETogepi]; + public static readonly TeamLock[] CMareep = [EMareep]; + public static readonly TeamLock[] CScizor = [EScizor]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3FRLG.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3FRLG.cs index 294840db4..264e5a502 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3FRLG.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3FRLG.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.EncounterUtil; using static PKHeX.Core.GameVersion; @@ -14,13 +15,13 @@ internal static class Encounters3FRLG internal static readonly EncounterArea3[] SlotsFR = GetRegular("fr", "fr"u8, FR); internal static readonly EncounterArea3[] SlotsLG = GetRegular("lg", "lg"u8, LG); - private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan ident, GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game); + private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan ident, GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game); private const string tradeFRLG = "tradefrlg"; private static readonly string[][] TradeNames = Util.GetLanguageStrings7(tradeFRLG); public static readonly EncounterStatic3[] StaticFRLG = - { + [ new(243, 50, FRLG) { Roaming = true, Location = 101 }, // Raikou new(244, 50, FRLG) { Roaming = true, Location = 101 }, // Entei new(245, 50, FRLG) { Roaming = true, Location = 101 }, // Suicune @@ -58,10 +59,10 @@ internal static class Encounters3FRLG // Event new(249, 70, FRLG) { Location = 174, FatefulEncounter = true }, // Lugia @ Navel Rock new(250, 70, FRLG) { Location = 174, FatefulEncounter = true }, // Ho-Oh @ Navel Rock - }; + ]; public static readonly EncounterStatic3[] StaticFR = - { + [ // Celadon City Game Corner new(063, 09, FR) { FixedBall = Ball.Poke, Location = 94 }, // Abra new(035, 08, FR) { FixedBall = Ball.Poke, Location = 94 }, // Clefairy @@ -70,10 +71,10 @@ internal static class Encounters3FRLG new(137, 26, FR) { FixedBall = Ball.Poke, Location = 94 }, // Porygon new(386, 30, FR ) { Location = 187, FatefulEncounter = true, Form = 1 }, // Deoxys @ Birth Island - }; + ]; public static readonly EncounterStatic3[] StaticLG = - { + [ // Celadon City Game Corner new(063, 09, FR) { FixedBall = Ball.Poke, Location = 94 }, // Abra new(035, 08, FR) { FixedBall = Ball.Poke, Location = 94 }, // Clefairy @@ -87,16 +88,16 @@ internal static class Encounters3FRLG new(147, 24, LG) { FixedBall = Ball.Poke, Location = 94 }, // Dratini new(137, 18, LG) { FixedBall = Ball.Poke, Location = 94 }, // Porygon new(386, 30, LG) { Location = 187, FatefulEncounter = true, Form = 2 }, // Deoxys @ Birth Island - }; + ]; - private static ReadOnlySpan TradeContest_Cool => new byte[] { 30, 05, 05, 05, 05, 10 }; - private static ReadOnlySpan TradeContest_Beauty => new byte[] { 05, 30, 05, 05, 05, 10 }; - private static ReadOnlySpan TradeContest_Cute => new byte[] { 05, 05, 30, 05, 05, 10 }; - private static ReadOnlySpan TradeContest_Clever => new byte[] { 05, 05, 05, 30, 05, 10 }; - private static ReadOnlySpan TradeContest_Tough => new byte[] { 05, 05, 05, 05, 30, 10 }; + private static ReadOnlySpan TradeContest_Cool => [ 30, 05, 05, 05, 05, 10 ]; + private static ReadOnlySpan TradeContest_Beauty => [ 05, 30, 05, 05, 05, 10 ]; + private static ReadOnlySpan TradeContest_Cute => [ 05, 05, 30, 05, 05, 10 ]; + private static ReadOnlySpan TradeContest_Clever => [ 05, 05, 05, 30, 05, 10 ]; + private static ReadOnlySpan TradeContest_Tough => [ 05, 05, 05, 05, 30, 10 ]; internal static readonly EncounterTrade3[] TradeGift_FRLG = - { + [ new(TradeNames, 00, FRLG, 0x00009CAE, 122, 05) { Ability = OnlyFirst, TID16 = 01985, OTGender = 0, Gender = 0, IVs = new(20,15,17,24,23,22), Contest = TradeContest_Clever }, // Abra (Level 5 Breeding) -> Mr. Mime new(TradeNames, 07, FRLG, 0x498A2E1D, 124, 20) { Ability = OnlyFirst, TID16 = 36728, OTGender = 0, Gender = 1, IVs = new(18,17,18,22,25,21), Contest = TradeContest_Beauty }, // Poliwhirl (Level 20) -> Jynx new(TradeNames, 08, FRLG, 0x151943D7, 083, 03) { Ability = OnlyFirst, TID16 = 08810, OTGender = 0, Gender = 0, IVs = new(20,25,21,24,15,20), Contest = TradeContest_Cool }, // Spearow (Level 3 Capture) -> Farfetch'd @@ -104,21 +105,21 @@ internal static class Encounters3FRLG new(TradeNames, 10, FRLG, 0x5C77ECFA, 114, 05) { Ability = OnlyFirst, TID16 = 60042, OTGender = 1, Gender = 0, IVs = new(22,17,25,16,23,20), Contest = TradeContest_Cute }, // Venonat (Level 5 Breeding) -> Tangela new(TradeNames, 11, FRLG, 0x482CAC89, 086, 05) { Ability = OnlyFirst, TID16 = 09853, OTGender = 0, Gender = 0, IVs = new(24,15,22,16,23,22), Contest = TradeContest_Tough }, // Ponyta (Level 5 Breeding) -> Seel * // If Pokémon with * is evolved in a Generation IV or V game, its Ability will become its second Ability. - }; + ]; internal static readonly EncounterTrade3[] TradeGift_FR = - { + [ new(TradeNames, 01, FR , 0x4C970B89, 029, 05) { Ability = OnlyFirst, TID16 = 63184, OTGender = 1, Gender = 1, IVs = new(22,18,25,19,15,22), Contest = TradeContest_Tough }, // Nidoran♀ new(TradeNames, 03, FR , 0x00EECA15, 030, 16) { Ability = OnlyFirst, TID16 = 13637, OTGender = 0, Gender = 1, IVs = new(22,25,18,19,22,15), Contest = TradeContest_Cute }, // Nidorina * new(TradeNames, 05, FR , 0x451308AB, 108, 25) { Ability = OnlyFirst, TID16 = 01239, OTGender = 0, Gender = 0, IVs = new(24,19,21,15,23,21), Contest = TradeContest_Tough }, // Golduck (Level 25) -> Lickitung * // If Pokémon with * is evolved in a Generation IV or V game, its Ability will become its second Ability. - }; + ]; internal static readonly EncounterTrade3[] TradeGift_LG = - { + [ new(TradeNames, 02, LG, 0x4C970B9E, 032, 05) { Ability = OnlyFirst, TID16 = 63184, OTGender = 1, Gender = 0, IVs = new(19,25,18,22,22,15), Contest = TradeContest_Cool }, // Nidoran♂ * new(TradeNames, 04, LG, 0x00EECA19, 033, 16) { Ability = OnlyFirst, TID16 = 13637, OTGender = 0, Gender = 0, IVs = new(19,18,25,22,15,22), Contest = TradeContest_Tough }, // Nidorino * new(TradeNames, 06, LG, 0x451308AB, 108, 25) { Ability = OnlyFirst, TID16 = 01239, OTGender = 0, Gender = 0, IVs = new(24,19,21,15,23,21), Contest = TradeContest_Tough }, // Slowbro (Level 25) -> Lickitung * // If Pokémon with * is evolved in a Generation IV or V game, its Ability will become its second Ability. - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3RSE.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3RSE.cs index e1508a9b3..07798d81b 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3RSE.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3RSE.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.EncounterUtil; using static PKHeX.Core.GameVersion; @@ -11,38 +12,38 @@ namespace PKHeX.Core; /// internal static class Encounters3RSE { - private static readonly EncounterArea3[] SlotsSwarmRSE = GetSwarm("rse_swarm", "rs"u8, RSE); - internal static readonly EncounterArea3[] SlotsR = ArrayUtil.ConcatAll(GetRegular("r", "ru"u8, R), SlotsSwarmRSE); - internal static readonly EncounterArea3[] SlotsS = ArrayUtil.ConcatAll(GetRegular("s", "sa"u8, S), SlotsSwarmRSE); - internal static readonly EncounterArea3[] SlotsE = ArrayUtil.ConcatAll(GetRegular("e", "em"u8, E), SlotsSwarmRSE); + internal static readonly EncounterArea3[] SlotsSwarmRSE = GetSwarm("rse_swarm", "rs"u8, RSE); + internal static readonly EncounterArea3[] SlotsR = GetRegular("r", "ru"u8, R); + internal static readonly EncounterArea3[] SlotsS = GetRegular("s", "sa"u8, S); + internal static readonly EncounterArea3[] SlotsE = GetRegular("e", "em"u8, E); - private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan ident, GameVersion game) + private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan ident, GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game); - private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan ident, GameVersion game) + private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan ident, GameVersion game) => EncounterArea3.GetAreasSwarm(Get(resource, ident), game); - private static readonly string[] TrainersPikachu = { string.Empty, "コロシアム", "COLOS", "COLOSSEUM", "ARENA", "COLOSSEUM", string.Empty, "CLAUDIO" }; - private static readonly string[] TrainersCelebi = { string.Empty, "アゲト", "AGATE", "SAMARAGD", "SOFO", "EMERITAE", string.Empty, "ÁGATA" }; - private static readonly string[] TrainersMattle = { string.Empty, "バトルやま", "MATTLE", "MT BATAILL", "MONTE LOTT", "DUELLBERG", string.Empty, "ERNESTO" }; // truncated on ck3->pk3 transfer + private static readonly string[] TrainersPikachu = [string.Empty, "コロシアム", "COLOS", "COLOSSEUM", "ARENA", "COLOSSEUM", string.Empty, "CLAUDIO"]; + private static readonly string[] TrainersCelebi = [string.Empty, "アゲト", "AGATE", "SAMARAGD", "SOFO", "EMERITAE", string.Empty, "ÁGATA"]; + private static readonly string[] TrainersMattle = [string.Empty, "バトルやま", "MATTLE", "MT BATAILL", "MONTE LOTT", "DUELLBERG", string.Empty, "ERNESTO"]; // truncated on ck3->pk3 transfer internal static readonly EncounterGift3Colo[] ColoGiftsR = - { + [ // In-Game Bonus Disk (Japan only) new(025, 10, TrainersPikachu, R) { Location = 255, TID16 = 31121, OT_Gender = 0 }, // Colosseum Pikachu bonus gift new(251, 10, TrainersCelebi, R) { Location = 255, TID16 = 31121, OT_Gender = 1 }, // Ageto Celebi bonus gift - }; + ]; internal static readonly EncounterGift3Colo[] ColoGiftsS = - { + [ // In-Game without Bonus Disk new(250, 70, TrainersMattle, S) { Location = 255, TID16 = 10048, OT_Gender = 0, Moves = new(105, 126, 241, 129) }, // Ho-oh @ Mt. Battle - }; + ]; private const string tradeRSE = "traderse"; private static readonly string[][] TradeNames = Util.GetLanguageStrings7(tradeRSE); public static readonly EncounterStatic3[] StaticRSE = - { + [ // Starters new(252, 05, RSE) { FixedBall = Ball.Poke, Location = 016 }, // Treecko @ Route 101 new(255, 05, RSE) { FixedBall = Ball.Poke, Location = 016 }, // Torchic @@ -66,28 +67,28 @@ private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [Co new(378, 40, RSE) { Location = 081 }, // Regice @ Island Cave new(379, 40, RSE) { Location = 083 }, // Registeel @ Ancient Tomb new(384, 70, RSE) { Location = 085 }, // Rayquaza @ Sky Pillar - }; + ]; public static readonly EncounterStatic3[] StaticR = - { + [ new(381, 40, R) { Roaming = true, Location = 016 }, // Latios new(380, 50, R) { Location = 073 }, // Latias @ Southern Island new(383, 45, R) { Location = 072 }, // Groudon @ Cave of Origin new(101, 30, R) { Location = 066 }, // Electrode @ Hideout (R:Magma Hideout/S:Aqua Hideout) - }; + ]; public static readonly EncounterStatic3[] StaticS = - { + [ new(380, 40, S) { Roaming = true, Location = 016 }, // Latias new(381, 50, S) { Location = 073 }, // Latios @ Southern Island new(382, 45, S) { Location = 072 }, // Kyogre @ Cave of Origin new(101, 30, S) { Location = 066 }, // Electrode @ Hideout (R:Magma Hideout/S:Aqua Hideout) - }; + ]; public static readonly EncounterStatic3[] StaticE = - { + [ new(380, 40, E) { Roaming = true, Location = 016 }, // Latias new(381, 40, E) { Roaming = true, Location = 016 }, // Latios new(382, 70, E) { Location = 203 }, // Kyogre @ Marine Cave @@ -108,27 +109,27 @@ private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [Co new(249, 70, E) { Location = 211, FatefulEncounter = true }, // Lugia @ Navel Rock new(250, 70, E) { Location = 211, FatefulEncounter = true }, // Ho-Oh @ Navel Rock new(386, 30, E) { Location = 200, FatefulEncounter = true, Form = 3 }, // Deoxys @ Birth Island - }; + ]; - private static ReadOnlySpan TradeContest_Cool => new byte[] { 30, 05, 05, 05, 05, 10 }; - private static ReadOnlySpan TradeContest_Beauty => new byte[] { 05, 30, 05, 05, 05, 10 }; - private static ReadOnlySpan TradeContest_Cute => new byte[] { 05, 05, 30, 05, 05, 10 }; - private static ReadOnlySpan TradeContest_Clever => new byte[] { 05, 05, 05, 30, 05, 10 }; - private static ReadOnlySpan TradeContest_Tough => new byte[] { 05, 05, 05, 05, 30, 10 }; + private static ReadOnlySpan TradeContest_Cool => [ 30, 05, 05, 05, 05, 10 ]; + private static ReadOnlySpan TradeContest_Beauty => [ 05, 30, 05, 05, 05, 10 ]; + private static ReadOnlySpan TradeContest_Cute => [ 05, 05, 30, 05, 05, 10 ]; + private static ReadOnlySpan TradeContest_Clever => [ 05, 05, 05, 30, 05, 10 ]; + private static ReadOnlySpan TradeContest_Tough => [ 05, 05, 05, 05, 30, 10 ]; internal static readonly EncounterTrade3[] TradeGift_RS = - { + [ new(TradeNames, 00, RS, 0x00009C40, 296, 05) { Ability = OnlySecond, TID16 = 49562, SID16 = 00000, OTGender = 0, Gender = 0, IVs = new(5,5,4,4,4,4), Contest = TradeContest_Tough }, // Slakoth (Level 5 Breeding) -> Makuhita new(TradeNames, 01, RS, 0x498A2E17, 300, 03) { Ability = OnlyFirst, TID16 = 02259, SID16 = 00000, OTGender = 1, Gender = 1, IVs = new(5,4,4,5,4,4), Contest = TradeContest_Cute }, // Pikachu (Level 3 Viridian Forest) -> Skitty new(TradeNames, 02, RS, 0x4C970B7F, 222, 21) { Ability = OnlySecond, TID16 = 50183, SID16 = 00000, OTGender = 1, Gender = 1, IVs = new(4,4,5,4,4,5), Contest = TradeContest_Beauty }, // Bellossom (Level 21 Oddish -> Gloom -> Bellossom) -> Corsola - }; + ]; internal static readonly EncounterTrade3[] TradeGift_E = - { + [ new(TradeNames, 03, E , 0x00000084, 273, 04) { Ability = OnlySecond, TID16 = 38726, SID16 = 00000, OTGender = 0, Gender = 0, IVs = new(5,4,5,4,4,4), Contest = TradeContest_Cool }, // Ralts (Level 4 Route 102) -> Seedot new(TradeNames, 04, E , 0x0000006F, 311, 05) { Ability = OnlyFirst, TID16 = 08460, SID16 = 00001, OTGender = 0, Gender = 1, IVs = new(4,4,4,5,5,4), Contest = TradeContest_Cute }, // Volbeat (Level 5 Breeding) -> Plusle new(TradeNames, 05, E , 0x0000007F, 116, 05) { Ability = OnlyFirst, TID16 = 46285, SID16 = 00000, OTGender = 0, Gender = 0, IVs = new(5,4,4,4,5,4), Contest = TradeContest_Tough }, // Bagon (Level 5 Breeding) -> Horsea* new(TradeNames, 06, E , 0x0000008B, 052, 03) { Ability = OnlyFirst, TID16 = 25945, SID16 = 00001, OTGender = 1, Gender = 0, IVs = new(4,5,4,5,4,4), Contest = TradeContest_Clever }, // Skitty (Level 3 Trade)-> Meowth* // If Pokémon with * is evolved in a Generation IV or V game, its Ability will become its second Ability. - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XD.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XD.cs index a98da1097..c26609bb1 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XD.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XD.cs @@ -5,27 +5,27 @@ namespace PKHeX.Core; internal static class Encounters3XD { internal static readonly EncounterStatic3XD[] Gifts = - { + [ new(133, 10) { FixedBall = Ball.Poke, FatefulEncounter = true, Location = 000, Moves = new(033,039,044,028) }, // Eevee (Bite) new(152, 05) { FixedBall = Ball.Poke, FatefulEncounter = true, Location = 016, Moves = new(246,033,045,338) }, // Chikorita new(155, 05) { FixedBall = Ball.Poke, FatefulEncounter = true, Location = 016, Moves = new(179,033,043,307) }, // Cyndaquil new(158, 05) { FixedBall = Ball.Poke, FatefulEncounter = true, Location = 016, Moves = new(242,010,043,308) }, // Totodile - }; + ]; - private static readonly string[] Hordel = { string.Empty, "ダニー", "HORDEL", "VOLKER", "ODINO", "HORAZ", string.Empty, "HORDEL" }; - private static readonly string[] Zaprong = { string.Empty, "コンセント", "ZAPRONG", "ZAPRONG", "ZAPRONG", "ZAPRONG", string.Empty, "ZAPRONG" }; + private static readonly string[] Hordel = [string.Empty, "ダニー", "HORDEL", "VOLKER", "ODINO", "HORAZ", string.Empty, "HORDEL"]; + private static readonly string[] Zaprong = [string.Empty, "コンセント", "ZAPRONG", "ZAPRONG", "ZAPRONG", "ZAPRONG", string.Empty, "ZAPRONG"]; private static string[] Duking => Encounters3Colo.TrainerNameDuking; internal static readonly EncounterTrade3XD[] Trades = - { + [ new(239, 20, Hordel, Zaprong) { Location = 164, TID16 = 41400, Moves = new(008, 007, 009, 238) }, // Elekid @ Snagem Hideout new(307, 20, Duking) { Location = 116, TID16 = 37149, Moves = new(223, 093, 247, 197) }, // Meditite @ Pyrite Town new(213, 20, Duking) { Location = 116, TID16 = 37149, Moves = new(092, 164, 188, 227) }, // Shuckle @ Pyrite Town new(246, 20, Duking) { Location = 116, TID16 = 37149, Moves = new(201, 349, 044, 200) }, // Larvitar @ Pyrite Town - }; + ]; internal static readonly EncounterShadow3XD[] Shadow = - { + [ new(01, 03000, First) { Species = 216, Level = 11, Moves = new(216,287,122,232), Location = 143, FixedBall = Ball.Poke }, // Teddiursa: Cipher Peon Naps @ Pokémon HQ Lab -- treat as Gift as it can only be captured in a Poké Ball new(02, 02000, Vulpix) { Species = 037, Level = 18, Moves = new(257,204,052,091), Location = 109 }, // Vulpix: Cipher Peon Mesin @ ONBS Building new(03, 01500, Spheal) { Species = 363, Level = 17, Moves = new(062,204,055,189), Location = 011 }, // Spheal: Cipher Peon Blusix @ Cipher Lab @@ -116,12 +116,12 @@ internal static class Encounters3XD new(81, 04500, First) { Species = 175, Level = 25, Moves = new(266,161,246,270), Location = 164, FixedBall = Ball.Poke }, // Togepi: Pokémon Trainer Hordel @ Outskirt Stand new(82, 02500, Poochyena) { Species = 261, Level = 10, Moves = new(091,215,305,336), Location = 162 }, // Poochyena: Bodybuilder Kilen @ Gateon Port new(83, 02500, Ledyba) { Species = 165, Level = 10, Moves = new(060,287,332,048), Location = 153 }, // Ledyba: Casual Guy Cyle @ Gateon Port - }; + ]; internal static readonly EncounterArea3XD[] Slots = - { + [ new(90, 027, 23, 207, 20, 328, 20), // Rock (Sandshrew, Gligar, Trapinch) new(91, 187, 20, 231, 20, 283, 20), // Oasis (Hoppip, Phanpy, Surskit) new(92, 041, 21, 304, 21, 194, 21), // Cave (Zubat, Aron, Wooper) - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDShadow.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDShadow.cs index 0c48ea9cf..b7ae1a6a3 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDShadow.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDShadow.cs @@ -3,1006 +3,1005 @@ namespace PKHeX.Core; /// -/// Team listings for that have a shadow Pokémon afterwards. +/// Team listings for that have a shadow Pokémon afterward. /// public static class Encounters3XDShadow { public static readonly TeamLock XRalts = new( 280, // Ralts - new[] { + [ new NPCLock(064, 00, 0, 063), // Kadabra (M) (Hardy) new NPCLock(180, 06, 1, 127), // Flaaffy (F) (Docile) new NPCLock(288, 18, 0, 127), // Vigoroth (M) (Bashful) - }); + ]); public static readonly TeamLock XPoochyena = new( 261, // Poochyena - new[] { + [ new NPCLock(041, 12, 1, 127), // Zubat (F) (Serious) - }); + ]); public static readonly TeamLock XLedyba = new( 165, // Ledyba - new[] { + [ new NPCLock(276, 00, 1, 127), // Taillow (F) (Hardy) - }); + ]); public static readonly TeamLock XSphealCipherLab = new( 363, // Spheal CipherLab, - new[] { + [ new NPCLock(116, 24, 0, 063), // Horsea (M) (Quirky) new NPCLock(118, 12, 1, 127), // Goldeen (F) (Serious) - }); + ]); public static readonly TeamLock XSphealPhenacCityandPost = new( 363, // Spheal PhenacCityAndPost, - new[] { + [ new NPCLock(116, 24, 0, 063), // Horsea (M) (Quirky) new NPCLock(118, 12, 1, 127), // Goldeen (F) (Serious) new NPCLock(374, 00, 2, 255), // Beldum (-) (Hardy) - }); + ]); public static readonly TeamLock XGulpin = new( 316, // Gulpin - new[] { + [ new NPCLock(109, 12, 1, 127), // Koffing (F) (Serious) new NPCLock(088, 06, 0, 127), // Grimer (M) (Docile) - }); + ]); public static readonly TeamLock XSeedotCipherLab = new( 273, // Seedot CipherLab, - new[] { + [ new NPCLock(043, 06, 0, 127), // Oddish (M) (Docile) new NPCLock(331, 24, 1, 127), // Cacnea (F) (Quirky) new NPCLock(285, 18, 1, 127), // Shroomish (F) (Bashful) new NPCLock(270, 00, 0, 127), // Lotad (M) (Hardy) new NPCLock(204, 12, 0, 127), // Pineco (M) (Serious) - }); + ]); public static readonly TeamLock XSeedotPhenacCity = new( 273, // Seedot PhenacCity, - new[] { + [ new NPCLock(043, 06, 0, 127), // Oddish (M) (Docile) new NPCLock(331, 24, 1, 127), // Cacnea (F) (Quirky) new NPCLock(285, 00, 1, 127), // Shroomish (F) (Hardy) new NPCLock(270, 00, 1, 127), // Lotad (F) (Hardy) new NPCLock(204, 06, 0, 127), // Pineco (M) (Docile) - }); + ]); public static readonly TeamLock XSeedotPost = new( 273, // Seedot Post, - new[] { + [ new NPCLock(045, 06, 0, 127), // Vileplume (M) (Docile) new NPCLock(332, 24, 1, 127), // Cacturne (F) (Quirky) new NPCLock(286, 00, 1, 127), // Breloom (F) (Hardy) new NPCLock(271, 00, 0, 127), // Lombre (M) (Hardy) new NPCLock(205, 12, 0, 127), // Forretress (M) (Serious) - }); + ]); public static readonly TeamLock XSpinarak = new( 167, // Spinarak - new[] { + [ new NPCLock(220, 12, 1, 127), // Swinub (F) (Serious) new NPCLock(353, 06, 0, 127), // Shuppet (M) (Docile) - }); + ]); public static readonly TeamLock XNumel = new( 322, // Numel - new[] { + [ new NPCLock(280, 06, 0, 127), // Ralts (M) (Docile) new NPCLock(100, 00, 2, 255), // Voltorb (-) (Hardy) new NPCLock(371, 24, 1, 127), // Bagon (F) (Quirky) - }); + ]); public static readonly TeamLock XShroomish = new( 285, // Shroomish - new[] { + [ new NPCLock(209, 24, 1, 191), // Snubbull (F) (Quirky) new NPCLock(352, 00, 1, 127), // Kecleon (F) (Hardy) - }); + ]); public static readonly TeamLock XDelcatty = new( 301, // Delcatty - new[] { + [ new NPCLock(370, 06, 1, 191), // Luvdisc (F) (Docile) new NPCLock(267, 00, 0, 127), // Beautifly (M) (Hardy) new NPCLock(315, 24, 0, 127), // Roselia (M) (Quirky) - }); + ]); public static readonly TeamLock XVoltorb = new( 100, // Voltorb - new[] { + [ new NPCLock(271, 00, 0, 127), // Lombre (M) (Hardy) new NPCLock(271, 18, 0, 127), // Lombre (M) (Bashful) new NPCLock(271, 12, 1, 127), // Lombre (F) (Serious) - }); + ]); public static readonly TeamLock XMakuhita = new( 296, // Makuhita - new[] { + [ new NPCLock(352, 06, 0, 127), // Kecleon (M) (Docile) new NPCLock(283, 18, 1, 127), // Surskit (F) (Bashful) - }); + ]); public static readonly TeamLock XVulpix = new( 037, // Vulpix - new[] { + [ new NPCLock(167, 00, 0, 127), // Spinarak (M) (Hardy) new NPCLock(267, 06, 1, 127), // Beautifly (F) (Docile) new NPCLock(269, 18, 0, 127), // Dustox (M) (Bashful) - }); + ]); public static readonly TeamLock XDuskull = new( 355, // Duskull - new[] { + [ new NPCLock(215, 12, 0, 127), // Sneasel (M) (Serious) new NPCLock(193, 18, 1, 127), // Yanma (F) (Bashful) new NPCLock(200, 24, 0, 127), // Misdreavus (M) (Quirky) - }); + ]); public static readonly TeamLock XMawile = new( 303, // Mawile - new[] { + [ new NPCLock(294, 06, 0, 127), // Loudred (M) (Docile) new NPCLock(203, 18, 1, 127), // Girafarig (F) (Bashful) - }); + ]); public static readonly TeamLock XSnorunt = new( 361, // Snorunt - new[] { + [ new NPCLock(336, 06, 1, 127), // Seviper (F) (Docile) - }); + ]); public static readonly TeamLock XPineco = new( 204, // Pineco - new[] { + [ new NPCLock(198, 06, 0, 127), // Murkrow (M) (Docile) - }); + ]); public static readonly TeamLock XNatu = new( 177, // Natu - new[] { + [ new NPCLock(281, 00, 0, 127), // Kirlia (M) (Hardy) new NPCLock(264, 00, 1, 127), // Linoone (F) (Hardy) - }); + ]); public static readonly TeamLock XRoselia = new( 315, // Roselia - new[] { + [ new NPCLock(223, 06, 0, 127), // Remoraid (M) (Docile) new NPCLock(042, 18, 0, 127), // Golbat (M) (Bashful) - }); + ]); public static readonly TeamLock XMeowth = new( 052, // Meowth - new[] { + [ new NPCLock(064, 06, 0, 063), // Kadabra (M) (Docile) new NPCLock(215, 00, 1, 127), // Sneasel (F) (Hardy) new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful) - }); + ]); public static readonly TeamLock XSwinub = new( 220, // Swinub - new[] { + [ new NPCLock(324, 18, 1, 127), // Torkoal (F) (Bashful) new NPCLock(274, 00, 0, 127), // Nuzleaf (M) (Hardy) - }); + ]); public static readonly TeamLock XSpearow = new( 021, // Spearow - new[] { + [ new NPCLock(279, 18, 0, 127), // Pelipper (M) (Bashful) new NPCLock(309, 06, 1, 127), // Electrike (F) (Docile) - }); + ]); public static readonly TeamLock XGrimer = new( 088, // Grimer - new[] { + [ new NPCLock(358, 12, 0, 127), // Chimecho (M) (Serious) new NPCLock(234, 18, 0, 127), // Stantler (M) (Bashful) - }); + ]); public static readonly TeamLock XSeel = new( 086, // Seel - new[] { + [ new NPCLock(163, 06, 0, 127), // Hoothoot (M) (Docile) new NPCLock(075, 18, 0, 127), // Graveler (M) (Bashful) new NPCLock(316, 18, 1, 127), // Gulpin (F) (Bashful) - }); + ]); public static readonly TeamLock XLunatone = new( 337, // Lunatone - new[] { + [ new NPCLock(171, 00, 1, 127), // Lanturn (F) (Hardy) new NPCLock(195, 18, 0, 127), // Quagsire (M) (Bashful) - }); + ]); public static readonly TeamLock XNosepass = new( 299, // Nosepass - new[] { + [ new NPCLock(271, 00, 0, 127), // Lombre (M) (Hardy) new NPCLock(271, 18, 0, 127), // Lombre (M) (Bashful) new NPCLock(271, 12, 1, 127), // Lombre (F) (Serious) - }); + ]); public static readonly TeamLock XParas = new( 046, // Paras - new[] { + [ new NPCLock(336, 24, 0, 127), // Seviper (M) (Quirky) new NPCLock(198, 06, 1, 127), // Murkrow (F) (Docile) - }); + ]); public static readonly TeamLock XGrowlithe = new( 058, // Growlithe - new[] { + [ new NPCLock(336, 24, 0, 127), // Seviper (M) (Quirky) new NPCLock(198, 06, 1, 127), // Murkrow (F) (Docile) new NPCLock(046), // Shadow Paras - }); + ]); public static readonly TeamLock XGrowlitheParasSeen = new( 058, // Growlithe SeenParas, - new[] { + [ new NPCLock(336, 24, 0, 127), // Seviper (M) (Quirky) new NPCLock(198, 06, 1, 127), // Murkrow (F) (Docile) new NPCLock(046, true), // Shadow Paras (Seen) - }); + ]); public static readonly TeamLock XPidgeotto = new( 017, // Pidgeotto - new[] { + [ new NPCLock(015), // Shadow Beedrill new NPCLock(162, 12, 0, 127), // Furret (M) (Serious) new NPCLock(176, 18, 0, 031), // Togetic (M) (Bashful) - }); + ]); public static readonly TeamLock XPidgeottoBeedrillSeen = new( 017, // Pidgeotto SeenBeedrill, - new[] { + [ new NPCLock(015, true), // Shadow Beedrill (Seen) new NPCLock(162, 12, 0, 127), // Furret (M) (Serious) new NPCLock(176, 18, 0, 031), // Togetic (M) (Bashful) - }); + ]); public static readonly TeamLock XTangela = new( 114, // Tangela - new[] { + [ new NPCLock(038, 12, 1, 191), // Ninetales (F) (Serious) new NPCLock(189, 06, 0, 127), // Jumpluff (M) (Docile) new NPCLock(184, 00, 1, 127), // Azumarill (F) (Hardy) - }); + ]); public static readonly TeamLock XButterfree = new( 012, // Butterfree - new[] { + [ new NPCLock(038, 12, 1, 191), // Ninetales (F) (Serious) new NPCLock(189, 06, 0, 127), // Jumpluff (M) (Docile) new NPCLock(184, 00, 1, 127), // Azumarill (F) (Hardy) new NPCLock(114), // Shadow Tangela - }); + ]); public static readonly TeamLock XButterfreeTangelaSeen = new( 012, // Butterfree SeenTangela, - new[] { + [ new NPCLock(038, 12, 1, 191), // Ninetales (F) (Serious) new NPCLock(189, 06, 0, 127), // Jumpluff (M) (Docile) new NPCLock(184, 00, 1, 127), // Azumarill (F) (Hardy) new NPCLock(114, true), // Shadow Tangela (Seen) - }); + ]); public static readonly TeamLock XMagneton = new( 082, // Magneton - new[] { + [ new NPCLock(292, 18, 2, 255), // Shedinja (-) (Bashful) new NPCLock(202, 00, 0, 127), // Wobbuffet (M) (Hardy) new NPCLock(329, 12, 1, 127), // Vibrava (F) (Serious) - }); + ]); public static readonly TeamLock XVenomoth = new( 049, // Venomoth - new[] { + [ new NPCLock(055, 18, 1, 127), // Golduck (F) (Bashful) new NPCLock(237, 24, 0, 000), // Hitmontop (M) (Quirky) new NPCLock(297, 12, 0, 063), // Hariyama (M) (Serious) - }); + ]); public static readonly TeamLock XWeepinbell = new( 070, // Weepinbell - new[] { + [ new NPCLock(055, 18, 1, 127), // Golduck (F) (Bashful) new NPCLock(237, 24, 0, 000), // Hitmontop (M) (Quirky) new NPCLock(297, 12, 0, 063), // Hariyama (M) (Serious) new NPCLock(049), // Shadow Venomoth - }); + ]); public static readonly TeamLock XWeepinbellVenomothSeen = new( 070, // Weepinbell SeenVenomoth, - new[] { + [ new NPCLock(055, 18, 1, 127), // Golduck (F) (Bashful) new NPCLock(237, 24, 0, 000), // Hitmontop (M) (Quirky) new NPCLock(297, 12, 0, 063), // Hariyama (M) (Serious) new NPCLock(049, true), // Shadow Venomoth (Seen) - }); + ]); public static readonly TeamLock XArbok = new( 024, // Arbok - new[] { + [ new NPCLock(367, 06, 0, 127), // Huntail (M) (Docile) new NPCLock(332, 00, 1, 127), // Cacturne (F) (Hardy) new NPCLock(110, 12, 1, 127), // Weezing (F) (Serious) new NPCLock(217, 18, 1, 127), // Ursaring (F) (Bashful) - }); + ]); public static readonly TeamLock XPrimeape = new( 057, // Primeape - new[] { + [ new NPCLock(305, 18, 1, 127), // Lairon (F) (Bashful) new NPCLock(364, 12, 1, 127), // Sealeo (F) (Serious) new NPCLock(199, 06, 1, 127), // Slowking (F) (Docile) new NPCLock(217, 24, 0, 127), // Ursaring (M) (Quirky) - }); + ]); public static readonly TeamLock XHypno = new( 097, // Hypno - new[] { + [ new NPCLock(305, 18, 1, 127), // Lairon (F) (Bashful) new NPCLock(364, 12, 1, 127), // Sealeo (F) (Serious) new NPCLock(199, 06, 1, 127), // Slowking (F) (Docile) new NPCLock(217, 24, 0, 127), // Ursaring (M) (Quirky) new NPCLock(057), // Shadow Primeape - }); + ]); public static readonly TeamLock XHypnoPrimeapeSeen = new( 097, // Hypno SeenPrimeape, - new[] { + [ new NPCLock(305, 18, 1, 127), // Lairon (F) (Bashful) new NPCLock(364, 12, 1, 127), // Sealeo (F) (Serious) new NPCLock(199, 06, 1, 127), // Slowking (F) (Docile) new NPCLock(217, 24, 0, 127), // Ursaring (M) (Quirky) new NPCLock(057, true), // Shadow Primeape (Seen) - }); + ]); public static readonly TeamLock XGolduck = new( 055, // Golduck - new[] { + [ new NPCLock(342, 24, 0, 127), // Crawdaunt (M) (Quirky) new NPCLock(279, 06, 1, 127), // Pelipper (F) (Docile) new NPCLock(226, 18, 1, 127), // Mantine (F) (Bashful) - }); + ]); public static readonly TeamLock XSableye = new( 302, // Sableye - new[] { + [ new NPCLock(342, 24, 0, 127), // Crawdaunt (M) (Quirky) new NPCLock(279, 06, 1, 127), // Pelipper (F) (Docile) new NPCLock(226, 18, 1, 127), // Mantine (F) (Bashful) new NPCLock(055), // Shadow Golduck - }); + ]); public static readonly TeamLock XSableyeGolduckSeen = new( 302, // Sableye SeenGolduck, - new[] { + [ new NPCLock(342, 24, 0, 127), // Crawdaunt (M) (Quirky) new NPCLock(279, 06, 1, 127), // Pelipper (F) (Docile) new NPCLock(226, 18, 1, 127), // Mantine (F) (Bashful) new NPCLock(055, true), // Shadow Golduck (Seen) - }); + ]); public static readonly TeamLock XDodrio = new( 085, // Dodrio - new[] { + [ new NPCLock(178, 18, 1, 127), // Xatu (F) (Bashful) - }); + ]); public static readonly TeamLock XRaticate = new( 020, // Raticate - new[] { + [ new NPCLock(178, 18, 1, 127), // Xatu (F) (Bashful) new NPCLock(085), // Shadow Dodrio new NPCLock(340, 18, 0, 127), // Whiscash (M) (Bashful) - }); + ]); public static readonly TeamLock XRaticateDodrioSeen = new( 020, // Raticate SeenDodrio, - new[] { + [ new NPCLock(178, 18, 1, 127), // Xatu (F) (Bashful) new NPCLock(085, true), // Shadow Dodrio (Seen) new NPCLock(340, 18, 0, 127), // Whiscash (M) (Bashful) - }); + ]); public static readonly TeamLock XFarfetchd = new( 083, // Farfetch’d - new[] { + [ new NPCLock(282, 12, 0, 127), // Gardevoir (M) (Serious) new NPCLock(368, 00, 1, 127), // Gorebyss (F) (Hardy) new NPCLock(315, 24, 0, 127), // Roselia (M) (Quirky) - }); + ]); public static readonly TeamLock XAltaria = new( 334, // Altaria - new[] { + [ new NPCLock(282, 12, 0, 127), // Gardevoir (M) (Serious) new NPCLock(368, 00, 1, 127), // Gorebyss (F) (Hardy) new NPCLock(315, 24, 0, 127), // Roselia (M) (Quirky) new NPCLock(083), // Shadow Farfetch’d - }); + ]); public static readonly TeamLock XAltariaFarfetchdSeen = new( 334, // Altaria SeenFarfetchd, - new[] { + [ new NPCLock(282, 12, 0, 127), // Gardevoir (M) (Serious) new NPCLock(368, 00, 1, 127), // Gorebyss (F) (Hardy) new NPCLock(315, 24, 0, 127), // Roselia (M) (Quirky) new NPCLock(083, true), // Shadow Farfetch’d (Seen) - }); + ]); public static readonly TeamLock XKangaskhan = new( 115, // Kangaskhan - new[] { + [ new NPCLock(101, 00, 2, 255), // Electrode (-) (Hardy) new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful) new NPCLock(344, 12, 2, 255), // Claydol (-) (Serious) - }); + ]); public static readonly TeamLock XBanette = new( 354, // Banette - new[] { + [ new NPCLock(101, 00, 2, 255), // Electrode (-) (Hardy) new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful) new NPCLock(344, 12, 2, 255), // Claydol (-) (Serious) new NPCLock(115), // Shadow Kangaskhan - }); + ]); public static readonly TeamLock XBanetteKangaskhanSeen = new( 354, // Banette SeenKangaskhan, - new[] { + [ new NPCLock(101, 00, 2, 255), // Electrode (-) (Hardy) new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful) new NPCLock(344, 12, 2, 255), // Claydol (-) (Serious) new NPCLock(115, true), // Shadow Kangaskhan (Seen) - }); + ]); public static readonly TeamLock XMagmar = new( 126, // Magmar - new[] { + [ new NPCLock(229, 18, 0, 127), // Houndoom (M) (Bashful) new NPCLock(038, 18, 0, 191), // Ninetales (M) (Bashful) new NPCLock(045, 00, 1, 127), // Vileplume (F) (Hardy) - }); + ]); public static readonly TeamLock XPinsir = new( 127, // Pinsir - new[] { + [ new NPCLock(229, 18, 0, 127), // Houndoom (M) (Bashful) new NPCLock(038, 18, 0, 191), // Ninetales (M) (Bashful) new NPCLock(045, 00, 1, 127), // Vileplume (F) (Hardy) new NPCLock(126), // Shadow Magmar - }); + ]); public static readonly TeamLock XPinsirMagmarSeen = new( 127, // Pinsir SeenMagmar, - new[] { + [ new NPCLock(229, 18, 0, 127), // Houndoom (M) (Bashful) new NPCLock(038, 18, 0, 191), // Ninetales (M) (Bashful) new NPCLock(045, 00, 1, 127), // Vileplume (F) (Hardy) new NPCLock(126, true), // Shadow Magmar (Seen) - }); + ]); public static readonly TeamLock XRapidash = new( 078, // Rapidash - new[] { + [ new NPCLock(323, 24, 0, 127), // Camerupt (M) (Quirky) new NPCLock(110, 06, 0, 127), // Weezing (M) (Docile) new NPCLock(089, 12, 1, 127), // Muk (F) (Serious) - }); + ]); public static readonly TeamLock XMagcargo = new( 219, // Magcargo - new[] { + [ new NPCLock(323, 24, 0, 127), // Camerupt (M) (Quirky) new NPCLock(110, 06, 0, 127), // Weezing (M) (Docile) new NPCLock(089, 12, 1, 127), // Muk (F) (Serious) new NPCLock(078), // Shadow Rapidash - }); + ]); public static readonly TeamLock XMagcargoRapidashSeen = new( 219, // Magcargo SeenRapidash, - new[] { + [ new NPCLock(323, 24, 0, 127), // Camerupt (M) (Quirky) new NPCLock(110, 06, 0, 127), // Weezing (M) (Docile) new NPCLock(089, 12, 1, 127), // Muk (F) (Serious) new NPCLock(078, true), // Shadow Rapidash (Seen) - }); + ]); public static readonly TeamLock XHitmonchan = new( 107, // Hitmonchan - new[] { + [ new NPCLock(308, 24, 0, 127), // Medicham (M) (Quirky) new NPCLock(076, 06, 1, 127), // Golem (F) (Docile) new NPCLock(178, 18, 1, 127), // Xatu (F) (Bashful) - }); + ]); public static readonly TeamLock XHitmonlee = new( 106, // Hitmonlee - new[] { + [ new NPCLock(326, 18, 0, 127), // Grumpig (M) (Bashful) new NPCLock(227, 12, 1, 127), // Skarmory (F) (Serious) new NPCLock(375, 06, 2, 255), // Metang (-) (Docile) new NPCLock(297, 24, 1, 063), // Hariyama (F) (Quirky) - }); + ]); public static readonly TeamLock XLickitung = new( 108, // Lickitung - new[] { + [ new NPCLock(171, 24, 0, 127), // Lanturn (M) (Quirky) new NPCLock(082, 06, 2, 255), // Magneton (-) (Docile) - }); + ]); public static readonly TeamLock XScyther = new( 123, // Scyther - new[] - { + [ new NPCLock(234, 06, 1, 127), // Stantler (F) (Docile) new NPCLock(295, 24, 0, 127), // Exploud (M) (Quirky) - }); + ]); public static readonly TeamLock XChansey = new( 113, // Chansey - new[] { + [ new NPCLock(234, 06, 1, 127), // Stantler (F) (Docile) new NPCLock(295, 24, 0, 127), // Exploud (M) (Quirky) new NPCLock(123), // Shadow Scyther - }); + ]); public static readonly TeamLock XChanseyScytherSeen = new( 113, // Chansey SeenScyther, - new[] { + [ new NPCLock(234, 06, 1, 127), // Stantler (F) (Docile) new NPCLock(295, 24, 0, 127), // Exploud (M) (Quirky) new NPCLock(123, true), // Shadow Scyther (Seen) - }); + ]); public static readonly TeamLock XSolrock = new( 338, // Solrock - new[] { + [ new NPCLock(375, 24, 2, 255), // Metang (-) (Quirky) new NPCLock(195, 06, 0, 127), // Quagsire (M) (Docile) new NPCLock(212, 00, 1, 127), // Scizor (F) (Hardy) - }); + ]); public static readonly TeamLock XStarmie = new( 121, // Starmie - new[] { + [ new NPCLock(375, 24, 2, 255), // Metang (-) (Quirky) new NPCLock(195, 06, 0, 127), // Quagsire (M) (Docile) new NPCLock(212, 00, 1, 127), // Scizor (F) (Hardy) new NPCLock(338), // Shadow Solrock new NPCLock(351, 18, 0, 127), // Castform (M) (Bashful) - }); + ]); public static readonly TeamLock XStarmieSolrockSeen = new( 121, // Starmie SeenSolrock, - new[] { + [ new NPCLock(375, 24, 2, 255), // Metang (-) (Quirky) new NPCLock(195, 06, 0, 127), // Quagsire (M) (Docile) new NPCLock(212, 00, 1, 127), // Scizor (F) (Hardy) new NPCLock(338, true), // Shadow Solrock (Seen) new NPCLock(351, 18, 0, 127), // Castform (M) (Bashful) - }); + ]); public static readonly TeamLock XElectabuzz = new( 125, // Electabuzz - new[] { + [ new NPCLock(277), // Shadow Swellow new NPCLock(065, 24, 0, 063), // Alakazam (M) (Quirky) new NPCLock(230, 6, 1, 127), // Kingdra (F) (Docile) new NPCLock(214, 18, 1, 127), // Heracross (F) (Bashful) - }); + ]); public static readonly TeamLock XElectabuzzSwellowSeen = new( 125, // Electabuzz SeenSwellow, - new[] { + [ new NPCLock(277, true), // Shadow Swellow (Seen) new NPCLock(065, 24, 0, 063), // Alakazam (M) (Quirky) new NPCLock(230, 6, 1, 127), // Kingdra (F) (Docile) new NPCLock(214, 18, 1, 127), // Heracross (F) (Bashful) - }); + ]); public static readonly TeamLock XSnorlax = new( 143, // Snorlax - new[] { + [ new NPCLock(277), // Shadow Swellow new NPCLock(065, 24, 0, 063), // Alakazam (M) (Quirky) new NPCLock(230, 6, 1, 127), // Kingdra (F) (Docile) new NPCLock(214, 18, 1, 127), // Heracross (F) (Bashful) new NPCLock(125), // Shadow Electabuzz - }); + ]); public static readonly TeamLock XSnorlaxSwellowSeen = new( 143, // Snorlax SeenSwellow, - new[] { + [ new NPCLock(277, true), // Shadow Swellow (Seen) new NPCLock(065, 24, 0, 063), // Alakazam (M) (Quirky) new NPCLock(230, 6, 1, 127), // Kingdra (F) (Docile) new NPCLock(214, 18, 1, 127), // Heracross (F) (Bashful) new NPCLock(125), // Shadow Electabuzz - }); + ]); public static readonly TeamLock XSnorlaxSwellowElectabuzzSeen = new( 143, // Snorlax SeenSwellowElectabuzz, - new[] { + [ new NPCLock(277, true), // Shadow Swellow (Seen) new NPCLock(065, 24, 0, 063), // Alakazam (M) (Quirky) new NPCLock(230, 6, 1, 127), // Kingdra (F) (Docile) new NPCLock(214, 18, 1, 127), // Heracross (F) (Bashful) new NPCLock(125, true), // Shadow Electabuzz - }); + ]); public static readonly TeamLock XPoliwrath = new( 062, // Poliwrath - new[] { + [ new NPCLock(199, 18, 0, 127), // Slowking (M) (Bashful) new NPCLock(217, 18, 0, 127), // Ursaring (M) (Bashful) new NPCLock(306, 24, 0, 127), // Aggron (M) (Quirky) new NPCLock(365, 06, 1, 127), // Walrein (F) (Docile) - }); + ]); public static readonly TeamLock XMrMime = new( 122, // Mr. Mime - new[] { + [ new NPCLock(199, 18, 0, 127), // Slowking (M) (Bashful) new NPCLock(217, 18, 0, 127), // Ursaring (M) (Bashful) new NPCLock(306, 24, 0, 127), // Aggron (M) (Quirky) new NPCLock(365, 06, 1, 127), // Walrein (F) (Docile) new NPCLock(062), // Shadow Poliwrath - }); + ]); public static readonly TeamLock XMrMimePoliwrathSeen = new( 122, // Mr. Mime SeenPoliwrath, - new[] { + [ new NPCLock(199, 18, 0, 127), // Slowking (M) (Bashful) new NPCLock(217, 18, 0, 127), // Ursaring (M) (Bashful) new NPCLock(306, 24, 0, 127), // Aggron (M) (Quirky) new NPCLock(365, 06, 1, 127), // Walrein (F) (Docile) new NPCLock(062, true), // Shadow Poliwrath (Seen) - }); + ]); public static readonly TeamLock XDugtrio = new( 051, // Dugtrio - new[] { + [ new NPCLock(362, 00, 0, 127), // Glalie (M) (Hardy) new NPCLock(181, 18, 0, 127), // Ampharos (M) (Bashful) new NPCLock(286, 06, 1, 127), // Breloom (F) (Docile) new NPCLock(232, 12, 0, 127), // Donphan (M) (Serious) - }); + ]); public static readonly TeamLock XManectric = new( 310, // Manectric - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) - }); + ]); public static readonly TeamLock XSalamence = new( 373, // Salamence - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310), // Shadow Manectric - }); + ]); public static readonly TeamLock XMarowak = new( 105, // Marowak - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310), // Shadow Manectric new NPCLock(373), // Shadow Salamence new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) - }); + ]); public static readonly TeamLock XLapras = new( 131, // Lapras - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310), // Shadow Manectric new NPCLock(373), // Shadow Salamence new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) new NPCLock(105), // Shadow Marowak - }); + ]); public static readonly TeamLock XSalamenceManectricSeen = new( 373, // Salamence SeenManectric, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) - }); + ]); public static readonly TeamLock XMarowakManectricSeen = new( 105, // Marowak SeenManectric, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) new NPCLock(373), // Shadow Salamence new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) - }); + ]); public static readonly TeamLock XMarowakManectricSalamenceSeen = new( 105, // Marowak SeenManectricSalamence, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) new NPCLock(373, true), // Shadow Salamence (Seen) new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) - }); + ]); public static readonly TeamLock XLaprasManectricSeen = new( 131, // Lapras SeenManectric, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) new NPCLock(373), // Shadow Salamence new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) new NPCLock(105), // Shadow Marowak - }); + ]); public static readonly TeamLock XLaprasManectricSalamenceSeen = new( 131, // Lapras SeenManectricSalamence, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) new NPCLock(373, true), // Shadow Salamence (Seen) new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) new NPCLock(105), // Shadow Marowak - }); + ]); public static readonly TeamLock XLaprasManectricMarowakSeen = new( 131, // Lapras SeenManectricMarowak, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) new NPCLock(373), // Shadow Salamence new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) new NPCLock(105, true), // Shadow Marowak (Seen) - }); + ]); public static readonly TeamLock XLaprasManectricSalamenceMarowakSeen = new( 131, // Lapras SeenManectricMarowakSalamence, - new[] { + [ new NPCLock(291, 06, 1, 127), // Ninjask (F) (Docile) new NPCLock(310, true), // Shadow Manectric (Seen) new NPCLock(373, true), // Shadow Salamence (Seen) new NPCLock(330, 24, 0, 127), // Flygon (M) (Quirky) new NPCLock(105, true), // Shadow Marowak (Seen) - }); + ]); public static readonly TeamLock XMoltres = new( 146, // Moltres - new[] { + [ new NPCLock(112), // Shadow Rhydon - }); + ]); public static readonly TeamLock XExeggutor = new( 103, // Exeggutor - new[] { + [ new NPCLock(112), // Shadow Rhydon new NPCLock(146), // Shadow Moltres - }); + ]); public static readonly TeamLock XTauros = new( 128, // Tauros - new[] { + [ new NPCLock(112), // Shadow Rhydon new NPCLock(146), // Shadow Moltres new NPCLock(103), // Shadow Exeggutor - }); + ]); public static readonly TeamLock XArticuno = new( 144, // Articuno - new[] { + [ new NPCLock(112), // Shadow Rhydon new NPCLock(146), // Shadow Moltres new NPCLock(103), // Shadow Exeggutor new NPCLock(128), // Shadow Tauros - }); + ]); public static readonly TeamLock XZapdos = new( 145, // Zapdos - new[] { + [ new NPCLock(112), // Shadow Rhydon new NPCLock(146), // Shadow Moltres new NPCLock(103), // Shadow Exeggutor new NPCLock(128), // Shadow Tauros new NPCLock(144), // Shadow Articuno - }); + ]); public static readonly TeamLock XExeggutorRhydonMoltresSeen = new( 103, // Exeggutor SeenRhydonMoltres, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) - }); + ]); public static readonly TeamLock XTaurosRhydonMoltresSeen = new( 128, // Tauros SeenRhydonMoltres, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor - }); + ]); public static readonly TeamLock XTaurosRhydonMoltresExeggutorSeen = new( 128, // Tauros SeenRhydonMoltresExeggutor, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) - }); + ]); public static readonly TeamLock XArticunoRhydonMoltresSeen = new( 144, // Articuno SeenRhydonMoltres, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor new NPCLock(128), // Shadow Tauros - }); + ]); public static readonly TeamLock XArticunoRhydonMoltresTaurosSeen = new( 144, // Articuno SeenRhydonMoltresTauros, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor new NPCLock(128, true), // Shadow Tauros (Seen) - }); + ]); public static readonly TeamLock XArticunoRhydonMoltresExeggutorSeen = new( 144, // Articuno SeenRhydonMoltresExeggutor, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) new NPCLock(128), // Shadow Tauros - }); + ]); public static readonly TeamLock XArticunoRhydonMoltresExeggutorTaurosSeen = new( 144, // Articuno SeenRhydonMoltresExeggutorTauros, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) new NPCLock(128, true), // Shadow Tauros (Seen) - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresSeen = new( 145, // Zapdos SeenRhydonMoltres, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor new NPCLock(128), // Shadow Tauros new NPCLock(144), // Shadow Articuno - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresTaurosSeen = new( 145, // Zapdos SeenRhydonMoltresTauros, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor new NPCLock(128, true), // Shadow Tauros (Seen) new NPCLock(144), // Shadow Articuno - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresArticunoSeen = new( 145, // Zapdos SeenRhydonMoltresArticuno, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor new NPCLock(128), // Shadow Tauros new NPCLock(144, true), // Shadow Articuno (Seen) - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresExeggutorSeen = new( 145, // Zapdos SeenRhydonMoltresExeggutor, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) new NPCLock(128), // Shadow Tauros new NPCLock(144), // Shadow Articuno - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresTaurosArticunoSeen = new( 145, // Zapdos SeenRhydonMoltresTaurosArticuno, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103), // Shadow Exeggutor new NPCLock(128, true), // Shadow Tauros (Seen) new NPCLock(144, true), // Shadow Articuno (Seen) - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresExeggutorTaurosSeen = new( 145, // Zapdos SeenRhydonMoltresExeggutorTauros, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) new NPCLock(128, true), // Shadow Tauros (Seen) new NPCLock(144), // Shadow Articuno - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresExeggutorArticunoSeen = new( 145, // Zapdos SeenRhydonMoltresExeggutorArticuno, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) new NPCLock(128), // Shadow Tauros new NPCLock(144, true), // Shadow Articuno (Seen) - }); + ]); public static readonly TeamLock XZapdosRhydonMoltresExeggutorTaurosArticunoSeen = new( 145, // Zapdos SeenRhydonMoltresExeggutorTaurosArticuno, - new[] { + [ new NPCLock(112, true), // Shadow Rhydon (Seen) new NPCLock(146, true), // Shadow Moltres (Seen) new NPCLock(103, true), // Shadow Exeggutor (Seen) new NPCLock(128, true), // Shadow Tauros (Seen) new NPCLock(144, true), // Shadow Articuno (Seen) - }); + ]); public static readonly TeamLock XDragonite = new( 149, // Dragonite - new[] { + [ new NPCLock(272, 00, 0, 127), // Ludicolo (M) (Hardy) new NPCLock(272, 18, 0, 127), // Ludicolo (M) (Bashful) new NPCLock(272, 12, 1, 127), // Ludicolo (F) (Serious) new NPCLock(272, 12, 1, 127), // Ludicolo (F) (Serious) new NPCLock(272, 00, 0, 127), // Ludicolo (M) (Hardy) - }); + ]); } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDTeams.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDTeams.cs index 516727b1a..03b10e5d1 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDTeams.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/Encounters3XDTeams.cs @@ -1,4 +1,3 @@ -using System; using static PKHeX.Core.Encounters3XDShadow; namespace PKHeX.Core; @@ -8,79 +7,79 @@ namespace PKHeX.Core; /// public static class Encounters3XDTeams { - public static readonly TeamLock[] First = Array.Empty(); + public static readonly TeamLock[] First = []; // XD - public static readonly TeamLock[] Spheal = { XSphealCipherLab, XSphealPhenacCityandPost }; - public static readonly TeamLock[] Seedot = { XSeedotCipherLab, XSeedotPhenacCity, XSeedotPost }; + public static readonly TeamLock[] Spheal = [XSphealCipherLab, XSphealPhenacCityandPost]; + public static readonly TeamLock[] Seedot = [XSeedotCipherLab, XSeedotPhenacCity, XSeedotPost]; - public static readonly TeamLock[] Ralts = { XRalts }; - public static readonly TeamLock[] Poochyena = { XPoochyena }; - public static readonly TeamLock[] Ledyba = { XLedyba }; - public static readonly TeamLock[] Gulpin = { XGulpin }; - public static readonly TeamLock[] Spinarak = { XSpinarak }; - public static readonly TeamLock[] Numel = { XNumel }; - public static readonly TeamLock[] Shroomish = { XShroomish }; - public static readonly TeamLock[] Delcatty = { XDelcatty }; - public static readonly TeamLock[] Voltorb = { XVoltorb }; - public static readonly TeamLock[] Makuhita = { XMakuhita }; - public static readonly TeamLock[] Vulpix = { XVulpix }; - public static readonly TeamLock[] Duskull = { XDuskull }; - public static readonly TeamLock[] Mawile = { XMawile }; - public static readonly TeamLock[] Snorunt = { XSnorunt }; - public static readonly TeamLock[] Pineco = { XPineco }; - public static readonly TeamLock[] Natu = { XNatu }; - public static readonly TeamLock[] Roselia = { XRoselia }; - public static readonly TeamLock[] Meowth = { XMeowth }; - public static readonly TeamLock[] Swinub = { XSwinub }; - public static readonly TeamLock[] Spearow = { XSpearow }; - public static readonly TeamLock[] Grimer = { XGrimer }; - public static readonly TeamLock[] Seel = { XSeel }; - public static readonly TeamLock[] Lunatone = { XLunatone }; - public static readonly TeamLock[] Nosepass = { XNosepass }; - public static readonly TeamLock[] Paras = { XParas }; - public static readonly TeamLock[] Growlithe = { XGrowlithe, XGrowlitheParasSeen }; - public static readonly TeamLock[] Pidgeotto = { XPidgeotto, XPidgeottoBeedrillSeen }; - public static readonly TeamLock[] Tangela = { XTangela }; - public static readonly TeamLock[] Butterfree = { XButterfree, XButterfreeTangelaSeen }; - public static readonly TeamLock[] Magneton = { XMagneton }; - public static readonly TeamLock[] Venomoth = { XVenomoth }; - public static readonly TeamLock[] Weepinbell = { XWeepinbell, XWeepinbellVenomothSeen }; - public static readonly TeamLock[] Arbok = { XArbok }; - public static readonly TeamLock[] Primeape = { XPrimeape }; - public static readonly TeamLock[] Hypno = { XHypno, XHypnoPrimeapeSeen }; - public static readonly TeamLock[] Golduck = { XGolduck }; - public static readonly TeamLock[] Sableye = { XSableye, XSableyeGolduckSeen }; - public static readonly TeamLock[] Dodrio = { XDodrio }; - public static readonly TeamLock[] Raticate = { XRaticate, XRaticateDodrioSeen }; - public static readonly TeamLock[] Farfetchd = { XFarfetchd }; - public static readonly TeamLock[] Altaria = { XAltaria, XAltariaFarfetchdSeen }; - public static readonly TeamLock[] Kangaskhan = { XKangaskhan }; - public static readonly TeamLock[] Banette = { XBanette, XBanetteKangaskhanSeen }; - public static readonly TeamLock[] Magmar = { XMagmar }; - public static readonly TeamLock[] Pinsir = { XPinsir, XPinsirMagmarSeen }; - public static readonly TeamLock[] Rapidash = { XRapidash }; - public static readonly TeamLock[] Magcargo = { XMagcargo, XMagcargoRapidashSeen }; - public static readonly TeamLock[] Hitmonchan = { XHitmonchan }; - public static readonly TeamLock[] Hitmonlee = { XHitmonlee }; - public static readonly TeamLock[] Lickitung = { XLickitung }; - public static readonly TeamLock[] Scyther = { XScyther }; - public static readonly TeamLock[] Chansey = { XChansey, XChanseyScytherSeen }; - public static readonly TeamLock[] Solrock = { XSolrock }; - public static readonly TeamLock[] Starmie = { XStarmie, XStarmieSolrockSeen }; - public static readonly TeamLock[] Electabuzz = { XElectabuzz, XElectabuzzSwellowSeen }; - public static readonly TeamLock[] Snorlax = { XSnorlax, XSnorlaxSwellowSeen, XSnorlaxSwellowElectabuzzSeen }; - public static readonly TeamLock[] Poliwrath = { XPoliwrath }; - public static readonly TeamLock[] MrMime = { XMrMime, XMrMimePoliwrathSeen }; - public static readonly TeamLock[] Dugtrio = { XDugtrio }; - public static readonly TeamLock[] Manectric = { XManectric }; - public static readonly TeamLock[] Salamence = { XSalamence, XSalamenceManectricSeen }; - public static readonly TeamLock[] Marowak = { XMarowak, XMarowakManectricSeen, XMarowakManectricSalamenceSeen }; - public static readonly TeamLock[] Lapras = { XLapras, XLaprasManectricSeen, XLaprasManectricSalamenceSeen, XLaprasManectricMarowakSeen, XLaprasManectricSalamenceMarowakSeen }; - public static readonly TeamLock[] Moltres = { XMoltres }; - public static readonly TeamLock[] Exeggutor = { XExeggutor, XExeggutorRhydonMoltresSeen }; - public static readonly TeamLock[] Tauros = { XTauros, XTaurosRhydonMoltresSeen, XTaurosRhydonMoltresExeggutorSeen }; - public static readonly TeamLock[] Articuno = { XArticuno, XArticunoRhydonMoltresSeen, XArticunoRhydonMoltresTaurosSeen, XArticunoRhydonMoltresExeggutorSeen, XArticunoRhydonMoltresExeggutorTaurosSeen }; - public static readonly TeamLock[] Zapdos = { XZapdos, XZapdosRhydonMoltresSeen, XZapdosRhydonMoltresTaurosSeen, XZapdosRhydonMoltresArticunoSeen, XZapdosRhydonMoltresExeggutorSeen, XZapdosRhydonMoltresTaurosArticunoSeen, XZapdosRhydonMoltresExeggutorTaurosSeen, XZapdosRhydonMoltresExeggutorArticunoSeen, XZapdosRhydonMoltresExeggutorTaurosArticunoSeen }; - public static readonly TeamLock[] Dragonite = { XDragonite }; + public static readonly TeamLock[] Ralts = [XRalts]; + public static readonly TeamLock[] Poochyena = [XPoochyena]; + public static readonly TeamLock[] Ledyba = [XLedyba]; + public static readonly TeamLock[] Gulpin = [XGulpin]; + public static readonly TeamLock[] Spinarak = [XSpinarak]; + public static readonly TeamLock[] Numel = [XNumel]; + public static readonly TeamLock[] Shroomish = [XShroomish]; + public static readonly TeamLock[] Delcatty = [XDelcatty]; + public static readonly TeamLock[] Voltorb = [XVoltorb]; + public static readonly TeamLock[] Makuhita = [XMakuhita]; + public static readonly TeamLock[] Vulpix = [XVulpix]; + public static readonly TeamLock[] Duskull = [XDuskull]; + public static readonly TeamLock[] Mawile = [XMawile]; + public static readonly TeamLock[] Snorunt = [XSnorunt]; + public static readonly TeamLock[] Pineco = [XPineco]; + public static readonly TeamLock[] Natu = [XNatu]; + public static readonly TeamLock[] Roselia = [XRoselia]; + public static readonly TeamLock[] Meowth = [XMeowth]; + public static readonly TeamLock[] Swinub = [XSwinub]; + public static readonly TeamLock[] Spearow = [XSpearow]; + public static readonly TeamLock[] Grimer = [XGrimer]; + public static readonly TeamLock[] Seel = [XSeel]; + public static readonly TeamLock[] Lunatone = [XLunatone]; + public static readonly TeamLock[] Nosepass = [XNosepass]; + public static readonly TeamLock[] Paras = [XParas]; + public static readonly TeamLock[] Growlithe = [XGrowlithe, XGrowlitheParasSeen]; + public static readonly TeamLock[] Pidgeotto = [XPidgeotto, XPidgeottoBeedrillSeen]; + public static readonly TeamLock[] Tangela = [XTangela]; + public static readonly TeamLock[] Butterfree = [XButterfree, XButterfreeTangelaSeen]; + public static readonly TeamLock[] Magneton = [XMagneton]; + public static readonly TeamLock[] Venomoth = [XVenomoth]; + public static readonly TeamLock[] Weepinbell = [XWeepinbell, XWeepinbellVenomothSeen]; + public static readonly TeamLock[] Arbok = [XArbok]; + public static readonly TeamLock[] Primeape = [XPrimeape]; + public static readonly TeamLock[] Hypno = [XHypno, XHypnoPrimeapeSeen]; + public static readonly TeamLock[] Golduck = [XGolduck]; + public static readonly TeamLock[] Sableye = [XSableye, XSableyeGolduckSeen]; + public static readonly TeamLock[] Dodrio = [XDodrio]; + public static readonly TeamLock[] Raticate = [XRaticate, XRaticateDodrioSeen]; + public static readonly TeamLock[] Farfetchd = [XFarfetchd]; + public static readonly TeamLock[] Altaria = [XAltaria, XAltariaFarfetchdSeen]; + public static readonly TeamLock[] Kangaskhan = [XKangaskhan]; + public static readonly TeamLock[] Banette = [XBanette, XBanetteKangaskhanSeen]; + public static readonly TeamLock[] Magmar = [XMagmar]; + public static readonly TeamLock[] Pinsir = [XPinsir, XPinsirMagmarSeen]; + public static readonly TeamLock[] Rapidash = [XRapidash]; + public static readonly TeamLock[] Magcargo = [XMagcargo, XMagcargoRapidashSeen]; + public static readonly TeamLock[] Hitmonchan = [XHitmonchan]; + public static readonly TeamLock[] Hitmonlee = [XHitmonlee]; + public static readonly TeamLock[] Lickitung = [XLickitung]; + public static readonly TeamLock[] Scyther = [XScyther]; + public static readonly TeamLock[] Chansey = [XChansey, XChanseyScytherSeen]; + public static readonly TeamLock[] Solrock = [XSolrock]; + public static readonly TeamLock[] Starmie = [XStarmie, XStarmieSolrockSeen]; + public static readonly TeamLock[] Electabuzz = [XElectabuzz, XElectabuzzSwellowSeen]; + public static readonly TeamLock[] Snorlax = [XSnorlax, XSnorlaxSwellowSeen, XSnorlaxSwellowElectabuzzSeen]; + public static readonly TeamLock[] Poliwrath = [XPoliwrath]; + public static readonly TeamLock[] MrMime = [XMrMime, XMrMimePoliwrathSeen]; + public static readonly TeamLock[] Dugtrio = [XDugtrio]; + public static readonly TeamLock[] Manectric = [XManectric]; + public static readonly TeamLock[] Salamence = [XSalamence, XSalamenceManectricSeen]; + public static readonly TeamLock[] Marowak = [XMarowak, XMarowakManectricSeen, XMarowakManectricSalamenceSeen]; + public static readonly TeamLock[] Lapras = [XLapras, XLaprasManectricSeen, XLaprasManectricSalamenceSeen, XLaprasManectricMarowakSeen, XLaprasManectricSalamenceMarowakSeen]; + public static readonly TeamLock[] Moltres = [XMoltres]; + public static readonly TeamLock[] Exeggutor = [XExeggutor, XExeggutorRhydonMoltresSeen]; + public static readonly TeamLock[] Tauros = [XTauros, XTaurosRhydonMoltresSeen, XTaurosRhydonMoltresExeggutorSeen]; + public static readonly TeamLock[] Articuno = [XArticuno, XArticunoRhydonMoltresSeen, XArticunoRhydonMoltresTaurosSeen, XArticunoRhydonMoltresExeggutorSeen, XArticunoRhydonMoltresExeggutorTaurosSeen]; + public static readonly TeamLock[] Zapdos = [XZapdos, XZapdosRhydonMoltresSeen, XZapdosRhydonMoltresTaurosSeen, XZapdosRhydonMoltresArticunoSeen, XZapdosRhydonMoltresExeggutorSeen, XZapdosRhydonMoltresTaurosArticunoSeen, XZapdosRhydonMoltresExeggutorTaurosSeen, XZapdosRhydonMoltresExeggutorArticunoSeen, XZapdosRhydonMoltresExeggutorTaurosArticunoSeen]; + public static readonly TeamLock[] Dragonite = [XDragonite]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen3/EncountersWC3.cs b/PKHeX.Core/Legality/Encounters/Data/Gen3/EncountersWC3.cs index 3dd600245..bda92fadd 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen3/EncountersWC3.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen3/EncountersWC3.cs @@ -10,14 +10,14 @@ namespace PKHeX.Core; internal static class EncountersWC3 { internal static readonly WC3[] Encounter_Event3_Special = - { + [ new() { Species = 385, Level = 05, ID32 = 20043, OT_Gender = 0, Version = GameVersion.R, Method = PIDType.BACD_R, OT_Name = "WISHMKR", CardTitle = "Wishmaker Jirachi", Language = (int)LanguageID.English }, - }; + ]; internal static readonly WC3[] Encounter_Event3 = Encounter_Event3_Special; internal static readonly WC3[] Encounter_Event3_FRLG = - { + [ // PCJP - Egg Pokémon Present Eggs (March 21 to April 4, 2004) new(true) { Species = 043, IsEgg = true, Level = 05, Version = GameVersion.FRLG, Moves = new(071,073,000,000), Method = PIDType.Method_2 }, // Oddish with Leech Seed new(true) { Species = 052, IsEgg = true, Level = 05, Version = GameVersion.FRLG, Moves = new(010,045,080,000), Method = PIDType.Method_2 }, // Meowth with Petal Dance @@ -48,10 +48,10 @@ internal static class EncountersWC3 new(true) { Species = 331, IsEgg = true, Level = 05, Version = GameVersion.FRLG, Moves = new(040,043,071,227), Method = PIDType.Method_2 }, // Cacnea with Encore new(true) { Species = 341, IsEgg = true, Level = 05, Version = GameVersion.FRLG, Moves = new(145,346,000,000), Method = PIDType.Method_2 }, // Corphish with Water Sport new(true) { Species = 360, IsEgg = true, Level = 05, Version = GameVersion.FRLG, Moves = new(150,204,227,321), Method = PIDType.Method_2 }, // Wynaut with Tickle - }; + ]; internal static readonly WC3[] Encounter_Event3_RS = - { + [ // PCJP - Pokémon Center 5th Anniversary Eggs (April 25 to May 18, 2003) new() { Species = 172, IsEgg = true, Level = 05, OT_Name = "オヤNAME", Version = GameVersion.R, Moves = new(084,204,298,000), Method = PIDType.BACD_R }, // Pichu with Teeter Dance new() { Species = 172, IsEgg = true, Level = 05, OT_Name = "オヤNAME", Version = GameVersion.R, Moves = new(084,204,273,000), Method = PIDType.BACD_R }, // Pichu with Wish @@ -69,11 +69,11 @@ internal static class EncountersWC3 new() { Species = 385, Level = 05, ID32 = 30719, OT_Name = "ネガイボシ", Version = GameVersion.RS, Method = PIDType.BACD_U_AX, Language = (int)LanguageID.Japanese, Shiny = Shiny.Never }, // Berry Glitch Fix - // PCJP - (December 29, 2003 to March 31, 2004) + // PCJP - (December 29, 2003, to March 31, 2004) new() { Species = 263, Level = 5, Version = GameVersion.S, Language = (int)LanguageID.Japanese, Method = PIDType.BACD_R_S, ID32 = 21121, OT_Name = "ルビー", OT_Gender = 1, Shiny = Shiny.Always }, new() { Species = 263, Level = 5, Version = GameVersion.S, Language = (int)LanguageID.Japanese, Method = PIDType.BACD_R_S, ID32 = 21121, OT_Name = "サファイア", OT_Gender = 0, Shiny = Shiny.Always }, - // EBGames/GameStop (March 1, 2004 to April 22, 2007), also via multi-game discs + // EBGames/GameStop (March 1, 2004, to April 22, 2007), also via multi-game discs new() { Species = 263, Level = 5, Version = GameVersion.S, Language = (int)LanguageID.English, Method = PIDType.BACD_R_S, ID32 = 30317, OT_Name = "RUBY", OT_Gender = 1 }, new() { Species = 263, Level = 5, Version = GameVersion.S, Language = (int)LanguageID.English, Method = PIDType.BACD_R_S, ID32 = 30317, OT_Name = "SAPHIRE", OT_Gender = 0 }, @@ -197,10 +197,10 @@ internal static class EncountersWC3 new() { Species = 359, Level = 70, Version = GameVersion.R, Moves = new(104,163,248,195), Language = (int)LanguageID.English, Method = PIDType.BACD_R, ID32 = 00010, OT_Name = "10 ANIV", Shiny = Shiny.Never }, // Absol new() { Species = 380, Level = 70, Version = GameVersion.R, Moves = new(296,094,105,204), Language = (int)LanguageID.English, Method = PIDType.BACD_R, ID32 = 00010, OT_Name = "10 ANIV", HeldItem = 191, Shiny = Shiny.Never }, // Latias new() { Species = 381, Level = 70, Version = GameVersion.R, Moves = new(295,094,105,349), Language = (int)LanguageID.English, Method = PIDType.BACD_R, ID32 = 00010, OT_Name = "10 ANIV", HeldItem = 191, Shiny = Shiny.Never }, // Latios - }; + ]; internal static readonly WC3[] Encounter_Event3_Common = - { + [ // Pokémon Box -- RSE Recipient new() { Species = 333, IsEgg = true, Level = 05, Moves = new(064,045,206,000), Method = PIDType.BACD_U, OT_Gender = 1, OT_Name = "AZUSA", Version = GameVersion.RSE }, // Swablu Egg with False Swipe new() { Species = 263, IsEgg = true, Level = 05, Moves = new(033,045,039,245), Method = PIDType.BACD_U, OT_Gender = 1, OT_Name = "AZUSA", Version = GameVersion.RSE }, // Zigzagoon Egg with Extreme Speed @@ -228,7 +228,7 @@ internal static class EncountersWC3 new() { Species = 331, IsEgg = true, Level = 05, Met_Level = 05, TID16 = 50318, OT_Gender = 0, OT_Name = "ポケパーク", Version = GameVersion.R, Moves = new(227), Method = PIDType.BACD_R }, // Cacnea with Encore new() { Species = 341, IsEgg = true, Level = 05, Met_Level = 05, TID16 = 50318, OT_Gender = 0, OT_Name = "ポケパーク", Version = GameVersion.R, Moves = new(346), Method = PIDType.BACD_R }, // Corphish with Water Sport new() { Species = 360, IsEgg = true, Level = 05, Met_Level = 05, TID16 = 50318, OT_Gender = 0, OT_Name = "ポケパーク", Version = GameVersion.R, Moves = new(321), Method = PIDType.BACD_R }, // Wynaut with Tickle - }; + ]; - internal static readonly WC3[] Encounter_WC3 = ArrayUtil.ConcatAll(Encounter_Event3, Encounter_Event3_RS, Encounter_Event3_FRLG, Encounter_Event3_Common); + internal static readonly WC3[] Encounter_WC3 = [..Encounter_Event3, ..Encounter_Event3_RS, ..Encounter_Event3_FRLG, ..Encounter_Event3_Common]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4DPPt.cs b/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4DPPt.cs index 8cbf61908..de876a6e9 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4DPPt.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4DPPt.cs @@ -20,7 +20,7 @@ internal static class Encounters4DPPt #region Static Encounter/Gift Tables public static readonly EncounterStatic4[] StaticDPPt = - { + [ // Gift new(DPPt) { FixedBall = Ball.Poke, Species = 447, Level = 01, Location = 000, EggLocation = 2010 }, // Riolu Egg from Riley new(DPPt) { Species = 442, Level = 25, Location = 24 }, // Spiritomb @ Route 209 @@ -30,10 +30,10 @@ internal static class Encounters4DPPt // Roamers new(DPPt) { Roaming = true, Location = 16, Species = 481, Level = 50, GroundTile = Grass | Water }, // Mesprit new(DPPt) { Roaming = true, Location = 16, Species = 488, Level = 50, GroundTile = Grass | Water }, // Cresselia - }; + ]; public static readonly EncounterStatic4[] StaticDP = - { + [ new(DP) { FixedBall = Ball.Poke, Species = 133, Level = 05, Location = 010, GroundTile = Max_DP }, // Eevee @ Hearthome City new(DP) { FixedBall = Ball.Poke, Species = 440, Level = 01, Location = 000, EggLocation = 2009 }, // Happiny Egg from Traveling Man @@ -50,16 +50,16 @@ internal static class Encounters4DPPt new(DP) { FixedBall = Ball.Poke, Species = 410, Level = 20, Location = 094, GroundTile = Max_DP }, // Shieldon new(DP) { Species = 425, Level = 22, Location = 47 }, // Drifloon @ Valley Windworks - new(DP) { Species = 479, Level = 15, Location = 70, GroundTile = Building }, // Rotom @ Old Chateau + new(DP) { Species = 479, Level = 15, Location = 70, GroundTile = Building }, // Rotom @ Old Château new(DP) { Species = 485, Level = 70, Location = 084, GroundTile = Cave }, // Heatran @ Stark Mountain new(DP) { Species = 486, Level = 70, Location = 064, GroundTile = Cave }, // Regigigas @ Snowpoint Temple new(DP) { Species = 487, Level = 70, Location = 062, GroundTile = Cave, Form = 0 }, // Giratina @ Turnback Cave //new(DP) { Species = 492, Form = 0, Level = 30, Location = 063, Fateful = false }, // Shaymin @ Flower Paradise (Unreleased in Diamond and Pearl) - }; + ]; public static readonly EncounterStatic4[] StaticPt = - { + [ new(Pt) { FixedBall = Ball.Poke, Species = 387, Level = 5, Location = 016, GroundTile = Max_Pt }, // Turtwig @ Route 201 new(Pt) { FixedBall = Ball.Poke, Species = 390, Level = 5, Location = 016, GroundTile = Max_Pt }, // Chimchar new(Pt) { FixedBall = Ball.Poke, Species = 393, Level = 5, Location = 016, GroundTile = Max_Pt }, // Piplup @@ -77,7 +77,7 @@ internal static class Encounters4DPPt new(Pt) { FixedBall = Ball.Poke, Species = 175, Level = 01, Location = 000, EggLocation = 2011 }, // Togepi Egg from Cynthia new(Pt) { Species = 425, Level = 15, Location = 47 }, // Drifloon @ Valley Windworks - new(Pt) { Species = 479, Level = 20, Location = 70, GroundTile = Building }, // Rotom @ Old Chateau + new(Pt) { Species = 479, Level = 20, Location = 70, GroundTile = Building }, // Rotom @ Old Château // Stationary Legendary new(Pt) { Species = 377, Level = 30, Location = 125, GroundTile = Cave }, // Regirock @ Rock Peak Ruins @@ -95,23 +95,23 @@ internal static class Encounters4DPPt new(Pt) { Roaming = true, Location = 16, Species = 144, Level = 60, GroundTile = Grass | Water }, // Articuno new(Pt) { Roaming = true, Location = 16, Species = 145, Level = 60, GroundTile = Grass | Water }, // Zapdos new(Pt) { Roaming = true, Location = 16, Species = 146, Level = 60, GroundTile = Grass | Water }, // Moltres - }; + ]; public static readonly EncounterStatic4[] StaticD = - { + [ new(D ) { Species = 483, Level = 47, Location = 051, GroundTile = Rock }, // Dialga @ Spear Pillar - }; + ]; public static readonly EncounterStatic4[] StaticP = - { + [ new( P) { Species = 484, Level = 47, Location = 051, GroundTile = Rock }, // Palkia @ Spear Pillar - }; + ]; #endregion #region Trade Tables internal static readonly EncounterTrade4RanchGift[] RanchGifts = - { + [ new(323975838, 025, 18) { Moves = new(447,085,148,104), TID16 = 1000, SID16 = 19840, OTGender = 1, MetLocation = 0068, Gender = 0, Ability = OnlyFirst, CurrentLevel = 20 }, // Pikachu new(323977664, 037, 16) { Moves = new(412,109,053,219), TID16 = 1000, SID16 = 21150, OTGender = 1, MetLocation = 3000, Gender = 0, Ability = OnlyFirst, CurrentLevel = 30 }, // Vulpix new(323975579, 077, 13) { Moves = new(036,033,039,052), TID16 = 1000, SID16 = 01123, OTGender = 1, MetLocation = 3000, Gender = 0, Ability = OnlySecond, CurrentLevel = 16 }, // Ponyta @@ -134,15 +134,15 @@ internal static class Encounters4DPPt new(323975582, 459, 32) { Moves = new(452,420,275,059), TID16 = 1000, SID16 = 23360, OTGender = 1, MetLocation = 0031, Gender = 0, Ability = OnlyFirst, CurrentLevel = 41 }, // Snover new(151, 50) { Moves = new(235,216,095,100), TID16 = 1000, SID16 = 59228, OTGender = 1, FixedBall = Ball.Cherish, Gender = 2, Ability = Any12 }, // Mew new(489, 01) { Moves = new(447,240,156,057), TID16 = 1000, SID16 = 09248, OTGender = 1, FixedBall = Ball.Cherish, Gender = 2, Ability = Any12, CurrentLevel = 50, EggLocation = 3000 }, // Phione - }; + ]; internal static readonly EncounterTrade4PID[] TradeGift_DPPtIngame = - { + [ new(TradeNames, 00, DPPt, 0x0000008E, 063, 01) { Ability = OnlyFirst, TID16 = 25643, SID16 = 00000, OTGender = 1, Gender = 0, IVs = new(15,15,15,20,25,25) }, // Machop -> Abra new(TradeNames, 01, DPPt, 0x00000867, 441, 01) { Ability = OnlySecond, TID16 = 44142, SID16 = 00000, OTGender = 0, Gender = 1, IVs = new(15,20,15,25,25,15), Contest = 20 }, // Buizel -> Chatot new(TradeNames, 02, DPPt, 0x00000088, 093, 35) { Ability = OnlyFirst, TID16 = 19248, SID16 = 00000, OTGender = 1, Gender = 0, IVs = new(20,25,15,25,15,15) }, // Medicham (35 from Route 217) -> Haunter new(TradeNames, 03, DPPt, 0x0000045C, 129, 01) { Ability = OnlyFirst, TID16 = 53277, SID16 = 00000, OTGender = 0, Gender = 1, IVs = new(15,25,15,20,25,15) }, // Finneon -> Magikarp - }; + ]; #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4HGSS.cs b/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4HGSS.cs index dd25fd9f9..90b1aa56d 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4HGSS.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen4/Encounters4HGSS.cs @@ -21,7 +21,7 @@ internal static class Encounters4HGSS #region Static Encounter/Gift Tables internal static readonly EncounterStatic4[] Encounter_HGSS = - { + [ // Starters new(HGSS) { FixedBall = Ball.Poke, Species = 001, Level = 05, Location = 138, GroundTile = Max_Pt }, // Bulbasaur @ Pallet Town new(HGSS) { FixedBall = Ball.Poke, Species = 004, Level = 05, Location = 138, GroundTile = Max_Pt }, // Charmander @@ -47,7 +47,7 @@ internal static class Encounters4HGSS new(HGSS) { FixedBall = Ball.Poke, Species = 133, Level = 05, Location = 131, GroundTile = Max_Pt }, // Eevee @ Goldenrod City new(HGSS) { FixedBall = Ball.Poke, Species = 147, Level = 15, Location = 222, GroundTile = Max_Pt, Moves = new(245) }, // Dratini @ Dragon's Den (ExtremeSpeed) new(HGSS) { FixedBall = Ball.Poke, Species = 236, Level = 10, Location = 216, GroundTile = Max_Pt }, // Tyrogue @ Mt. Mortar - new(HGSS) { FixedBall = Ball.Poke, Species = 175, Level = 01, Location = 000, EggLocation = 2013, Moves = new((int)Move.Growl, (int)Move.Charm, (int)Move.Extrasensory) }, // Togepi Egg from Mr. Pokemon (Extrasensory as Egg move) + new(HGSS) { FixedBall = Ball.Poke, Species = 175, Level = 01, Location = 000, EggLocation = 2013, Moves = new((int)Move.Growl, (int)Move.Charm, (int)Move.Extrasensory) }, // Togepi Egg from Mr. Pokémon (Extrasensory as Egg move) new(HGSS) { FixedBall = Ball.Poke, Species = 179, Level = 01, Location = 000, EggLocation = 2014 }, // Mareep Egg from Primo new(HGSS) { FixedBall = Ball.Poke, Species = 194, Level = 01, Location = 000, EggLocation = 2014 }, // Wooper Egg from Primo new(HGSS) { FixedBall = Ball.Poke, Species = 218, Level = 01, Location = 000, EggLocation = 2014 }, // Slugma Egg from Primo @@ -102,38 +102,38 @@ internal static class Encounters4HGSS // Johto Roamers new(HGSS) { Roaming = true, Species = 243, Location = 177, Level = 40, GroundTile = Grass | Water }, // Raikou new(HGSS) { Roaming = true, Species = 244, Location = 177, Level = 40, GroundTile = Grass | Water }, // Entei - }; + ]; internal static readonly EncounterStatic4[] StaticHG = - { + [ new(HG ) { FixedBall = Ball.Poke, Species = 023, Level = 15, Location = 131, GroundTile = Max_Pt }, // Ekans new(HG ) { Species = 249, Level = 70, Location = 218, GroundTile = Water }, // Lugia @ Whirl Islands new(HG ) { Species = 250, Level = 45, Location = 205, GroundTile = Building }, // Ho-Oh @ Bell Tower new(HG ) { Species = 381, Level = 40, Location = 140, GroundTile = Building }, // Latios @ Pewter City new(HG ) { Species = 382, Level = 50, Location = 232, GroundTile = Cave }, // Kyogre @ Embedded Tower new(HG ) { Roaming = true, Species = 380, Location = 149, Level = 35, GroundTile = Grass | Water }, // Latias - }; + ]; internal static readonly EncounterStatic4[] StaticSS = - { + [ new( SS) { FixedBall = Ball.Poke, Species = 027, Level = 15, Location = 131, GroundTile = Max_Pt }, // Sandshrew new( SS) { Species = 249, Level = 45, Location = 218, GroundTile = Water }, // Lugia @ Whirl Islands new( SS) { Species = 250, Level = 70, Location = 205, GroundTile = Building }, // Ho-Oh @ Bell Tower new( SS) { Species = 380, Level = 40, Location = 140, GroundTile = Building }, // Latias @ Pewter City new( SS) { Species = 383, Level = 50, Location = 232, GroundTile = Cave }, // Groudon @ Embedded Tower new( SS) { Roaming = true, Species = 381, Location = 149, Level = 35, GroundTile = Grass | Water }, // Latios - }; + ]; #endregion #region Trade Tables internal static readonly EncounterTrade4PID[] TradeGift_HGSS = - { + [ new(TradeNames, 00, HGSS, 0x000025EF, 095, 01) { Ability = OnlySecond, TID16 = 48926, SID16 = 00000, OTGender = 0, Gender = 0, IVs = new(25,20,25,15,15,15) }, // Bellsprout -> Onix new(TradeNames, 01, HGSS, 0x00002310, 066, 01) { Ability = OnlyFirst, TID16 = 37460, SID16 = 00000, OTGender = 0, Gender = 1, IVs = new(15,25,20,20,15,15) }, // Drowzee -> Machop new(TradeNames, 02, HGSS, 0x000001DB, 100, 01) { Ability = OnlySecond, TID16 = 29189, SID16 = 00000, OTGender = 0, Gender = 2, IVs = new(15,20,15,25,25,15) }, // Krabby -> Voltorb new(TradeNames, 03, HGSS, 0x0001FC0A, 085, 15) { Ability = OnlyFirst, TID16 = 00283, SID16 = 00000, OTGender = 1, Gender = 1, IVs = new(20,20,20,15,15,15) }, // Dragonair (15 from DPPt) -> Dodrio new(TradeNames, 04, HGSS, 0x0000D136, 082, 19) { Ability = OnlyFirst, TID16 = 50082, SID16 = 00000, OTGender = 0, Gender = 2, IVs = new(15,20,15,20,20,20) }, // Dugtrio (19 from Diglett's Cave) -> Magneton - new(TradeNames, 05, HGSS, 0x000034E4, 178, 16) { Ability = OnlyFirst, TID16 = 15616, SID16 = 00000, OTGender = 0, Gender = 0, IVs = new(15,20,15,20,20,20) }, // Haunter (16 from Old Chateau) -> Xatu + new(TradeNames, 05, HGSS, 0x000034E4, 178, 16) { Ability = OnlyFirst, TID16 = 15616, SID16 = 00000, OTGender = 0, Gender = 0, IVs = new(15,20,15,20,20,20) }, // Haunter (16 from Old Château) -> Xatu new(TradeNames, 06, HGSS, 0x00485876, 025, 02) { Ability = OnlyFirst, TID16 = 33038, SID16 = 00000, OTGender = 0, Gender = 1, IVs = new(20,25,18,31,25,13) }, // Pikachu new(TradeNames, 07, HGSS, 0x0012B6D4, 374, 31) { Ability = OnlyFirst, TID16 = 23478, SID16 = 00000, OTGender = 0, Gender = 2, IVs = new(28,29,24,23,24,25) }, // Forretress -> Beldum new(TradeNames, 08, HGSS, 0x0012971C, 111, 01) { Ability = OnlyFirst, TID16 = 06845, SID16 = 00000, OTGender = 0, Gender = 1, IVs = new(22,31,13,00,22,09), Moves = new(422) }, // Bonsly -> Rhyhorn w/ Thunder Fang @@ -142,6 +142,6 @@ internal static class Encounters4HGSS //Gift new(TradeNames, 10, HGSS, 0x00006B5E, 021, 20) { Ability = OnlyFirst, TID16 = 01001, SID16 = 00000, OTGender = 0, Gender = 1, IVs = new(15,20,15,20,20,20), MetLocation = 183, Moves = new(043,031,228,332) },// Webster's Spearow new(TradeNames, 11, HGSS, 0x000214D7, 213, 20) { Ability = OnlySecond, TID16 = 04336, SID16 = 00001, OTGender = 0, Gender = 0, IVs = new(15,20,15,20,20,20), MetLocation = 130, Moves = new(132,117,227,219) },// Kirk's Shuckle - }; + ]; #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5B2W2.cs b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5B2W2.cs index 8a72b71ba..9143d78a1 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5B2W2.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5B2W2.cs @@ -16,8 +16,8 @@ public static class Encounters5B2W2 private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeB2W2); #region DreamWorld Encounter - public static readonly EncounterStatic5Entree[] DreamWorld_B2W2 = DreamWorldEntry.GetArray(B2W2, stackalloc DreamWorldEntry[] - { + public static readonly EncounterStatic5Entree[] DreamWorld_B2W2 = DreamWorldEntry.GetArray(B2W2, + [ // Pleasant Forest new(535, 10, 496, 414, 352), // Tympole new(546, 10, 073, 227, 388), // Cottonee @@ -78,12 +78,12 @@ public static class Encounters5B2W2 new(390, 10, 252, Gender: 0), // Chimchar new(393, 10, 297, Gender: 0), // Piplup new(575, 32, 286, Gender: 0), // Gothorita - }); + ]); #endregion #region Static Encounter/Gift Tables public static readonly EncounterStatic5[] Encounter_B2W2_Regular = - { + [ // Starters @ Aspertia City new(B2W2) { FixedBall = Ball.Poke, Species = 495, Level = 05, Location = 117 }, // Snivy new(B2W2) { FixedBall = Ball.Poke, Species = 498, Level = 05, Location = 117 }, // Tepig @@ -114,7 +114,7 @@ public static class Encounters5B2W2 new(B2W2) { Species = 591, Level = 43, Location = 024 }, // Amoonguss @ Route 11 new(B2W2) { Species = 591, Level = 47, Location = 127 }, // Amoonguss @ Route 22 new(B2W2) { Species = 591, Level = 56, Location = 128 }, // Amoonguss @ Route 23 - new(B2W2) { Species = 593, Level = 40, Location = 071 }, // HA Jellicent @ Undella Bay EncounterSlot collision + new(B2W2) { Species = 593, Level = 40, Location = 071, Ability = OnlyHidden }, // Jellicent @ Undella Bay w/ Hidden Ability new(B2W2) { Species = 637, Level = 35, Location = 035 }, // Volcarona @ Relic Castle new(B2W2) { Species = 637, Level = 65, Location = 035 }, // Volcarona @ Relic Castle new(B2W2) { Species = 558, Level = 42, Location = 141 }, // Crustle @ Seaside Cave @@ -137,28 +137,28 @@ public static class Encounters5B2W2 new(B2W2) { Species = 640, Level = 45, Location = 024 }, // Virizion @ Route 11 new(B2W2) { Species = 640, Level = 65, Location = 024 }, // Virizion @ Route 11 new(B2W2) { Species = 646, Level = 70, Location = 061, Form = 0 }, // Kyurem @ Giant Chasm - }; + ]; public static readonly EncounterStatic5[] StaticB2 = - { + [ new(B2 ) { Species = 443, Level = 01, Location = 122, Shiny = Shiny.Always, Gender = 0, FixedBall = Ball.Poke }, // Shiny Gible @ Floccesy Town new(B2 ) { Species = 381, Level = 68, Location = 032 }, // Latios @ Dreamyard new(B2 ) { Species = 593, Level = 40, Location = 071, Ability = OnlyHidden, Gender = 0 }, // HA Jellicent @ Undella Bay Mon Only new(B2 ) { Species = 630, Level = 25, Location = 017, Ability = OnlyHidden, Gender = 1 }, // HA Mandibuzz @ Route 4 Thurs Only new(B2 ) { Species = 644, Level = 70, Location = 039, Shiny = Shiny.Never }, // Zekrom @ Dragonspiral Tower - }; + ]; public static readonly EncounterStatic5[] StaticW2 = - { + [ new( W2) { Species = 147, Level = 01, Location = 122, Shiny = Shiny.Always, Gender = 0, FixedBall = Ball.Poke }, // Shiny Dratini @ Floccesy Town new( W2) { Species = 380, Level = 68, Location = 032 }, // Latias @ Dreamyard new( W2) { Species = 593, Level = 40, Location = 071, Ability = OnlyHidden, Gender = 1 }, // HA Jellicent @ Undella Bay Thurs Only new( W2) { Species = 628, Level = 25, Location = 017, Ability = OnlyHidden, Gender = 0 }, // HA Braviary @ Route 4 Mon Only new( W2) { Species = 643, Level = 70, Location = 039, Shiny = Shiny.Never }, // Reshiram @ Dragonspiral Tower - }; + ]; public static readonly EncounterStatic5N[] Encounter_B2W2_N = - { + [ // N's Pokemon new(0xFF01007F) { Species = 509, Level = 07, Location = 015, Ability = OnlySecond, Nature = Nature.Timid }, // Purloin @ Route 2 new(0xFF01007F) { Species = 519, Level = 13, Location = 033, Ability = OnlySecond, Nature = Nature.Sassy }, // Pidove @ Pinwheel Forest @@ -175,17 +175,17 @@ public static class Encounters5B2W2 new(0xFF00007F) { Species = 597, Level = 28, Location = 037, Ability = OnlyFirst, Nature = Nature.Bashful }, // Ferroseed @ Chargestone Cave new(0xFF000000) { Species = 599, Level = 28, Location = 037, Ability = OnlyFirst, Nature = Nature.Rash }, // Klink @ Chargestone Cave new(0xFF00001F) { Species = 570, Level = 25, Location = 010, Ability = OnlyFirst, Nature = Nature.Hasty }, // N's Zorua @ Driftveil City - }; + ]; #endregion #region Trade Tables private const ushort YancyTID = 10303; private const ushort CurtisTID = 54118; - private static readonly string[] TradeOT_B2W2_F = { string.Empty, "ルリ", "Yancy", "Brenda", "Lilì", "Sabine", string.Empty, "Belinda", "루리" }; - private static readonly string[] TradeOT_B2W2_M = { string.Empty, "テツ", "Curtis", "Julien", "Dadi", "Markus", string.Empty, "Julián", "철권" }; + private static readonly string[] TradeOT_B2W2_F = [string.Empty, "ルリ", "Yancy", "Brenda", "Lilì", "Sabine", string.Empty, "Belinda", "루리"]; + private static readonly string[] TradeOT_B2W2_M = [string.Empty, "テツ", "Curtis", "Julien", "Dadi", "Markus", string.Empty, "Julián", "철권"]; public static readonly EncounterTrade5B2W2[] TradeGift_B2W2 = - { + [ new(TradeNames, 00, B2 ) { Species = 548, Level = 20, Ability = OnlySecond, ID32 = 65217, OTGender = 1, Gender = 1, IVs = new(20,20,20,20,31,20), Nature = Nature.Timid }, // Petilil new(TradeNames, 01, W2) { Species = 546, Level = 20, Ability = OnlyFirst, ID32 = 71256, OTGender = 0, Gender = 0, IVs = new(20,20,20,20,31,20), Nature = Nature.Modest }, // Cottonee new(TradeNames, 02, B2W2) { Species = 526, Level = 35, Ability = OnlyFirst, ID32 = 11195, OTGender = 0, Gender = 0, IVs = new(20,31,20,20,20,20), Nature = Nature.Adamant, IsFixedNickname = false }, // Gigalith @@ -221,17 +221,17 @@ public static class Encounters5B2W2 new(TradeOT_B2W2_M, B2W2) { Species = 231, Level = 50, Ability = OnlyHidden, ID32 = CurtisTID, OTGender = 0 }, // Phanpy new(TradeOT_B2W2_M, B2W2) { Species = 327, Level = 50, Ability = OnlyHidden, ID32 = CurtisTID, OTGender = 0 }, // Spinda new(TradeOT_B2W2_M, B2W2) { Species = 175, Level = 50, Ability = OnlyHidden, ID32 = CurtisTID, OTGender = 0 }, // Togepi - }; + ]; public static readonly EncounterTrade5B2W2[] TradeGift_W2 = - { + [ new(TradeNames, 01, W2) { Species = 546, Level = 20, Ability = OnlyFirst, ID32 = 71256, OTGender = 0, Gender = 0, IVs = new(20,20,20,20,31,20), Nature = Nature.Modest }, // Cottonee - }; + ]; public static readonly EncounterTrade5B2W2[] TradeGift_B2 = - { + [ new(TradeNames, 00, B2 ) { Species = 548, Level = 20, Ability = OnlySecond, ID32 = 65217, OTGender = 1, Gender = 1, IVs = new(20,20,20,20,31,20), Nature = Nature.Timid }, // Petilil - }; + ]; #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs index 36000480e..5a096ae69 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs @@ -17,8 +17,8 @@ public static class Encounters5BW #region DreamWorld Encounter - public static readonly EncounterStatic5Entree[] DreamWorld_BW = DreamWorldEntry.GetArray(BW, stackalloc DreamWorldEntry[] - { + public static readonly EncounterStatic5Entree[] DreamWorld_BW = DreamWorldEntry.GetArray(BW, + [ // Pleasant Forest new(029, 10, 010, 389, 162), // Nidoran♀ new(032, 10, 064, 068, 162), // Nidoran♂ @@ -116,12 +116,12 @@ public static class Encounters5BW new(242, 10), // Blissey new(448, 10, 418, Gender: 0), // Lucario new(189, 27, 206, Gender: 0), // Jumpluff - }); + ]); #endregion #region Static Encounter/Gift Tables public static readonly EncounterStatic5[] Encounter_BW = - { + [ // Starters @ Nuvema Town new(BW) { FixedBall = Ball.Poke, Species = 495, Level = 05, Location = 004 }, // Snivy new(BW) { FixedBall = Ball.Poke, Species = 498, Level = 05, Location = 004 }, // Tepig @@ -164,40 +164,40 @@ public static class Encounters5BW new(BW) { Species = 494, Level = 15, Location = 062, Shiny = Shiny.Never}, // Victini @ Liberty Garden new(BW) { Species = 570, Level = 10, Location = 008, Shiny = Shiny.Never, Gender = 0 }, // Zorua @ Castelia City new(BW) { Species = 571, Level = 25, Location = 072, Shiny = Shiny.Never, Gender = 1 }, // Zoroark @ Lostlorn Forest - }; + ]; public static readonly EncounterStatic5[] StaticB = - { + [ new(B) { Species = 643, Level = 50, Location = 045, Shiny = Shiny.Never }, // Reshiram @ N's Castle new(B) { Species = 643, Level = 50, Location = 039, Shiny = Shiny.Never }, // Reshiram @ Dragonspiral Tower new(B) { Roaming = true, Species = 641, Level = 40, Location = 25 }, // Tornadus - }; + ]; public static readonly EncounterStatic5[] StaticW = - { + [ new( W) { Species = 644, Level = 50, Location = 045, Shiny = Shiny.Never }, // Zekrom @ N's Castle new( W) { Species = 644, Level = 50, Location = 039, Shiny = Shiny.Never }, // Zekrom @ Dragonspiral Tower new( W) { Roaming = true, Species = 642, Level = 40, Location = 25 }, // Thundurus - }; + ]; #endregion #region Trade Tables internal static readonly EncounterTrade5BW[] TradeGift_BW = - { + [ new(TradeNames, 04, BW, 0xD400007F) { Species = 587, Level = 30, Ability = OnlyFirst, ID32 = 11195, OTGender = 0, Gender = 0, IVs = new(20,20,31,20,20,20), Nature = Nature.Lax }, // Emolga new(TradeNames, 05, BW, 0x2A000000) { Species = 479, Level = 60, Ability = OnlyFirst, ID32 = 54673, OTGender = 1, Gender = 2, IVs = new(20,20,20,20,20,31), Nature = Nature.Gentle }, // Rotom new(TradeNames, 06, BW, 0x6200001F) { Species = 446, Level = 60, Ability = OnlySecond, ID32 = 40217, OTGender = 0, Gender = 0, IVs = new(31,20,20,20,20,20), Nature = Nature.Serious }, // Munchlax - }; + ]; internal static readonly EncounterTrade5BW[] TradeGift_B = - { + [ new(TradeNames, 00, B , 0x64000000) { Species = 548, Level = 15, Ability = OnlyFirst, ID32 = 39922, OTGender = 1, Gender = 1, IVs = new(20,20,20,20,31,20), Nature = Nature.Modest }, // Petilil new(TradeNames, 02, B , 0x9400007F) { Species = 550, Level = 25, Ability = OnlyFirst, ID32 = 27646, OTGender = 0, Gender = 0, IVs = new(20,31,20,20,20,20), Nature = Nature.Adamant, Form = 0 }, // Basculin-Red - }; + ]; internal static readonly EncounterTrade5BW[] TradeGift_W = - { + [ new(TradeNames, 01, W, 0x6400007E) { Species = 546, Level = 15, Ability = OnlyFirst, ID32 = 39922, OTGender = 1, Gender = 1, IVs = new(20,20,20,20,31,20), Nature = Nature.Modest }, // Cottonee new(TradeNames, 03, W, 0x9400007F) { Species = 550, Level = 25, Ability = OnlyFirst, ID32 = 27646, OTGender = 0, Gender = 0, IVs = new(20,31,20,20,20,20), Nature = Nature.Adamant, Form = 1 }, // Basculin-Blue - }; + ]; #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5DR.cs b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5DR.cs index 762b17342..5087e7155 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5DR.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5DR.cs @@ -11,7 +11,7 @@ public static class Encounters5DR #region Dream Radar Tables internal static readonly EncounterStatic5Radar[] Encounter_DreamRadar = - { + [ new(079, 0), // Slowpoke new(120, 0), // Staryu new(137, 0), // Porygon @@ -38,13 +38,13 @@ public static class Encounters5DR new(641, 1), // Therian Tornadus new(642, 1), // Therian Thundurus new(645, 1), // Therian Landorus - }; + ]; #endregion #region DreamWorld Encounter - public static readonly EncounterStatic5Entree[] DreamWorld_Common = DreamWorldEntry.GetArray(Gen5, stackalloc DreamWorldEntry[] - { + public static readonly EncounterStatic5Entree[] DreamWorld_Common = DreamWorldEntry.GetArray(Gen5, + [ // Pleasant Forest new(019, 10, 098, 382, 231), // Rattata new(043, 10, 230, 298, 202), // Oddish @@ -217,7 +217,7 @@ public static class Encounters5DR new(149, 55, 245, Gender: 0), // Dragonite new(248, 55, 069, Gender: 0), // Tyranitar new(376, 45, 038, Gender: 2), // Metagross - }); + ]); #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6AO.cs b/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6AO.cs index 233cf9c02..7b733cebf 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6AO.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6AO.cs @@ -35,7 +35,7 @@ internal static class Encounters6AO }; private static readonly EncounterStatic6[] Encounter_AO_Regular = - { + [ // Starters @ Route 101 new(ORAS) { FixedBall = Ball.Poke, Species = 252, Level = 5, Location = 204 }, // Treeko new(ORAS) { FixedBall = Ball.Poke, Species = 255, Level = 5, Location = 204 }, // Torchic @@ -124,10 +124,10 @@ internal static class Encounters6AO BaseCosplay with {Form = 4, Moves = new(098, 486, 086, (int)Move.ElectricTerrain)}, // Ph.D. BaseCosplay with {Form = 5, Moves = new(098, 486, 086, (int)Move.FlyingPress)}, // Libre BaseCosplay, // Cosplay, same 3 level up moves. - }; + ]; internal static readonly EncounterStatic6[] StaticA = - { + [ new( AS) { Species = 380, Level = 30, Location = 320, Ability = OnlyFirst, FixedBall = Ball.Poke, FlawlessIVCount = 3 }, // Latias new( AS) { Species = 382, Level = 45, Location = 296, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Kyogre new( AS) { Species = 249, Level = 50, Location = 304, FlawlessIVCount = 3 }, // Lugia @@ -136,10 +136,10 @@ internal static class Encounters6AO new( AS) { Species = 642, Level = 50, Location = 348, FlawlessIVCount = 3 }, // Thundurus new( AS) { Species = 381, Level = 30, Location = 320, FlawlessIVCount = 3 }, // Latios new( AS) { Species = 101, Level = 40, Location = 292 }, // Electrode - }; + ]; internal static readonly EncounterStatic6[] StaticO = - { + [ new(OR ) { Species = 381, Level = 30, Location = 320, Ability = OnlyFirst, FixedBall = Ball.Poke, FlawlessIVCount = 3 }, // Latios new(OR ) { Species = 383, Level = 45, Location = 296, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Groudon new(OR ) { Species = 250, Level = 50, Location = 304, FlawlessIVCount = 3 }, // Ho-Oh @@ -148,17 +148,17 @@ internal static class Encounters6AO new(OR ) { Species = 641, Level = 50, Location = 348, FlawlessIVCount = 3 }, // Tornadus new(OR ) { Species = 380, Level = 30, Location = 320, FlawlessIVCount = 3 }, // Latias new(OR ) { Species = 101, Level = 40, Location = 314 }, // Electrode - }; + ]; internal static readonly EncounterStatic6[] Encounter_AO = Encounter_AO_Regular; #endregion #region Trade Tables internal static readonly EncounterTrade6[] TradeGift_AO = - { + [ new(TradeNames, 00, ORAS, 01,3,05,040) { Species = 296, Level = 09, Ability = OnlySecond, ID32 = 30724, Gender = 0, OTGender = 0, IVs = new(-1,31,-1,-1,-1,-1), Nature = Nature.Brave }, // Makuhita new(TradeNames, 01, ORAS, 34,3,13,176) { Species = 300, Level = 30, Ability = OnlyFirst, ID32 = 03239, Gender = 1, OTGender = 1, IVs = new(-1,-1,-1,31,-1,-1), Nature = Nature.Naughty }, // Skitty new(TradeNames, 02, ORAS, 07,4,10,319) { Species = 222, Level = 50, Ability = OnlyHidden, ID32 = 00325, Gender = 1, OTGender = 1, IVs = new(31,-1,-1,-1,-1,31), Nature = Nature.Calm }, // Corsola - }; + ]; #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6XY.cs b/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6XY.cs index d49be0077..ad0bc9e16 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6XY.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen6/Encounters6XY.cs @@ -18,7 +18,7 @@ internal static class Encounters6XY #region Static Encounter/Gift Tables internal static readonly EncounterStatic6[] Encounter_XY = - { + [ // Kalos Starters @ Aquacorde Town new(XY) { FixedBall = Ball.Poke, Species = 650, Level = 5, Location = 10 }, // Chespin new(XY) { FixedBall = Ball.Poke, Species = 653, Level = 5, Location = 10 }, // Fennekin @@ -56,7 +56,7 @@ internal static class Encounters6XY new(XY) { Species = 569, Level = 38, Location = 142 }, // Garbodor new(XY) { Species = 479, Level = 38, Location = 142 }, // Rotom - // Shaking Trash Cans @ Pokemon Village + // Shaking Trash Cans @ Pokémon Village new(XY) { Species = 569, Level = 46, Location = 98 }, // Garbodor new(XY) { Species = 569, Level = 47, Location = 98 }, // Garbodor new(XY) { Species = 569, Level = 48, Location = 98 }, // Garbodor @@ -74,22 +74,22 @@ internal static class Encounters6XY new(XY) { Species = 144, Level = 70, Location = 146, Ability = OnlyFirst, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Articuno new(XY) { Species = 145, Level = 70, Location = 146, Ability = OnlyFirst, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Zapdos new(XY) { Species = 146, Level = 70, Location = 146, Ability = OnlyFirst, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Moltres - }; + ]; internal static readonly EncounterStatic6[] StaticX = - { + [ new(X ) { Species = 716, Level = 50, Location = 138, Ability = OnlyFirst, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Xerneas - }; + ]; internal static readonly EncounterStatic6[] StaticY = - { + [ new( Y) { Species = 717, Level = 50, Location = 138, Ability = OnlyFirst, Shiny = Shiny.Never, FlawlessIVCount = 3 }, // Yveltal - }; + ]; #endregion #region Trade Tables internal static readonly EncounterTrade6[] TradeGift_XY = - { + [ new(TradeNames, 00, XY, 01,3,23,049) { Species = 129, Level = 05, Ability = OnlyFirst, ID32 = 44285, Gender = 0, OTGender = 0, IVs = new(-1,31,-1,-1,31,-1), Nature = Nature.Adamant }, // Magikarp new(TradeNames, 01, XY, 10,3,00,000) { Species = 133, Level = 05, Ability = OnlyFirst, ID32 = 29294, Gender = 1, OTGender = 1, IVs = default, Nature = Nature.Docile }, // Eevee @@ -101,6 +101,6 @@ internal static class Encounters6XY new(TradeNames, 06, XY, 02,3,09,005) { Species = 650, Level = 05, Ability = OnlyFirst, ID32 = 00037, Gender = 0, OTGender = 1, IVs = new(20,31,20,20,20,20), Nature = Nature.Adamant }, // Chespin new(TradeNames, 07, XY, 02,3,18,005) { Species = 653, Level = 05, Ability = OnlyFirst, ID32 = 00037, Gender = 0, OTGender = 1, IVs = new(20,20,20,20,31,20), Nature = Nature.Modest }, // Fennekin new(TradeNames, 08, XY, 51,4,04,033) { Species = 280, Level = 05, Ability = OnlyFirst, ID32 = 37110, Gender = 1, OTGender = 1, IVs = new(20,20,20,31,31,20), Nature = Nature.Modest, IsFixedNickname = false }, // Ralts - }; + ]; #endregion } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7GG.cs b/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7GG.cs index 20a77839c..78ae60f9a 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7GG.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7GG.cs @@ -9,7 +9,7 @@ internal static class Encounters7GG internal static readonly EncounterArea7b[] SlotsGE = EncounterArea7b.GetAreas(Get("ge", "gg"u8), GE); internal static readonly EncounterStatic7b[] Encounter_GG = - { + [ // encounters new(GG) { Species = 144, Level = 50, Location = 44, FlawlessIVCount = 3 }, // Articuno @ Seafoam Islands new(GG) { Species = 145, Level = 50, Location = 42, FlawlessIVCount = 3 }, // Zapdos @ Power Plant @@ -34,31 +34,31 @@ internal static class Encounters7GG new(GG) { Species = 004, Level = 14, Location = 26, FixedBall = Ball.Poke, IVs = new(25,30,25,31,30,25) }, // Charmander @ Route 24 new(GG) { Species = 007, Level = 16, Location = 33, FixedBall = Ball.Poke, IVs = new(25,25,30,25,31,30) }, // Squirtle @ Vermillion City new(GG) { Species = 137, Level = 34, Location = 38, FixedBall = Ball.Poke, IVs = new(25,25,30,25,31,30) }, // Porygon @ Saffron City (Silph Co. Employee, outside) - }; + ]; internal static readonly EncounterStatic7b[] StaticGP = - { + [ new(GP) { Species = 025, Level = 05, Location = 28, FixedBall = Ball.Poke, IVs = new(31,31,31,31,31,31), Shiny = Shiny.Never, Form = 8 }, // Pikachu @ Pallet Town new(GP) { Species = 053, Level = 16, Location = 33, FixedBall = Ball.Poke, IVs = new(30,30,25,31,25,25) }, // Persian @ Vermillion City (Outside Fan Club) - }; + ]; internal static readonly EncounterStatic7b[] StaticGE = - { + [ new(GE) { Species = 133, Level = 05, Location = 28, FixedBall = Ball.Poke, IVs = new(31,31,31,31,31,31), Shiny = Shiny.Never, Form = 1 }, // Eevee @ Pallet Town new(GE) { Species = 059, Level = 16, Location = 33, FixedBall = Ball.Poke, IVs = new(25,30,25,31,30,25) }, // Arcanine @ Vermillion City (Outside Fan Club) - }; + ]; - private static readonly string[] T1 = { string.Empty, "ミニコ", "Tatianna", "BarbaRatatta", "Addoloratta", "Barbaratt", string.Empty, "Tatiana", "미니꼬", "小幂妮", "小幂妮" }; - private static readonly string[] T2 = { string.Empty, "ボーアイス", "Nicholice", "Iceman-4L0L4", "Goffreddo", "Eisper", string.Empty, "Gelasio", "보아이스", "露冰冰", "露冰冰" }; - private static readonly string[] T3 = { string.Empty, "レディダグ", "Diggette", "Taupilady", "Lady Glett", "Digga", string.Empty, "Glenda", "레이디그다", "蒂淑", "蒂淑" }; - private static readonly string[] T4 = { string.Empty, "ワルモン", "Darko", "AlolaZeDark", "Mattetro", "Bösbert", string.Empty, "Sinesio", "나뻐기", "达怀丹", "达怀丹" }; - private static readonly string[] T5 = { string.Empty, "エリッチ", "Psytrice", "TopDeTonCœur", "Chulia", "Assana", string.Empty, "Menchu", "엘리츄", "晶莹丘", "晶莹丘" }; - private static readonly string[] T6 = { string.Empty, "ジェンガラ", "Genmar", "OSS-Dandy7", "Mr. Owak", "Knoggelius", string.Empty, "Mario", "젠구리", "申史加拉", "申史加拉" }; - private static readonly string[] T7 = { string.Empty, "マニシ", "Exemann", "Koko-fan", "Exechiele", "Einrich", string.Empty, "Gunter", "마니시", "艾浩舒", "艾浩舒" }; - private static readonly string[] T8 = { string.Empty, "コツブ", "Higeo", "Montagnou", "George", "Karstein", string.Empty, "Georgie", "산돌", "科布", "科布" }; + private static readonly string[] T1 = [string.Empty, "ミニコ", "Tatianna", "BarbaRatatta", "Addoloratta", "Barbaratt", string.Empty, "Tatiana", "미니꼬", "小幂妮", "小幂妮"]; + private static readonly string[] T2 = [string.Empty, "ボーアイス", "Nicholice", "Iceman-4L0L4", "Goffreddo", "Eisper", string.Empty, "Gelasio", "보아이스", "露冰冰", "露冰冰"]; + private static readonly string[] T3 = [string.Empty, "レディダグ", "Diggette", "Taupilady", "Lady Glett", "Digga", string.Empty, "Glenda", "레이디그다", "蒂淑", "蒂淑"]; + private static readonly string[] T4 = [string.Empty, "ワルモン", "Darko", "AlolaZeDark", "Mattetro", "Bösbert", string.Empty, "Sinesio", "나뻐기", "达怀丹", "达怀丹"]; + private static readonly string[] T5 = [string.Empty, "エリッチ", "Psytrice", "TopDeTonCœur", "Chulia", "Assana", string.Empty, "Menchu", "엘리츄", "晶莹丘", "晶莹丘"]; + private static readonly string[] T6 = [string.Empty, "ジェンガラ", "Genmar", "OSS-Dandy7", "Mr. Owak", "Knoggelius", string.Empty, "Mario", "젠구리", "申史加拉", "申史加拉"]; + private static readonly string[] T7 = [string.Empty, "マニシ", "Exemann", "Koko-fan", "Exechiele", "Einrich", string.Empty, "Gunter", "마니시", "艾浩舒", "艾浩舒"]; + private static readonly string[] T8 = [string.Empty, "コツブ", "Higeo", "Montagnou", "George", "Karstein", string.Empty, "Georgie", "산돌", "科布", "科布"]; internal static readonly EncounterTrade7b[] TradeGift_GG = - { + [ // Random candy values! They can be zero so no impact on legality even though statistically rare. new(GG) { Species = 019, Form = 1, Level = 12, TrainerNames = T1, ID32 = 121106, OTGender = 1, IVs = new(31,31,-1,-1,-1,-1) }, // Rattata @ Cerulean City, AV rand [0-5) new(GG) { Species = 050, Form = 1, Level = 25, TrainerNames = T3, ID32 = 520159, OTGender = 1, IVs = new(-1,31,-1,31,-1,-1) }, // Diglett @ Lavender Town, AV rand [0-5) @@ -66,17 +66,17 @@ internal static class Encounters7GG new(GG) { Species = 105, Form = 1, Level = 38, TrainerNames = T6, ID32 = 102595, OTGender = 0, IVs = new(-1,31,31,-1,-1,-1) }, // Marowak @ Fuchsia City, AV rand [0-10) new(GG) { Species = 103, Form = 1, Level = 46, TrainerNames = T7, ID32 = 060310, OTGender = 0, IVs = new(-1,31,-1,-1,31,-1) }, // Exeggutor @ Indigo Plateau, AV rand [0-15) new(GG) { Species = 074, Form = 1, Level = 16, TrainerNames = T8, ID32 = 551873, OTGender = 0, IVs = new(31,31,-1,-1,-1,-1) }, // Geodude @ Vermilion City, AV rand [0-5) - }; + ]; internal static readonly EncounterTrade7b[] TradeGift_GP = - { + [ new(GP) { Species = 027, Form = 1, Level = 27, TrainerNames = T2, ID32 = 703019, OTGender = 0, IVs = new(-1,31,31,-1,-1,-1) }, // Sandshrew @ Celadon City, AV rand [0-5) new(GP) { Species = 088, Form = 1, Level = 44, TrainerNames = T4, ID32 = 000219, OTGender = 0, IVs = new(31,31,-1,-1,-1,-1) }, // Grimer @ Cinnabar Island, AV rand [0-10) - }; + ]; internal static readonly EncounterTrade7b[] TradeGift_GE = - { + [ new(GE) { Species = 037, Form = 1, Level = 27, TrainerNames = T2, ID32 = 703019, OTGender = 0, IVs = new(-1,-1,-1,31,31,-1) }, // Vulpix @ Celadon City, AV rand [0-5) new(GE) { Species = 052, Form = 1, Level = 44, TrainerNames = T4, ID32 = 000219, OTGender = 0, IVs = new(31,-1,-1,31,-1,-1) }, // Meowth @ Cinnabar Island, AV rand [0-10) - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7SM.cs b/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7SM.cs index 471704e82..7f81756ce 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7SM.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7SM.cs @@ -16,7 +16,7 @@ internal static class Encounters7SM private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeSM); public static readonly EncounterStatic7[] StaticSM = // @ a\1\5\5 - { + [ // Gifts - 0.bin new(SM) { FixedBall = Ball.Poke, Species = 722, Level = 5, Location = 024 }, // Rowlet new(SM) { FixedBall = Ball.Poke, Species = 725, Level = 5, Location = 024 }, // Litten @@ -71,7 +71,7 @@ internal static class Encounters7SM new(SM) { Species = 799, Level = 70, Location = 182, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Guzzlord @ Resolution Cave new(SM) { Species = 800, Level = 75, Location = 036, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Necrozma @ Ten Carat Hill (Farthest Hollow) - // QR Scan: Su/M/Tu/W/Th/F/Sa + // QR Scan: Su/M/Tu/W/Thu/F/Sa // Melemele Island new(SM) { Species = 155, Level = 12, Location = 010, Relearn = new(024, 052, 108, 043) }, // Cyndaquil @ Route 3 new(SM) { Species = 158, Level = 12, Location = 042, Relearn = new(232, 099, 055, 043) }, // Totodile @ Seaward Cave @@ -107,26 +107,26 @@ internal static class Encounters7SM new(SM) { Species = 497, Level = 43, Location = 184, Relearn = new(137, 489, 348, 021) }, // Serperior @ Exeggutor Island new(SM) { Species = 503, Level = 43, Location = 158, Relearn = new(362, 227, 453, 279) }, // Samurott @ Poni Wilds new(SM) { Species = 500, Level = 43, Location = 160, Relearn = new(276, 053, 372, 535) }, // Emboar @ Ancient Poni Path - }; + ]; public static readonly EncounterStatic7[] StaticSN = - { + [ new(SN) { Species = 791, Level = 55, Location = 176, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3, Relearn = new(713, 322, 242, 428) }, // Solgaleo new(SN) { Species = 794, Level = 65, Location = 040, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Buzzwole @ Melemele Meadow new(SN) { Species = 798, Level = 60, Location = 134, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Kartana @ Malie Garden new(SN) { Species = 798, Level = 60, Location = 120, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Kartana @ Route 17 - }; + ]; public static readonly EncounterStatic7[] StaticMN = - { + [ new(MN) { Species = 792, Level = 55, Location = 178, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3, Relearn = new(714, 322, 539, 247) }, // Lunala new(MN) { Species = 795, Level = 60, Location = 046, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Pheromosa @ Verdant Cavern (Trial Site) new(MN) { Species = 797, Level = 65, Location = 124, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Celesteela @ Haina Desert new(MN) { Species = 797, Level = 65, Location = 134, Shiny = Shiny.Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Celesteela @ Malie Garden - }; + ]; internal static readonly EncounterTrade7[] TradeGift_SM = // @ a\1\5\5 - { + [ // Trades - 4.bin new(TradeNames, 00, SM) { Species = 066, Form = 0, Level = 09, Ability = OnlySecond, ID32 = 000410, IVs = new(-1,31,-1,-1,-1,-1), OTGender = 1, Gender = 0, Nature = Nature.Brave }, // Machop new(TradeNames, 01, SM) { Species = 761, Form = 0, Level = 16, Ability = OnlyFirst, ID32 = 610507, IVs = new(-1,31,-1,-1,-1,-1), OTGender = 0, Gender = 1, Nature = Nature.Adamant }, // Bounsweet @@ -135,5 +135,5 @@ internal static class Encounters7SM new(TradeNames, 04, SM) { Species = 075, Form = 1, Level = 32, Ability = OnlyFirst, ID32 = 610602, IVs = new(-1,-1,31,-1,-1,-1), OTGender = 0, Gender = 0, Nature = Nature.Impish, EvolveOnTrade = true }, // Graveler-1 new(TradeNames, 05, SM) { Species = 762, Form = 0, Level = 43, Ability = OnlyFirst, ID32 = 610503, IVs = new(-1,-1,-1,-1,-1,31), OTGender = 1, Gender = 1, Nature = Nature.Careful }, // Steenee new(TradeNames, 06, SM) { Species = 663, Form = 0, Level = 59, Ability = OnlyHidden, ID32 = 581022, IVs = new(-1,-1,-1,31,-1,-1), OTGender = 0, Gender = 0, Nature = Nature.Jolly }, // Talonflame - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7USUM.cs b/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7USUM.cs index cff31e754..86d8b719c 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7USUM.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen7/Encounters7USUM.cs @@ -16,7 +16,7 @@ internal static class Encounters7USUM private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeUSUM); public static readonly EncounterStatic7[] StaticUSUM = - { + [ new(USUM) { FixedBall = Ball.Poke, Species = 722, Level = 05, Location = 008 }, // Rowlet new(USUM) { FixedBall = Ball.Poke, Species = 725, Level = 05, Location = 008 }, // Litten new(USUM) { FixedBall = Ball.Poke, Species = 728, Level = 05, Location = 008 }, // Popplio @@ -54,7 +54,7 @@ internal static class Encounters7USUM new(USUM) { FixedBall = Ball.Poke, Species = 718, Form = 2, Level = 50, Shiny = Shiny.Never, Location = 118, FlawlessIVCount = 3 }, // Zygarde (10%-C) new(USUM) { FixedBall = Ball.Poke, Species = 718, Form = 3, Level = 50, Shiny = Shiny.Never, Location = 118, FlawlessIVCount = 3 }, // Zygarde (50%-C) - // QR Scan: Su/M/Tu/W/Th/F/Sa + // QR Scan: Su/M/Tu/W/Thu/F/Sa // Melemele Island new(USUM) { Species = 004, Level = 12, Location = 010, Relearn = new(068,108,052,010) }, // Charmander @ Route 3 new(USUM) { Species = 007, Level = 12, Location = 042, Relearn = new(453,110,055,033) }, // Squirtle @ Seaward Cave @@ -173,10 +173,10 @@ internal static class Encounters7USUM new(USUM) { Species = 739, Level = 28, Location = 110 }, // Ula'ula Beach new(USUM) { Species = 739, Level = 31, Location = 118 }, // Route 16 new(USUM) { Species = 739, Level = 32, Location = 120 }, // Route 17 - }; + ]; public static readonly EncounterStatic7[] StaticUS = - { + [ new(US ) { FixedBall = Ball.Poke, Species = 789, Level = 05, Location = 142, FlawlessIVCount = 3, Shiny = Shiny.Never, Ability = OnlySecond }, // Cosmog @ Lake of the Sunne // Totem-Sized Gifts @ Heahea Beach @@ -200,10 +200,10 @@ internal static class Encounters7USUM new(US ) { Species = 794, Level = 60, Location = 218, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Buzzwole @ Ultra Jungle new(US ) { Species = 798, Level = 60, Location = 216, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Kartana @ Ultra Forest new(US ) { Species = 806, Level = 60, Location = 164, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Blacephalon @ Poni Grove - }; + ]; public static readonly EncounterStatic7[] StaticUM = - { + [ new( UM) { FixedBall = Ball.Poke, Species = 789, Level = 05, Location = 144, FlawlessIVCount = 3, Shiny = Shiny.Never, Ability = OnlySecond }, // Cosmog @ Lake of the Moone // Totem-Sized Gifts @ Heahea Beach @@ -229,10 +229,10 @@ internal static class Encounters7USUM new( UM) { Species = 805, Level = 60, Location = 164, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Stakataka @ Poni Grove new( UM) { Species = 769, Level = 30, Location = 116, Shiny = Shiny.Never, Relearn = new(310,523,072,328) }, // Sandygast @ Route 15 - }; + ]; internal static readonly EncounterTrade7[] TradeGift_USUM = - { + [ // Trades - 4.bin new(TradeNames, 00, USUM) { Species = 701, Form = 0, Level = 08, Ability = OnlySecond, ID32 = 000410, IVs = new(-1,31,-1,-1,-1,-1), OTGender = 1, Gender = 0, Nature = Nature.Brave }, // Hawlucha new(TradeNames, 01, USUM) { Species = 714, Form = 0, Level = 19, Ability = OnlyFirst, ID32 = 610507, IVs = new(-1,-1,-1,-1,31,-1), OTGender = 0, Gender = 0, Nature = Nature.Modest }, // Noibat @@ -241,5 +241,5 @@ internal static class Encounters7USUM new(TradeNames, 04, USUM) { Species = 708, Form = 0, Level = 33, Ability = OnlyFirst, ID32 = 610602, IVs = new(-1,-1,-1,-1,-1,31), OTGender = 0, Gender = 0, Nature = Nature.Calm, EvolveOnTrade = true }, // Phantump new(TradeNames, 05, USUM) { Species = 422, Form = 0, Level = 44, Ability = OnlySecond, ID32 = 610503, IVs = new(-1,-1,31,-1,-1,-1), OTGender = 1, Gender = 1, Nature = Nature.Quiet }, // Shellos new(TradeNames, 06, USUM) { Species = 128, Form = 0, Level = 59, Ability = OnlyFirst, ID32 = 581022, IVs = new(-1,-1,-1,31,-1,-1), OTGender = 0, Gender = 0, Nature = Nature.Jolly }, // Tauros - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8.cs b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8.cs index aa4f0d82d..1bd47fd2b 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8.cs @@ -17,7 +17,7 @@ internal static class Encounters8 public static readonly EncounterArea8[] SlotsSH_Hidden = EncounterArea8.GetAreas(Get("sh_hidden", "sh"u8), SH); public static readonly EncounterStatic8[] StaticSWSH = - { + [ // gifts new() { FixedBall = Ball.Poke, Species = 810, Shiny = Never, Level = 05, Location = 006 }, // Grookey new() { FixedBall = Ball.Poke, Species = 813, Shiny = Never, Level = 05, Location = 006 }, // Scorbunny @@ -696,10 +696,10 @@ internal static class Encounters8 new() { Species = 305, Level = 63, Location = 232, Weather = Overcast }, // Lairon in Lakeside Cave new() { Species = 839, Level = 68, Location = 232, Weather = Overcast }, // Coalossal in Lakeside Cave new() { Species = 820, Level = 68, Location = 234, Weather = All_Ballimere }, // Greedent at Dyna Tree Hill - }; + ]; public static readonly EncounterStatic8[] StaticSW = - { + [ new(SW ) { Species = 888, Level = 70, Location = 66, ScriptedNoMarks = true, Moves = new(533,014,442,242), Shiny = Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Zacian new(SW ) { Species = 275, Level = 34, Location = 124, Weather = Normal | Overcast | Stormy | Heavy_Fog }, // Shiftry in the Dappled Grove @@ -726,10 +726,10 @@ internal static class Encounters8 new(SW ) { Species = 635, Level = 68, Location = 224, Weather = No_Sun_Sand }, // Hydreigon in Roaring-Sea Caves, weather from Frigid Sea new(SW ) { Species = 139, Level = 68, Location = 224, Weather = Overcast }, // Omastar in Roaring-Sea Caves new(SW ) { Species = 876, Level = 65, Location = 230, Weather = Normal | Heavy_Fog }, // Indeedee at Ballimere Lake - }; + ]; public static readonly EncounterStatic8[] StaticSH = - { + [ new( SH) { Species = 889, Level = 70, Location = 66, ScriptedNoMarks = true, Moves = new(163,242,442,334), Shiny = Never, Ability = OnlyFirst, FlawlessIVCount = 3 }, // Zamazenta new( SH) { Species = 272, Level = 34, Location = 124, Weather = Normal | Overcast | Stormy | Heavy_Fog }, // Ludicolo in the Dappled Grove @@ -755,15 +755,15 @@ internal static class Encounters8 new( SH) { Species = 141, Level = 68, Location = 224, Weather = Overcast }, // Kabutops in Roaring-Sea Caves new( SH) { Species = 875, Level = 65, Location = 226, Weather = No_Sun_Sand }, // Eiscue at the Frigid Sea new( SH) { Species = 876, Level = 65, Location = 230, Form = 01, Weather = Normal | Heavy_Fog }, // Indeedee-1 at Ballimere Lake - }; + ]; private const string tradeSWSH = "tradeswsh"; private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeSWSH, "zh2"); - private static readonly string[] TradeOT_R1 = { string.Empty, "チホコ", "Regina", "Régiona", "Regionalia", "Regine", string.Empty, "Tatiana", "지민", "易蒂", "易蒂" }; + private static readonly string[] TradeOT_R1 = [string.Empty, "チホコ", "Regina", "Régiona", "Regionalia", "Regine", string.Empty, "Tatiana", "지민", "易蒂", "易蒂"]; private static readonly IndividualValueSet TradeIVs = new(15, 15, 15, 15, 15, 15); public static readonly EncounterTrade8[] TradeSWSH = - { + [ new(TradeNames, 00, SWSH, 052,18,08,000,04,5) { Ability = OnlySecond, ID32 = 263455, IVs = TradeIVs, DynamaxLevel = 1, OTGender = 0, Gender = 0, Nature = Nature.Timid, Relearn = new(387) }, // Meowth new(TradeNames, 01, SWSH, 819,10,01,044,01,2) { Ability = OnlyFirst, ID32 = 648753, IVs = TradeIVs, DynamaxLevel = 1, OTGender = 1, Gender = 0, Nature = Nature.Mild }, // Skwovet new(TradeNames, 02, SWSH, 546,23,11,000,09,5) { Ability = OnlyFirst, ID32 = 101154, IVs = TradeIVs, DynamaxLevel = 1, OTGender = 1, Gender = 1, Nature = Nature.Modest }, // Cottonee @@ -779,21 +779,21 @@ internal static class Encounters8 new(TradeOT_R1, SWSH, 110,15,01,040,12,2) { Ability = Any12H, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(220) }, // Weezing new(TradeOT_R1, SWSH, 103,15,01,038,06,2) { Ability = Any12, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(246), Form = 1 }, // Exeggutor-1 new(TradeOT_R1, SWSH, 105,15,01,038,06,2) { Ability = Any12, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(174), Form = 1 }, // Marowak-1 - }; + ]; internal static readonly EncounterTrade8[] TradeSW = - { + [ new(TradeNames, 04, SW , 856,30,09,859,08,3) { Ability = OnlySecond, ID32 = 101101, IVs = TradeIVs, DynamaxLevel = 1, OTGender = 0, Gender = 1, Nature = Nature.Quiet }, // Hatenna new(TradeNames, 07, SW , 538,37,17,129,20,7) { Ability = OnlySecond, ID32 = 768945, IVs = TradeIVs, DynamaxLevel = 2, OTGender = 0, Gender = 0, Nature = Nature.Adamant }, // Throh new(TradeOT_R1, SW , 083,15,01,013,10,2) { Ability = OnlyHidden, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(098) }, // Farfetch’d new(TradeOT_R1, SW , 554,15,01,040,12,2) { Ability = OnlyHidden, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(326) }, // Darumaka - }; + ]; internal static readonly EncounterTrade8[] TradeSH = - { + [ new(TradeNames, 05, SH, 859,30,43,000,07,6) { Ability = OnlyFirst, ID32 = 256081, IVs = TradeIVs, DynamaxLevel = 1, OTGender = 0, Gender = 0, Nature = Nature.Brave, Relearn = new(252) }, // Impidimp new(TradeNames, 08, SH, 539,37,17,129,14,6) { Ability = OnlyFirst, ID32 = 881426, IVs = TradeIVs, DynamaxLevel = 2, OTGender = 0, Gender = 0, Nature = Nature.Adamant }, // Sawk new(TradeOT_R1, SH, 222,15,01,069,12,2) { Ability = OnlyHidden, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(457) }, // Corsola new(TradeOT_R1, SH, 077,15,01,047,06,2) { Ability = OnlyHidden, ID32 = 101141, FlawlessIVCount = 3, IVs = default, DynamaxLevel = 5, OTGender = 1, Relearn = new(234) }, // Ponyta - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8Nest.cs b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8Nest.cs index ce13bac14..80ac020b4 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8Nest.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8Nest.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.GameVersion; @@ -7,246 +7,254 @@ namespace PKHeX.Core; internal static class Encounters8Nest { - internal static readonly IReadOnlyList NestLocations = new [] - { - new byte[] {144, 134, 122}, // 000 : Stony Wilderness, South Lake Miloch, Rolling Fields - new byte[] {144, 126}, // 001 : Stony Wilderness, Watchtower Ruins - new byte[] {144, 122}, // 002 : Stony Wilderness, Rolling Fields - new byte[] {142, 124, 122}, // 003 : Bridge Field, Dappled Grove, Rolling Fields - new byte[] {142, 134}, // 004 : Bridge Field, South Lake Miloch - new byte[] {144, 126}, // 005 : Stony Wilderness, Watchtower Ruins - new byte[] {128, 130}, // 006 : East Lake Axewell, West Lake Axewell - new byte[] {154, 142, 134}, // 007 : Lake of Outrage, Bridge Field, South Lake Miloch - new byte[] {146, 130}, // 008 : Dusty Bowl, West Lake Axewell - new byte[] {146, 138}, // 009 : Dusty Bowl, North Lake Miloch - new byte[] {146, 136}, // 010 : Dusty Bowl, Giants Seat - new byte[] {150, 144, 136}, // 011 : Hammerlocke Hills, Stony Wilderness, Giants Seat - new byte[] {142}, // 012 : Bridge Field - new byte[] {150, 144, 140}, // 013 : Hammerlocke Hills, Stony Wilderness, Motostoke Riverbank - new byte[] {146, 136}, // 014 : Dusty Bowl, Giants Seat - new byte[] {142, 122}, // 015 : Bridge Field, Rolling Fields - new byte[] {146}, // 016 : Dusty Bowl - new byte[] {154, 152, 144}, // 017 : Lake of Outrage, Giants Cap, Stony Wilderness - new byte[] {150, 144}, // 018 : Hammerlocke Hills, Stony Wilderness - new byte[] {146}, // 019 : Dusty Bowl - new byte[] {146}, // 020 : Dusty Bowl - new byte[] {144}, // 021 : Stony Wilderness - new byte[] {150, 152}, // 022 : Hammerlocke Hills, Giants Cap - new byte[] {152, 140}, // 023 : Giants Cap, Motostoke Riverbank - new byte[] {154, 148}, // 024 : Lake of Outrage, Giants Mirror - new byte[] {124}, // 025 : Dappled Grove - new byte[] {148, 144, 142}, // 026 : Giants Mirror, Stony Wilderness, Bridge Field - new byte[] {148, 124, 146}, // 027 : Giants Mirror, Dappled Grove AND Dusty Bowl (Giant's Mirror load-line overlap) - new byte[] {138, 128}, // 028 : North Lake Miloch, East Lake Axewell - new byte[] {150, 152, 140}, // 029 : Hammerlocke Hills, Giants Cap, Motostoke Riverbank - new byte[] {128, 122}, // 030 : East Lake Axewell, Rolling Fields - new byte[] {150, 152}, // 031 : Hammerlocke Hills, Giants Cap - new byte[] {150, 122}, // 032 : Hammerlocke Hills, Rolling Fields - new byte[] {154, 142}, // 033 : Lake of Outrage, Bridge Field - new byte[] {144, 130}, // 034 : Stony Wilderness, West Lake Axewell - new byte[] {142, 146, 148}, // 035 : Bridge Field, Dusty Bowl, Giants Mirror - new byte[] {122}, // 036 : Rolling Fields - new byte[] {132}, // 037 : Axew's Eye - new byte[] {128, 122}, // 038 : East Lake Axewell, Rolling Fields - new byte[] {144, 142, 140}, // 039 : Stony Wilderness, Bridge Field, Motostoke Riverbank - new byte[] {134, 138}, // 040 : South Lake Miloch, North Lake Miloch - new byte[] {148, 130}, // 041 : Giants Mirror, West Lake Axewell - new byte[] {148, 144, 134, 146}, // 042 : Giants Mirror, Stony Wilderness, South Lake Miloch AND Dusty Bowl (Giant's Mirror load-line overlap) - new byte[] {154, 142, 128, 130}, // 043 : Lake of Outrage, Bridge Field, East Lake Axewell, West Lake Axewell - new byte[] {150, 136}, // 044 : Hammerlocke Hills, Giants Seat - new byte[] {142, 134, 122}, // 045 : Bridge Field, South Lake Miloch, Rolling Fields - new byte[] {126}, // 046 : Watchtower Ruins - new byte[] {146, 138, 122, 134}, // 047 : Dusty Bowl, North Lake Miloch, Rolling Fields, South Lake Miloch - new byte[] {146, 136}, // 048 : Dusty Bowl, Giants Seat - new byte[] {144, 140, 126}, // 049 : Stony Wilderness, Motostoke Riverbank, Watchtower Ruins - new byte[] {144, 136, 122}, // 050 : Stony Wilderness, Giants Seat, Rolling Fields - new byte[] {146, 142, 122}, // 051 : Dusty Bowl, Bridge Field, Rolling Fields - new byte[] {150}, // 052 : Hammerlocke Hills - new byte[] {146, 144}, // 053 : Dusty Bowl, Stony Wilderness - new byte[] {152, 146, 144}, // 054 : Giants Cap, Dusty Bowl, Stony Wilderness - new byte[] {154, 140}, // 055 : Lake of Outrage, Motostoke Riverbank - new byte[] {150}, // 056 : Hammerlocke Hills - new byte[] {124}, // 057 : Dappled Grove - new byte[] {144, 142, 124}, // 058 : Stony Wilderness, Bridge Field, Dappled Grove - new byte[] {152, 140, 138}, // 059 : Giants Cap, Motostoke Riverbank, North Lake Miloch - new byte[] {150, 128}, // 060 : Hammerlocke Hills, East Lake Axewell - new byte[] {150, 122}, // 061 : Hammerlocke Hills, Rolling Fields - new byte[] {144, 142, 130}, // 062 : Stony Wilderness, Bridge Field, West Lake Axewell - new byte[] {132, 122}, // 063 : Axew's Eye, Rolling Fields - new byte[] {142, 140, 128, 122}, // 064 : Bridge Field, Motostoke Riverbank, East Lake Axewell, Rolling Fields - new byte[] {144}, // 065 : Stony Wilderness - new byte[] {148}, // 066 : Giants Mirror - new byte[] {150}, // 067 : Hammerlocke Hills - new byte[] {148}, // 068 : Giants Mirror - new byte[] {148}, // 069 : Giants Mirror - new byte[] {152}, // 070 : Giants Cap - new byte[] {148}, // 071 : Giants Mirror - new byte[] {150}, // 072 : Hammerlocke Hills - new byte[] {154}, // 073 : Lake of Outrage - new byte[] {146, 130}, // 074 : Dusty Bowl, West Lake Axewell - new byte[] {138, 134}, // 075 : North Lake Miloch, South Lake Miloch - new byte[] {154}, // 076 : Lake of Outrage - new byte[] {152}, // 077 : Giants Cap - new byte[] {124}, // 078 : Dappled Grove - new byte[] {144}, // 079 : Stony Wilderness - new byte[] {144}, // 080 : Stony Wilderness - new byte[] {142}, // 081 : Bridge Field - new byte[] {136}, // 082 : Giants Seat - new byte[] {136}, // 083 : Giants Seat - new byte[] {144}, // 084 : Stony Wilderness - new byte[] {128}, // 085 : East Lake Axewell - new byte[] {142}, // 086 : Bridge Field - new byte[] {146}, // 087 : Dusty Bowl - new byte[] {152}, // 088 : Giants Cap - new byte[] {122}, // 089 : Rolling Fields - new byte[] {130, 134}, // 090 : West Lake Axewell, South Lake Miloch - new byte[] {142, 124}, // 091 : Bridge Field, Dappled Grove - new byte[] {146}, // 092 : Dusty Bowl - Array.Empty(), // 093 : None - Array.Empty(), // 094 : None - Array.Empty(), // 095 : None - Array.Empty(), // 096 : None - Array.Empty(), // 097 : None - new byte[] {164, 166, 188, 190}, // 098 : Fields of Honor, Soothing Wetlands, Stepping-Stone Sea, Insular Sea - new byte[] {164, 166, 188, 190}, // 099 : Fields of Honor, Soothing Wetlands, Stepping-Stone Sea, Insular Sea - new byte[] {166, 176, 180}, // 100 : Soothing Wetlands, Courageous Cavern, Training Lowlands - new byte[] {166, 176, 180}, // 101 : Soothing Wetlands, Courageous Cavern, Training Lowlands - new byte[] {170, 176, 184, 188}, // 102 : Challenge Beach, Courageous Cavern, Potbottom Desert, Stepping-Stone Sea - new byte[] {170, 176, 188}, // 103 : Challenge Beach, Courageous Cavern, Stepping-Stone Sea - new byte[] {164, 168, 170, 192}, // 104 : Fields of Honor, Forest of Focus, Challenge Beach, Honeycalm Sea - new byte[] {164, 168, 170, 192}, // 105 : Fields of Honor, Forest of Focus, Challenge Beach, Honeycalm Sea - new byte[] {174, 178, 186, 188}, // 106 : Challenge Road, Loop Lagoon, Workout Sea, Stepping-Stone Sea - new byte[] {174, 178, 186, 188}, // 107 : Challenge Road, Loop Lagoon, Workout Sea, Stepping-Stone Sea - new byte[] {164, 168, 180, 186}, // 108 : Fields of Honor, Forest of Focus, Training Lowlands, Workout Sea - new byte[] {164, 168, 186}, // 109 : Fields of Honor, Forest of Focus, Workout Sea - new byte[] {164, 166, 180, 190}, // 110 : Fields of Honor, Soothing Wetlands, Training Lowlands, Insular Sea - new byte[] {164, 166, 180, 190}, // 111 : Fields of Honor, Soothing Wetlands, Training Lowlands, Insular Sea - new byte[] {164, 170, 178, 184}, // 112 : Fields of Honor, Challenge Beach, Loop Lagoon, Potbottom Desert - new byte[] {164, 170, 178, 184}, // 113 : Fields of Honor, Challenge Beach, Loop Lagoon, Potbottom Desert - new byte[] {164, 180, 184}, // 114 : Fields of Honor, Training Lowlands, Potbottom Desert - new byte[] {164, 180, 184}, // 115 : Fields of Honor, Training Lowlands, Potbottom Desert - new byte[] {166, 170, 180, 188}, // 116 : Soothing Wetlands, Challenge Beach, Training Lowlands, Stepping-Stone Sea - new byte[] {166, 170, 180, 188}, // 117 : Soothing Wetlands, Challenge Beach, Training Lowlands, Stepping-Stone Sea - new byte[] {166, 168, 180, 188}, // 118 : Soothing Wetlands, Forest of Focus, Training Lowlands, Stepping-Stone Sea - new byte[] {166, 168, 180, 188}, // 119 : Soothing Wetlands, Forest of Focus, Training Lowlands, Stepping-Stone Sea - new byte[] {166, 174, 186, 192}, // 120 : Soothing Wetlands, Challenge Road, Workout Sea, Honeycalm Sea - new byte[] {166, 174, 186, 192}, // 121 : Soothing Wetlands, Challenge Road, Workout Sea, Honeycalm Sea - new byte[] {164, 170, 174, 192}, // 122 : Fields of Honor, Challenge Beach, Challenge Road, Honeycalm Sea - new byte[] {164, 170, 174, 192}, // 123 : Fields of Honor, Challenge Beach, Challenge Road, Honeycalm Sea - new byte[] {164, 166, 168, 190}, // 124 : Fields of Honor, Soothing Wetlands, Forest of Focus, Insular Sea - new byte[] {164, 166, 168, 190}, // 125 : Fields of Honor, Soothing Wetlands, Forest of Focus, Insular Sea - new byte[] {170, 176, 188}, // 126 : Challenge Beach, Courageous Cavern, Stepping-Stone Sea - new byte[] {170, 176, 188}, // 127 : Challenge Beach, Courageous Cavern, Stepping-Stone Sea - new byte[] {172, 176, 188}, // 128 : Brawlers' Cave, Courageous Cavern, Stepping-Stone Sea - new byte[] {172, 176, 188}, // 129 : Brawlers' Cave, Courageous Cavern, Stepping-Stone Sea - new byte[] {178, 186, 192}, // 130 : Loop Lagoon, Workout Sea, Honeycalm Sea - new byte[] {186, 192}, // 131 : Workout Sea, Honeycalm Sea - new byte[] {164, 166, 176}, // 132 : Fields of Honor, Soothing Wetlands, Courageous Cavern - new byte[] {164, 166, 176}, // 133 : Fields of Honor, Soothing Wetlands, Courageous Cavern - new byte[] {166, 168, 170, 176}, // 134 : Soothing Wetlands, Forest of Focus, Challenge Beach, Courageous Cavern - new byte[] {166, 168, 170}, // 135 : Soothing Wetlands, Forest of Focus, Challenge Beach - new byte[] {164, 170, 178, 190}, // 136 : Fields of Honor, Challenge Beach, Loop Lagoon, Insular Sea - new byte[] {164, 170, 178}, // 137 : Fields of Honor, Challenge Beach, Loop Lagoon - new byte[] {186, 188, 190, 192}, // 138 : Workout Sea, Stepping-Stone Sea, Insular Sea, Honeycalm Sea - new byte[] {186, 188, 190, 192}, // 139 : Workout Sea, Stepping-Stone Sea, Insular Sea, Honeycalm Sea - Array.Empty(), // 140 : None - Array.Empty(), // 141 : None - new byte[] {194}, // 142 : Honeycalm Island - new byte[] {194}, // 143 : Honeycalm Island - new byte[] {168, 180}, // 144 : Forest of Focus, Training Lowlands - new byte[] {186, 188}, // 145 : Workout Sea, Stepping-Stone Sea - new byte[] {190}, // 146 : Insular Sea - new byte[] {176}, // 147 : Courageous Cavern - new byte[] {180}, // 148 : Training Lowlands - new byte[] {184}, // 149 : Potbottom Desert - new byte[] {178}, // 150 : Loop Lagoon - new byte[] {186}, // 151 : Workout Sea - new byte[] {186}, // 152 : Workout Sea - new byte[] {168, 180}, // 153 : Forest of Focus, Training Lowlands - new byte[] {186, 188}, // 154 : Workout Sea, Stepping-Stone Sea - new byte[] {174}, // 155 : Challenge Road - new byte[] {174}, // 156 : Challenge Road + internal static readonly byte[][] NestLocations = + [ + [144, 134, 122], // 000 : Stony Wilderness, South Lake Miloch, Rolling Fields + [144, 126], // 001 : Stony Wilderness, Watchtower Ruins + [144, 122], // 002 : Stony Wilderness, Rolling Fields + [142, 124, 122], // 003 : Bridge Field, Dappled Grove, Rolling Fields + [142, 134], // 004 : Bridge Field, South Lake Miloch + [144, 126], // 005 : Stony Wilderness, Watchtower Ruins + [128, 130], // 006 : East Lake Axewell, West Lake Axewell + [154, 142, 134], // 007 : Lake of Outrage, Bridge Field, South Lake Miloch + [146, 130], // 008 : Dusty Bowl, West Lake Axewell + [146, 138], // 009 : Dusty Bowl, North Lake Miloch + [146, 136], // 010 : Dusty Bowl, Giants Seat + [150, 144, 136], // 011 : Hammerlocke Hills, Stony Wilderness, Giants Seat + [142], // 012 : Bridge Field + [150, 144, 140], // 013 : Hammerlocke Hills, Stony Wilderness, Motostoke Riverbank + [146, 136], // 014 : Dusty Bowl, Giants Seat + [142, 122], // 015 : Bridge Field, Rolling Fields + [146], // 016 : Dusty Bowl + [154, 152, 144], // 017 : Lake of Outrage, Giants Cap, Stony Wilderness + [150, 144], // 018 : Hammerlocke Hills, Stony Wilderness + [146], // 019 : Dusty Bowl + [146], // 020 : Dusty Bowl + [144], // 021 : Stony Wilderness + [150, 152], // 022 : Hammerlocke Hills, Giants Cap + [152, 140], // 023 : Giants Cap, Motostoke Riverbank + [154, 148], // 024 : Lake of Outrage, Giants Mirror + [124], // 025 : Dappled Grove + [148, 144, 142], // 026 : Giants Mirror, Stony Wilderness, Bridge Field + [148, 124, 146], // 027 : Giants Mirror, Dappled Grove AND Dusty Bowl (Giant's Mirror load-line overlap) + [138, 128], // 028 : North Lake Miloch, East Lake Axewell + [150, 152, 140], // 029 : Hammerlocke Hills, Giants Cap, Motostoke Riverbank + [128, 122], // 030 : East Lake Axewell, Rolling Fields + [150, 152], // 031 : Hammerlocke Hills, Giants Cap + [150, 122], // 032 : Hammerlocke Hills, Rolling Fields + [154, 142], // 033 : Lake of Outrage, Bridge Field + [144, 130], // 034 : Stony Wilderness, West Lake Axewell + [142, 146, 148], // 035 : Bridge Field, Dusty Bowl, Giants Mirror + [122], // 036 : Rolling Fields + [132], // 037 : Axew's Eye + [128, 122], // 038 : East Lake Axewell, Rolling Fields + [144, 142, 140], // 039 : Stony Wilderness, Bridge Field, Motostoke Riverbank + [134, 138], // 040 : South Lake Miloch, North Lake Miloch + [148, 130], // 041 : Giants Mirror, West Lake Axewell + [148, 144, 134, 146], // 042 : Giants Mirror, Stony Wilderness, South Lake Miloch AND Dusty Bowl (Giant's Mirror load-line overlap) + [154, 142, 128, 130], // 043 : Lake of Outrage, Bridge Field, East Lake Axewell, West Lake Axewell + [150, 136], // 044 : Hammerlocke Hills, Giants Seat + [142, 134, 122], // 045 : Bridge Field, South Lake Miloch, Rolling Fields + [126], // 046 : Watchtower Ruins + [146, 138, 122, 134], // 047 : Dusty Bowl, North Lake Miloch, Rolling Fields, South Lake Miloch + [146, 136], // 048 : Dusty Bowl, Giants Seat + [144, 140, 126], // 049 : Stony Wilderness, Motostoke Riverbank, Watchtower Ruins + [144, 136, 122], // 050 : Stony Wilderness, Giants Seat, Rolling Fields + [146, 142, 122], // 051 : Dusty Bowl, Bridge Field, Rolling Fields + [150], // 052 : Hammerlocke Hills + [146, 144], // 053 : Dusty Bowl, Stony Wilderness + [152, 146, 144], // 054 : Giants Cap, Dusty Bowl, Stony Wilderness + [154, 140], // 055 : Lake of Outrage, Motostoke Riverbank + [150], // 056 : Hammerlocke Hills + [124], // 057 : Dappled Grove + [144, 142, 124], // 058 : Stony Wilderness, Bridge Field, Dappled Grove + [152, 140, 138], // 059 : Giants Cap, Motostoke Riverbank, North Lake Miloch + [150, 128], // 060 : Hammerlocke Hills, East Lake Axewell + [150, 122], // 061 : Hammerlocke Hills, Rolling Fields + [144, 142, 130], // 062 : Stony Wilderness, Bridge Field, West Lake Axewell + [132, 122], // 063 : Axew's Eye, Rolling Fields + [142, 140, 128, 122], // 064 : Bridge Field, Motostoke Riverbank, East Lake Axewell, Rolling Fields + [144], // 065 : Stony Wilderness + [148], // 066 : Giants Mirror + [150], // 067 : Hammerlocke Hills + [148], // 068 : Giants Mirror + [148], // 069 : Giants Mirror + [152], // 070 : Giants Cap + [148], // 071 : Giants Mirror + [150], // 072 : Hammerlocke Hills + [154], // 073 : Lake of Outrage + [146, 130], // 074 : Dusty Bowl, West Lake Axewell + [138, 134], // 075 : North Lake Miloch, South Lake Miloch + [154], // 076 : Lake of Outrage + [152], // 077 : Giants Cap + [124], // 078 : Dappled Grove + [144], // 079 : Stony Wilderness + [144], // 080 : Stony Wilderness + [142], // 081 : Bridge Field + [136], // 082 : Giants Seat + [136], // 083 : Giants Seat + [144], // 084 : Stony Wilderness + [128], // 085 : East Lake Axewell + [142], // 086 : Bridge Field + [146], // 087 : Dusty Bowl + [152], // 088 : Giants Cap + [122], // 089 : Rolling Fields + [130, 134], // 090 : West Lake Axewell, South Lake Miloch + [142, 124], // 091 : Bridge Field, Dappled Grove + [146], // 092 : Dusty Bowl + [], // 093 : None + [], // 094 : None + [], // 095 : None + [], // 096 : None + [], // 097 : None + [164, 166, 188, 190], // 098 : Fields of Honor, Soothing Wetlands, Stepping-Stone Sea, Insular Sea + [164, 166, 188, 190], // 099 : Fields of Honor, Soothing Wetlands, Stepping-Stone Sea, Insular Sea + [166, 176, 180], // 100 : Soothing Wetlands, Courageous Cavern, Training Lowlands + [166, 176, 180], // 101 : Soothing Wetlands, Courageous Cavern, Training Lowlands + [170, 176, 184, 188], // 102 : Challenge Beach, Courageous Cavern, Potbottom Desert, Stepping-Stone Sea + [170, 176, 188], // 103 : Challenge Beach, Courageous Cavern, Stepping-Stone Sea + [164, 168, 170, 192], // 104 : Fields of Honor, Forest of Focus, Challenge Beach, Honeycalm Sea + [164, 168, 170, 192], // 105 : Fields of Honor, Forest of Focus, Challenge Beach, Honeycalm Sea + [174, 178, 186, 188], // 106 : Challenge Road, Loop Lagoon, Workout Sea, Stepping-Stone Sea + [174, 178, 186, 188], // 107 : Challenge Road, Loop Lagoon, Workout Sea, Stepping-Stone Sea + [164, 168, 180, 186], // 108 : Fields of Honor, Forest of Focus, Training Lowlands, Workout Sea + [164, 168, 186], // 109 : Fields of Honor, Forest of Focus, Workout Sea + [164, 166, 180, 190], // 110 : Fields of Honor, Soothing Wetlands, Training Lowlands, Insular Sea + [164, 166, 180, 190], // 111 : Fields of Honor, Soothing Wetlands, Training Lowlands, Insular Sea + [164, 170, 178, 184], // 112 : Fields of Honor, Challenge Beach, Loop Lagoon, Potbottom Desert + [164, 170, 178, 184], // 113 : Fields of Honor, Challenge Beach, Loop Lagoon, Potbottom Desert + [164, 180, 184], // 114 : Fields of Honor, Training Lowlands, Potbottom Desert + [164, 180, 184], // 115 : Fields of Honor, Training Lowlands, Potbottom Desert + [166, 170, 180, 188], // 116 : Soothing Wetlands, Challenge Beach, Training Lowlands, Stepping-Stone Sea + [166, 170, 180, 188], // 117 : Soothing Wetlands, Challenge Beach, Training Lowlands, Stepping-Stone Sea + [166, 168, 180, 188], // 118 : Soothing Wetlands, Forest of Focus, Training Lowlands, Stepping-Stone Sea + [166, 168, 180, 188], // 119 : Soothing Wetlands, Forest of Focus, Training Lowlands, Stepping-Stone Sea + [166, 174, 186, 192], // 120 : Soothing Wetlands, Challenge Road, Workout Sea, Honeycalm Sea + [166, 174, 186, 192], // 121 : Soothing Wetlands, Challenge Road, Workout Sea, Honeycalm Sea + [164, 170, 174, 192], // 122 : Fields of Honor, Challenge Beach, Challenge Road, Honeycalm Sea + [164, 170, 174, 192], // 123 : Fields of Honor, Challenge Beach, Challenge Road, Honeycalm Sea + [164, 166, 168, 190], // 124 : Fields of Honor, Soothing Wetlands, Forest of Focus, Insular Sea + [164, 166, 168, 190], // 125 : Fields of Honor, Soothing Wetlands, Forest of Focus, Insular Sea + [170, 176, 188], // 126 : Challenge Beach, Courageous Cavern, Stepping-Stone Sea + [170, 176, 188], // 127 : Challenge Beach, Courageous Cavern, Stepping-Stone Sea + [172, 176, 188], // 128 : Brawlers' Cave, Courageous Cavern, Stepping-Stone Sea + [172, 176, 188], // 129 : Brawlers' Cave, Courageous Cavern, Stepping-Stone Sea + [178, 186, 192], // 130 : Loop Lagoon, Workout Sea, Honeycalm Sea + [186, 192], // 131 : Workout Sea, Honeycalm Sea + [164, 166, 176], // 132 : Fields of Honor, Soothing Wetlands, Courageous Cavern + [164, 166, 176], // 133 : Fields of Honor, Soothing Wetlands, Courageous Cavern + [166, 168, 170, 176], // 134 : Soothing Wetlands, Forest of Focus, Challenge Beach, Courageous Cavern + [166, 168, 170], // 135 : Soothing Wetlands, Forest of Focus, Challenge Beach + [164, 170, 178, 190], // 136 : Fields of Honor, Challenge Beach, Loop Lagoon, Insular Sea + [164, 170, 178], // 137 : Fields of Honor, Challenge Beach, Loop Lagoon + [186, 188, 190, 192], // 138 : Workout Sea, Stepping-Stone Sea, Insular Sea, Honeycalm Sea + [186, 188, 190, 192], // 139 : Workout Sea, Stepping-Stone Sea, Insular Sea, Honeycalm Sea + [], // 140 : None + [], // 141 : None + [194], // 142 : Honeycalm Island + [194], // 143 : Honeycalm Island + [168, 180], // 144 : Forest of Focus, Training Lowlands + [186, 188], // 145 : Workout Sea, Stepping-Stone Sea + [190], // 146 : Insular Sea + [176], // 147 : Courageous Cavern + [180], // 148 : Training Lowlands + [184], // 149 : Potbottom Desert + [178], // 150 : Loop Lagoon + [186], // 151 : Workout Sea + [186], // 152 : Workout Sea + [168, 180], // 153 : Forest of Focus, Training Lowlands + [186, 188], // 154 : Workout Sea, Stepping-Stone Sea + [174], // 155 : Challenge Road + [174], // 156 : Challenge Road - new byte[] {204,210,222,230}, // 157 : Slippery Slope, Giant's Bed, Giant's Foot, Ballimere Lake - new byte[] {204,210,222,230}, // 158 : Slippery Slope, Giant's Bed, Giant's Foot, Ballimere Lake - new byte[] {210,214,222,230}, // 159 : Giant's Bed, Snowslide Slope, Giant's Foot, Ballimere Lake - new byte[] {210,214,222,230}, // 160 : Giant's Bed, Snowslide Slope, Giant's Foot, Ballimere Lake - new byte[] {210,222,226,230}, // 161 : Giant's Bed, Giant's Foot, Frigid Sea, Ballimere Lake - new byte[] {210,222,226,230}, // 162 : Giant's Bed, Giant's Foot, Frigid Sea, Ballimere Lake - new byte[] {208,210,226,228,230},// 163 : Frostpoint Field, Giant's Bed, Frigid Sea, Three-Point Pass, Ballimere Lake - new byte[] {208,210,226,228,230},// 164 : Frostpoint Field, Giant's Bed, Frigid Sea, Three-Point Pass, Ballimere Lake - new byte[] {204,210,220,222,230},// 165 : Slippery Slope, Giant's Bed, Crown Shrine, Giant's Foot, Ballimere Lake - new byte[] {204,210,220,222,230},// 166 : Slippery Slope, Giant's Bed, Crown Shrine, Giant's Foot, Ballimere Lake - new byte[] {204,214,226}, // 167 : Slippery Slope, Snowslide Slope, Frigid Sea - new byte[] {204,214,226}, // 168 : Slippery Slope, Snowslide Slope, Frigid Sea - new byte[] {210,226}, // 169 : Giant's Bed, Frigid Sea - new byte[] {210,226}, // 170 : Giant's Bed, Frigid Sea - new byte[] {208,210,214,226,230},// 171 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake - new byte[] {208,210,214,226,230},// 172 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake - new byte[] {210,226,230}, // 173 : Giant's Bed, Frigid Sea, Ballimere Lake - new byte[] {210,226,230}, // 174 : Giant's Bed, Frigid Sea, Ballimere Lake - new byte[] {208,210,226,230,234},// 175 : Frostpoint Field, Giant's Bed, Frigid Sea, Ballimere Lake, Dyna Tree Hill - new byte[] {208,210,226,230,234},// 176 : Frostpoint Field, Giant's Bed, Frigid Sea, Ballimere Lake, Dyna Tree Hill - new byte[] {210,214,218,230}, // 177 : Giant's Bed, Snowslide Slope, Path to the Peak, Ballimere Lake - new byte[] {210,214,218,230}, // 178 : Giant's Bed, Snowslide Slope, Path to the Peak, Ballimere Lake - new byte[] {204,210,214,230}, // 179 : Slippery Slope, Giant's Bed, Snowslide Slope, Ballimere Lake - new byte[] {204,210,214,230}, // 180 : Slippery Slope, Giant's Bed, Snowslide Slope, Ballimere Lake - new byte[] {204,212,222,226,230},// 181 : Slippery Slope, Old Cemetery, Giant's Foot, Frigid Sea, Ballimere Lake - new byte[] {204,212,222,226,230},// 182 : Slippery Slope, Old Cemetery, Giant's Foot, Frigid Sea, Ballimere Lake - new byte[] {210,218,226,228,230},// 183 : Giant's Bed, Path to the Peak, Frigid Sea, Three-Point Pass, Ballimere Lake - new byte[] {210,218,226,228,230},// 184 : Giant's Bed, Path to the Peak, Frigid Sea, Three-Point Pass, Ballimere Lake - new byte[] {208,210,214,222,226},// 185 : Frostpoint Field, Giant's Bed, Snowslide Slope, Giant's Foot, Frigid Sea - new byte[] {208,210,214,222,226},// 186 : Frostpoint Field, Giant's Bed, Snowslide Slope, Giant's Foot, Frigid Sea - new byte[] {210,214,218,226}, // 187 : Giant's Bed, Snowslide Slope, Path to the Peak, Frigid Sea - new byte[] {210,214,218,226}, // 188 : Giant's Bed, Snowslide Slope, Path to the Peak, Frigid Sea - new byte[] {208,210,214,226,230},// 189 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake - new byte[] {208,210,214,226,230},// 190 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake - new byte[] {210,212,230}, // 191 : Giant's Bed, Old Cemetery, Ballimere Lake - new byte[] {210,212,230}, // 192 : Giant's Bed, Old Cemetery, Ballimere Lake - new byte[] {230}, // 193 : Ballimere Lake - new byte[] {230}, // 194 : Ballimere Lake - new byte[] {214}, // 195 : Snowslide Slope - new byte[] {214}, // 196 : Snowslide Slope - }; + [204,210,222,230], // 157 : Slippery Slope, Giant's Bed, Giant's Foot, Ballimere Lake + [204,210,222,230], // 158 : Slippery Slope, Giant's Bed, Giant's Foot, Ballimere Lake + [210,214,222,230], // 159 : Giant's Bed, Snowslide Slope, Giant's Foot, Ballimere Lake + [210,214,222,230], // 160 : Giant's Bed, Snowslide Slope, Giant's Foot, Ballimere Lake + [210,222,226,230], // 161 : Giant's Bed, Giant's Foot, Frigid Sea, Ballimere Lake + [210,222,226,230], // 162 : Giant's Bed, Giant's Foot, Frigid Sea, Ballimere Lake + [208,210,226,228,230],// 163 : Frostpoint Field, Giant's Bed, Frigid Sea, Three-Point Pass, Ballimere Lake + [208,210,226,228,230],// 164 : Frostpoint Field, Giant's Bed, Frigid Sea, Three-Point Pass, Ballimere Lake + [204,210,220,222,230],// 165 : Slippery Slope, Giant's Bed, Crown Shrine, Giant's Foot, Ballimere Lake + [204,210,220,222,230],// 166 : Slippery Slope, Giant's Bed, Crown Shrine, Giant's Foot, Ballimere Lake + [204,214,226], // 167 : Slippery Slope, Snowslide Slope, Frigid Sea + [204,214,226], // 168 : Slippery Slope, Snowslide Slope, Frigid Sea + [210,226], // 169 : Giant's Bed, Frigid Sea + [210,226], // 170 : Giant's Bed, Frigid Sea + [208,210,214,226,230],// 171 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake + [208,210,214,226,230],// 172 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake + [210,226,230], // 173 : Giant's Bed, Frigid Sea, Ballimere Lake + [210,226,230], // 174 : Giant's Bed, Frigid Sea, Ballimere Lake + [208,210,226,230,234],// 175 : Frostpoint Field, Giant's Bed, Frigid Sea, Ballimere Lake, Dyna Tree Hill + [208,210,226,230,234],// 176 : Frostpoint Field, Giant's Bed, Frigid Sea, Ballimere Lake, Dyna Tree Hill + [210,214,218,230], // 177 : Giant's Bed, Snowslide Slope, Path to the Peak, Ballimere Lake + [210,214,218,230], // 178 : Giant's Bed, Snowslide Slope, Path to the Peak, Ballimere Lake + [204,210,214,230], // 179 : Slippery Slope, Giant's Bed, Snowslide Slope, Ballimere Lake + [204,210,214,230], // 180 : Slippery Slope, Giant's Bed, Snowslide Slope, Ballimere Lake + [204,212,222,226,230],// 181 : Slippery Slope, Old Cemetery, Giant's Foot, Frigid Sea, Ballimere Lake + [204,212,222,226,230],// 182 : Slippery Slope, Old Cemetery, Giant's Foot, Frigid Sea, Ballimere Lake + [210,218,226,228,230],// 183 : Giant's Bed, Path to the Peak, Frigid Sea, Three-Point Pass, Ballimere Lake + [210,218,226,228,230],// 184 : Giant's Bed, Path to the Peak, Frigid Sea, Three-Point Pass, Ballimere Lake + [208,210,214,222,226],// 185 : Frostpoint Field, Giant's Bed, Snowslide Slope, Giant's Foot, Frigid Sea + [208,210,214,222,226],// 186 : Frostpoint Field, Giant's Bed, Snowslide Slope, Giant's Foot, Frigid Sea + [210,214,218,226], // 187 : Giant's Bed, Snowslide Slope, Path to the Peak, Frigid Sea + [210,214,218,226], // 188 : Giant's Bed, Snowslide Slope, Path to the Peak, Frigid Sea + [208,210,214,226,230],// 189 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake + [208,210,214,226,230],// 190 : Frostpoint Field, Giant's Bed, Snowslide Slope, Frigid Sea, Ballimere Lake + [210,212,230], // 191 : Giant's Bed, Old Cemetery, Ballimere Lake + [210,212,230], // 192 : Giant's Bed, Old Cemetery, Ballimere Lake + [230], // 193 : Ballimere Lake + [230], // 194 : Ballimere Lake + [214], // 195 : Snowslide Slope + [214], // 196 : Snowslide Slope + ]; /// /// Location IDs containing Dens that cannot be accessed without Rotom Bike's Water Mode. /// - internal static ReadOnlySpan InaccessibleRank12DistributionLocations => new byte[] {154,178,186,188,190,192,194,226,228,230,234}; // Areas that are entirely restricted to water + internal static ReadOnlySpan InaccessibleRank12DistributionLocations => [154,178,186,188,190,192,194,226,228,230,234]; // Areas that are entirely restricted to water /// /// Location IDs containing Dens that cannot be accessed without Rotom Bike's Water Mode. /// - internal static readonly Dictionary InaccessibleRank12Nests = new() + internal static bool IsInaccessibleRank12Nest(byte nestID, byte location) { - {128, new byte[] {6,43}}, // East Lake Axewell - {130, new byte[] {6,41,43}}, // West Lake Axewell - {132, new byte[] {37,63}}, // Axew's Eye - {134, new byte[] {7,40,75,90}}, // South Lake Miloch - {138, new byte[] {40,75}}, // North Lake Miloch - {142, new byte[] {7,43}}, // Bridge Field - {146, new byte[] {8,74}}, // Dusty Bowl - {148, new byte[] {41,66}}, // Giant's Mirror - {154, new byte[] {7,17,24,33,43,55,73,76}}, // Lake of Outrage - {164, new byte[] {136,137}}, // Fields of Honor - {168, new byte[] {124,125,134,135,144,153}}, // Forest of Focus - {170, new byte[] {126,127}}, // Challenge Beach - {176, new byte[] {132,133}}, // Courageous Cavern - {178, new byte[] {106,107,112,113,130,136,137,150}}, // Loop Lagoon - {180, new byte[] {116,117}}, // Training Lowlands - {186, new byte[] {106,107,108,109,120,121,130,131,138,139,145,151,152,154}}, // Workout Sea - {188, new byte[] {98,99,102,103,106,107,116,117,118,119,126,127,128,129,138,139,145,154}}, // Stepping-Stone Sea - {190, new byte[] {98,99,110,111,124,125,136,138,139,146}}, // Insular Sea - {192, new byte[] {104,105,120,121,122,123,130,131,138,139}}, // Honeycalm Sea - {194, new byte[] {142,143}}, // Honeycalm Island - {210, new byte[] {169,170,183,184}}, // Giant's Bed - {222, new byte[] {181,182,185,186}}, // Giant's Foot - {226, new byte[] {161,162,163,164,167,168,169,170,171,172,173,174,175,176,181,182,183,184,185,186,187,188,189,190}}, // Frigid Sea - {228, new byte[] {163,164,183,184}}, // Three-Point Pass - {230, new byte[] {157,158,159,160,161,162,163,164,165,166,171,172,173,174,175,176,177,178,179,180,181,182,183,184,189,190,191,192,193,194}}, // Ballimere Lake - {234, new byte[] {175,176}}, // Dyna Tree Hill + var noNest = GetInaccessibleRank12Nests(location); + return noNest.Length > 0 && noNest.Contains(nestID); + } - {162, new byte[] {6,7,37,40,41,43,66,73,75,76,130,131,138,139,142,143,145,146,150,151,152,154,169,170,193,194}}, // Completely inaccessible + private static ReadOnlySpan GetInaccessibleRank12Nests(byte location) => location switch + { + 128 => [6,43], // East Lake Axewell + 130 => [6,41,43], // West Lake Axewell + 132 => [37,63], // Axew's Eye + 134 => [7,40,75,90], // South Lake Miloch + 138 => [40,75], // North Lake Miloch + 142 => [7,43], // Bridge Field + 146 => [8,74], // Dusty Bowl + 148 => [41,66], // Giant's Mirror + 154 => [7,17,24,33,43,55,73,76], // Lake of Outrage + 164 => [136,137], // Fields of Honor + 168 => [124,125,134,135,144,153], // Forest of Focus + 170 => [126,127], // Challenge Beach + 176 => [132,133], // Courageous Cavern + 178 => [106,107,112,113,130,136,137,150], // Loop Lagoon + 180 => [116,117], // Training Lowlands + 186 => [106,107,108,109,120,121,130,131,138,139,145,151,152,154], // Workout Sea + 188 => [98,99,102,103,106,107,116,117,118,119,126,127,128,129,138,139,145,154], // Stepping-Stone Sea + 190 => [98,99,110,111,124,125,136,138,139,146], // Insular Sea + 192 => [104,105,120,121,122,123,130,131,138,139], // Honeycalm Sea + 194 => [142,143], // Honeycalm Island + 210 => [169,170,183,184], // Giant's Bed + 222 => [181,182,185,186], // Giant's Foot + 226 => [161,162,163,164,167,168,169,170,171,172,173,174,175,176,181,182,183,184,185,186,187,188,189,190], // Frigid Sea + 228 => [163,164,183,184], // Three-Point Pass + 230 => [157,158,159,160,161,162,163,164,165,166,171,172,173,174,175,176,177,178,179,180,181,182,183,184,189,190,191,192,193,194], // Ballimere Lake + 234 => [175,176], // Dyna Tree Hill + + 162 => [6,7,37,40,41,43,66,73,75,76,130,131,138,139,142,143,145,146,150,151,152,154,169,170,193,194], // Completely inaccessible + + _ => [], }; // Abilities Allowed @@ -269,7 +277,7 @@ internal static class Encounters8Nest internal static readonly EncounterStatic8U[] DynAdv_SWSH = GetUnderground(); internal static readonly EncounterStatic8NC[] Crystal_SWSH = - { + [ new(SWSH) { Species = 782, Level = 16, Ability = A3, IVs = new(31,31,31,-1,-1,-1), DynamaxLevel = 2, Moves = new(033,029,525,043) }, // ★And458 Jangmo-o new(SWSH) { Species = 246, Level = 16, Ability = A3, IVs = new(31,31,31,-1,-1,-1), DynamaxLevel = 2, Moves = new(033,157,371,044) }, // ★And15 Larvitar new(SWSH) { Species = 823, Level = 50, Ability = A2, IVs = new(31,31,31,-1,-1,31), DynamaxLevel = 5, Moves = new(065,442,034,796), CanGigantamax = true }, // ★And337 Gigantamax Corviknight @@ -283,9 +291,9 @@ internal static class Encounters8Nest new(SWSH) { Species = 884, Level = 40, Ability = A2, IVs = new(31,-1,-1,31,31,-1), DynamaxLevel = 5, Moves = new(796,063,784,319), CanGigantamax = true }, // ★Sgr7121 Gigantamax Duraludon new(SWSH) { Species = 025, Level = 25, Ability = A2, IVs = new(31,31,31,-1,-1,-1), DynamaxLevel = 5, Moves = new(606,273,104,085), CanGigantamax = true }, // ★Sgr6746 Gigantamax Pikachu new(SWSH) { Species = 133, Level = 25, Ability = A2, IVs = new(31,31,31,-1,-1,-1), DynamaxLevel = 5, Moves = new(606,273,038,129), CanGigantamax = true }, // ★Sgr7194 Gigantamax Eevee - }; + ]; - private static EncounterStatic8N[] GetBase([ConstantExpected] string name, [ConstantExpected] GameVersion game) + private static EncounterStatic8N[] GetBase([Length(2, 2)] string name, [ConstantExpected] GameVersion game) { var data = EncounterUtil.Get($"{name}_nest"); const int size = 10; @@ -300,7 +308,7 @@ private static EncounterStatic8N[] GetBase([ConstantExpected] string name, [Cons return result; } - private static EncounterStatic8ND[] GetDist([ConstantExpected] string name, [ConstantExpected] GameVersion game) + private static EncounterStatic8ND[] GetDist([Length(2, 2)] string name, [ConstantExpected] GameVersion game) { var data = EncounterUtil.Get($"{name}_dist"); const int size = 0x10; diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8a.cs b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8a.cs index cac84ccb6..c9905e032 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8a.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8a.cs @@ -13,7 +13,7 @@ internal static class Encounters8a private const byte U = 128; // Middle Height - Unown internal static readonly EncounterStatic8a[] StaticLA = - { + [ // Gifts new(722,000,05,M,M) { Location = 006, FixedBall = Ball.LAPoke, Method = Fixed }, // Rowlet new(155,000,05,M,M) { Location = 006, FixedBall = Ball.LAPoke, Method = Fixed }, // Cyndaquil @@ -107,5 +107,5 @@ internal static class Encounters8a new(571,001,58,M,M) { Location = 111, Method = Fixed, IsAlpha = true, Moves = new(555,421,841,417) }, // zoroark01: Zoroark-1 new(706,001,58,M,M) { Location = 104, Method = Fixed, IsAlpha = true, Moves = new(231,406,842,056) }, // numelgon01: Goodra-1 new(904,000,58,M,M) { Location = 105, Method = Fixed, IsAlpha = true, Moves = new(301,398,401,038) }, // harysen01: Overqwil - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8b.cs b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8b.cs index 378f1b0eb..e085516a8 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8b.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen8/Encounters8b.cs @@ -12,11 +12,11 @@ internal static class Encounters8b private static readonly EncounterArea8b[] SlotsBD_UG = EncounterArea8b.GetAreas(Get("bd_underground", "bs"u8), BD); private static readonly EncounterArea8b[] SlotsSP_UG = EncounterArea8b.GetAreas(Get("sp_underground", "bs"u8), SP); - internal static readonly EncounterArea8b[] SlotsBD = ArrayUtil.ConcatAll(SlotsBD_OW, SlotsBD_UG); - internal static readonly EncounterArea8b[] SlotsSP = ArrayUtil.ConcatAll(SlotsSP_OW, SlotsSP_UG); + internal static readonly EncounterArea8b[] SlotsBD = [..SlotsBD_OW, ..SlotsBD_UG]; + internal static readonly EncounterArea8b[] SlotsSP = [..SlotsSP_OW, ..SlotsSP_UG]; internal static readonly EncounterStatic8b[] Encounter_BDSP = - { + [ // Gifts new(BDSP) { FixedBall = Ball.Poke, Species = 387, Level = 05, Location = 323 }, // Turtwig new(BDSP) { FixedBall = Ball.Poke, Species = 390, Level = 05, Location = 323 }, // Chimchar @@ -70,36 +70,36 @@ internal static class Encounters8b new(BDSP) { Species = 382, Level = 70, Location = 507, FlawlessIVCount = 3 }, // Kyogre new(BDSP) { Species = 383, Level = 70, Location = 507, FlawlessIVCount = 3 }, // Groudon new(BDSP) { Species = 384, Level = 70, Location = 507, FlawlessIVCount = 3 }, // Rayquaza - }; + ]; internal static readonly EncounterStatic8b[] StaticBD = - { + [ new(BD ) { Species = 483, Level = 47, Location = 216, FlawlessIVCount = 3 }, // Dialga new(BD ) { Species = 493, Level = 80, Location = 218, FlawlessIVCount = 3, FatefulEncounter = true }, // Arceus (Brilliant Diamond) new(BD ) { Species = 243, Level = 70, Location = 506, FlawlessIVCount = 3, Ability = OnlyHidden }, // Raikou new(BD ) { Species = 244, Level = 70, Location = 506, FlawlessIVCount = 3, Ability = OnlyHidden }, // Entei new(BD ) { Species = 245, Level = 70, Location = 506, FlawlessIVCount = 3, Ability = OnlyHidden }, // Suicune new(BD ) { Species = 250, Level = 70, Location = 507, FlawlessIVCount = 3, Ability = OnlyHidden }, // Ho-Oh - }; + ]; internal static readonly EncounterStatic8b[] StaticSP = - { + [ new( SP) { Species = 484, Level = 47, Location = 217, FlawlessIVCount = 3 }, // Palkia new( SP) { Species = 493, Level = 80, Location = 618, FlawlessIVCount = 3, FatefulEncounter = true }, // Arceus (Shining Pearl) new( SP) { Species = 144, Level = 70, Location = 506, FlawlessIVCount = 3, Ability = OnlyHidden }, // Articuno new( SP) { Species = 145, Level = 70, Location = 506, FlawlessIVCount = 3, Ability = OnlyHidden }, // Zapdos new( SP) { Species = 146, Level = 70, Location = 506, FlawlessIVCount = 3, Ability = OnlyHidden }, // Moltres new( SP) { Species = 249, Level = 70, Location = 507, FlawlessIVCount = 3, Ability = OnlyHidden }, // Lugia - }; + ]; private const string tradeBDSP = "tradebdsp"; private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeBDSP, "zh2"); internal static readonly EncounterTrade8b[] TradeGift_BDSP = - { + [ new(TradeNames, 00, BDSP) { Species = 063, EncryptionConstant = 0x0000008E, PID = 0xFF50A8F5, Level = 09, Ability = OnlyFirst, Gender = 0, OTGender = 0, ID32 = 25643, IVs = new(28,10,09,31,11,03), Moves = new(100,000,000,000), HeightScalar = 029, WeightScalar = 202, Nature = Nature.Quiet }, // Abra new(TradeNames, 01, BDSP) { Species = 441, EncryptionConstant = 0x00000867, PID = 0x17DAAB19, Level = 15, Ability = OnlySecond, Gender = 1, OTGender = 0, ID32 = 44142, IVs = new(17,08,29,25,17,23), Moves = new(448,047,064,045), HeightScalar = 088, WeightScalar = 091, Nature = Nature.Lonely }, // Chatot new(TradeNames, 02, BDSP) { Species = 093, EncryptionConstant = 0x00000088, PID = 0xF60AB5BB, Level = 33, Ability = OnlyFirst, Gender = 0, OTGender = 0, ID32 = 19248, IVs = new(18,24,28,02,22,30), Moves = new(247,371,389,109), HeightScalar = 096, WeightScalar = 208, Nature = Nature.Hasty }, // Haunter new(TradeNames, 03, BDSP) { Species = 129, EncryptionConstant = 0x0000045C, PID = 0xFCE82F88, Level = 45, Ability = OnlyFirst, Gender = 1, OTGender = 0, ID32 = 53277, IVs = new(03,03,31,02,11,03), Moves = new(150,000,000,000), HeightScalar = 169, WeightScalar = 068, Nature = Nature.Mild }, // Magikarp - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen9/Encounters9.cs b/PKHeX.Core/Legality/Encounters/Data/Gen9/Encounters9.cs index a85acd442..0f598bd8d 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen9/Encounters9.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen9/Encounters9.cs @@ -13,7 +13,7 @@ internal static class Encounters9 internal static readonly EncounterArea9[] Slots = EncounterArea9.GetAreas(Get("wild_paldea", "sv"u8), SV); internal static readonly EncounterStatic9[] Encounter_SV = - { + [ // Starters new(SV) { FixedBall = Ball.Poke, Species = 0906, Shiny = Never, Level = 05, Location = 080, Ability = OnlyFirst, Size = 128 }, // Sprigatito new(SV) { FixedBall = Ball.Poke, Species = 0909, Shiny = Never, Level = 05, Location = 080, Ability = OnlyFirst, Size = 128 }, // Fuecoco @@ -74,10 +74,10 @@ internal static class Encounters9 new(SV) { FixedBall = Ball.Poke, Species = 0390, Shiny = Never, Level = 01, Location = 000, Ability = OnlyFirst, Size = 128, EggLocation = 60005 }, // Chimchar new(SV) { FixedBall = Ball.Poke, Species = 0393, Shiny = Never, Level = 01, Location = 000, Ability = OnlyFirst, Size = 128, EggLocation = 60005 }, // Piplup #endregion - }; + ]; internal static readonly EncounterStatic9[] StaticSL = - { + [ // Box Legendary (Ride Form) new(SL) { FixedBall = Ball.Poke, Species = 1007, Shiny = Never, Level = 68, Location = 070, Ability = OnlyFirst, Nature = Nature.Quirky, TeraType = GemType.Dragon, Size = 128, IVs = new(31,31,28,31,31,28), Moves = new(053,878,203,851) }, // Koraidon @@ -89,10 +89,10 @@ internal static class Encounters9 // Former Quaking Earth Titan new(SL) { Species = 0984, Shiny = Never, Level = 45, Location = 024, Ability = OnlyFirst, Nature = Nature.Naughty, Size = 255, IVs = new(30,30,30,30,30,30), Moves = new(229,280,282,707), IsTitan = true }, // Great Tusk - }; + ]; internal static readonly EncounterStatic9[] StaticVL = - { + [ // Box Legendary (Ride Form) new(VL) { FixedBall = Ball.Poke, Species = 1008, Shiny = Never, Level = 68, Location = 070, Ability = OnlyFirst, Nature = Nature.Quirky, TeraType = GemType.Dragon, Size = 128, IVs = new(31,31,28,31,31,28), Moves = new(408,879,203,851) }, // Miraidon @@ -105,17 +105,17 @@ internal static class Encounters9 // Former Quaking Earth Titan new(VL) { Species = 0990, Shiny = Never, Level = 45, Location = 024, Ability = OnlyFirst, Nature = Nature.Naughty, Size = 255, IVs = new(30,30,30,30,30,30), Moves = new(229,442,282,707), IsTitan = true }, // Iron Treads - }; + ]; private const string tradeSV = "tradesv"; private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeSV, "zh2"); internal static readonly EncounterTrade9[] TradeGift_SV = - { + [ new(TradeNames, 00, SV, 0194,18) { ID32 = 033081, Ability = OnlySecond, OTGender = 1, Gender = 0, Nature = Nature.Relaxed, IVs = new(27,18,25,13,16,31) }, // Wooper new(TradeNames, 01, SV, 0093,25) { ID32 = 016519, Ability = OnlyFirst, OTGender = 1, Gender = 1, Nature = Nature.Lonely, IVs = new(14,20,25,31,28,16), EvolveOnTrade = true }, // Haunter new(TradeNames, 02, SV, 0872,10) { ID32 = 050724, Ability = Any12, OTGender = 0, Gender = 1, Nature = Nature.Bashful, IVs = new(31,18,13,20,28,26) }, // Snom - }; + ]; internal static readonly EncounterTera9[] TeraBase = EncounterTera9.GetArray(Get("gem_paldea"), TeraRaidMapParent.Paldea); internal static readonly EncounterTera9[] TeraDLC1 = EncounterTera9.GetArray(Get("gem_kitakami"), TeraRaidMapParent.Kitakami); diff --git a/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs b/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs index c55bc47d8..6498cd7c9 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Live/EncountersGO.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; namespace PKHeX.Core; @@ -28,7 +29,7 @@ public static void Reload() SlotsGO = EncounterArea8g.GetArea(Get("go_home", "go"u8)); } - private static BinLinkerAccessor Get([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan ident) + private static BinLinkerAccessor Get([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan ident) { var name = $"encounter_{resource}.pkl"; var data = System.IO.File.Exists(name) ? System.IO.File.ReadAllBytes(name) : Util.GetBinaryResource(name); diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator1.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator1.cs index d40b920ab..ac06cc209 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator1.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator1.cs @@ -26,7 +26,7 @@ public IEnumerable GetEncounters(PKM pk, GameVersion game) // Favor special event move gifts as Static Encounters when applicable var chain = EncounterOrigin.GetOriginChain12(pk, game); if (chain.Length == 0) - return Array.Empty(); + return []; return GetEncounters(pk, chain); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator2.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator2.cs index 0318ad765..e11aa46fc 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator2.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator2.cs @@ -24,7 +24,7 @@ public IEnumerable GetEncounters(PKM pk, GameVersion game) { var chain = EncounterOrigin.GetOriginChain12(pk, game); if (chain.Length == 0) - return Array.Empty(); + return []; return GetEncounters(pk, chain); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs index d408b841f..7f8fdffb8 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator4.cs @@ -16,7 +16,7 @@ public IEnumerable GetEncounters(PKM pk, LegalInfo info) { var chain = EncounterOrigin.GetOriginChain(pk, 4); if (chain.Length == 0) - return Array.Empty(); + return []; return GetEncounters(pk, chain, info); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs index c2f1f8122..43e9b7c86 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator5.cs @@ -12,7 +12,7 @@ public IEnumerable GetEncounters(PKM pk, LegalInfo info) { var chain = EncounterOrigin.GetOriginChain(pk, 5); if (chain.Length == 0) - return Array.Empty(); + return []; return GetEncounters(pk, chain, info); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator9.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator9.cs index b311d2381..fd09d6cb3 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator9.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/EncounterGenerator9.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.GameVersion; @@ -13,7 +12,7 @@ public IEnumerable GetEncounters(PKM pk, LegalInfo info) { var chain = EncounterOrigin.GetOriginChain(pk, 9); if (chain.Length == 0) - return Array.Empty(); + return []; return (GameVersion)pk.Version switch { diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorDummy.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorDummy.cs index 67370c73a..74f1c2406 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorDummy.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorDummy.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace PKHeX.Core; @@ -7,18 +6,7 @@ internal sealed class EncounterGeneratorDummy : IEncounterGenerator { public static readonly EncounterGeneratorDummy Instance = new(); - public IEnumerable GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) - { - return Array.Empty(); - } - - public IEnumerable GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info) - { - return Array.Empty(); - } - - public IEnumerable GetEncounters(PKM _, LegalInfo __) - { - return Array.Empty(); - } + public IEnumerable GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) => []; + public IEnumerable GetEncounters(PKM pk, EvoCriteria[] chain, LegalInfo info) => []; + public IEnumerable GetEncounters(PKM _, LegalInfo __) => []; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorGO.cs b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorGO.cs index 2d520cab4..2b89126ab 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorGO.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/ByGeneration/Lump/EncounterGeneratorGO.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace PKHeX.Core; @@ -14,7 +13,7 @@ public IEnumerable GetEncounters(PKM pk, EvoCriteria[] chain, Le return EncounterGenerator7GO.Instance.GetEncounters(pk, chain, info); if (loc == Locations.GO8) return EncounterGenerator8GO.Instance.GetEncounters(pk, chain, info); - return Array.Empty(); + return []; } public IEnumerable GetPossible(PKM pk, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs index a28b2ec08..dcf78d6fd 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs @@ -112,7 +112,7 @@ private static AbilityPermission GetAbilityPermissions(int ability, IPersonalAbi if (count < 2 || pi is not IPersonalAbility12 a) return Any12; var dual = GetAbilityValueDual(ability, a); - if (count == 2 || pi is not IPersonalAbility12H h) // prior to gen5 + if (count == 2 || pi is not IPersonalAbility12H h) // prior to Gen5 return dual; if (ability == h.AbilityH) return dual == Any12 ? Any12H : OnlyHidden; @@ -235,7 +235,7 @@ public void SetRandomIVsGO(PKM pk, int minIV = 0, int maxIV = 15) public void SetRandomIVs(PKM pk, int flawless) { - Span ivs = stackalloc[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + Span ivs = [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; flawless -= ivs.Count(31); int remain = ivs.Count(RandomIV); if (flawless > remain) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs index 08eec81ad..c684b8e0f 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterFinder.cs @@ -78,13 +78,13 @@ public static void FindVerifiedEncounter(PKM pk, LegalInfo info) /// /// /// When an encounter is initially validated, only encounter-related checks are performed. - /// By checking Moves, Evolution, and data, a best match encounter can be found. + /// By checking Moves, Evolution, and data, the best match encounter can be found. /// If the encounter is not valid, the method will not reject it unless another encounter is available to check. /// /// Source data to check the match for /// Information containing the matched encounter /// Peekable iterator - /// Indication whether or not the encounter passes secondary checks + /// Indication whether the encounter passes secondary checks private static bool VerifySecondaryChecks(PKM pk, LegalInfo info, PeekEnumerator iterator) { var relearn = info.Relearn.AsSpan(); diff --git a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs index 4a54e6c2c..f8a7e5135 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs @@ -46,7 +46,7 @@ public static IEnumerable GenerateEncounters(PKM pk, ITrainerInf } /// - /// Adapts the input so that it may match as many encounters as possible (indications of trades to other game pairs, etc). + /// Adapts the input so that it may match as many encounters as possible (indications of trades to other game pairs, etc.). /// /// Rough Pokémon data which contains the requested species, gender, and form. /// Trainer information of the receiver. @@ -207,7 +207,7 @@ private static bool IsPlausibleSmeargleMoveset(EntityContext context, ReadOnlySp private static ushort[] GetNeededMoves(PKM pk, ReadOnlySpan moves, GameVersion ver, int generation, EntityContext context) { if (pk.Species == (int)Species.Smeargle) - return Array.Empty(); + return []; var length = pk.MaxMoveID + 1; var rent = ArrayPool.Shared.Rent(length); @@ -231,7 +231,7 @@ private static ushort[] GetNeededMoves(PKM pk, ReadOnlySpan moves, GameV ArrayPool.Shared.Return(rent); if (ctr == 0) - return Array.Empty(); + return []; return result[..ctr].ToArray(); } diff --git a/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible3.cs b/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible3.cs index 341121d35..48ff38e73 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible3.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Possible/EncounterPossible3.cs @@ -42,6 +42,7 @@ private enum YieldState : byte SlotR, SlotS, SlotE, + SwarmRSE, SlotFR, SlotLG, SlotEnd, @@ -188,18 +189,24 @@ public bool MoveNext() if (Version == GameVersion.LG) { State = YieldState.SlotLG; goto case YieldState.SlotLG; } throw new ArgumentOutOfRangeException(nameof(Version)); + case YieldState.SlotR: if (TryGetNext(Encounters3RSE.SlotsR)) return true; - Index = 0; goto case YieldState.SlotEnd; + Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; case YieldState.SlotS: if (TryGetNext(Encounters3RSE.SlotsS)) return true; - Index = 0; goto case YieldState.SlotEnd; + Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; case YieldState.SlotE: if (TryGetNext(Encounters3RSE.SlotsE)) return true; + Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + case YieldState.SwarmRSE: + if (TryGetNext(Encounters3RSE.SlotsSwarmRSE)) + return true; Index = 0; goto case YieldState.SlotEnd; + case YieldState.SlotFR: if (TryGetNext(Encounters3FRLG.SlotsFR)) return true; @@ -208,6 +215,7 @@ public bool MoveNext() if (TryGetNext(Encounters3FRLG.SlotsLG)) return true; Index = 0; goto case YieldState.SlotEnd; + case YieldState.SlotEnd: break; } diff --git a/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs b/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs index 2690d0625..f5a68aadd 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs @@ -50,6 +50,7 @@ private enum YieldState : byte SlotR, SlotS, SlotE, + SwarmRSE, SlotFR, SlotLG, SlotEnd, @@ -142,18 +143,24 @@ public bool MoveNext() if (Version == GameVersion.LG) { State = YieldState.SlotLG; goto case YieldState.SlotLG; } throw new ArgumentOutOfRangeException(nameof(Version)); + case YieldState.SlotR: if (TryGetNext(Encounters3RSE.SlotsR)) return true; - Index = 0; goto case YieldState.SlotEnd; + Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; case YieldState.SlotS: if (TryGetNext(Encounters3RSE.SlotsS)) return true; - Index = 0; goto case YieldState.SlotEnd; + Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; case YieldState.SlotE: if (TryGetNext(Encounters3RSE.SlotsE)) return true; + Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + case YieldState.SwarmRSE: + if (TryGetNext(Encounters3RSE.SlotsSwarmRSE)) + return true; Index = 0; goto case YieldState.SlotEnd; + case YieldState.SlotFR: if (TryGetNext(Encounters3FRLG.SlotsFR)) return true; @@ -162,6 +169,7 @@ public bool MoveNext() if (TryGetNext(Encounters3FRLG.SlotsLG)) return true; Index = 0; goto case YieldState.SlotEnd; + case YieldState.SlotEnd: if (mustBeSlot) goto case YieldState.StaticStart; // be generous with bad balls diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs index b9c6013d3..f2b3357cf 100644 --- a/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs +++ b/PKHeX.Core/Legality/Encounters/Information/EncounterDate.cs @@ -37,7 +37,7 @@ public static class EncounterDate GameConsole.NDS => GetDateNDS(), GameConsole._3DS => GetDate3DS(), GameConsole.NX => GetDateSwitch(), - _ => throw new ArgumentOutOfRangeException(nameof(console), console, null) + _ => throw new ArgumentOutOfRangeException(nameof(console), console, null), }; public static bool IsValidDateNDS(DateOnly date) diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterLearn.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterLearn.cs index 0da2b336e..82c53ec27 100644 --- a/PKHeX.Core/Legality/Encounters/Information/EncounterLearn.cs +++ b/PKHeX.Core/Legality/Encounters/Information/EncounterLearn.cs @@ -46,7 +46,7 @@ public static IEnumerable GetLearn(string species, IEnumerable(); + return []; var allMoves = moves.ToList(); var span = new ushort[allMoves.Count]; @@ -55,7 +55,7 @@ public static IEnumerable GetLearn(string species, IEnumerable(); + return []; span[i] = (ushort)index; } @@ -68,9 +68,9 @@ public static IEnumerable GetLearn(string species, IEnumerable GetLearn(ushort species, ushort[] moves, byte form = 0) { if (species == 0) - return Array.Empty(); + return []; if (moves.AsSpan().Contains(0)) - return Array.Empty(); + return []; var vers = GameUtil.GameVersions; return GetLearnInternal(species, form, moves, vers); diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs index 68ab8fb5c..6c216599c 100644 --- a/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs +++ b/PKHeX.Core/Legality/Encounters/Information/EncounterSuggestion.cs @@ -64,7 +64,7 @@ public static int GetSuggestedEncounterEggMetLevel(PKM pk) return pk.CurrentLevel; // be generous with transfer conditions if (pk.Format < 5) // and native return pk.Format == 2 && pk.Met_Location != 0 ? 1 : 0; - return 1; // gen5+ + return 1; // Gen5+ } public static int GetSuggestedEncounterEggLocationEgg(PKM pk, bool traded = false) diff --git a/PKHeX.Core/Legality/Encounters/Information/EncounterSummary.cs b/PKHeX.Core/Legality/Encounters/Information/EncounterSummary.cs index 5f8b9ae82..b7f8bea8e 100644 --- a/PKHeX.Core/Legality/Encounters/Information/EncounterSummary.cs +++ b/PKHeX.Core/Legality/Encounters/Information/EncounterSummary.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core; /// -/// Provides a summary for an object. +/// Provides a summary for objects. /// public sealed record EncounterSummary { diff --git a/PKHeX.Core/Legality/Encounters/Templates/Enums/AbilityPermission.cs b/PKHeX.Core/Legality/Encounters/Templates/Enums/AbilityPermission.cs index 64155825d..8174eb1a6 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Enums/AbilityPermission.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Enums/AbilityPermission.cs @@ -54,7 +54,7 @@ public static bool IsSingleValue(this AbilityPermission value, out int index) /// Indicates if the given value can be initially obtained with a hidden ability. /// /// Value to check - /// True if can be hidden. + /// True if it can be a hidden ability. public static bool CanBeHidden(this AbilityPermission value) => value switch { Any12H => true, diff --git a/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs b/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs index c55fa480f..17b727eed 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/GO/EncounterSlot7GO.cs @@ -104,8 +104,8 @@ private void SetPINGA(PB7 pk, EncounterCriteria criteria) private void SetEncounterMoves(PB7 pk, int level) { Span moves = stackalloc ushort[4]; - ILearnSource source = LearnSource7GG.Instance; - source.SetEncounterMoves(Species, Form, level, moves); + var source = LearnSource7GG.Instance; + ((ILearnSource)source).SetEncounterMoves(Species, Form, level, moves); pk.SetMoves(moves); } #endregion diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterGift1.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterGift1.cs index 6a4d05255..60bc85fc8 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterGift1.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen1/EncounterGift1.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; @@ -29,7 +28,7 @@ public sealed record EncounterGift1(ushort Species, byte Level, GameVersion Vers /// Trainer name for the event. public string OT_Name { get; init; } = string.Empty; - public IReadOnlyList OT_Names { get; init; } = Array.Empty(); + public IReadOnlyList OT_Names { get; init; } = []; /// Trainer ID for the event. public ushort TID16 { get; init; } = UnspecifiedID; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterArea2.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterArea2.cs index acb2d9b2b..0cacb9c09 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterArea2.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterArea2.cs @@ -10,9 +10,9 @@ public sealed record EncounterArea2 : IEncounterArea, IAreaLocat public EncounterSlot2[] Slots { get; } public GameVersion Version { get; } - private static ReadOnlySpan BCC_SlotRates => new byte[] { 20, 20, 10, 10, 05, 05, 10, 10, 05, 05 }; - private static ReadOnlySpan RatesGrass => new byte[] { 30, 30, 20, 10, 5, 4, 1 }; - private static ReadOnlySpan RatesSurf => new byte[] { 60, 30, 10 }; + private static ReadOnlySpan BCC_SlotRates => [ 20, 20, 10, 10, 05, 05, 10, 10, 05, 05 ]; + private static ReadOnlySpan RatesGrass => [ 30, 30, 20, 10, 5, 4, 1 ]; + private static ReadOnlySpan RatesSurf => [ 60, 30, 10 ]; public readonly byte[]? Rates; internal readonly EncounterTime Time; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterGift2.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterGift2.cs index b0b7f2abe..0ca1ae69d 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterGift2.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterGift2.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; @@ -35,7 +34,7 @@ public sealed record EncounterGift2(ushort Species, byte Level, GameVersion Vers /// Trainer name for the event. public string OT_Name { get; init; } = string.Empty; - public IReadOnlyList OT_Names { get; init; } = Array.Empty(); + public IReadOnlyList OT_Names { get; init; } = []; private const ushort UnspecifiedID = 0; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterSlot2.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterSlot2.cs index f1605727d..fd654a892 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterSlot2.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen2/EncounterSlot2.cs @@ -31,13 +31,13 @@ public sealed record EncounterSlot2(EncounterArea2 Parent, ushort Species, byte public SlotType SlotType => Type & (SlotType)0xF; public bool IsHeadbutt => SlotType == SlotType.Headbutt; - private static ReadOnlySpan TreeIndexes => new byte[] - { + private static ReadOnlySpan TreeIndexes => + [ 02, 04, 05, 08, 11, 12, 14, 15, 18, 20, 21, 25, 26, 34, 37, 38, 39, 91, 92, - }; + ]; - private static ReadOnlySpan Trees => new[] - { + private static ReadOnlySpan Trees => + [ 0x3FF_3FF, // Route 29 0x0FF_3FF, // Route 30 0x3FE_3FF, // Route 31 @@ -57,7 +57,7 @@ public sealed record EncounterSlot2(EncounterArea2 Parent, ushort Species, byte 0x2FF_3FF, // Route 44 0x200_1FF, // Route 26 0x2BB_3FF, // Route 27 - }; + ]; public bool IsTreeAvailable(ushort trainerID) { diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterArea3XD.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterArea3XD.cs index e599c3e36..5a49aca22 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterArea3XD.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen3/XD/EncounterArea3XD.cs @@ -15,11 +15,11 @@ public sealed record EncounterArea3XD : IVersion, IEncounterArea()) { } + public EncounterTrade3XD(ushort species, byte level, string[] trainer) : this(species, level, trainer, []) { } public EncounterTrade3XD(ushort species, byte level, string[] trainer, string[] nicknames) { diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs index f26291c06..0b4d1225e 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterArea4.cs @@ -86,8 +86,8 @@ private static bool IsMunchlaxTree(ReadOnlySpan trees, ushort location) || LocationID_HoneyTree[trees[3]] == location; } - private static ReadOnlySpan LocationID_HoneyTree => new byte[] - { + private static ReadOnlySpan LocationID_HoneyTree => + [ 20, // 00 Route 205 Floaroma 20, // 01 Route 205 Eterna 21, // 02 Route 206 @@ -109,5 +109,5 @@ private static bool IsMunchlaxTree(ReadOnlySpan trees, ushort location) 48, // 18 Eterna Forest 49, // 19 Fuego Ironworks 58, // 20 Floaroma Meadow - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs index ac7c367f8..7821fa3ce 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterSlot4.cs @@ -156,7 +156,8 @@ public bool IsCompatible(PIDType val, PKM pk) { if (val is PIDType.Method_1) return true; - // Chain shiny with Poké Radar is only possible in DPPt, in grass. Safari Zone does not allow using the Poké Radar + // Chain shiny with Poké Radar is only possible in D/P/Pt, in grass. + // Safari Zone does not allow using the Poké Radar if (val is PIDType.ChainShiny) return pk.IsShiny && CanUseRadar; if (val is PIDType.CuteCharm) diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4PID.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4PID.cs index d93f137b9..b130a64e3 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4PID.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4PID.cs @@ -138,7 +138,7 @@ private int GetReceivedLanguage(int lang, GameVersion game) if (Version == GameVersion.DPPt) return GetLanguageDPPt(lang, game); - // HGSS + // HG/SS // Has English Language ID for all except English origin, which is French if (Species == (int)Core.Species.Pikachu) return (int)(lang == (int)LanguageID.English ? LanguageID.French : LanguageID.English); @@ -150,7 +150,7 @@ private int GetLanguageDPPt(int lang, GameVersion game) // Has German Language ID for all except German origin, which is English if (Species == (int)Core.Species.Magikarp) return (int)(lang == (int)LanguageID.German ? LanguageID.English : LanguageID.German); - // All other trades received (DP only): English games have a Japanese language ID instead of English. + // All other trades received (D/P only): English games have a Japanese language ID instead of English. if (game is not GameVersion.Pt && lang == (int)LanguageID.English) return (int)LanguageID.Japanese; return lang; @@ -233,12 +233,12 @@ public int DetectOriginalLanguage(PKM pk) int lang = pk.Language; switch (Species) { - case (int)Core.Species.Pikachu: // HGSS Pikachu + case (int)Core.Species.Pikachu: // HG/SS Pikachu return DetectTradeLanguageG4SurgePikachu(pk, lang); - case (int)Core.Species.Magikarp: // DPPt Magikarp + case (int)Core.Species.Magikarp: // D/P/Pt Magikarp return DetectTradeLanguageG4MeisterMagikarp(pk, lang); } - // DP English origin are Japanese lang. Can't have LanguageID 2 + // D/P English origin are Japanese lang. Can't have LanguageID 2 if (lang != 1 || pk.Version is not ((int)GameVersion.D or (int)GameVersion.P)) return lang; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs index aad643f1f..457ea0862 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/EncounterTrade4RanchGift.cs @@ -44,7 +44,7 @@ public sealed record EncounterTrade4RanchGift public byte CurrentLevel { get; init; } public byte Form { get; init; } - private static readonly string[] TrainerNames = { string.Empty, "ユカリ", "Hayley", "EULALIE", "GIULIA", "EUKALIA", string.Empty, "Eulalia" }; + private static readonly string[] TrainerNames = [string.Empty, "ユカリ", "Hayley", "EULALIE", "GIULIA", "EUKALIA", string.Empty, "Eulalia"]; private const string _name = "In-game Trade"; public string Name => _name; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen4/GroundTileAllowed.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen4/GroundTileAllowed.cs index c916b2705..9e9774416 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen4/GroundTileAllowed.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen4/GroundTileAllowed.cs @@ -24,7 +24,7 @@ public enum GroundTileAllowed Building = 1 << 09, Marsh = 1 << 10, Bridge = 1 << 11, // No encounters from this tile type - Max_DP = 1 << 12, // Unspecific, catch-all for DP undefined tiles. + Max_DP = 1 << 12, // Unspecific, catch-all for D/P undefined tiles. // added tile types in Pt // no encounters from these tile types diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5.cs index f64b9a037..0181a84a0 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5.cs @@ -148,7 +148,7 @@ public bool IsMatchExact(PKM pk, EvoCriteria evo) private bool IsMatchPartial(PKM pk) { - // BW/2 Jellicent collision with wild surf slot, resolved by duplicating the encounter with any abil + // B2/W2 has a static encounter Jellicent with Hidden Ability. Collides with wild surf slots. if (Ability == AbilityPermission.OnlyHidden && pk.AbilityNumber != 4 && pk.Format <= 7) return true; if (EggLocation == Locations.Daycare5 && pk.RelearnMove1 != 0) diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5Entree.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5Entree.cs index ec8786cb7..ae3087af7 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5Entree.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterStatic5Entree.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Generation 5 Entree Forest static encounter +/// Generation 5 Entrée Forest static encounter /// public sealed record EncounterStatic5Entree(GameVersion Version, ushort Species, byte Level, byte Form, byte Gender, AbilityPermission Ability) : IEncounterable, IEncounterMatch, IEncounterConvertible, IMoveset, IFixedGender diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterTrade5B2W2.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterTrade5B2W2.cs index 1a3eb2e0a..f7e44ab49 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterTrade5B2W2.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen5/EncounterTrade5B2W2.cs @@ -54,7 +54,7 @@ public EncounterTrade5B2W2(string[] names, GameVersion version) Version = version; Gender = FixedGenderUtil.GenderRandom; Nature = Nature.Random; - Nicknames = Array.Empty(); + Nicknames = []; TrainerNames = names; IsFixedNickname = false; } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterArea6XY.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterArea6XY.cs index 14a976e95..5f993fde9 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterArea6XY.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterArea6XY.cs @@ -66,8 +66,8 @@ private EncounterSlot6XY[] LoadSafariSlots() return slots; } - private static ReadOnlySpan AllSpecies => new ushort[] - { + private static ReadOnlySpan AllSpecies => + [ 002, 005, 008, 012, 014, 016, 021, 025, 027, 035, 038, 039, 043, 044, 046, 049, 049, 051, 056, 058, 061, 063, 067, 077, 082, 083, 084, 087, 089, 091, @@ -90,7 +90,7 @@ private EncounterSlot6XY[] LoadSafariSlots() 712, 714, // Handle Floette (670) and Vivillon (666) separately - }; + ]; private EncounterSlot6XY[] ReadSlots(ReadOnlySpan data) { diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs index ca41c9986..da0dfc0d7 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen6/EncounterSlot6XY.cs @@ -23,7 +23,7 @@ public sealed record EncounterSlot6XY(EncounterArea6XY Parent, ushort Species, b public GameVersion Version => Parent.Version; public int Location => Parent.Location; public SlotType Type => Parent.Type; - + public bool IsFriendSafari => Type == SlotType.FriendSafari; public bool IsHorde => Type == SlotType.Horde; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8/AreaWeather8.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8/AreaWeather8.cs index 8cb1ba54a..9bfa2bfb0 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8/AreaWeather8.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8/AreaWeather8.cs @@ -50,6 +50,6 @@ public static bool IsMarkCompatible(this AreaWeather8 weather, IRibbonSetMark8 m if (m.RibbonMarkDry) return (weather & Intense_Sun) != 0; if (m.RibbonMarkSandstorm) return (weather & Sandstorm) != 0; if (m.RibbonMarkMisty) return (weather & Heavy_Fog) != 0; - return true; // no mark / etc is fine; check later. + return true; // no mark / etc. is fine; check later. } } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterArea8.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterArea8.cs index dcc3de6b7..00c97ead0 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterArea8.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterArea8.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using static PKHeX.Core.AreaWeather8; using static PKHeX.Core.AreaSlotType8; using static System.Buffers.Binary.BinaryPrimitives; @@ -32,12 +31,11 @@ public bool IsMatchLocation(int location) if (!PermitCrossover) return false; - // Get all other areas that the Location can bleed encounters to - if (!ConnectingArea8.TryGetValue(Location, out var others)) - return false; - // Check if any of the other areas are the met location - return Array.IndexOf(others, (byte)location) != -1; + if (location > byte.MaxValue) + return false; + var others = GetAreasCanWanderTo(Location); + return others.Contains((byte)location); } public static bool CanCrossoverTo(int fromLocation, int toLocation, AreaSlotType8 type) @@ -60,239 +58,253 @@ public static bool CanCrossoverTo(int fromLocation, int toLocation, AreaSlotType public static bool IsWildArea8Armor(int location) => location is >= 164 and <= 194; // Fields of Honor -> Honeycalm Island public static bool IsWildArea8Crown(int location) => location is >= 204 and <= 234 and not 206; // Slippery Slope -> Dyna Tree Hill, skip Freezington - // Location, and areas that it can feed encounters to. - public static readonly IReadOnlyDictionary ConnectingArea8 = new Dictionary + /// + /// Location, and areas that it can feed encounters to. + /// + public static ReadOnlySpan GetAreasCanWanderTo(byte location) => location switch { // Route 3 // City of Motostoke - {28, new byte[] {20}}, + 28 => [20], // Rolling Fields // Dappled Grove, East Lake Axewell, West Lake Axewell // Also connects to South Lake Miloch but too much of a stretch - {122, new byte[] {124, 128, 130}}, + 122 => [124, 128, 130], // Dappled Grove // Rolling Fields, Watchtower Ruins - {124, new byte[] {122, 126}}, + 124 => [122, 126], // Watchtower Ruins // Dappled Grove, West Lake Axewell - {126, new byte[] {124, 130}}, + 126 => [124, 130], // East Lake Axewell // Rolling Fields, West Lake Axewell, Axew's Eye, North Lake Miloch - {128, new byte[] {122, 130, 132, 138}}, + 128 => [122, 130, 132, 138], // West Lake Axewell // Rolling Fields, Watchtower Ruins, East Lake Axewell, Axew's Eye - {130, new byte[] {122, 126, 128, 132}}, + 130 => [122, 126, 128, 132], // Axew's Eye // East Lake Axewell, West Lake Axewell - {132, new byte[] {128, 130}}, + 132 => [128, 130], // South Lake Miloch // Giant's Seat, North Lake Miloch - {134, new byte[] {136, 138}}, + 134 => [136, 138], // Giant's Seat // South Lake Miloch, North Lake Miloch - {136, new byte[] {134, 138}}, + 136 => [134, 138], // North Lake Miloch // East Lake Axewell, South Lake Miloch, Giant's Seat // Also connects to Motostoke Riverbank but too much of a stretch - {138, new byte[] {134, 136}}, + 138 => [134, 136], // Motostoke Riverbank // Bridge Field - {140, new byte[] {142}}, + 140 => [142], // Bridge Field // Motostoke Riverbank, Stony Wilderness - {142, new byte[] {140, 144}}, + 142 => [140, 144], // Stony Wilderness // Bridge Field, Dusty Bowl, Giant's Mirror, Giant's Cap - {144, new byte[] {142, 146, 148, 152}}, + 144 => [142, 146, 148, 152], // Dusty Bowl // Stony Wilderness, Giant's Mirror, Hammerlocke Hills - {146, new byte[] {144, 148, 150}}, + 146 => [144, 148, 150], // Giant's Mirror // Stony Wilderness, Dusty Bowl, Hammerlocke Hills - {148, new byte[] {144, 146, 148}}, + 148 => [144, 146, 148], // Hammerlocke Hills // Dusty Bowl, Giant's Mirror, Giant's Cap - {150, new byte[] {146, 148, 152}}, + 150 => [146, 148, 152], // Giant's Cap // Stony Wilderness, Giant's Cap // Also connects to Lake of Outrage but too much of a stretch - {152, new byte[] {144, 150}}, + 152 => [144, 150], // Lake of Outrage is just itself. // Challenge Beach // Soothing Wetlands, Courageous Cavern - {170, new byte[] {166, 176}}, + 170 => [166, 176], // Challenge Road // Brawler's Cave - {174, new byte[] {172}}, + 174 => [172], // Courageous Cavern // Loop Lagoon - {176, new byte[] {178}}, + 176 => [178], // Warm-Up Tunnel // Training Lowlands, Potbottom Desert - {182, new byte[] {180, 184}}, + 182 => [180, 184], // Workout Sea // Fields of Honor - {186, new byte[] {164}}, + 186 => [164], // Stepping-Stone Sea // Fields of Honor - {188, new byte[] {170}}, + 188 => [170], // Insular Sea // Honeycalm Sea - {190, new byte[] {192}}, + 190 => [192], // Honeycalm Sea // Honeycalm Island - {192, new byte[] {194}}, + 192 => [194], // Frostpoint Field // Freezington - {208, new byte[] {206}}, + 208 => [206], // Old Cemetery // Giant’s Bed - {212, new byte[] {210}}, + 212 => [210], // Roaring-Sea Caves // Giant’s Foot - {224, new byte[] {222}}, + 224 => [222], // Ballimere Lake // Lakeside Cave - {230, new byte[] {232}}, + 230 => [232], + _ => [], }; /// /// Location IDs matched with possible weather types. Unlisted locations may only have Normal weather. /// - internal static readonly Dictionary WeatherbyArea = new() + public static AreaWeather8 GetWeather(byte location) => location switch { - { 68, Intense_Sun }, // Route 6 - { 88, Snowing }, // Route 8 (Steamdrift Way) - { 90, Snowing }, // Route 9 - { 92, Snowing }, // Route 9 (Circhester Bay) - { 94, Overcast }, // Route 9 (Outer Spikemuth) - { 106, Snowstorm }, // Route 10 - { 122, All }, // Rolling Fields - { 124, All }, // Dappled Grove - { 126, All }, // Watchtower Ruins - { 128, All }, // East Lake Axewell - { 130, All }, // West Lake Axewell - { 132, All }, // Axew's Eye - { 134, All }, // South Lake Miloch - { 136, All }, // Giant's Seat - { 138, All }, // North Lake Miloch - { 140, All }, // Motostoke Riverbank - { 142, All }, // Bridge Field - { 144, All }, // Stony Wilderness - { 146, All }, // Dusty Bowl - { 148, All }, // Giant's Mirror - { 150, All }, // Hammerlocke Hills - { 152, All }, // Giant's Cap - { 154, All }, // Lake of Outrage - { 164, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Fields of Honor - { 166, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Soothing Wetlands - { 168, All_IoA }, // Forest of Focus - { 170, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Challenge Beach - { 174, All_IoA }, // Challenge Road - { 178, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Loop Lagoon - { 180, All_IoA }, // Training Lowlands - { 184, Normal | Overcast | Raining | Sandstorm | Intense_Sun | Heavy_Fog }, // Potbottom Desert - { 186, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Workout Sea - { 188, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Stepping-Stone Sea - { 190, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Insular Sea - { 192, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Honeycalm Sea - { 194, Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog }, // Honeycalm Island - { 204, Normal | Overcast | Intense_Sun | Icy | Heavy_Fog }, // Slippery Slope - { 208, Normal | Overcast | Intense_Sun | Icy | Heavy_Fog }, // Frostpoint Field - { 210, All_CT }, // Giant's Bed - { 212, All_CT }, // Old Cemetery - { 214, Normal | Overcast | Intense_Sun | Icy | Heavy_Fog }, // Snowslide Slope - { 216, Overcast }, // Tunnel to the Top - { 218, Normal | Overcast | Intense_Sun | Icy | Heavy_Fog }, // Path to the Peak - { 222, All_CT }, // Giant's Foot - { 224, Overcast }, // Roaring-Sea Caves - { 226, No_Sun_Sand }, // Frigid Sea - { 228, All_CT }, // Three-Point Pass - { 230, All_Ballimere }, // Ballimere Lake - { 232, Overcast }, // Lakeside Cave + 068 => Intense_Sun, // Route 6 + 088 => Snowing, // Route 8 (Steamdrift Way) + 090 => Snowing, // Route 9 + 092 => Snowing, // Route 9 (Circhester Bay) + 094 => Overcast, // Route 9 (Outer Spikemuth) + 106 => Snowstorm, // Route 10 + 122 => All, // Rolling Fields + 124 => All, // Dappled Grove + 126 => All, // Watchtower Ruins + 128 => All, // East Lake Axewell + 130 => All, // West Lake Axewell + 132 => All, // Axew's Eye + 134 => All, // South Lake Miloch + 136 => All, // Giant's Seat + 138 => All, // North Lake Miloch + 140 => All, // Motostoke Riverbank + 142 => All, // Bridge Field + 144 => All, // Stony Wilderness + 146 => All, // Dusty Bowl + 148 => All, // Giant's Mirror + 150 => All, // Hammerlocke Hills + 152 => All, // Giant's Cap + 154 => All, // Lake of Outrage + 164 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Fields of Honor + 166 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Soothing Wetlands + 168 => All_IoA, // Forest of Focus + 170 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Challenge Beach + 174 => All_IoA, // Challenge Road + 178 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Loop Lagoon + 180 => All_IoA, // Training Lowlands + 184 => Normal | Overcast | Raining | Sandstorm | Intense_Sun | Heavy_Fog, // Potbottom Desert + 186 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Workout Sea + 188 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Stepping-Stone Sea + 190 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Insular Sea + 192 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Honeycalm Sea + 194 => Normal | Overcast | Stormy | Intense_Sun | Heavy_Fog, // Honeycalm Island + 204 => Normal | Overcast | Intense_Sun | Icy | Heavy_Fog, // Slippery Slope + 208 => Normal | Overcast | Intense_Sun | Icy | Heavy_Fog, // Frostpoint Field + 210 => All_CT, // Giant's Bed + 212 => All_CT, // Old Cemetery + 214 => Normal | Overcast | Intense_Sun | Icy | Heavy_Fog, // Snowslide Slope + 216 => Overcast, // Tunnel to the Top + 218 => Normal | Overcast | Intense_Sun | Icy | Heavy_Fog, // Path to the Peak + 222 => All_CT, // Giant's Foot + 224 => Overcast, // Roaring-Sea Caves + 226 => No_Sun_Sand, // Frigid Sea + 228 => All_CT, // Three-Point Pass + 230 => All_Ballimere, // Ballimere Lake + 232 => Overcast, // Lakeside Cave + _ => Normal, }; /// /// Weather types that may bleed into each location from adjacent locations for standard symbol encounter slots. /// - internal static readonly Dictionary WeatherBleedSymbol = new() + public static AreaWeather8 GetWeatherBleedSymbol(byte location) => location switch { - { 166, All_IoA }, // Soothing Wetlands from Forest of Focus - { 170, All_IoA }, // Challenge Beach from Forest of Focus - { 182, All_IoA }, // Warm-Up Tunnel from Training Lowlands - { 208, All_CT }, // Frostpoint Field from Giant's Bed - { 216, Normal | Overcast | Intense_Sun | Icy | Heavy_Fog }, // Tunnel to the Top from Path to the Peak - { 224, All_CT }, // Roaring-Sea Caves from Three-Point Pass - { 232, All_Ballimere }, // Lakeside Cave from Ballimere Lake - { 230, All_CT }, // Ballimere Lake from Giant's Bed + 166 => All_IoA, // Soothing Wetlands from Forest of Focus + 170 => All_IoA, // Challenge Beach from Forest of Focus + 182 => All_IoA, // Warm-Up Tunnel from Training Lowlands + 208 => All_CT, // Frostpoint Field from Giant's Bed + 216 => Normal | Overcast | Intense_Sun | Icy | Heavy_Fog, // Tunnel to the Top from Path to the Peak + 224 => All_CT, // Roaring-Sea Caves from Three-Point Pass + 232 => All_Ballimere, // Lakeside Cave from Ballimere Lake + 230 => All_CT, // Ballimere Lake from Giant's Bed + _ => None, }; /// /// Weather types that may bleed into each location from adjacent locations for surfing symbol encounter slots. /// - private static readonly Dictionary WeatherBleedSymbolSurfing = new() + public static AreaWeather8 GetWeatherBleedSymbolSurfing(byte location) => location switch { - { 192, All_IoA }, // Honeycalm Sea from Training Lowlands - { 224, All_CT }, // Roaring-Sea Caves from Giant's Foot + 192 => All_IoA, // Honeycalm Sea from Training Lowlands + 224 => All_CT, // Roaring-Sea Caves from Giant's Foot + _ => None, }; /// /// Weather types that may bleed into each location from adjacent locations for Sharpedo symbol encounter slots. /// - private static readonly Dictionary WeatherBleedSymbolSharpedo = new() + public static AreaWeather8 GetWeatherBleedSymbolSharpedo(byte location) => location switch { - { 192, All_IoA }, // Honeycalm Sea from Training Lowlands + 192 => All_IoA, // Honeycalm Sea from Training Lowlands + _ => None, }; /// /// Weather types that may bleed into each location from adjacent locations, for standard hidden grass encounter slots. /// - private static readonly Dictionary WeatherBleedHiddenGrass = new() + public static AreaWeather8 GetWeatherBleedHiddenGrass(byte location) => location switch { - { 166, All_IoA }, // Soothing Wetlands from Forest of Focus - { 170, All_IoA }, // Challenge Beach from Forest of Focus - { 208, All_CT }, // Frostpoint Field from Giant's Bed - { 230, All_CT }, // Ballimere Lake from Giant's Bed + 166 => All_IoA, // Soothing Wetlands from Forest of Focus + 170 => All_IoA, // Challenge Beach from Forest of Focus + 208 => All_CT, // Frostpoint Field from Giant's Bed + 230 => All_CT, // Ballimere Lake from Giant's Bed + _ => None, }; public static bool IsCrossoverBleedPossible(AreaSlotType8 type, int fromLocation, byte toLocation) => true; - public static bool IsWeatherBleedPossible(AreaSlotType8 type, AreaWeather8 permit, byte location) => type switch + public static bool IsWeatherBleedPossible(AreaSlotType8 type, AreaWeather8 permit, byte location) { - SymbolMain or SymbolMain2 or SymbolMain3 => WeatherBleedSymbol .TryGetValue(location, out var weather) && weather.HasFlag(permit), - HiddenMain or HiddenMain2 => WeatherBleedHiddenGrass .TryGetValue(location, out var weather) && weather.HasFlag(permit), - Surfing => WeatherBleedSymbolSurfing .TryGetValue(location, out var weather) && weather.HasFlag(permit), - Sharpedo => WeatherBleedSymbolSharpedo.TryGetValue(location, out var weather) && weather.HasFlag(permit), - _ => false, + var weather = GetWeatherBleed(type, location); + return weather.HasFlag(permit); + } + + private static AreaWeather8 GetWeatherBleed(AreaSlotType8 type, byte location) => type switch + { + SymbolMain or SymbolMain2 or SymbolMain3 => GetWeatherBleedSymbol(location), + HiddenMain or HiddenMain2 => GetWeatherBleedHiddenGrass(location), + Surfing => GetWeatherBleedSymbolSurfing(location), + Sharpedo => GetWeatherBleedSymbolSharpedo(location), + _ => None, }; public static EncounterArea8[] GetAreas(BinLinkerAccessor input, GameVersion game, bool symbol = false) diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterStatic8N.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterStatic8N.cs index edcec2e0d..8f8d28efc 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterStatic8N.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterStatic8N.cs @@ -41,14 +41,14 @@ public static EncounterStatic8N Read(ReadOnlySpan data, GameVersion game) CanGigantamax = data[5] != 0, }; - private static ReadOnlySpan LevelCaps => new byte[] - { + private static ReadOnlySpan LevelCaps => + [ 15, 20, // 0 25, 30, // 1 35, 40, // 2 45, 50, // 3 55, 60, // 4 - }; + ]; protected override bool IsMatchLevel(PKM pk) { @@ -62,12 +62,8 @@ protected override bool IsMatchLevel(PKM pk) if (rank <= 1 && met <= byte.MaxValue) { - if (InaccessibleRank12Nests.TryGetValue((byte)met, out var nests)) - { - var nest = Array.IndexOf(nests, NestID); - if (nest >= 0) - return false; - } + if (IsInaccessibleRank12Nest(NestID, (byte)met)) + return false; } if (rank < MinRank) // down-leveled diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterTrade8.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterTrade8.cs index 729c9f490..91b7f26e3 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterTrade8.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8/EncounterTrade8.cs @@ -71,7 +71,7 @@ public EncounterTrade8(ReadOnlySpan names, byte index, GameVersion gam public EncounterTrade8(string[] trainerNames, GameVersion game, ushort species, byte level, byte memory, ushort arg, byte feel, byte intensity) { Version = game; - Nicknames = Array.Empty(); + Nicknames = []; TrainerNames = trainerNames; Species = species; Level = level; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs index e436b1529..68a0221c4 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8a/EncounterStatic8a.cs @@ -142,7 +142,7 @@ private OverworldParam8a GetParams() IsAlpha = IsAlpha, FlawlessIVs = FlawlessIVCount, Shiny = Shiny, - RollCount = 1, // Everything is shiny locked anyways + RollCount = 1, // Everything is shiny locked anyway GenderRatio = gender, }; } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterArea8b.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterArea8b.cs index 306d3fd47..a6787ac5e 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterArea8b.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterArea8b.cs @@ -101,8 +101,8 @@ private static bool IsMunchlaxTree(ReadOnlySpan trees, ushort location) || LocationID_HoneyTree[trees[3]] == location; } - private static ReadOnlySpan LocationID_HoneyTree => new ushort[] - { + private static ReadOnlySpan LocationID_HoneyTree => + [ 359, // 00 Route 205 Floaroma 361, // 01 Route 205 Eterna 362, // 02 Route 206 @@ -124,5 +124,5 @@ private static bool IsMunchlaxTree(ReadOnlySpan trees, ushort location) 199, // 18 Eterna Forest 201, // 19 Fuego Ironworks 253, // 20 Floaroma Meadow - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs index 144ba6f7d..f080afc0d 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterSlot8b.cs @@ -42,7 +42,7 @@ public sealed record EncounterSlot8b(EncounterArea8b Parent, ushort Species, byt 294 or 295 => false, // Ruin Maniac Cave 296 => false, // Maniac Tunnel 299 or 300 or 301 or 302 or 303 or 304 or 305 => false, // Iron Island, 298 exterior - 306 or 307 or 308 or 309 or 310 or 311 or 312 or 313 or 314 => false, // Old Chateau + 306 or 307 or 308 or 309 or 310 or 311 or 312 or 313 or 314 => false, // Old Château 368 or 369 or 370 or 371 or 372 => false, // Route 209 (Lost Tower) _ => true, }; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterStatic8b.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterStatic8b.cs index 1d1724c7f..bec33a39b 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterStatic8b.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen8b/EncounterStatic8b.cs @@ -44,12 +44,12 @@ public bool IsStaticCorrelationCorrect(PKM pk) } // defined by mvpoke in encounter data - private static ReadOnlySpan Roaming_MetLocation_BDSP => new ushort[] - { + private static ReadOnlySpan Roaming_MetLocation_BDSP => + [ 197, 201, 354, 355, 356, 357, 358, 359, 361, 362, 364, 365, 367, 373, 375, 377, 378, 379, 383, 385, 392, 394, 395, 397, 400, 403, 404, 407, 485, - }; + ]; #region Generating diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterOutbreak9.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterOutbreak9.cs index b64aa5132..5de19b099 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterOutbreak9.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterOutbreak9.cs @@ -59,11 +59,7 @@ private static EncounterOutbreak9 ReadEncounter(ReadOnlySpan data) => new( ScaleMin = data[0x09], ScaleMax = data[0x0A], IsShiny = data[0x0B] != 0, -#if NET8_0_OR_GREATER -FAIL TO COMPILE, USE THE NEW UINT128 METHOD -- DOUBLE CHECK IF GetFirstMetLocation CAN USE UINT128 TOO MetFlags = ReadUInt128LittleEndian(data[0x0C..]), -#endif - MetFlags = new UInt128(ReadUInt64LittleEndian(data[0x14..]), ReadUInt64LittleEndian(data[0x0C..])), }; public string Name => "Distribution Outbreak Encounter"; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterSlot9.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterSlot9.cs index 14943d8cf..164fe3ef4 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterSlot9.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9/EncounterSlot9.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using static PKHeX.Core.AreaWeather9; namespace PKHeX.Core; @@ -43,69 +42,70 @@ public bool CanSpawnInWeather(RibbonIndex mark) public static bool CanSpawnInWeather(RibbonIndex mark, byte loc) { - if (AreaWeather.TryGetValue(loc, out var areaWeather)) - return areaWeather.IsMarkCompatible(mark); - return false; + var weather = GetWeather(loc); + return weather.IsMarkCompatible(mark); } /// - /// Location IDs matched with possible weather types. + /// Location IDs matched with possible weather types. Unlisted locations may only have Normal weather. /// - internal static readonly Dictionary AreaWeather = new() + public static AreaWeather9 GetWeather(byte location) => location switch { - { 6, Standard }, // South Province (Area One) - { 10, Standard }, // Pokémon League - { 12, Standard }, // South Province (Area Two) - { 14, Standard }, // South Province (Area Four) - { 16, Standard }, // South Province (Area Six) - { 18, Standard }, // South Province (Area Five) - { 20, Standard }, // South Province (Area Three) - { 22, Standard }, // West Province (Area One) - { 24, Sand }, // Asado Desert - { 26, Standard }, // West Province (Area Two) - { 28, Standard }, // West Province (Area Three) - { 30, Standard }, // Tagtree Thicket - { 32, Standard }, // East Province (Area Three) - { 34, Standard }, // East Province (Area One) - { 36, Standard }, // East Province (Area Two) - { 38, Snow }, // Glaseado Mountain (1) - { 40, Standard }, // Casseroya Lake - { 44, Standard }, // North Province (Area Three) - { 46, Standard }, // North Province (Area One) - { 48, Standard }, // North Province (Area Two) - { 50, Standard }, // Great Crater of Paldea - { 56, Standard }, // South Paldean Sea - { 58, Standard }, // West Paldean Sea - { 60, Standard }, // East Paldean Sea - { 62, Standard }, // North Paldean Sea - { 64, Inside }, // Inlet Grotto - { 67, Inside }, // Alfornada Cavern - { 69, Standard | Inside | Snow | Snow },// Dalizapa Passage (Near Medali, Tunnels, Near Pokémon Center, Near Zapico) - { 70, Standard }, // Poco Path - { 80, Standard }, // Cabo Poco - { 109, Standard }, // Socarrat Trail - { 124, Inside }, // Area Zero (5) + 006 => Standard, // South Province (Area One) + 010 => Standard, // Pokémon League + 012 => Standard, // South Province (Area Two) + 014 => Standard, // South Province (Area Four) + 016 => Standard, // South Province (Area Six) + 018 => Standard, // South Province (Area Five) + 020 => Standard, // South Province (Area Three) + 022 => Standard, // West Province (Area One) + 024 => Sand, // Asado Desert + 026 => Standard, // West Province (Area Two) + 028 => Standard, // West Province (Area Three) + 030 => Standard, // Tagtree Thicket + 032 => Standard, // East Province (Area Three) + 034 => Standard, // East Province (Area One) + 036 => Standard, // East Province (Area Two) + 038 => Snow, // Glaseado Mountain (1) + 040 => Standard, // Casseroya Lake + 044 => Standard, // North Province (Area Three) + 046 => Standard, // North Province (Area One) + 048 => Standard, // North Province (Area Two) + 050 => Standard, // Great Crater of Paldea + 056 => Standard, // South Paldean Sea + 058 => Standard, // West Paldean Sea + 060 => Standard, // East Paldean Sea + 062 => Standard, // North Paldean Sea + 064 => Inside, // Inlet Grotto + 067 => Inside, // Alfornada Cavern + 069 => Standard | Inside | Snow | Snow,// Dalizapa Passage (Near Medali, Tunnels, Near Pokémon Center, Near Zapico) + 070 => Standard, // Poco Path + 080 => Standard, // Cabo Poco + 109 => Standard, // Socarrat Trail + 124 => Inside, // Area Zero (5) - { 132, Standard }, // Kitakami Road - { 134, Standard }, // Mossui Town - { 136, Standard }, // Apple Hills - { 138, Standard }, // Loyalty Plaza - { 140, Standard }, // Reveler’s Road - { 142, Standard }, // Kitakami Hall - { 144, Standard }, // Oni Mountain - { 146, Standard }, // Dreaded Den - { 148, Standard }, // Oni’s Maw - { 150, Standard }, // Oni Mountain - { 152, Standard }, // Crystal Pool - { 154, Standard }, // Crystal Pool - { 156, Standard }, // Wistful Fields - { 158, Standard }, // Mossfell Confluence - { 160, Standard }, // Fellhorn Gorge - { 162, Standard }, // Paradise Barrens - { 164, Standard }, // Kitakami Wilds - { 166, Standard }, // Timeless Woods - { 168, Standard }, // Infernal Pass - { 170, Standard }, // Chilling Waterhead + 132 => Standard, // Kitakami Road + 134 => Standard, // Mossui Town + 136 => Standard, // Apple Hills + 138 => Standard, // Loyalty Plaza + 140 => Standard, // Reveler’s Road + 142 => Standard, // Kitakami Hall + 144 => Standard, // Oni Mountain + 146 => Standard, // Dreaded Den + 148 => Standard, // Oni’s Maw + 150 => Standard, // Oni Mountain + 152 => Standard, // Crystal Pool + 154 => Standard, // Crystal Pool + 156 => Standard, // Wistful Fields + 158 => Standard, // Mossfell Confluence + 160 => Standard, // Fellhorn Gorge + 162 => Standard, // Paradise Barrens + 164 => Standard, // Kitakami Wilds + 166 => Standard, // Timeless Woods + 168 => Standard, // Infernal Pass + 170 => Standard, // Chilling Waterhead + + _ => None, }; #region Generating diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9/IGemType.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9/IGemType.cs index 338952357..5c3e3cdb0 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen9/IGemType.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9/IGemType.cs @@ -11,12 +11,13 @@ public interface IGemType /// /// Possible values the encounter may have. /// -public enum GemType : sbyte +public enum GemType : byte { /// Default value, first type when encountered. Default = 0, /// Random type [0,17] Random = 1, + Normal = 2, Fighting = 3, Flying = 4, diff --git a/PKHeX.Core/Legality/Encounters/Templates/Interfaces/IEncounterInfo.cs b/PKHeX.Core/Legality/Encounters/Templates/Interfaces/IEncounterInfo.cs index 0d552d4c5..083478489 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Interfaces/IEncounterInfo.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Interfaces/IEncounterInfo.cs @@ -1,9 +1,7 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Exposes simple encounter info and can be converted to a . /// /// Combined interface used to require multiple interfaces being present for a calling method. -public interface IEncounterInfo : IEncounterTemplate, IEncounterConvertible -{ -} +public interface IEncounterInfo : IEncounterTemplate, IEncounterConvertible; diff --git a/PKHeX.Core/Legality/Encounters/Templates/Interfaces/Properties/IEncounterFormRandom.cs b/PKHeX.Core/Legality/Encounters/Templates/Interfaces/Properties/IEncounterFormRandom.cs index cdfce32d9..36304ec6f 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Interfaces/Properties/IEncounterFormRandom.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Interfaces/Properties/IEncounterFormRandom.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Interface for an that can be one of many forms. +/// Interface for objects that can be one of many forms. /// public interface IEncounterFormRandom { diff --git a/PKHeX.Core/Legality/Encounters/Templates/Shared/Moveset.cs b/PKHeX.Core/Legality/Encounters/Templates/Shared/Moveset.cs index 3a7ec84af..fb348dede 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Shared/Moveset.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Shared/Moveset.cs @@ -15,7 +15,7 @@ namespace PKHeX.Core; public bool Contains(ushort move) => move == Move1 || move == Move2 || move == Move3 || move == Move4; public bool AnyAbove(int max) => Move1 > max || Move2 > max || Move3 > max || Move4 > max; - public ushort[] ToArray() => new[] { Move1, Move2, Move3, Move4 }; + public ushort[] ToArray() => [Move1, Move2, Move3, Move4]; public void CopyTo(Span moves) { diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation3.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation3.cs index 56e8183b8..aa4f2eea0 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation3.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation3.cs @@ -32,15 +32,15 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat } // 064 is an unused location for Meteor Falls - // 084 is Inside of a truck, no possible pokemon can be hatched there + // 084 is Inside a truck, no possible Pokémon can be obtained at the start of the game // 071 is Mirage island, cannot be obtained as the player is technically still on Route 130's map. // 075 is an unused location for Fiery Path // 077 is an unused location for Jagged Pass // 155 - 158 Sevii Isle 6-9 Unused // 171 - 173 Sevii Isle 22-24 Unused - private static ReadOnlySpan LocationPermitted3 => new byte[] - { + private static ReadOnlySpan LocationPermitted3 => + [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -63,5 +63,5 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat 4, 4, 4, 4, 4, 4, 6, 2, 2, 2, // 196 = fr/lg & e 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation4.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation4.cs index e011e537c..3b6ee42e5 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation4.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation4.cs @@ -31,8 +31,8 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat return (flags & mask) != 0; } - private static ReadOnlySpan LocationPermitted4 => new byte[] - { + private static ReadOnlySpan LocationPermitted4 => + [ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -57,5 +57,5 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation5.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation5.cs index 385e1269b..fc30ff77d 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation5.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation5.cs @@ -33,11 +33,11 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat return (flags & mask) != 0; } - // Two game-specific locations we need to double check for. + // Two game-specific locations we need to double-check for. // White / White2 cannot access Black Gate (112) // Black / Black2 cannot access White Gate (113) - private static ReadOnlySpan LocationPermitted5 => new byte[] - { + private static ReadOnlySpan LocationPermitted5 => + [ 00, 00, 00, 00, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 03, 15, 15, 15, 15, 15, 15, @@ -54,5 +54,5 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat 12, 12, 12, 12, 12, 12, 12, 12, 00, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation7.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation7.cs index cfeea48b5..47d334ca6 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation7.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation7.cs @@ -29,8 +29,8 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat return (flags & mask) != 0; } - private static ReadOnlySpan LocationPermitted7 => new byte[] - { + private static ReadOnlySpan LocationPermitted7 => + [ 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, // 000 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, @@ -55,5 +55,5 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8.cs index 980505372..c586238f1 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8.cs @@ -17,8 +17,8 @@ public static bool IsValidMet8SWSH(int location) } // Odd indexes ignored. - private static ReadOnlySpan LocationPermitted8 => new byte[] - { + private static ReadOnlySpan LocationPermitted8 => + [ 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, @@ -32,5 +32,5 @@ public static bool IsValidMet8SWSH(int location) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8b.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8b.cs index 00d163059..5325835dd 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8b.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation8b.cs @@ -64,8 +64,8 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat // 639, 640, 641, 642, 643, 644, // Grand Underground (Secret Base) // 645, 646, 647, // Grand Underground (Secret Base) - private static ReadOnlySpan LocationPermitted8b => new byte[] - { + private static ReadOnlySpan LocationPermitted8b => + [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -83,5 +83,5 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 0, 0, 0, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation9.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation9.cs index 58d828d92..7d211a609 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation9.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EggHatchLocation9.cs @@ -19,8 +19,8 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat // 130 Naranja Academy does not exist in Violet // 131 Uva Academy does not exist in Scarlet - private static ReadOnlySpan LocationPermitted9 => new byte[] - { + private static ReadOnlySpan LocationPermitted9 => + [ 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, @@ -39,5 +39,5 @@ private static bool HasLocationFlag(ReadOnlySpan arr, byte mask, int locat 0, 0, 3, 0, 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, - }; + ]; } diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs index 1b4791a63..1dae5905f 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EncounterVerifier.cs @@ -319,8 +319,8 @@ private static CheckResult VerifyEncounterTrade(ISpeciesForm pk, EncounterTrade1 var species = pk.Species; if (trade.EvolveOnTrade && trade.Species == species) { - // Pokemon that evolve on trade can not be in the phase evolution after the trade - // If the trade holds an everstone EvolveOnTrade will be false for the encounter + // Pokémon that evolve on trade can not be in the phase evolution after the trade + // If the trade holds an Everstone, EvolveOnTrade will be false for the encounter var names = ParseSettings.SpeciesStrings; var evolved = names[species + 1]; var unevolved = names[species]; diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs index a93a89045..3c6dcddcd 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/EvolutionVerifier.cs @@ -11,7 +11,7 @@ public static class EvolutionVerifier private static readonly CheckResult VALID = new(CheckIdentifier.Evolution); /// - /// Verifies Evolution scenarios of an for an input and relevant . + /// Verifies Evolution scenarios of templates for an input and relevant . /// /// Source data to verify /// Source supporting information to verify with diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs index 4bb97aa93..bc7bd97a9 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionChain.cs @@ -88,7 +88,7 @@ public static EvoCriteria[] GetOriginChain(PKM pk, EvolutionOrigin enc, ushort e Span result = stackalloc EvoCriteria[EvolutionTree.MaxEvolutions]; int count = GetOriginChain(result, pk, enc, encSpecies, discard); if (count == 0) - return Array.Empty(); + return []; var chain = result[..count]; return chain.ToArray(); diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroupUtil.cs b/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroupUtil.cs index 529515e49..ba45779c1 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroupUtil.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionGroupUtil.cs @@ -3,7 +3,7 @@ namespace PKHeX.Core; /// -/// Utility logic for getting an based on the input. +/// Utility logic for getting the based on the input. /// public static class EvolutionGroupUtil { diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionUtil.cs b/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionUtil.cs index 6c0651dcf..842c772b8 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionUtil.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionGroup/EvolutionUtil.cs @@ -42,7 +42,7 @@ internal static class EvolutionUtil private static EvoCriteria[] GetLocalEvolutionArray(Span result) { if (result.Length == 0) - return Array.Empty(); + return []; var array = result.ToArray(); var length = CleanEvolve(array); diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionHistory.cs b/PKHeX.Core/Legality/Evolutions/EvolutionHistory.cs index 718d8368a..cb51e5ca7 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionHistory.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionHistory.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; /// public sealed class EvolutionHistory { - private static readonly EvoCriteria[] NONE = Array.Empty(); + private static readonly EvoCriteria[] NONE = []; public EvoCriteria[] Gen1 = NONE; public EvoCriteria[] Gen2 = NONE; diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionSet.cs b/PKHeX.Core/Legality/Evolutions/EvolutionSet.cs index f062571de..17ef0e43c 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionSet.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionSet.cs @@ -21,7 +21,7 @@ public static EvolutionMethod[][] GetArray(BinLinkerAccessor data, byte levelUp private static EvolutionMethod[] GetEntry(ReadOnlySpan data, byte levelUp) { if (data.Length == 0) - return Array.Empty(); + return []; var result = new EvolutionMethod[data.Length / SIZE]; for (int i = 0, offset = 0; i < result.Length; i++, offset += SIZE) diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs index 14aee00ee..3fc26196b 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; namespace PKHeX.Core; @@ -26,7 +27,7 @@ public sealed class EvolutionTree : EvolutionNetwork public static readonly EvolutionTree Evolves9 = GetViaPersonal(PersonalTable.SV, EvolutionSet.GetArray(GetReader("sv", "sv"u8))); private static ReadOnlySpan GetResource([ConstantExpected] string resource) => Util.GetBinaryResource($"evos_{resource}.pkl"); - private static BinLinkerAccessor GetReader([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan identifier) => BinLinkerAccessor.Get(GetResource(resource), identifier); + private static BinLinkerAccessor GetReader([ConstantExpected] string resource, [Length(2, 2)] ReadOnlySpan identifier) => BinLinkerAccessor.Get(GetResource(resource), identifier); private EvolutionTree(IEvolutionForward forward, IEvolutionReverse reverse) : base(forward, reverse) { } private static EvolutionTree GetViaSpecies(IPersonalTable t, EvolutionMethod[][] entries) diff --git a/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardPersonal.cs b/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardPersonal.cs index 7a029895e..f4885211f 100644 --- a/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardPersonal.cs +++ b/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardPersonal.cs @@ -6,17 +6,8 @@ namespace PKHeX.Core; /// /// Provides forward evolution pathways with reliance on personal table data for form branched evolutions. /// -public sealed class EvolutionForwardPersonal : IEvolutionForward +public sealed class EvolutionForwardPersonal(EvolutionMethod[][] Entries, IPersonalTable Personal) : IEvolutionForward { - private readonly IPersonalTable Personal; - private readonly EvolutionMethod[][] Entries; - - public EvolutionForwardPersonal(EvolutionMethod[][] entries, IPersonalTable personal) - { - Entries = entries; - Personal = personal; - } - public ReadOnlyMemory GetForward(ushort species, byte form) { int index = Personal.GetFormIndex(species, form); diff --git a/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardSpecies.cs b/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardSpecies.cs index fa76c6027..dfb8d3100 100644 --- a/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardSpecies.cs +++ b/PKHeX.Core/Legality/Evolutions/Forward/EvolutionForwardSpecies.cs @@ -6,12 +6,8 @@ namespace PKHeX.Core; /// /// Provides forward evolution pathways based only on species. /// -public sealed class EvolutionForwardSpecies : IEvolutionForward +public sealed class EvolutionForwardSpecies(EvolutionMethod[][] Entries) : IEvolutionForward { - private readonly EvolutionMethod[][] Entries; - - public EvolutionForwardSpecies(EvolutionMethod[][] entries) => Entries = entries; - public IEnumerable<(ushort Species, byte Form)> GetEvolutions(ushort species, byte form) { var methods = GetForward(species, form); @@ -20,10 +16,9 @@ public IEnumerable<(ushort Species, byte Form)> GetEvolutions(ushort species, by public ReadOnlyMemory GetForward(ushort species, byte form) { - var arr = Entries; - if (species >= arr.Length) - return Array.Empty(); - return arr[species]; + if (species >= Entries.Length) + return ReadOnlyMemory.Empty; + return Entries[species]; } private IEnumerable<(ushort Species, byte Form)> GetEvolutions(ReadOnlyMemory evos, byte form) diff --git a/PKHeX.Core/Legality/Evolutions/Methods/EvolutionMethod.cs b/PKHeX.Core/Legality/Evolutions/Methods/EvolutionMethod.cs index 0a27a7b35..bd9a83bd5 100644 --- a/PKHeX.Core/Legality/Evolutions/Methods/EvolutionMethod.cs +++ b/PKHeX.Core/Legality/Evolutions/Methods/EvolutionMethod.cs @@ -39,7 +39,7 @@ public byte GetDestinationForm(byte form) /// Current level /// Minimum level to sanity check with /// Option to skip some comparisons to return a 'possible' evolution. - /// True if a evolution criteria is valid. + /// True if the evolution criteria is valid. public EvolutionCheckResult Check(PKM pk, byte lvl, byte levelMin, bool skipChecks) { if (!Method.IsLevelUpRequired()) diff --git a/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseLookup.cs b/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseLookup.cs index c622ad737..5e93073a0 100644 --- a/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseLookup.cs +++ b/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseLookup.cs @@ -5,18 +5,11 @@ namespace PKHeX.Core; /// /// Object storing a reversal path for evolution nodes. /// -public sealed class EvolutionReverseLookup : IEvolutionLookup +public sealed class EvolutionReverseLookup(ushort MaxSpecies) : IEvolutionLookup { - private readonly EvolutionNode[] Nodes; - private readonly Dictionary KeyLookup; - private readonly ushort MaxSpecies; - - public EvolutionReverseLookup(ushort maxSpecies) - { - Nodes = new EvolutionNode[maxSpecies * 2]; - KeyLookup = new Dictionary(maxSpecies); - MaxSpecies = maxSpecies; - } + private const int ExtraBufferFraction = 3; // magic number that gives a minimal-ish allocation + private readonly EvolutionNode[] Nodes = new EvolutionNode[MaxSpecies + (MaxSpecies >> ExtraBufferFraction)]; + private readonly Dictionary KeyLookup = new(MaxSpecies >> ExtraBufferFraction); private void Register(in EvolutionLink link, int index) { @@ -54,7 +47,7 @@ private int GetIndex(ushort species, byte form) if (form == 0) return species; int key = GetKey(species, form); - return KeyLookup.TryGetValue(key, out var index) ? index : 0; + return KeyLookup.GetValueOrDefault(key, 0); } private static int GetKey(ushort species, byte form) => species | form << 11; diff --git a/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReversePersonal.cs b/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReversePersonal.cs index c4a796df1..e9c6b1e11 100644 --- a/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReversePersonal.cs +++ b/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReversePersonal.cs @@ -2,10 +2,9 @@ namespace PKHeX.Core; -public sealed class EvolutionReversePersonal : IEvolutionReverse +public sealed class EvolutionReversePersonal(EvolutionMethod[][] Entries, IPersonalTable Personal) : IEvolutionReverse { - public IEvolutionLookup Lineage { get; } - public EvolutionReversePersonal(EvolutionMethod[][] entries, IPersonalTable t) => Lineage = GetLineage(t, entries); + public IEvolutionLookup Lineage { get; } = GetLineage(Personal, Entries); public ref readonly EvolutionNode GetReverse(ushort species, byte form) => ref Lineage[species, form]; private static EvolutionReverseLookup GetLineage(IPersonalTable t, EvolutionMethod[][] entries) diff --git a/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseSpecies.cs b/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseSpecies.cs index d63916814..3f9e253c7 100644 --- a/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseSpecies.cs +++ b/PKHeX.Core/Legality/Evolutions/Reversal/EvolutionReverseSpecies.cs @@ -2,10 +2,9 @@ namespace PKHeX.Core; -public sealed class EvolutionReverseSpecies : IEvolutionReverse +public sealed class EvolutionReverseSpecies(EvolutionMethod[][] Entries, IPersonalTable Personal) : IEvolutionReverse { - public EvolutionReverseLookup Lineage { get; } - public EvolutionReverseSpecies(EvolutionMethod[][] entries, IPersonalTable t) => Lineage = GetLineage(t, entries); + public EvolutionReverseLookup Lineage { get; } = GetLineage(Personal, Entries); public ref readonly EvolutionNode GetReverse(ushort species, byte form) => ref Lineage[species, form]; private static EvolutionReverseLookup GetLineage(IPersonalTable t, EvolutionMethod[][] entries) diff --git a/PKHeX.Core/Legality/Formatting/BaseLegalityFormatter.cs b/PKHeX.Core/Legality/Formatting/BaseLegalityFormatter.cs index ef54ac9b5..32b5d0c21 100644 --- a/PKHeX.Core/Legality/Formatting/BaseLegalityFormatter.cs +++ b/PKHeX.Core/Legality/Formatting/BaseLegalityFormatter.cs @@ -19,7 +19,7 @@ public string GetReport(LegalityAnalysis l) if (!l.Parsed) return L_AnalysisUnavailable; - List lines = new(); + List lines = []; GetLegalityReportLines(l, lines); return string.Join(Environment.NewLine, lines); } @@ -48,7 +48,7 @@ private static void GetLegalityReportLines(LegalityAnalysis l, List line LegalityFormatting.AddSecondaryChecksInvalid(l.Results, lines); } - private static IReadOnlyList GetVerboseLegalityReportLines(LegalityAnalysis l) + private static List GetVerboseLegalityReportLines(LegalityAnalysis l) { var lines = new List(); if (l.Valid) diff --git a/PKHeX.Core/Legality/Formatting/LegalityFormatting.cs b/PKHeX.Core/Legality/Formatting/LegalityFormatting.cs index bf47599f3..61e457499 100644 --- a/PKHeX.Core/Legality/Formatting/LegalityFormatting.cs +++ b/PKHeX.Core/Legality/Formatting/LegalityFormatting.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core; /// -/// Formatting logic for to create a human readable . +/// Formatting logic for to create a human-readable . /// public static class LegalityFormatting { diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup5.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup5.cs index 4077bec61..5bc3d9679 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup5.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup5.cs @@ -121,7 +121,7 @@ private static void GetAllMoves(Span result, PKM pk, EvoCriteria evo, Move if (!inst.TryGetPersonal(evo.Species, evo.Form, out var pi)) return; - // Above species have same level up moves on BW & B2/W2; just check B2/W2. + // Above species have same level up moves on B/W & B2/W2; just check B2/W2. var fc = pi.FormCount; for (int i = 0; i < fc; i++) LearnSource5B2W2.Instance.GetAllMoves(result, pk, evo with { Form = (byte)i }, types); diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup8.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup8.cs index 9fa74c97a..2f14c68cb 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup8.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup8.cs @@ -78,9 +78,9 @@ private static void CheckSharedMoves(Span result, ReadOnlySpan result, ReadOnlySpan current, EncounterEgg egg) { - ILearnSource game = LearnSource8SWSH.Instance; + var game = LearnSource8SWSH.Instance; var eggMoves = game.GetEggMoves(egg.Species, egg.Form); - var levelMoves = game.GetInheritMoves(egg.Species, egg.Form); + var levelMoves = ((ILearnSource)game).GetInheritMoves(egg.Species, egg.Form); for (var i = result.Length - 1; i >= 0; i--) { diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup9.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup9.cs index bb507aafa..965055982 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroup9.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroup9.cs @@ -59,9 +59,9 @@ private static void CheckSharedMoves(Span result, ReadOnlySpan result, ReadOnlySpan current, EncounterEgg egg) { - ILearnSource game = LearnSource9SV.Instance; + var game = LearnSource9SV.Instance; var eggMoves = game.GetEggMoves(egg.Species, egg.Form); - var levelMoves = game.GetInheritMoves(egg.Species, egg.Form); + var levelMoves = ((ILearnSource)game).GetInheritMoves(egg.Species, egg.Form); for (var i = result.Length - 1; i >= 0; i--) { diff --git a/PKHeX.Core/Legality/LearnSource/Group/LearnGroupHOME.cs b/PKHeX.Core/Legality/LearnSource/Group/LearnGroupHOME.cs index ecb1fd9be..8ca04e4dc 100644 --- a/PKHeX.Core/Legality/LearnSource/Group/LearnGroupHOME.cs +++ b/PKHeX.Core/Legality/LearnSource/Group/LearnGroupHOME.cs @@ -99,8 +99,8 @@ public sealed class LearnGroupHOME : ILearnGroup /// True if all results are valid. private static bool CleanPurge(Span result, ReadOnlySpan current, PKM pk, MoveSourceType types, IHomeSource local, ReadOnlySpan evos) { - // The logic used to update the results did not check if the move was actually able to be learned in the local game. - // Double check the results and remove any that are not valid for the local game. + // The logic used to update the results did not check if the move was could be learned in the local game. + // Double-check the results and remove any that are not valid for the local game. // SW/SH will continue to iterate downwards to previous groups after HOME is checked, so we can exactly check via Environment. for (int i = 0; i < result.Length; i++) { @@ -124,7 +124,7 @@ private static bool CleanPurge(Span result, ReadOnlySpan cur valid = true; } - // HOME has special handling to allow Volt Tackle outside of learnset possibilities. + // HOME has special handling to allow Volt Tackle outside learnset possibilities. // Most games do not have a Learn Source for Volt Tackle besides it being specially inserted for Egg Encounters. if (!valid && move is not (ushort)Move.VoltTackle) r = default; @@ -276,7 +276,7 @@ private static void LoopMerge(Span result, PKM pk, ReadOnlySpan history.Gen8a, BDSP => history.Gen8b, SV => history.Gen9, - _ => ReadOnlySpan.Empty, + _ => [], }; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2C.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2C.cs index 7ae2be151..072ae1a3d 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2C.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2C.cs @@ -42,7 +42,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2GS.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2GS.cs index 64219f177..12700f73c 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2GS.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource2GS.cs @@ -42,7 +42,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs index b26d23cea..cb5d46d30 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3E.cs @@ -41,7 +41,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } @@ -140,10 +140,10 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } - private static ReadOnlySpan Tutor_E => new ushort[] - { + private static ReadOnlySpan Tutor_E => + [ 005, 014, 025, 034, 038, 068, 069, 102, 118, 135, 138, 086, 153, 157, 164, 223, 205, 244, 173, 196, 203, 189, 008, 207, 214, 129, 111, 009, 007, 210, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3FR.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3FR.cs index 9f482b45a..a77acd911 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3FR.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3FR.cs @@ -41,7 +41,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3LG.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3LG.cs index 831592729..bb2761310 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3LG.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3LG.cs @@ -41,7 +41,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3RS.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3RS.cs index b47e37f80..b47f46083 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3RS.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource3RS.cs @@ -40,7 +40,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } @@ -150,34 +150,34 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } - private static ReadOnlySpan Tutor_3Mew => new ushort[] - { + private static ReadOnlySpan Tutor_3Mew => + [ (int)Move.FeintAttack, (int)Move.FakeOut, (int)Move.Hypnosis, (int)Move.NightShade, (int)Move.RolePlay, (int)Move.ZapCannon, - }; + ]; - private static ReadOnlySpan SpecialTutors_XD_SelfDestruct => new ushort[] - { + private static ReadOnlySpan SpecialTutors_XD_SelfDestruct => + [ 074, 075, 076, 088, 089, 090, 091, 092, 093, 094, 095, 100, 101, 102, 103, 109, 110, 143, 150, 151, 185, 204, 205, 208, 211, 218, 219, 222, 273, 274, 275, 299, 316, 317, 320, 321, 323, 324, 337, 338, 343, 344, 362, 375, 376, 377, 378, 379, - }; + ]; - private static ReadOnlySpan SpecialTutors_XD_SkyAttack => new ushort[] - { + private static ReadOnlySpan SpecialTutors_XD_SkyAttack => + [ 016, 017, 018, 021, 022, 084, 085, 142, 144, 145, 146, 151, 163, 164, 176, 177, 178, 198, 225, 227, 250, 276, 277, 278, 279, 333, 334, - }; + ]; - private static ReadOnlySpan SpecialTutors_XD_Nightmare => new ushort[] - { + private static ReadOnlySpan SpecialTutors_XD_Nightmare => + [ 012, 035, 036, 039, 040, 052, 053, 063, 064, 065, 079, 080, 092, 093, 094, 096, 097, 102, 103, 108, 121, 122, 124, 131, 137, 150, 151, 163, 164, 173, 174, 177, 178, @@ -185,5 +185,5 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy 233, 234, 238, 248, 249, 250, 251, 280, 281, 282, 284, 292, 302, 315, 316, 317, 327, 353, 354, 355, 356, 358, 359, 385, 386, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4DP.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4DP.cs index 2878153be..f7cc79c43 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4DP.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4DP.cs @@ -40,7 +40,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4HGSS.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4HGSS.cs index 0ed96be5e..c897b5e27 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4HGSS.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4HGSS.cs @@ -41,7 +41,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4Pt.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4Pt.cs index 46ee61587..4f050632d 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4Pt.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource4Pt.cs @@ -39,7 +39,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5B2W2.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5B2W2.cs index 75cb3f1eb..0e9688511 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5B2W2.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5B2W2.cs @@ -38,7 +38,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5BW.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5BW.cs index aaf012c91..da945a1b2 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5BW.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource5BW.cs @@ -38,7 +38,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6AO.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6AO.cs index c4b4faa11..d9cb4b950 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6AO.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6AO.cs @@ -39,7 +39,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } @@ -122,8 +122,8 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } - internal static ReadOnlySpan TMHM_AO => new ushort[] - { + internal static ReadOnlySpan TMHM_AO => + [ 468, 337, 473, 347, 046, 092, 258, 339, 474, 237, 241, 269, 058, 059, 063, 113, 182, 240, 355, 219, 218, 076, 479, 085, 087, 089, 216, 091, 094, 247, @@ -136,5 +136,5 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy 430, 433, 528, 290, 555, 267, 399, 612, 605, 590, 15, 19, 57, 70, 127, 249, 291, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6XY.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6XY.cs index a8158b4d4..5c0e318b6 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6XY.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource6XY.cs @@ -39,7 +39,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves[species].Moves; } @@ -112,8 +112,8 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } - private static ReadOnlySpan TMHM_XY => new ushort[] - { + private static ReadOnlySpan TMHM_XY => + [ 468, 337, 473, 347, 046, 092, 258, 339, 474, 237, 241, 269, 058, 059, 063, 113, 182, 240, 355, 219, 218, 076, 479, 085, 087, 089, 216, 091, 094, 247, @@ -126,5 +126,5 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy 430, 433, 528, 249, 555, 267, 399, 612, 605, 590, 15, 19, 57, 70, 127, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7GG.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7GG.cs index 28ed76b4d..f948571ea 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7GG.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7GG.cs @@ -87,8 +87,8 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } - private static ReadOnlySpan TMHM_GG => new ushort[] - { + private static ReadOnlySpan TMHM_GG => + [ 029, 269, 270, 100, 156, 113, 182, 164, 115, 091, 261, 263, 280, 019, 069, 086, 525, 369, 231, 399, 492, 157, 009, 404, 127, 398, 092, 161, 503, 339, @@ -98,18 +98,18 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy // rest are same as SM, unused // No HMs - }; + ]; - private static ReadOnlySpan Tutor_StarterPikachu => new ushort[] - { + private static ReadOnlySpan Tutor_StarterPikachu => + [ (int)Move.ZippyZap, (int)Move.SplishySplash, (int)Move.FloatyFall, //(int)Move.PikaPapow, // Joycon Shake - }; + ]; - private static ReadOnlySpan Tutor_StarterEevee => new ushort[] - { + private static ReadOnlySpan Tutor_StarterEevee => + [ (int)Move.BouncyBubble, (int)Move.BuzzyBuzz, (int)Move.SizzlySlide, @@ -119,5 +119,5 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy (int)Move.FreezyFrost, (int)Move.SparklySwirl, //(int)Move.VeeveeVolley, // Joycon Shake - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7SM.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7SM.cs index 4f41f0dd0..62db793a1 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7SM.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7SM.cs @@ -41,7 +41,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves.GetFormEggMoves(species, form); } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7USUM.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7USUM.cs index 98346bad2..1b90df0e5 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7USUM.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource7USUM.cs @@ -41,7 +41,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves.GetFormEggMoves(species, form); } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8BDSP.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8BDSP.cs index e1470f17c..77ec71ed6 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8BDSP.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8BDSP.cs @@ -43,7 +43,7 @@ public ReadOnlySpan GetEggMoves(ushort species, byte form) // Array is optimized to not have entries for species above 460 (not able to breed / no egg moves). var arr = EggMoves; if (species >= arr.Length) - return ReadOnlySpan.Empty; + return []; return arr[species].Moves; } @@ -125,8 +125,8 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy } } - public static ReadOnlySpan TMHM_BDSP => new ushort[] - { + public static ReadOnlySpan TMHM_BDSP => + [ 264, 337, 352, 347, 046, 092, 258, 339, 331, 526, 241, 269, 058, 059, 063, 113, 182, 240, 202, 219, 605, 076, 231, 085, 087, 089, 490, 091, 094, 247, @@ -138,15 +138,15 @@ public void GetAllMoves(Span result, PKM pk, EvoCriteria evo, MoveSourceTy 404, 214, 523, 398, 138, 447, 207, 365, 369, 164, 430, 433, 015, 019, 057, 070, 432, 249, 127, 431, - }; + ]; - internal static ReadOnlySpan TypeTutor8b => new ushort[] - { + internal static ReadOnlySpan TypeTutor8b => + [ (int)Move.FrenzyPlant, (int)Move.BlastBurn, (int)Move.HydroCannon, (int)Move.DracoMeteor, - }; + ]; public LearnEnvironment Environment => Game; public MoveLearnInfo GetCanLearnHOME(PKM pk, EvoCriteria evo, ushort move, MoveSourceType types = MoveSourceType.All) diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8SWSH.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8SWSH.cs index 8b33a9103..1790416a5 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8SWSH.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource8SWSH.cs @@ -39,7 +39,7 @@ public bool GetIsEggMove(ushort species, byte form, ushort move) public ReadOnlySpan GetEggMoves(ushort species, byte form) { if (species > MaxSpecies) - return ReadOnlySpan.Empty; + return []; return EggMoves.GetFormEggMoves(species, form); } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource9SV.cs b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource9SV.cs index 8adf765cf..46745ea37 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/LearnSource9SV.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/LearnSource9SV.cs @@ -42,7 +42,7 @@ public ReadOnlySpan GetEggMoves(ushort species, byte form) { var index = Personal.GetFormIndex(species, form); if (index >= EggMoves.Length) - return ReadOnlySpan.Empty; + return []; return EggMoves[index]; } @@ -59,7 +59,7 @@ public ReadOnlySpan GetReminderMoves(ushort species, byte form) { var index = Personal.GetFormIndex(species, form); if (index >= Reminder.Length) - return ReadOnlySpan.Empty; + return []; return Reminder[index]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/ILearnSource.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/ILearnSource.cs index 977c28e62..75b581b77 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/ILearnSource.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/ILearnSource.cs @@ -31,7 +31,7 @@ public void SetEncounterMoves(ushort species, byte form, int level, Span learn.SetEncounterMoves(level, init, start); } - public ReadOnlySpan GetEggMoves(ushort species, byte form) => ReadOnlySpan.Empty; + public ReadOnlySpan GetEggMoves(ushort species, byte form) => []; public ReadOnlySpan GetInheritMoves(ushort species, byte form) { @@ -55,7 +55,7 @@ public interface ILearnSource : ILearnSource where T : PersonalInfo /// Move ID to check /// Types of move sources to iterate /// Option to check if it can be currently known, or previously known. - /// Details about how the move can be learned. Will be equivalent to default if cannot learn. + /// Details about how the move can be learned. Will be equivalent to default if it cannot learn. public MoveLearnInfo GetCanLearn(PKM pk, T pi, EvoCriteria evo, ushort move, MoveSourceType types = MoveSourceType.All, LearnOption option = LearnOption.Current); /// diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource1.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource1.cs index 34800a98d..f90419003 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource1.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource1.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class LearnSource1 { - internal static ReadOnlySpan TMHM_RBY => new byte[] - { + internal static ReadOnlySpan TMHM_RBY => + [ 005, 013, 014, 018, 025, 092, 032, 034, 036, 038, 061, 055, 058, 059, 063, 006, 066, 068, 069, 099, 072, 076, 082, 085, 087, 089, 090, 091, 094, 100, @@ -13,5 +13,5 @@ internal static class LearnSource1 135, 138, 143, 156, 086, 149, 153, 157, 161, 164, 015, 019, 057, 070, 148, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource2.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource2.cs index 63a38e9a9..1417ff3bb 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource2.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource2.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class LearnSource2 { - internal static ReadOnlySpan TMHM_GSC => new byte[] - { + internal static ReadOnlySpan TMHM_GSC => + [ 223, 029, 174, 205, 046, 092, 192, 249, 244, 237, 241, 230, 173, 059, 063, 196, 182, 240, 202, 203, 218, 076, 231, 225, 087, 089, 216, 091, 094, 247, @@ -13,7 +13,7 @@ internal static class LearnSource2 009, 138, 197, 156, 213, 168, 211, 007, 210, 171, 015, 019, 057, 070, 148, 250, 127, - }; + ]; - internal static ReadOnlySpan Tutors_GSC => new byte[] { (int)Move.Flamethrower, (int)Move.Thunderbolt, (int)Move.IceBeam }; + internal static ReadOnlySpan Tutors_GSC => [ (int)Move.Flamethrower, (int)Move.Thunderbolt, (int)Move.IceBeam ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource3.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource3.cs index 58c15eb83..dd562bb61 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource3.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource3.cs @@ -6,14 +6,14 @@ public abstract class LearnSource3 { private protected readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_rs.pkl"), "rs"u8)); // same for all Gen3 games - internal static ReadOnlySpan TM_3 => new ushort[] - { + internal static ReadOnlySpan TM_3 => + [ 264, 337, 352, 347, 046, 092, 258, 339, 331, 237, 241, 269, 058, 059, 063, 113, 182, 240, 202, 219, 218, 076, 231, 085, 087, 089, 216, 091, 094, 247, 280, 104, 115, 351, 053, 188, 201, 126, 317, 332, 259, 263, 290, 156, 213, 168, 211, 285, 289, 315, - }; + ]; - internal static ReadOnlySpan HM_3 => new ushort[] { 15, 19, 57, 70, 148, 249, 127, 291 }; + internal static ReadOnlySpan HM_3 => [ 15, 19, 57, 70, 148, 249, 127, 291 ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource4.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource4.cs index be8d9e636..c0b0721c2 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource4.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource4.cs @@ -10,27 +10,27 @@ public abstract class LearnSource4 /// Gets the preferred list of HM moves to disallow on transfer from to . /// /// - /// If the moveset has Defog, then we prefer HG/SS (remove Whirlpool) over D/P/Pt. + /// If Defog is in the moveset, then we prefer HG/SS (remove Whirlpool) over D/P/Pt. /// Defog is a competitively viable move, while Whirlpool is not really useful. /// /// True if the current moveset has . public static ReadOnlySpan GetPreferredTransferHMs(bool hasDefog) => hasDefog ? HM_HGSS : HM_DPPt; - internal static ReadOnlySpan SpecialTutors_Compatibility_4_BlastBurn => new ushort[] { 006, 157, 257, 392 }; - internal static ReadOnlySpan SpecialTutors_Compatibility_4_HydroCannon => new ushort[] { 009, 160, 260, 395 }; - internal static ReadOnlySpan SpecialTutors_Compatibility_4_FrenzyPlant => new ushort[] { 003, 154, 254, 389 }; - internal static ReadOnlySpan SpecialTutors_Compatibility_4_DracoMeteor => new ushort[] { 147, 148, 149, 230, 329, 330, 334, 371, 372, 373, 380, 381, 384, 443, 444, 445, 483, 484, 487 }; + internal static ReadOnlySpan SpecialTutors_Compatibility_4_BlastBurn => [ 006, 157, 257, 392 ]; + internal static ReadOnlySpan SpecialTutors_Compatibility_4_HydroCannon => [ 009, 160, 260, 395 ]; + internal static ReadOnlySpan SpecialTutors_Compatibility_4_FrenzyPlant => [ 003, 154, 254, 389 ]; + internal static ReadOnlySpan SpecialTutors_Compatibility_4_DracoMeteor => [ 147, 148, 149, 230, 329, 330, 334, 371, 372, 373, 380, 381, 384, 443, 444, 445, 483, 484, 487 ]; - internal static ReadOnlySpan Tutors_4 => new ushort[] - { + internal static ReadOnlySpan Tutors_4 => + [ 291, 189, 210, 196, 205, 009, 007, 276, 008, 442, 401, 466, 380, 173, 180, 314, 270, 283, 200, 246, 235, 324, 428, 410, 414, 441, 239, 402, 334, 393, 387, 340, 271, 257, 282, 389, 129, 253, 162, 220, 081, 366, 356, 388, 277, 272, 215, 067, 143, 335, 450, 029, - }; + ]; - internal static ReadOnlySpan TM_4 => new ushort[] - { + internal static ReadOnlySpan TM_4 => + [ 264, 337, 352, 347, 046, 092, 258, 339, 331, 237, 241, 269, 058, 059, 063, 113, 182, 240, 202, 219, 218, 076, 231, 085, 087, 089, 216, 091, 094, 247, @@ -41,10 +41,10 @@ public abstract class LearnSource4 444, 419, 086, 360, 014, 446, 244, 445, 399, 157, 404, 214, 363, 398, 138, 447, 207, 365, 369, 164, 430, 433, - }; + ]; - internal static ReadOnlySpan HM_DPPt => new ushort[] - { + internal static ReadOnlySpan HM_DPPt => + [ (int)Move.Cut, (int)Move.Fly, (int)Move.Surf, @@ -53,10 +53,10 @@ public abstract class LearnSource4 (int)Move.RockSmash, (int)Move.Waterfall, (int)Move.RockClimb, - }; + ]; - internal static ReadOnlySpan HM_HGSS => new ushort[] - { + internal static ReadOnlySpan HM_HGSS => + [ (int)Move.Cut, (int)Move.Fly, (int)Move.Surf, @@ -65,5 +65,5 @@ public abstract class LearnSource4 (int)Move.RockSmash, (int)Move.Waterfall, (int)Move.RockClimb, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource5.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource5.cs index 0ce7f2d69..e209b7844 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource5.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource5.cs @@ -6,8 +6,8 @@ public abstract class LearnSource5 { private protected readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_bw.pkl"), "bw"u8)); - internal static ReadOnlySpan TMHM_BW => new ushort[] - { + internal static ReadOnlySpan TMHM_BW => + [ 468, 337, 473, 347, 046, 092, 258, 339, 474, 237, 241, 269, 058, 059, 063, 113, 182, 240, 477, 219, 218, 076, 479, 085, 087, 089, 216, 091, 094, 247, @@ -20,10 +20,10 @@ public abstract class LearnSource5 430, 433, 528, 249, 555, 015, 019, 057, 070, 127, 291, - }; + ]; - internal static ReadOnlySpan TypeTutor567 => new ushort[] - { + internal static ReadOnlySpan TypeTutor567 => + [ (int)Move.GrassPledge, (int)Move.FirePledge, (int)Move.WaterPledge, @@ -32,5 +32,5 @@ public abstract class LearnSource5 (int)Move.HydroCannon, (int)Move.DracoMeteor, (int)Move.DragonAscent, - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource7.cs b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource7.cs index d499b5b1b..20614892f 100644 --- a/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource7.cs +++ b/PKHeX.Core/Legality/LearnSource/Sources/Shared/LearnSource7.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; internal static class LearnSource7 { - internal static ReadOnlySpan TMHM_SM => new ushort[] - { + internal static ReadOnlySpan TMHM_SM => + [ 526, 337, 473, 347, 046, 092, 258, 339, 474, 237, 241, 269, 058, 059, 063, 113, 182, 240, 355, 219, 218, 076, 479, 085, 087, 089, 216, 141, 094, 247, @@ -18,5 +18,5 @@ internal static class LearnSource7 430, 433, 528, 057, 555, 267, 399, 127, 605, 590, // No HMs - }; + ]; } diff --git a/PKHeX.Core/Legality/LearnSource/Verify/LearnPossible.cs b/PKHeX.Core/Legality/LearnSource/Verify/LearnPossible.cs index 78f651fae..19ec0bea1 100644 --- a/PKHeX.Core/Legality/LearnSource/Verify/LearnPossible.cs +++ b/PKHeX.Core/Legality/LearnSource/Verify/LearnPossible.cs @@ -63,7 +63,7 @@ private static void SetAll(ReadOnlySpan moves, Span result) private static void IterateAndFlag(Span result, PKM pk, IEncounterTemplate enc, EvolutionHistory history, MoveSourceType types) { // Similar to the iteration when validating a set of currently known moves, iterate backwards. - // Instead of checking if a single move can be learned, get an enumerable of moves and flag. + // Instead of checking if a single move can be learned, get an iterable chain of sources and flag for each. // Keep iterating backwards, as an older game may have an exclusive move. var game = LearnGroupUtil.GetCurrentGroup(pk); while (true) diff --git a/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierRelearn.cs b/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierRelearn.cs index 80605ce97..ca5459921 100644 --- a/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierRelearn.cs +++ b/PKHeX.Core/Legality/LearnSource/Verify/LearnVerifierRelearn.cs @@ -46,7 +46,7 @@ private static MoveResult ParseExpect(ushort move, ushort expect = 0) private static void VerifyRelearnDexNav(PKM pk, Span result, EncounterSlot6AO slot) { - // All other relearn moves must be empty. + // Only has one relearn move from the encounter. Every other relearn move must be empty. result[3] = ParseExpect(pk.RelearnMove4); result[2] = ParseExpect(pk.RelearnMove3); result[1] = ParseExpect(pk.RelearnMove2); @@ -57,7 +57,7 @@ private static void VerifyRelearnDexNav(PKM pk, Span result, Encount private static void VerifyRelearnUnderground(PKM pk, Span result, EncounterSlot8b slot) { - // All other relearn moves must be empty. + // Only has one relearn move from the encounter. Every other relearn move must be empty. result[3] = ParseExpect(pk.RelearnMove4); result[2] = ParseExpect(pk.RelearnMove3); result[1] = ParseExpect(pk.RelearnMove2); diff --git a/PKHeX.Core/Legality/Learnset/EggMoves.cs b/PKHeX.Core/Legality/Learnset/EggMoves.cs index 0472cbd2d..5c9ab1b97 100644 --- a/PKHeX.Core/Legality/Learnset/EggMoves.cs +++ b/PKHeX.Core/Legality/Learnset/EggMoves.cs @@ -6,11 +6,10 @@ namespace PKHeX.Core; /// /// Stores the valid Move IDs the entry can be obtained with. /// -public abstract class EggMoves +public abstract class EggMoves(ushort[] moves) { - public readonly ushort[] Moves; - protected EggMoves(ushort[] moves) => Moves = moves; - public bool GetHasEggMove(ushort move) => Array.IndexOf(Moves, move) != -1; + public ReadOnlySpan Moves => moves; + public bool GetHasEggMove(ushort move) => Moves.Contains(move); } /// @@ -28,7 +27,7 @@ public sealed class EggMoves2 : EggMoves public static EggMoves2[] GetArray(ReadOnlySpan data, ushort count) { var entries = new EggMoves2[count + 1]; - var empty = entries[0] = new EggMoves2(Array.Empty()); + var empty = entries[0] = new EggMoves2([]); int baseOffset = ReadInt16LittleEndian(data) - (count * 2); for (int i = 1; i < entries.Length; i++) @@ -63,7 +62,7 @@ public sealed class EggMoves6 : EggMoves public static EggMoves6[] GetArray(BinLinkerAccessor entries) { var result = new EggMoves6[entries.Length]; - var empty = result[0] = new EggMoves6(Array.Empty()); + var empty = result[0] = new EggMoves6([]); for (int i = 1; i < result.Length; i++) { var data = entries[i]; @@ -99,7 +98,7 @@ public sealed class EggMoves7 : EggMoves public static EggMoves7[] GetArray(BinLinkerAccessor entries) { var result = new EggMoves7[entries.Length]; - var empty = result[0] = new EggMoves7(Array.Empty()); + var empty = result[0] = new EggMoves7([]); for (int i = 1; i < result.Length; i++) { var data = entries[i]; @@ -109,7 +108,7 @@ public static EggMoves7[] GetArray(BinLinkerAccessor entries) { // Might need to keep track of the Form Index for unavailable forms pointing to valid forms. if (formIndex != 0) - result[i] = new EggMoves7(Array.Empty(), formIndex); + result[i] = new EggMoves7([], formIndex); else result[i] = empty; continue; @@ -130,7 +129,7 @@ internal static class EggMovesExtensions public static ReadOnlySpan GetFormEggMoves(this EggMoves7[] table, ushort species, byte form) { if (species >= table.Length) - return ReadOnlySpan.Empty; + return []; var entry = table[species]; if (form == 0 || species >= entry.FormTableIndex) @@ -140,10 +139,10 @@ public static ReadOnlySpan GetFormEggMoves(this EggMoves7[] table, ushor var baseIndex = entry.FormTableIndex; var index = baseIndex + form - 1; if ((uint)index >= table.Length) - return ReadOnlySpan.Empty; + return []; entry = table[index]; if (entry.FormTableIndex != baseIndex) - return ReadOnlySpan.Empty; + return []; return entry.Moves; } @@ -157,7 +156,7 @@ public static class EggMoves9 public static ushort[][] GetArray(BinLinkerAccessor entries) { var result = new ushort[entries.Length][]; - var empty = result[0] = Array.Empty(); + var empty = result[0] = []; for (int i = 1; i < result.Length; i++) { var data = entries[i]; diff --git a/PKHeX.Core/Legality/Learnset/Learnset.cs b/PKHeX.Core/Legality/Learnset/Learnset.cs index 06a049104..30a7fde85 100644 --- a/PKHeX.Core/Legality/Learnset/Learnset.cs +++ b/PKHeX.Core/Legality/Learnset/Learnset.cs @@ -5,26 +5,20 @@ namespace PKHeX.Core; /// /// Level Up Learn Movepool Information /// -public sealed class Learnset +public sealed class Learnset(ushort[] Moves, byte[] Levels) { /// /// Moves that can be learned. /// - private readonly ushort[] Moves; + private readonly ushort[] Moves = Moves; /// /// Levels at which a move at a given index can be learned. /// - private readonly byte[] Levels; + private readonly byte[] Levels = Levels; private const byte MagicEvolutionMoveLevel = 0; - public Learnset(ushort[] moves, byte[] levels) - { - Moves = moves; - Levels = levels; - } - public ReadOnlySpan GetAllMoves() => Moves; public ReadOnlySpan GetMoveRange(int maxLevel, int minLevel = 0) @@ -251,7 +245,7 @@ public ReadOnlySpan GetBaseEggMoves(byte level) // Return a slice containing the moves <= level. if (count == 0) - return ReadOnlySpan.Empty; + return []; int start = 0; if (count > 4) diff --git a/PKHeX.Core/Legality/Learnset/LearnsetReader.cs b/PKHeX.Core/Legality/Learnset/LearnsetReader.cs index a4290de22..5422fc89a 100644 --- a/PKHeX.Core/Legality/Learnset/LearnsetReader.cs +++ b/PKHeX.Core/Legality/Learnset/LearnsetReader.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; /// public static class LearnsetReader { - private static readonly Learnset EMPTY = new(Array.Empty(), Array.Empty()); + private static readonly Learnset EMPTY = new([], []); /// /// Loads a learnset using the 8-bit-per-move storage structure used by Generation 1 & 2 games. diff --git a/PKHeX.Core/Legality/MoveListSuggest.cs b/PKHeX.Core/Legality/MoveListSuggest.cs index a10f2ab7c..1b589fe50 100644 --- a/PKHeX.Core/Legality/MoveListSuggest.cs +++ b/PKHeX.Core/Legality/MoveListSuggest.cs @@ -167,7 +167,9 @@ private static void GetSuggestedRelearnEgg(this IEncounterTemplate enc, ReadOnly { enc.GetEggRelearnMoves(parse, pk, moves); int generation = enc.Generation; - if (generation <= 5) // gen2 does not have splitbreed, <=5 do not have relearn moves and shouldn't even be here. + + // Gen2 does not have split breed, Gen5 and below do not store relearn moves in the data structure. + if (generation <= 5) return; // Split-breed species like Budew & Roselia may be legal for one, and not the other. diff --git a/PKHeX.Core/Legality/Moves/Breeding/BreedInfo.cs b/PKHeX.Core/Legality/Moves/Breeding/BreedInfo.cs index 5c6744c95..8c6b118a9 100644 --- a/PKHeX.Core/Legality/Moves/Breeding/BreedInfo.cs +++ b/PKHeX.Core/Legality/Moves/Breeding/BreedInfo.cs @@ -6,29 +6,21 @@ namespace PKHeX.Core; /// Value passing object to simplify some initialization. /// /// Egg Move source type enumeration. -internal readonly ref struct BreedInfo where T : unmanaged +internal readonly ref struct BreedInfo(Span Actual, Span Possible, Learnset Learnset, ReadOnlySpan Moves, byte Level) + where T : unmanaged { /// Indicates the analyzed source of each move. - public readonly Span Actual; + public readonly Span Actual = Actual; /// Indicates all possible sources of each move. - public readonly Span Possible; + public readonly Span Possible = Possible; /// Level Up entry for the egg. - public readonly Learnset Learnset; + public readonly Learnset Learnset = Learnset; /// Moves the egg knows after it is finalized. - public readonly ReadOnlySpan Moves; + public readonly ReadOnlySpan Moves = Moves; /// Level the egg originated at. - public readonly byte Level; - - public BreedInfo(Span actual, Span possible, Learnset learnset, ReadOnlySpan moves, byte level) - { - Actual = actual; - Possible = possible; - Learnset = learnset; - Moves = moves; - Level = level; - } + public readonly byte Level = Level; } diff --git a/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs b/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs index 39e68d298..353d5f418 100644 --- a/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs +++ b/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs @@ -87,12 +87,12 @@ public enum EggSource6 : byte } /// -/// Utility logic for converting a move result into a user friendly string. +/// Utility logic for converting a move result into a user-friendly string. /// public static class EggSourceUtil { /// - /// Unboxes the parse result and returns a user friendly string for the move result. + /// Unboxes the parse result and returns a user-friendly string for the move result. /// public static string GetSourceString(Array parse, int generation, int index) { @@ -153,7 +153,7 @@ public static string GetSourceString(Array parse, int generation, int index) }; /// - /// Converts the parse result and returns a user friendly string for the move result. + /// Converts the parse result and returns a user-friendly string for the move result. /// public static LearnMethod GetSource(byte value, int generation) => generation switch { diff --git a/PKHeX.Core/Legality/Moves/Breeding/MoveBreed.cs b/PKHeX.Core/Legality/Moves/Breeding/MoveBreed.cs index ca6dff86c..66462bd70 100644 --- a/PKHeX.Core/Legality/Moves/Breeding/MoveBreed.cs +++ b/PKHeX.Core/Legality/Moves/Breeding/MoveBreed.cs @@ -59,7 +59,7 @@ public static bool GetExpectedMoves(int generation, ushort species, byte form, G // Group and order moves by their possible origin flags. Span expected = stackalloc MoveOrder[moves.Length]; GetSortedMoveOrder(generation, moves, origins, expected); - // Don't mutate the expected list any more. + // Don't mutate the expected list anymore. // Temp buffer for the validation origin flags, unused in current scope but used inside the called method. Span temp = stackalloc byte[moves.Length]; diff --git a/PKHeX.Core/Legality/RNG/Algorithms/Xoroshiro128PlusReversal.cs b/PKHeX.Core/Legality/RNG/Algorithms/Xoroshiro128PlusReversal.cs index 34a126c9d..17b6b314f 100644 --- a/PKHeX.Core/Legality/RNG/Algorithms/Xoroshiro128PlusReversal.cs +++ b/PKHeX.Core/Legality/RNG/Algorithms/Xoroshiro128PlusReversal.cs @@ -54,7 +54,7 @@ public static bool Explore(out ulong seed, uint out1, uint out2, ulong assume1, var test1 = check.Next(); var test2 = check.Next(); - // Double check our result. + // Double-check our result. if ((uint)test1 != out1) return false; if ((uint)test2 != out2) @@ -109,7 +109,7 @@ public static bool ExploreDouble(out ulong seed, uint out1, uint out2, ulong ass x0 = seed ^ XOROSHIRO_CONST; seed |= (((((out2 >> 21) - ((seed >> 24) ^ (x0 >> 48) ^ (x0 >> 32) ^ (x0 >> 11)) - assume1) >> 3) ^ (XOROSHIRO_CONST ^ (seed >> 48) ^ (x0 >> 24) ^ (x0 >> 51) ^ (x0 >> 35))) & 0xFF) << 40; - // Double check our result. + // Double-check our result. var check = new Xoroshiro128Plus(seed); var test1 = check.Next(); _ = check.Next(); // gap diff --git a/PKHeX.Core/Legality/RNG/CXD/TeamLock.cs b/PKHeX.Core/Legality/RNG/CXD/TeamLock.cs index 254f0e865..fa4052d10 100644 --- a/PKHeX.Core/Legality/RNG/CXD/TeamLock.cs +++ b/PKHeX.Core/Legality/RNG/CXD/TeamLock.cs @@ -3,29 +3,22 @@ namespace PKHeX.Core; /// /// Represents a Team of Pokémon that is generated before a shadow . /// -public sealed class TeamLock +public sealed class TeamLock(ushort Species, NPCLockDetail Comment, NPCLock[] Locks) { /// /// Team generated before the Species. /// - public readonly NPCLock[] Locks; + public readonly NPCLock[] Locks = Locks; /// /// For trainers that have different teams, this indicates what conditions (when/where) the trainer must be battled. /// - public readonly NPCLockDetail Comment; + public readonly NPCLockDetail Comment = Comment; /// /// Species of shadow Pokémon that is generated after the . /// - public readonly ushort Species; + public readonly ushort Species = Species; - public TeamLock(ushort species, NPCLock[] locks) : this(species, 0, locks) { } - - public TeamLock(ushort species, NPCLockDetail comment, NPCLock[] locks) - { - Species = species; - Locks = locks; - Comment = comment; - } + public TeamLock(ushort Species, NPCLock[] Locks) : this(Species, 0, Locks) { } public override string ToString() { diff --git a/PKHeX.Core/Legality/RNG/CXD/TeamLockResult.cs b/PKHeX.Core/Legality/RNG/CXD/TeamLockResult.cs index 1f05ccb22..9f40282dc 100644 --- a/PKHeX.Core/Legality/RNG/CXD/TeamLockResult.cs +++ b/PKHeX.Core/Legality/RNG/CXD/TeamLockResult.cs @@ -41,7 +41,7 @@ public sealed class TeamLockResult /// /// /// If this value is >= 0, the CPU Trainer Shiny Value must be equal to this value as a skipped over a matching interrupt frame. - /// If this value is , the CPU Trainer Shiny Value can be anything (except matching any of the result members. + /// If this value is , the CPU Trainer Shiny Value can be anything (except matching any of the result members). /// private uint RCSV = NOT_FORCED; @@ -100,14 +100,14 @@ private bool FindLockSeed(int frame = 0, NPCLock? prior = null) /// /// Starting frame for the traversal. /// Current lock criteria to satisfy. Used to find valid results to yield. - /// Prior lock criteria. Used for determining when the traversal stops. + /// Lock criteria for previous party member. Used for determining when the traversal stops. /// List of possible locks for the provided input. private IEnumerable GetPossibleLocks(int ctr, NPCLock current, NPCLock? prior) { - if (prior?.Shadow != false) + if (prior is not { Shadow: false } x) return GetSingleLock(ctr, current); - return GetAllLocks(ctr, current, (NPCLock)prior); + return GetAllLocks(ctr, current, x); } /// @@ -144,7 +144,7 @@ private IEnumerable GetSingleLock(int ctr, NPCLock current) { if (sv == RCSV) { - // No CPU shiny value forced yet. Lets try to skip this lock by requiring the eventual OT to get this shiny. + // No CPU shiny value forced yet. Let's try to skip this lock by requiring the eventual OT to get this shiny. RCSV = sv; forcedOT = true; continue; // don't break @@ -165,7 +165,7 @@ private IEnumerable GetSingleLock(int ctr, NPCLock current) /// /// Starting frame for the traversal. /// Current lock criteria to satisfy. Used to find valid results to yield. - /// Prior lock criteria. Used for determining when the traversal stops. + /// Lock criteria for previous party member. Used for determining when the traversal stops. /// List of possible locks for the provided input. /// /// An "interrupt" signals the end of the traversal. @@ -206,7 +206,7 @@ private IEnumerable GetAllLocks(int ctr, NPCLock current, NPCLock pri yield break; // Since we can't skip this interrupt, we're done. } } - else // No CPU shiny value forced yet. Lets try to skip this lock by requiring the eventual OT to get this shiny. + else // No CPU shiny value forced yet. Let's try to skip this lock by requiring the eventual OT to get this shiny. { RCSV = sv; forcedOT = true; diff --git a/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs b/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs index dc4ecade7..2c7836d63 100644 --- a/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs +++ b/PKHeX.Core/Legality/RNG/Frame/FrameFinder.cs @@ -18,7 +18,7 @@ public static class FrameFinder public static IEnumerable GetFrames(PIDIV pidiv, PKM pk) { if (pk.Version == (int)GameVersion.CXD) - return Array.Empty(); + return []; // Don't trust pk.Nature, just get the correct original via EncryptionConstant var info = new FrameGenerator(pk) {Nature = pk.EncryptionConstant % 25}; @@ -87,7 +87,7 @@ private static IEnumerable RefineFrames3(IEnumerable frames, Frame private static IEnumerable GenerateLeadSpecificFrames3(Frame f, FrameGenerator info) { // Check leads -- none in list if leads are not allowed - // Certain leads inject a RNG call + // Certain leads inject an RNG call // 3 different rand places LeadRequired lead; var prev0 = f.Seed; // 0 diff --git a/PKHeX.Core/Legality/RNG/Frame/SlotNumber.cs b/PKHeX.Core/Legality/RNG/Frame/SlotNumber.cs index 492a9b461..7fb98a6c6 100644 --- a/PKHeX.Core/Legality/RNG/Frame/SlotNumber.cs +++ b/PKHeX.Core/Legality/RNG/Frame/SlotNumber.cs @@ -7,6 +7,10 @@ public static class SlotNumber { private const int Invalid = -1; + /// + /// Calculates the encounter slot index based on the roll for a Gen3 Old Rod encounter. + /// + /// [0,100) public static int GetHOldRod(uint roll) => roll switch { < 70 => 0, // 00,69 (70%) @@ -14,6 +18,10 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a Gen3 Good Rod encounter. + /// + /// [0,100) public static int GetHGoodRod(uint roll) => roll switch { < 60 => 0, // 00,59 (60%) @@ -22,6 +30,10 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a Gen3 Super Rod encounter. + /// + /// [0,100) public static int GetHSuperRod(uint roll) => roll switch { < 40 => 0, // 00,39 (40%) @@ -32,6 +44,10 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a Gen3 Surf encounter. + /// + /// [0,100) public static int GetHSurf(uint roll) => roll switch { < 60 => 0, // 00,59 (60%) @@ -42,6 +58,10 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a Gen3 Wild encounter. + /// + /// [0,100) public static int GetHRegular(uint roll) => roll switch { < 20 => 0, // 00,19 (20%) @@ -59,6 +79,10 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a D/P/Pt Super Rod encounter. + /// + /// [0,100) public static int GetJSuperRod(uint roll) => roll switch { < 40 => 0, // 00,39 (40%) @@ -69,6 +93,10 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a HG/SS Super Rod encounter. + /// + /// [0,100) public static int GetKSuperRod(uint roll) => roll switch { < 40 => 0, // 00,39 (40%) @@ -79,21 +107,32 @@ public static class SlotNumber _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a Bug Catching Contest encounter. + /// + /// [0,100) + /// + /// Slot indexes are reversed for the Bug Catching Contest. + /// public static int GetKBCC(uint roll) => roll switch { - >= 100 => Invalid, - >= 80 => 0, // 80,99 (20%) - >= 60 => 1, // 60,79 (20%) - >= 50 => 2, // 50,59 (10%) - >= 40 => 3, // 40,49 (10%) - >= 30 => 4, // 30,39 (10%) - >= 20 => 5, // 20,29 (10%) - >= 15 => 6, // 15,19 ( 5%) - >= 10 => 7, // 10,14 ( 5%) - >= 05 => 8, // 05,09 ( 5%) - >= 00 => 9, // 00,04 ( 5%) + < 05 => 9, // 00,04 ( 5%) + < 10 => 8, // 05,09 ( 5%) + < 15 => 7, // 10,14 ( 5%) + < 20 => 6, // 15,19 ( 5%) + < 30 => 5, // 20,29 (10%) + < 40 => 4, // 30,39 (10%) + < 50 => 3, // 40,49 (10%) + < 60 => 2, // 50,59 (10%) + < 80 => 1, // 60,79 (20%) + < 100=> 0, // 80,99 (20%) + _ => Invalid, }; + /// + /// Calculates the encounter slot index based on the roll for a HG/SS Headbutt encounter. + /// + /// [0,100) public static int GetKHeadbutt(uint roll) => roll switch { < 50 => 0, // 00,49 (50%) diff --git a/PKHeX.Core/Legality/RNG/MethodFinder.cs b/PKHeX.Core/Legality/RNG/MethodFinder.cs index 2db30d631..3122f16d1 100644 --- a/PKHeX.Core/Legality/RNG/MethodFinder.cs +++ b/PKHeX.Core/Legality/RNG/MethodFinder.cs @@ -262,16 +262,16 @@ private static bool GetXDRNGMatch(Span seeds, PKM pk, uint top, uint bot, return true; } - // check for anti-shiny against player TSV + // Check for anti-shiny against player TSV var tsv = (uint)(pk.TID16 ^ pk.SID16) >> 3; var psv = (top ^ bot) >> 3; - if (psv == tsv) // already shiny, wouldn't be anti-shiny + if (psv == tsv) // Already shiny, wouldn't be made anti-shiny continue; var p2 = seed; var p1 = B; psv = ((p2 ^ p1) >> 19); - if (psv != tsv) // prior PID must be shiny + if (psv != tsv) // The prior PID must be shiny! continue; do @@ -561,7 +561,7 @@ private static bool GetPokewalkerMatch(PKM pk, uint pid, out PIDIV pidiv) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool IsAzurillEdgeCaseM(PKM pk, uint nature, uint oldpid) { - // check for Azurill evolution edge case... 75% F-M is now 50% F-M; was this a F->M bend? + // check for Azurill evolution edge case... 75% F-M is now 50% F-M; was this a Female->Male bend? ushort species = pk.Species; if (species is not ((int)Species.Marill or (int)Species.Azumarill)) return false; @@ -743,7 +743,7 @@ public static bool IsPokeSpotActivation(int slot, uint seed, out uint s) s = XDRNG.Prev(seed); if ((s >> 16) % 3 != 0) { - if ((s >> 16) % 100 < 10) // can't fail a munchlax/bonsly encounter check + if ((s >> 16) % 100 < 10) // can't fail a Munchlax/Bonsly encounter check { // todo } @@ -787,7 +787,7 @@ internal static bool IsCuteCharm4Valid(ISpeciesForm enc, PKM pk) // These evolved species cannot be encountered with cute charm. // 100% fixed gender does not modify PID; override this with the encounter species for correct calculation. - // We can assume the re-mapped species's [gender ratio] is what was encountered. + // We can assume the re-mapped species' [gender ratio] is what was encountered. (int)Species.Wormadam => ((int)Species.Burmy, 1), (int)Species.Mothim => ((int)Species.Burmy, 0), (int)Species.Vespiquen => ((int)Species.Combee, 1), @@ -795,7 +795,7 @@ internal static bool IsCuteCharm4Valid(ISpeciesForm enc, PKM pk) (int)Species.Froslass => ((int)Species.Snorunt, 1), // Azurill & Marill/Azumarill collision // Changed gender ratio (25% M -> 50% M) needs special treatment. - // Double check the encounter species with IsCuteCharm4Valid afterwards. + // Double-check the encounter species with IsCuteCharm4Valid afterward. (int)Species.Marill or (int)Species.Azumarill when IsCuteCharmAzurillMale(pid) => ((int)Species.Azurill, 0), // Future evolutions diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen4/PokewalkerRNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen4/PokewalkerRNG.cs index a98b568e3..ded0218e4 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen4/PokewalkerRNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen4/PokewalkerRNG.cs @@ -35,8 +35,8 @@ public static class PokewalkerRNG /// All species for all Pokéwalker courses. /// /// 6 species per course; each course has 3 groups (A/B/C) of 2 species (0/1). - private static ReadOnlySpan CourseSpecies => new ushort[] - { + private static ReadOnlySpan CourseSpecies => + [ 115, 084, 029, 032, 016, 161, // 00 Refreshing Field 202, 069, 048, 046, 043, 021, // 01 Noisy Forest 240, 095, 066, 077, 163, 074, // 02 Rugged Road @@ -64,7 +64,7 @@ public static class PokewalkerRNG 255, 133, 279, 061, 052, 025, // 24 Sightseeing 446, 374, 116, 355, 129, 436, // 25 Winners Path 239, 240, 238, 440, 174, 173, // 26 Amity Meadow - }; + ]; /// /// Gets the first valid seed for the given Pokéwalker IVs. diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen8/Overworld8RNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen8/Overworld8RNG.cs index ec4ca2251..b6f251ad0 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen8/Overworld8RNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen8/Overworld8RNG.cs @@ -59,7 +59,7 @@ private static bool TryApplyFromSeed(PKM pk, EncounterCriteria criteria, Shiny s pk.PID = pid; // IVs - Span ivs = stackalloc[] {UNSET, UNSET, UNSET, UNSET, UNSET, UNSET}; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; const int MAX = 31; for (int i = 0; i < flawless; i++) { @@ -164,7 +164,7 @@ private static int GetIsMatchEnd(PKM pk, Xoroshiro128Plus xoro, int start = 0, i continue; var copy = xoro; - Span ivs = stackalloc [] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; const int MAX = 31; for (int i = 0; i < iv_count; i++) { diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs index a34549115..7aab3eb1d 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen8a/Overworld8aRNG.cs @@ -132,7 +132,7 @@ public static bool TryApplyFromSeed(PKM pk, EncounterCriteria criteria, in Overw } pk.PID = pid; - Span ivs = stackalloc[] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; const int MAX = 31; for (int i = 0; i < para.FlawlessIVs; i++) { @@ -231,7 +231,7 @@ public static bool Verify(PKM pk, ulong seed, in OverworldParam8a para) if (pk.PID != pid) return false; - Span ivs = stackalloc[] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; const int MAX = 31; for (int i = 0; i < para.FlawlessIVs; i++) { diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen8b/Roaming8bRNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen8b/Roaming8bRNG.cs index 8f4448473..e53c318d7 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen8b/Roaming8bRNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen8b/Roaming8bRNG.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; /// Contains logic for the Generation 8b (BD/SP) roaming spawns. /// /// -/// Roaming encounters use the pokemon's 32-bit as RNG seed. +/// Roaming encounters use the Pokémon's 32-bit as RNG seed. /// public static class Roaming8bRNG { @@ -64,7 +64,7 @@ private static bool TryApplyFromSeed(PKM pk, EncounterCriteria criteria, Shiny s pk.PID = pid; // Check IVs: Create flawless IVs at random indexes, then the random IVs for not flawless. - Span ivs = stackalloc [] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; const int MAX = 31; var determined = 0; while (determined < flawless) @@ -118,7 +118,7 @@ public static bool ValidateRoamingEncounter(PKM pk, Shiny shiny = Shiny.Random, return false; // Check IVs: Create flawless IVs at random indexes, then the random IVs for not flawless. - Span ivs = stackalloc [] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; var determined = 0; while (determined < flawless) diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen8b/Wild8bRNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen8b/Wild8bRNG.cs index bfdab0ef0..8eef9016c 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen8b/Wild8bRNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen8b/Wild8bRNG.cs @@ -68,7 +68,7 @@ public static bool TryApplyFromSeed(PKM pk, EncounterCriteria criteria, Shiny sh pk.PID = pid; // Check IVs: Create flawless IVs at random indexes, then the random IVs for not flawless. - Span ivs = stackalloc[] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; const int MAX = 31; var determined = 0; while (determined < flawless) diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs index 0b6731b17..3287850bb 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen9/Encounter9RNG.cs @@ -66,7 +66,7 @@ public static bool GenerateData(PK9 pk, in GenerateParam9 enc, EncounterCriteria const int UNSET = -1; const int MAX = 31; - Span ivs = stackalloc[] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; if (enc.IVs.IsSpecified) { enc.IVs.CopyToSpeedLast(ivs); @@ -143,7 +143,7 @@ public static bool IsMatch(PKM pk, in GenerateParam9 enc, in ulong seed) return false; const int UNSET = -1; - Span ivs = stackalloc[] { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET }; + Span ivs = [UNSET, UNSET, UNSET, UNSET, UNSET, UNSET]; if (enc.IVs.IsSpecified) { enc.IVs.CopyToSpeedLast(ivs); diff --git a/PKHeX.Core/Legality/RNG/Methods/Gen9/Tera9RNG.cs b/PKHeX.Core/Legality/RNG/Methods/Gen9/Tera9RNG.cs index 80f2159ab..4eaa7af7a 100644 --- a/PKHeX.Core/Legality/RNG/Methods/Gen9/Tera9RNG.cs +++ b/PKHeX.Core/Legality/RNG/Methods/Gen9/Tera9RNG.cs @@ -227,14 +227,14 @@ public static bool IsMatchStarChoice(in uint seed, in byte stars, in byte raidRa // Thanks to a silly <= check, the range check edge is inclusive (unlike the slot determination). // Each rate has its low bound used by the prior's rate check. // This results in: - // - the first rate check having a total range of one more than the intended range. - // - the last rate check having a total range of one less than the intended range. - 1 => rand <= 80, // [ 0, 80], [ 0, 30], or [ 0, 20] - 2 => rand is (> 80) or (> 30 and <= 70) or (> 20 and <= 40), // (80, 100], (30, 70], or (20, 40] - 3 => true, // all progress ranges overlap! // (70, 100], (40, 70], or [ 0, 40] - 4 => rand is (> 70) or (> 40 and <= 75) or (> 30 and <= 70), // (70, 100], (40, 75], or (30, 70] - 5 => rand > 70, // (70, 100] - _ => true, // forced star count + // - the 1st rate check has a total range of one more than the intended range. + // - the last rate check has a total range of one less than the intended range. + 1 => rand <= 80, // [ 0, 80], [ 0, 30], or [ 0, 20] + 2 => rand is (<=70 and >20) or (>80), // (80, 100], (30, 70], or (20, 40] + 3 => true, // all ranges overlap! // (70, 100], (40, 70], or [ 0, 40] + 4 => rand > 30, // (70, 100], (40, 75], or (30, 70] + 5 => rand > 70, // (70, 100] + _ => true, // forced star count }; /// diff --git a/PKHeX.Core/Legality/RNG/PIDGenerator.cs b/PKHeX.Core/Legality/RNG/PIDGenerator.cs index 24e2cfa7d..102996ed7 100644 --- a/PKHeX.Core/Legality/RNG/PIDGenerator.cs +++ b/PKHeX.Core/Legality/RNG/PIDGenerator.cs @@ -16,7 +16,7 @@ private static void SetValuesFromSeedLCRNG(PKM pk, PIDType type, uint seed) B = LCRNG.Next(B); var swappedPIDHalves = type is >= PIDType.Method_1_Unown and <= PIDType.Method_4_Unown; - if (swappedPIDHalves) // switched order of PID halves, "BA.." + if (swappedPIDHalves) // switched order of PID halves, "BA**" pk.PID = (A & 0xFFFF0000) | (B >> 16); else pk.PID = (B & 0xFFFF0000) | (A >> 16); diff --git a/PKHeX.Core/Legality/RNG/PIDType.cs b/PKHeX.Core/Legality/RNG/PIDType.cs index b207fae47..0ac273108 100644 --- a/PKHeX.Core/Legality/RNG/PIDType.cs +++ b/PKHeX.Core/Legality/RNG/PIDType.cs @@ -182,7 +182,7 @@ public enum PIDType Overworld8, /// - /// Generation 8b Roaming Pokemon PID + /// Generation 8b Roaming Pokémon PID /// /// Formulaic based on EC value = 32bit-seed. Roaming8b, diff --git a/PKHeX.Core/Legality/RNG/Util/ToxtricityUtil.cs b/PKHeX.Core/Legality/RNG/Util/ToxtricityUtil.cs index 4f426ee65..7ba2684fc 100644 --- a/PKHeX.Core/Legality/RNG/Util/ToxtricityUtil.cs +++ b/PKHeX.Core/Legality/RNG/Util/ToxtricityUtil.cs @@ -8,9 +8,9 @@ namespace PKHeX.Core; public static class ToxtricityUtil { /// Amped Nature Table - private static ReadOnlySpan Nature0 => new byte[] { 3, 4, 2, 8, 9, 19, 22, 11, 13, 14, 0, 6, 24 }; + private static ReadOnlySpan Nature0 => [ 3, 4, 2, 8, 9, 19, 22, 11, 13, 14, 0, 6, 24 ]; /// Low Key Nature Table - private static ReadOnlySpan Nature1 => new byte[] { 1, 5, 7, 10, 12, 15, 16, 17, 18, 20, 21, 23 }; + private static ReadOnlySpan Nature1 => [ 1, 5, 7, 10, 12, 15, 16, 17, 18, 20, 21, 23 ]; /// /// Gets a random nature for Toxel -> Toxtricity. diff --git a/PKHeX.Core/Legality/Restrictions/EvolutionRestrictions.cs b/PKHeX.Core/Legality/Restrictions/EvolutionRestrictions.cs index 3146900b4..d2681812a 100644 --- a/PKHeX.Core/Legality/Restrictions/EvolutionRestrictions.cs +++ b/PKHeX.Core/Legality/Restrictions/EvolutionRestrictions.cs @@ -38,11 +38,11 @@ internal static class EvolutionRestrictions private const ushort NONE = 0; private const ushort EEVEE = ushort.MaxValue; - private static ReadOnlySpan EeveeFairyMoves => new ushort[] - { + private static ReadOnlySpan EeveeFairyMoves => + [ (int)Charm, (int)BabyDollEyes, - }; + ]; /// /// Checks if the is correctly evolved, assuming it had a known move requirement evolution in its evolution chain. @@ -98,8 +98,8 @@ private static bool IsValidEvolutionWithMoveSylveon(PKM pk, IEncounterTemplate e private static bool IsMoveSlotAvailable(ReadOnlySpan moves) { - // If the pokemon does not currently have the move, it could have been an egg move that was forgotten. - // This requires the pokemon to not have 4 other moves identified as egg moves or inherited level up moves. + // If the Pokémon does not currently have the move, it could have been an egg move that was forgotten. + // This requires the Pokémon to not have 4 other moves identified as egg moves or inherited level up moves. // If any move is not an egg source, then a slot could have been forgotten. foreach (var move in moves) { diff --git a/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs b/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs index bc2bda03d..88267a9fb 100644 --- a/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs +++ b/PKHeX.Core/Legality/Restrictions/GBRestrictions.cs @@ -120,7 +120,7 @@ private static bool GetCatchRateMatchesPreEvolution(PK1 pk, byte catch_rate) /// Checks if the can inhabit /// /// Data to check - /// true if can inhabit, false if not. + /// true if it can inhabit, false if it can not. internal static bool CanInhabitGen1(this PKM pk) { // Korean Gen2 games can't trade-back because there are no Gen1 Korean games released @@ -128,7 +128,7 @@ internal static bool CanInhabitGen1(this PKM pk) return false; // Gen2 format with met data can't receive Gen1 moves, unless Stadium 2 is used (Oak's PC). - // If you put a Pokemon in the N64 box, the met info is retained, even if you switch over to a Gen1 game to teach it TMs + // If you put a Pokémon in the N64 box, the met info is retained, even if you switch over to a Gen1 game to teach it TMs // You can use rare candies from within the lab, so level-up moves from RBY context can be learned this way as well // Stadium 2 is GB Cart Era only (not 3DS Virtual Console). if (pk is ICaughtData2 {CaughtData: not 0} && !ParseSettings.AllowGBStadium2) @@ -144,17 +144,17 @@ internal static bool CanInhabitGen1(this PKM pk) /// /// Gets the Tradeback status depending on various values. /// - /// Pokémon to guess the tradeback status from. + /// Pokémon to guess the Tradeback status from. internal static PotentialGBOrigin GetTradebackStatusInitial(PKM pk) { if (pk is PK1 pk1) return GetTradebackStatusRBY(pk1); - if (pk.Format == 2 || pk.VC2) // Check for impossible tradeback scenarios + if (pk.Format == 2 || pk.VC2) // Check for impossible Tradeback scenarios return !pk.CanInhabitGen1() ? Gen2Only : Either; // VC2 is released, we can assume it will be TradebackType.Any. - // Is impossible to differentiate a VC1 pokemon traded to Gen7 after VC2 is available. + // Is impossible to differentiate a VC1 Pokémon traded to Gen7 after VC2 is available. // Met Date cannot be used definitively as the player can change their system clock. return Either; } @@ -162,13 +162,13 @@ internal static PotentialGBOrigin GetTradebackStatusInitial(PKM pk) /// /// Gets the Tradeback status depending on the /// - /// Pokémon to guess the tradeback status from. + /// Pokémon to guess the Tradeback status from. private static PotentialGBOrigin GetTradebackStatusRBY(PK1 pk) { if (!ParseSettings.AllowGen1Tradeback) return Gen1Only; - // Detect tradeback status by comparing the catch rate(Gen1)/held item(Gen2) to the species in the pk's evolution chain. + // Detect Tradeback status by comparing the catch rate(Gen1)/held item(Gen2) to the species in the Pokémon's evolution chain. var catch_rate = pk.Catch_Rate; if (catch_rate == 0) return Either; diff --git a/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs b/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs index 01ad89efe..bd0dc7d01 100644 --- a/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs +++ b/PKHeX.Core/Legality/Restrictions/ItemRestrictions.cs @@ -20,7 +20,7 @@ public static bool IsHeldItemAllowed(PKM pk) } /// - /// Checks if an is available to be held in . + /// Checks if an item is available to be held in . /// /// Held Item ID /// Entity context to check @@ -45,7 +45,7 @@ public static bool IsHeldItemAllowed(int item, EntityContext context) EntityContext.Gen9 => ReleasedHeldItems_9, EntityContext.Gen8b => ReleasedHeldItems_8b, - _ => Array.Empty(), // lgp/e, pla, etc + _ => [], // lgp/e, pla, etc }; private static readonly bool[] ReleasedHeldItems_2 = GetPermitList(MaxItemID_2, HeldItems_GSC); diff --git a/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs b/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs index 5c7f506ad..99875acd8 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/Memories.cs @@ -8,8 +8,8 @@ namespace PKHeX.Core; /// public static class Memories { - private static ReadOnlySpan ArgTypes => new byte[] - { + private static ReadOnlySpan ArgTypes => + [ 0, 1, 1, 1, 1, 5, 2, 3, 0, 3, 0, 0, 4, 3, 3, 5, 4, 3, 3, 1, 0, 3, 0, 0, 1, 3, 5, 0, 0, 3, @@ -19,7 +19,7 @@ public static class Memories 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 0, 0, 3, 0, 0, 0, 0, 4, 4, 3, 3, 5, 0, 1, 3, 5, 4, - }; + ]; public static MemoryArgType GetMemoryArgType(byte memory, int memoryGen) { diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs index db3948a3d..7eed98c64 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6.cs @@ -122,8 +122,12 @@ public static bool CanHaveFeeling6(int memory, int feeling, int argument) return (MemoryFeelings[memory] & (1 << feeling)) != 0; } + public const byte MaxIntensity = 7; + public static bool CanHaveIntensity6(int memory, int intensity) { + if ((uint)intensity > MaxIntensity) + return false; if (memory >= MemoryFeelings.Length) return false; return MemoryMinIntensity[memory] <= intensity; @@ -141,10 +145,10 @@ public static byte GetRandomFeeling6(int memory, int max = 24) } } - public static int GetMinimumIntensity6(int memory) + public static byte GetMinimumIntensity6(int memory) { if (memory >= MemoryMinIntensity.Length) - return -1; + return 0; return MemoryMinIntensity[memory]; } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6Data.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6Data.cs index e0b5b6a1c..71b87ca47 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6Data.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext6Data.cs @@ -5,27 +5,27 @@ namespace PKHeX.Core; // data tables stored separately! public partial class MemoryContext6 { - private static ReadOnlySpan Memory_NotXY => new byte[] - { + private static ReadOnlySpan Memory_NotXY => + [ 65, // {0} was with {1} when (he/she) built a Secret Base. {4} that {3}. 66, // {0} participated in a contest with {1} and impressed many people. {4} that {3}. 67, // {0} participated in a contest with {1} and won the title. {4} that {3}. 68, // {0} soared through the sky with {1} and went to many different places. {4} that {3}. 69, // {1} asked {0} to dive. Down it went, deep into the ocean, to explore the bottom of the sea. {4} that {3}. - }; + ]; - private static ReadOnlySpan Memory_NotAO => new byte[] - { + private static ReadOnlySpan Memory_NotAO => + [ 11, // {0} went clothes shopping with {1}. {4} that {3}. 43, // {0} was impressed by the speed of the train it took with {1}. {4} that {3}. 44, // {0} encountered {2} with {1} using the Poké Radar. {4} that {3}. 56, // {0} was with {1} when (he/she) went to a boutique and tried on clothes, but (he/she) left the boutique without buying anything. {4} that {3}. 57, // {0} went to a nice restaurant with {1} and ate until it got totally full. {4} that {3}. 62, // {0} saw itself in a mirror in a mirror cave that it went to with {1}. {4} that {3}. - }; + ]; - internal static ReadOnlySpan MoveSpecificMemoryHM => new byte[] // Ordered by HM index for bitflag checks. - { + internal static ReadOnlySpan MoveSpecificMemoryHM => // Ordered by HM index for bitflag checks. + [ 36, // {0} proudly used Cut at {1}’s instruction in... {2}. {4} that {3}. 24, // {0} flew, carrying {1} on its back, to {2}. {4} that {3}. 20, // {0} surfed across the water, carrying {1} on its back. {4} that {3}. @@ -33,13 +33,13 @@ public partial class MemoryContext6 38, // {0} used Waterfall while carrying {1} on its back in... {2}. {4} that {3}. 37, // {0} shattered rocks to its heart’s content at {1}’s instruction in... {2}. {4} that {3}. 69, // {1} asked {0} to dive. Down it went, deep into the ocean, to explore the bottom of the sea. {4} that {3}. - }; + ]; /// /// Kalos locations with a Pokémon Center /// - private static ReadOnlySpan LocationsWithPokeCenter_XY => new byte[] - { + private static ReadOnlySpan LocationsWithPokeCenter_XY => + [ // Kalos locations with a PKMN CENTER 018, // Santalune City 022, // Lumiose City @@ -55,13 +55,13 @@ public partial class MemoryContext6 090, // Couriway Town 094, // Snowbelle City 106, // Pokémon League (X/Y) - }; + ]; /// /// Hoenn locations with a Pokémon Center /// - private static ReadOnlySpan LocationsWithPokeCenter_AO => new byte[] - { + private static ReadOnlySpan LocationsWithPokeCenter_AO => + [ // Hoenn locations with a PKMN CENTER 172, // Oldale Town 174, // Dewford Town @@ -79,10 +79,10 @@ public partial class MemoryContext6 198, // Sootopolis City 200, // Ever Grande City 202, // Pokémon League (OR/AS) - }; + ]; - private static ReadOnlySpan MemoryMinIntensity => new byte[] - { + private static ReadOnlySpan MemoryMinIntensity => + [ 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, @@ -90,10 +90,10 @@ public partial class MemoryContext6 3, 3, 1, 3, 2, 2, 4, 3, 4, 4, 4, 4, 2, 4, 2, 4, 3, 3, 4, 2, 3, 3, 3, 3, 3, 2, 3, 4, 4, 2, - }; + ]; - private static ReadOnlySpan MemoryRandChance => new byte[] - { + private static ReadOnlySpan MemoryRandChance => + [ 000, 100, 100, 100, 100, 005, 005, 005, 005, 005, 005, 005, 005, 005, 010, 020, 010, 001, 050, 030, 005, 005, 020, 005, 005, 005, 001, 050, 100, 050, @@ -101,13 +101,13 @@ public partial class MemoryContext6 020, 020, 005, 010, 001, 001, 050, 030, 020, 020, 010, 010, 001, 010, 001, 050, 030, 030, 030, 002, 050, 020, 020, 020, 020, 010, 010, 050, 020, 005, - }; + ]; /// /// 24bits of flags allowing certain feelings for a given memory index. /// - private static ReadOnlySpan MemoryFeelings => new[] - { + private static ReadOnlySpan MemoryFeelings => + [ 0x000000, 0x04CBFD, 0x004BFD, 0x04CBFD, 0x04CBFD, 0xFFFBFB, 0x84FFF9, 0x47FFFF, 0xBF7FFA, 0x7660B0, 0x80BDF9, 0x88FB7A, 0x083F79, 0x0001FE, 0xCFEFFF, 0x84EBAF, 0xB368B0, 0x091F7E, 0x0320A0, 0x080DDD, 0x081A7B, 0x404030, 0x0FFFFF, 0x9A08BC, 0x089A7B, 0x0032AA, 0x80FF7A, 0x0FFFFF, 0x0805FD, 0x098278, @@ -115,15 +115,15 @@ public partial class MemoryContext6 0xBFFFFF, 0x8B837C, 0x848AFA, 0x88FFFE, 0x8B0B7C, 0xB76AB2, 0x8B1FFF, 0xBE7AB8, 0xB77EB8, 0x8C9FFD, 0xBF9BFF, 0xF408B0, 0xBCFE7A, 0x8F3F72, 0x90DB7A, 0xBCEBFF, 0xBC5838, 0x9C3FFE, 0x9CFFFF, 0x96D83A, 0xB770B0, 0x881F7A, 0x839F7A, 0x839F7A, 0x839F7A, 0x53897F, 0x41BB6F, 0x0C35FF, 0x8BBF7F, 0x8BBF7F, - }; + ]; - private static ReadOnlySpan KeyItemMemoryArgsAnySpecies => new ushort[] - { + private static ReadOnlySpan KeyItemMemoryArgsAnySpecies => + [ 466, // Gracidea 628, 629, // DNA Splicers 638, // Reveal Glass 765, // Prison Bottle - }; + ]; private static bool IsKeyItemMemoryArgValid(ushort species, ushort arg) => species switch { @@ -141,8 +141,8 @@ public partial class MemoryContext6 /// private const ushort KeyItemUsableObserveEonFlute = 775; // Eon Flute - private static ReadOnlySpan PurchaseableItemXY => new ushort[] - { + private static ReadOnlySpan PurchaseableItemXY => + [ 002, 003, 004, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 034, 035, 036, 037, 045, @@ -151,10 +151,10 @@ public partial class MemoryContext6 254, 255, 314, 315, 316, 317, 318, 319, 320, 334, 338, 341, 342, 343, 345, 347, 352, 355, 360, 364, 365, 377, 379, 395, 402, 403, 405, 411, 618, - }; + ]; - private static ReadOnlySpan PurchaseableItemAO => new ushort[] - { + private static ReadOnlySpan PurchaseableItemAO => + [ 002, 003, 004, 006, 007, 008, 009, 010, 011, 013, 014, 015, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 034, 035, 036, 037, 045, 046, @@ -164,50 +164,50 @@ public partial class MemoryContext6 342, 343, 344, 347, 352, 360, 365, 367, 369, 374, 379, 384, 395, 398, 400, 403, 405, 409, 577, 692, 694, - }; + ]; - private static ReadOnlySpan LotoPrizeXYAO => new ushort[] - { + private static ReadOnlySpan LotoPrizeXYAO => + [ 0001, 0033, 0050, 0051, 0053, - }; + ]; - public static ReadOnlySpan CaptureFlagsX => new byte[] - { + public static ReadOnlySpan CaptureFlagsX => + [ 0xB6, 0x75, 0xE1, 0x7B, 0xCB, 0x5A, 0x4A, 0xF5, 0x6C, 0xAD, 0x9C, 0xAA, 0x65, 0x93, 0xFF, 0xFF, 0x3F, 0xD4, 0x5F, 0x00, 0x3A, 0x8D, 0x8C, 0xCF, 0x4E, 0xEC, 0xEA, 0xEF, 0x9B, 0x58, 0x82, 0x00, 0xC0, 0x98, 0x54, 0x53, 0x64, 0xDE, 0xCB, 0xFF, 0xF9, 0xF1, 0x7F, 0x0A, 0xB7, 0xCA, 0x9E, 0x00, 0x00, 0xB0, 0x51, 0x95, 0x8A, 0x06, 0xA6, 0x9E, 0xFB, 0x1C, 0x00, 0x80, 0x00, 0x00, 0x00, 0xC6, 0x2A, 0xB9, 0x2C, 0xAD, 0xD1, 0xB0, 0x52, 0x9B, 0x76, 0xDC, 0x34, 0x81, 0xED, 0xED, 0xA9, 0x1D, 0x00, 0x6C, 0x7B, 0x7F, 0xB7, 0x54, 0x73, 0xE5, 0x7B, 0x55, - }; + ]; - public static ReadOnlySpan CaptureFlagsY => new byte[] - { + public static ReadOnlySpan CaptureFlagsY => + [ 0xB6, 0x7D, 0xE1, 0x7B, 0xCB, 0x5A, 0x4A, 0xF5, 0x6C, 0xAD, 0x9C, 0xAE, 0x65, 0x93, 0xFF, 0xFC, 0x3F, 0xD4, 0x5F, 0x00, 0x3A, 0x8D, 0x8C, 0xCF, 0x4E, 0xEC, 0xEA, 0xEF, 0x8B, 0x58, 0xC2, 0x00, 0xC0, 0x98, 0x54, 0x53, 0x64, 0xDE, 0xE8, 0xFF, 0xF9, 0xF1, 0x7F, 0x0A, 0xB7, 0x4A, 0x9F, 0x00, 0x00, 0xB0, 0x51, 0x95, 0x8A, 0x06, 0xA6, 0x9E, 0xFB, 0x1C, 0x00, 0x80, 0x00, 0x00, 0x00, 0xC6, 0x2A, 0xB9, 0x2C, 0xAD, 0xD1, 0xB0, 0x52, 0x9B, 0x76, 0xDC, 0x34, 0x81, 0xED, 0xED, 0xA9, 0x1D, 0x00, 0x6C, 0x7B, 0x7F, 0xB7, 0x54, 0x4F, 0xE5, 0x7B, 0x65, - }; + ]; - public static ReadOnlySpan CaptureFlagsAS => new byte[] - { + public static ReadOnlySpan CaptureFlagsAS => + [ 0x00, 0x40, 0x1A, 0x0A, 0xA8, 0x5E, 0x66, 0x85, 0x04, 0xAF, 0xD2, 0x81, 0x36, 0xA0, 0xF4, 0x81, 0x36, 0x56, 0x00, 0x49, 0x00, 0x8D, 0x84, 0xC1, 0x40, 0x2F, 0x40, 0xC4, 0x0F, 0x95, 0x39, 0x92, 0xA4, 0xD7, 0xD0, 0xB9, 0x64, 0x5B, 0xBB, 0xDF, 0xBD, 0x29, 0xFB, 0xAB, 0xEB, 0x5B, 0x4E, 0x7E, 0x4D, 0x02, 0x14, 0x05, 0x60, 0x8A, 0x11, 0x0F, 0x08, 0x05, 0x00, 0x00, 0xEF, 0x81, 0x24, 0x04, 0xA0, 0x38, 0x9C, 0x18, 0x94, 0xF8, 0x58, 0x55, 0x00, 0x02, 0x8D, 0x24, 0x24, 0x20, 0x3C, 0xD2, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x05, 0x18, - }; + ]; - public static ReadOnlySpan CaptureFlagsOR => new byte[] - { + public static ReadOnlySpan CaptureFlagsOR => + [ 0x00, 0x40, 0x1A, 0x0A, 0xA8, 0x5E, 0x66, 0x85, 0x04, 0xAF, 0xD2, 0x81, 0x36, 0xA0, 0xF4, 0x81, 0x36, 0x56, 0x00, 0x49, 0x00, 0x8D, 0x84, 0xC1, 0x40, 0x2F, 0x40, 0xC4, 0x0F, 0x95, 0x39, 0x94, 0xA4, 0x17, 0xD6, 0xB9, 0x64, 0x9B, 0xBB, 0xDF, 0xBD, 0xA9, 0xFC, 0xAB, 0xEB, 0x5B, 0x4E, 0xBE, 0x4D, 0x02, 0x14, 0x05, 0x60, 0x8A, 0x11, 0x0F, 0x08, 0x05, 0x00, 0x00, 0xF7, 0x81, 0x24, 0x04, 0xA0, 0x38, 0x9C, 0x14, 0x94, 0xF8, 0x58, 0x55, 0x00, 0x02, 0x8D, 0x24, 0x24, 0x20, 0x3C, 0xD2, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0x18, - }; + ]; } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs index b6d807ae0..71ebdda8b 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8.cs @@ -178,8 +178,12 @@ public static bool CanHaveFeeling8(byte memory, byte feeling, ushort argument) return (MemoryFeelings[memory] & (1 << --feeling)) != 0; } + public const byte MaxIntensity = 7; + public static bool CanHaveIntensity8(byte memory, byte intensity) { + if ((uint)intensity > MaxIntensity) + return false; if (memory >= MemoryFeelings.Length) return false; return MemoryMinIntensity[memory] <= intensity; @@ -197,10 +201,10 @@ public static byte GetRandomFeeling8(int memory, int max = 24) } } - public static int GetMinimumIntensity8(int memory) + public static byte GetMinimumIntensity8(int memory) { if (memory >= MemoryMinIntensity.Length) - return -1; + return 0; return MemoryMinIntensity[memory]; } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs index 8f2316489..07b14c72d 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryContext8Data.cs @@ -4,8 +4,8 @@ namespace PKHeX.Core; public partial class MemoryContext8 { - private static ReadOnlySpan Memory_NotSWSH => new byte[] - { + private static ReadOnlySpan Memory_NotSWSH => + [ 10, // {0} got treats from {1}. {4} that {3}. 17, // {0} battled at {1}’s side and beat {2}. {4} that {3}. 20, // {0} surfed across the water, carrying {1} on its back. {4} that {3}. @@ -40,15 +40,15 @@ public partial class MemoryContext8 87, // {0} got in a fight with the {2} that it was in a Box with about {1}. {4} that {3}. 88, // When {0} was in a Box, it thought about the reason why {1} had it hold the {2}. {4} that {3}. 89, // When {0} was in a Box, it had a weird dream in which {1} was using the move {2}. {4} that {3}. - }; + ]; - private static ReadOnlySpan KeyItemMemoryArgsAnySpecies => new ushort[] - { + private static ReadOnlySpan KeyItemMemoryArgsAnySpecies => + [ 628, 629, // DNA Splicers 943, 944, 945, 946, // N-Lunarizer / N-Solarizer 1278, // Rotom Catalog 1590, 1591, // Reigns of Unity - }; + ]; private static bool IsKeyItemMemoryArgValid(ushort species, ushort arg) => species switch { @@ -62,8 +62,8 @@ public partial class MemoryContext8 /// /// Includes all purchase-able items except for TRs (separate span). /// - private static ReadOnlySpan PurchaseItemsNoTR => new ushort[] - { + private static ReadOnlySpan PurchaseItemsNoTR => + [ 0002, 0003, 0004, 0006, 0007, 0008, 0009, 0010, 0011, 0013, 0014, 0015, 0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, 0028, 0033, 0034, 0035, 0036, 0037, 0042, @@ -79,30 +79,27 @@ public partial class MemoryContext8 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, - }; + ]; - private static ReadOnlySpan LotoPrizeSWSH => new byte[] - { - 0001, 0033, 0050, 0051, 0053, - }; + private static ReadOnlySpan LotoPrizeSWSH => [0001, 0033, 0050, 0051, 0053]; // {met, values allowed} - private static ReadOnlySpan MultiLoc006 => new byte[] { 1, 2, 3 }; // town of Postwick: first town, at home, friend's house - private static ReadOnlySpan MultiLoc014 => new byte[] { 4, 6, 8, 9 }; // town of Wedgehurst: someone's house, boutique, simple town, Pokémon Center - private static ReadOnlySpan MultiLoc018 => new byte[] { 16, 44, 71 }; // Route 2: lab, tranquil road, lakeside road - private static ReadOnlySpan MultiLoc020 => new byte[] { 6, 9, 11, 20, 24, 30, 35 }; // city of Motostoke: boutique, Pokémon Center, hotel, Pokémon Gym, stylish café, hair salon, town with a mysterious air - private static ReadOnlySpan MultiLoc024 => new byte[] { 20, 73 };// Motostoke Stadium: Pokémon Gym, stadium - private static ReadOnlySpan MultiLoc034 => new byte[] { 9, 12 }; // town of Turffield: Pokémon Center, town with a mysterious air - private static ReadOnlySpan MultiLoc040 => new byte[] { 44, 74 }; // Route 5: tranquil road, Pokémon Nursery - private static ReadOnlySpan MultiLoc044 => new byte[] { 4, 9, 31, 33 }; // town of Hulbury: someone’s house, Pokémon Center, restaurant, seaside town - private static ReadOnlySpan MultiLoc056 => new byte[] { 4, 6, 9, 20, 24, 30, 35 }; // city of Hammerlocke: someone’s house, boutique, Pokémon Center, Pokémon Gym, stylish café, hair salon, town with a mysterious air - private static ReadOnlySpan MultiLoc070 => new byte[] { 4, 9, 76 }; // town of Stow-on-Side: someone’s house, Pokémon Center, town in the mountains - private static ReadOnlySpan MultiLoc078 => new byte[] { 4, 9, 12 }; // town of Ballonlea: someone’s house, Pokémon Center, town with a mysterious air - private static ReadOnlySpan MultiLoc096 => new byte[] { 4, 6, 9, 11, 30, 31, 37 }; // town of Circhester: someone’s house, boutique, Pokémon Center, hotel, hair salon, restaurant, snowcapped town - private static ReadOnlySpan MultiLoc102 => new byte[] { 9, 77 }; // town of Spikemuth: Pokémon Center, run-down town - private static ReadOnlySpan MultiLoc110 => new byte[] { 4, 6, 9, 11, 22, 24, 30 }; // city of Wyndon: someone’s house, boutique, Pokémon Center, hotel, large town, stylish café, hair salon - private static ReadOnlySpan MultiLoc206 => new byte[] { 04, 37 }; // town of Freezington: someone’s house, snowcapped town - private static ReadOnlySpan MultiLoc220 => new byte[] { 53, 65 };// at the Crown Shrine: on a snow-swept road, in a mystical place + private static ReadOnlySpan MultiLoc006 => [ 1, 2, 3 ]; // town of Postwick: first town, at home, friend's house + private static ReadOnlySpan MultiLoc014 => [ 4, 6, 8, 9 ]; // town of Wedgehurst: someone's house, boutique, simple town, Pokémon Center + private static ReadOnlySpan MultiLoc018 => [ 16, 44, 71 ]; // Route 2: lab, tranquil road, lakeside road + private static ReadOnlySpan MultiLoc020 => [ 6, 9, 11, 20, 24, 30, 35 ]; // city of Motostoke: boutique, Pokémon Center, hotel, Pokémon Gym, stylish café, hair salon, town with a mysterious air + private static ReadOnlySpan MultiLoc024 => [ 20, 73 ];// Motostoke Stadium: Pokémon Gym, stadium + private static ReadOnlySpan MultiLoc034 => [ 9, 12 ]; // town of Turffield: Pokémon Center, town with a mysterious air + private static ReadOnlySpan MultiLoc040 => [ 44, 74 ]; // Route 5: tranquil road, Pokémon Nursery + private static ReadOnlySpan MultiLoc044 => [ 4, 9, 31, 33 ]; // town of Hulbury: someone’s house, Pokémon Center, restaurant, seaside town + private static ReadOnlySpan MultiLoc056 => [ 4, 6, 9, 20, 24, 30, 35 ]; // city of Hammerlocke: someone’s house, boutique, Pokémon Center, Pokémon Gym, stylish café, hair salon, town with a mysterious air + private static ReadOnlySpan MultiLoc070 => [ 4, 9, 76 ]; // town of Stow-on-Side: someone’s house, Pokémon Center, town in the mountains + private static ReadOnlySpan MultiLoc078 => [ 4, 9, 12 ]; // town of Ballonlea: someone’s house, Pokémon Center, town with a mysterious air + private static ReadOnlySpan MultiLoc096 => [ 4, 6, 9, 11, 30, 31, 37 ]; // town of Circhester: someone’s house, boutique, Pokémon Center, hotel, hair salon, restaurant, snowcapped town + private static ReadOnlySpan MultiLoc102 => [ 9, 77 ]; // town of Spikemuth: Pokémon Center, run-down town + private static ReadOnlySpan MultiLoc110 => [ 4, 6, 9, 11, 22, 24, 30 ]; // city of Wyndon: someone’s house, boutique, Pokémon Center, hotel, large town, stylish café, hair salon + private static ReadOnlySpan MultiLoc206 => [ 04, 37 ]; // town of Freezington: someone’s house, snowcapped town + private static ReadOnlySpan MultiLoc220 => [ 53, 65 ];// at the Crown Shrine: on a snow-swept road, in a mystical place private static bool IsMultiGenLocArea(int location, out ReadOnlySpan expect) { @@ -128,7 +125,7 @@ private static bool IsMultiGenLocArea(int location, out ReadOnlySpan expec 110 => MultiLoc110, 206 => MultiLoc206, 220 => MultiLoc220, - _ => ReadOnlySpan.Empty, + _ => [], }; private static bool IsSingleGenLocArea(int location, out byte expect) @@ -144,8 +141,8 @@ private static bool IsSingleGenLocArea(int location, out byte expect) } // {met, value allowed} - private static ReadOnlySpan SingleGenLocAreas => new byte[] - { + private static ReadOnlySpan SingleGenLocAreas => + [ // {008, 41}, // Slumbering Weald, forest // {012, 44}, // Route 1, tranquil road // {016, 28}, // Wedgehurst Station, train station @@ -253,12 +250,12 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 34, 28, 53, 00, 53, 72, 48, 53, 40, 53, 00, 44, 40, 49, 72, 72, 40, 72, 65, 65, 65, 65, 40, 28, - }; + ]; public static bool IsGeneralLocation8(byte location) => PossibleGeneralLocations8.BinarySearch(location) >= 0; - private static ReadOnlySpan PossibleGeneralLocations8 => new byte[] - { + private static ReadOnlySpan PossibleGeneralLocations8 => + [ 01, 02, 03, 04, 06, 08, 09, 11, 12, 16, 20, 22, 24, 28, 29, @@ -267,10 +264,10 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 50, 51, 53, 65, 71, 72, 73, 74, 75, 76, 77, 78, 79, - }; + ]; - private static ReadOnlySpan MemoryMinIntensity => new byte[] - { + private static ReadOnlySpan MemoryMinIntensity => + [ 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 5, @@ -280,7 +277,7 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 3, 3, 3, 3, 3, 2, 3, 4, 4, 2, // same as Gen6 2, 3, 3, 3, 3, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - }; + ]; #if FALSE // [0,99]+1 >= CHANCE -> abort @@ -288,8 +285,8 @@ private static bool IsSingleGenLocArea(int location, out byte expect) // 100% memories to fail 1% of the time // 1% memories to fail 100% of the time (!!!) // SW/SH v1.3 sub_71013B0C40 - private static ReadOnlySpan MemoryRandChance => new byte[] - { + private static ReadOnlySpan MemoryRandChance => + [ 000, 100, 100, 100, 100, 005, 005, 005, 005, 005, 005, 005, 005, 005, 010, 020, 010, 001, 050, 030, 005, 005, 020, 005, 005, 005, 001, 050, 100, 050, @@ -299,15 +296,15 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 050, 020, 020, 020, 020, 010, 010, 050, 020, 005, // same as Gen6 005, 010, 010, 020, 020, 010, 100, 010, 005, 010, 010, 010, 010, 010, 010, 010, 010, 001, 001, 001, - }; + ]; #endif /// /// 24bits of flags allowing certain feelings for a given memory index. /// /// Beware, there was an off-by-one error in the game that made Feeling 0 unobtainable, and thus the Happy feeling bit (rightmost) is omitted. - private static ReadOnlySpan MemoryFeelings => new[] - { + private static ReadOnlySpan MemoryFeelings => + [ 0x000000, 0x04CBFD, 0x004BFD, 0x04CBFD, 0x04CBFD, 0xFFFBFB, 0x84FFF9, 0x47FFFF, 0xBF7FFA, 0x7660B0, 0x80BDF9, 0x88FB7A, 0x083F79, 0x0001FE, 0xCFEFFF, 0x84EBAF, 0xB368B0, 0x091F7E, 0x0320A0, 0x080DDD, 0x081A7B, 0x404030, 0x0FFFFF, 0x9A08BC, 0x089A7B, 0x0032AA, 0x80FF7A, 0x0FFFFF, 0x0805FD, 0x098278, @@ -317,10 +314,10 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 0xB770B0, 0x881F7A, 0x839F7A, 0x839F7A, 0x839F7A, 0x53897F, 0x41BB6F, 0x0C35FF, 0x8BBF7F, 0x8BBF7F, // same as Gen6 0x90CC7E, 0x2FBF7F, 0x2FBF7F, 0xB797FF, 0x3FB7FF, 0xBFFFFF, 0xCC8BFF, 0xF69F7F, 0x37FDFF, 0x2B277F, 0x8FFBFA, 0x8CDFFA, 0xFCE9EF, 0x8F6F7B, 0x826AB0, 0x866AB0, 0x8C69FE, 0x776AB0, 0x8CFB7A, 0x0CFEBA, - }; + ]; - public static ReadOnlySpan CaptureFlagsSW => new byte[] - { + public static ReadOnlySpan CaptureFlagsSW => + [ 0xFE, 0x1F, 0x00, 0xFE, 0xFF, 0x3F, 0xFC, 0xFC, 0x1F, 0xE3, 0x0F, 0xFC, 0xCC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x18, 0xFE, 0xC7, 0x07, 0xBC, 0x44, 0xF9, 0xF0, 0x4F, 0xF0, 0xFF, 0x67, 0x9B, 0xC1, 0xCF, 0x07, 0xFC, 0xC4, 0x67, 0xC8, 0x13, 0x67, 0xFE, 0x7F, 0x98, 0x3F, 0xFA, 0xFF, @@ -329,10 +326,10 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 0xFF, 0x00, 0xF8, 0x00, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x24, 0x01, 0xC7, 0xFF, 0xFF, 0xFF, 0x1F, 0xF7, 0xBF, 0xFF, 0x69, 0x24, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCD, 0x07, - }; + ]; - public static ReadOnlySpan CaptureFlagsSH => new byte[] - { + public static ReadOnlySpan CaptureFlagsSH => + [ 0xFE, 0x1F, 0x00, 0xFE, 0xFF, 0x3F, 0xFC, 0xFC, 0x1F, 0xE3, 0x0F, 0xFC, 0xCC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x18, 0xFE, 0xC7, 0x07, 0xBC, 0x44, 0xF9, 0xF0, 0x4F, 0xF0, 0xFF, 0x67, 0x9B, 0xC1, 0xCF, 0x07, 0xFC, 0xC4, 0x67, 0xC8, 0x13, 0x67, 0xFE, 0x7F, 0x98, 0x3F, 0xFA, 0xFF, @@ -341,5 +338,5 @@ private static bool IsSingleGenLocArea(int location, out byte expect) 0xFF, 0x00, 0xF8, 0x00, 0xEC, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x24, 0x01, 0xC7, 0xFF, 0xFF, 0xFF, 0x1F, 0xF7, 0xBF, 0xFF, 0x69, 0x24, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCE, 0x07, - }; + ]; } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs index 64a577c11..f2cd58c0c 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryPermissions.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using static PKHeX.Core.Move; using static PKHeX.Core.Species; @@ -132,14 +131,14 @@ public static bool GetCanRelearnMove(PKM pk, ushort move, EntityContext context, if (context == EntityContext.Gen6) { Span result = stackalloc MoveResult[1]; - Span moves = stackalloc ushort[] { move }; + Span moves = [move]; LearnGroup6.Instance.Check(result, moves, pk, history, enc, MoveSourceType.Reminder, LearnOption.AtAnyTime); return result[0].Valid; } if (context == EntityContext.Gen8) { Span result = stackalloc MoveResult[1]; - Span moves = stackalloc ushort[] { move }; + Span moves = [move]; LearnGroup8.Instance.Check(result, moves, pk, history, enc, MoveSourceType.Reminder, LearnOption.AtAnyTime); return result[0].Valid; } @@ -165,7 +164,7 @@ private static bool GetCanKnowMove(PKM pk, ushort move, EntityContext context, E public static bool GetCanKnowMove(IEncounterTemplate enc, ushort move, EvolutionHistory history, PKM pk, ILearnGroup game) { Span result = stackalloc MoveResult[1]; - Span moves = stackalloc ushort[] { move }; + Span moves = [move]; LearnVerifierHistory.MarkAndIterate(result, moves, enc, pk, history, game, MoveSourceType.All, LearnOption.AtAnyTime); return result[0].Valid; } @@ -184,136 +183,154 @@ public static bool GetCanDynamaxTrainer(ushort species, int gen, GameVersion ver return version switch { - GameVersion.SW => DynamaxTrainer_SWSH.Contains(species) || IsDynamaxSW(species), - GameVersion.SH => DynamaxTrainer_SWSH.Contains(species) || IsDynamaxSH(species), - _ => DynamaxTrainer_SWSH.Contains(species) || IsDynamaxSW(species) || IsDynamaxSH(species), + GameVersion.SW => IsDynamaxSWSH(species) || IsDynamaxSW(species), + GameVersion.SH => IsDynamaxSWSH(species) || IsDynamaxSH(species), + _ => IsDynamaxSWSH(species) || IsDynamaxSW(species) || IsDynamaxSH(species), }; } - // exclusive to version + /// + /// Checks if the can be Dynamaxed by a trainer available exclusively in Sword. + /// private static bool IsDynamaxSW(ushort species) => species is (int)Machamp or (int)Gigalith or (int)Conkeldurr or (int)Coalossal or (int)Flapple; + + /// + /// Checks if the can be Dynamaxed by a trainer available exclusively in Sword. + /// private static bool IsDynamaxSH(ushort species) => species is (int)Gengar or (int)Lapras or (int)Dusknoir or (int)Froslass or (int)Appletun; - // common to SW & SH - private static readonly HashSet DynamaxTrainer_SWSH = new() - { - (int)Venusaur, - (int)Blastoise, - (int)Charizard, - (int)Slowbro, - (int)Gyarados, - (int)Snorlax, - (int)Slowking, - (int)Torkoal, - (int)Vespiquen, - (int)Regigigas, - (int)Garbodor, - (int)Haxorus, - (int)Tsareena, - (int)Rillaboom, - (int)Inteleon, - (int)Cinderace, - (int)Greedent, - (int)Corviknight, - (int)Eldegoss, - (int)Drednaw, - (int)Centiskorch, - (int)Hatterene, - (int)Grimmsnarl, - (int)Alcremie, - (int)Copperajah, - (int)Duraludon, - (int)Urshifu, - }; + /// + /// Checks if the can be Dynamaxed by a trainer available in both Sword and Shield. + /// + private static bool IsDynamaxSWSH(ushort species) => species is + (int)Venusaur or + (int)Blastoise or + (int)Charizard or + (int)Slowbro or + (int)Gyarados or + (int)Snorlax or + (int)Slowking or + (int)Torkoal or + (int)Vespiquen or + (int)Regigigas or + (int)Garbodor or + (int)Haxorus or + (int)Tsareena or + (int)Rillaboom or + (int)Inteleon or + (int)Cinderace or + (int)Greedent or + (int)Corviknight or + (int)Eldegoss or + (int)Drednaw or + (int)Centiskorch or + (int)Hatterene or + (int)Grimmsnarl or + (int)Alcremie or + (int)Copperajah or + (int)Duraludon or + (int)Urshifu + ; public static bool GetCanFishSpecies(ushort species, EntityContext context, GameVersion version) => context switch { EntityContext.Gen6 => version switch { - GameVersion.Any => FishingSpecies_XY.Contains(species) || FishingSpecies_AO.Contains(species) - || IsFishingSpeciesX(species) || IsFishingSpeciesY(species), + GameVersion.Any => IsFishingSpeciesXY(species) || IsFishingSpeciesAO(species) + || IsFishingSpeciesX(species) || IsFishingSpeciesY(species), - GameVersion.X => FishingSpecies_XY.Contains(species) || IsFishingSpeciesX(species), - GameVersion.Y => FishingSpecies_XY.Contains(species) || IsFishingSpeciesY(species), + GameVersion.X => IsFishingSpeciesXY(species) || IsFishingSpeciesX(species), + GameVersion.Y => IsFishingSpeciesXY(species) || IsFishingSpeciesY(species), - GameVersion.OR or GameVersion.AS => FishingSpecies_AO.Contains(species), + GameVersion.OR or GameVersion.AS => IsFishingSpeciesAO(species), _ => false, }, EntityContext.Gen8 => version switch { - GameVersion.Any or GameVersion.SW or GameVersion.SH => FishingSpecies_SWSH.Contains(species), + GameVersion.Any or GameVersion.SW or GameVersion.SH => IsFishingSpeciesSWSH(species), _ => false, }, _ => false, }; - private static readonly HashSet FishingSpecies_SWSH = new() - { - (int)Shellder, (int)Cloyster, - (int)Krabby, - (int)Goldeen, - (int)Magikarp, (int)Gyarados, - (int)Lapras, - (int)Dratini, - (int)Chinchou, (int)Lanturn, - (int)Qwilfish, - (int)Remoraid, (int)Octillery, - (int)Carvanha, (int)Sharpedo, - (int)Wailmer, (int)Wailord, - (int)Barboach, (int)Whiscash, - (int)Corphish, - (int)Lileep, - (int)Feebas, - (int)Mantyke, (int)Mantine, - (int)Basculin, - (int)Wishiwashi, - (int)Mareanie, - (int)Pyukumuku, - (int)Dhelmise, - (int)Chewtle, (int)Drednaw, - (int)Arrokuda, (int)Barraskewda, - }; + /// + /// Checks if the can be fished in either or . + /// + private static bool IsFishingSpeciesSWSH(ushort species) => species is + (int)Shellder or (int)Cloyster or + (int)Krabby or + (int)Goldeen or + (int)Magikarp or (int)Gyarados or + (int)Lapras or + (int)Dratini or + (int)Chinchou or (int)Lanturn or + (int)Qwilfish or + (int)Remoraid or (int)Octillery or + (int)Carvanha or (int)Sharpedo or + (int)Wailmer or (int)Wailord or + (int)Barboach or (int)Whiscash or + (int)Corphish or + (int)Lileep or + (int)Feebas or + (int)Mantyke or (int)Mantine or + (int)Basculin or + (int)Wishiwashi or + (int)Mareanie or + (int)Pyukumuku or + (int)Dhelmise or + (int)Chewtle or (int)Drednaw or + (int)Arrokuda or (int)Barraskewda + ; - private static readonly HashSet FishingSpecies_AO = new() - { - (int)Tentacool, - (int)Horsea, (int)Seadra, - (int)Goldeen, (int)Seaking, - (int)Staryu, - (int)Magikarp, (int)Gyarados, - (int)Corsola, - (int)Remoraid, (int)Octillery, - (int)Carvanha, (int)Sharpedo, - (int)Wailmer, - (int)Barboach, (int)Whiscash, - (int)Corphish, (int)Crawdaunt, - (int)Feebas, - (int)Luvdisc, - }; + /// + /// Checks if the can be fished in either or . + /// + public static bool IsFishingSpeciesAO(ushort species) => species is + (int)Tentacool or + (int)Horsea or (int)Seadra or + (int)Goldeen or (int)Seaking or + (int)Staryu or + (int)Magikarp or (int)Gyarados or + (int)Corsola or + (int)Remoraid or (int)Octillery or + (int)Carvanha or (int)Sharpedo or + (int)Wailmer or + (int)Barboach or (int)Whiscash or + (int)Corphish or (int)Crawdaunt or + (int)Feebas or + (int)Luvdisc + ; - // exclusive to version - private static bool IsFishingSpeciesX(ushort species) => species is (int)Staryu or (int)Starmie or (int)Huntail or (int)Clauncher or (int)Clawitzer; - private static bool IsFishingSpeciesY(ushort species) => species is (int)Shellder or (int)Cloyster or (int)Gorebyss or (int)Skrelp or (int)Dragalge; + /// + /// Checks if the can be fished in only . + /// + public static bool IsFishingSpeciesX(ushort species) => species is (int)Staryu or (int)Starmie or (int)Huntail or (int)Clauncher or (int)Clawitzer; - // common to X & Y - private static readonly HashSet FishingSpecies_XY = new() - { - (int)Poliwag, (int)Poliwhirl, (int)Poliwrath, (int)Politoed, - (int)Horsea, (int)Seadra, - (int)Goldeen, (int)Seaking, - (int)Magikarp, (int)Gyarados, - (int)Dratini, (int)Dragonair, - (int)Chinchou, (int)Lanturn, - (int)Qwilfish, - (int)Corsola, - (int)Remoraid, (int)Octillery, - (int)Carvanha, (int)Sharpedo, - (int)Barboach, (int)Whiscash, - (int)Corphish, (int)Crawdaunt, - (int)Clamperl, - (int)Relicanth, - (int)Luvdisc, - (int)Basculin, - (int)Alomomola, - }; + /// + /// Checks if the can be fished in only . + /// + public static bool IsFishingSpeciesY(ushort species) => species is (int)Shellder or (int)Cloyster or (int)Gorebyss or (int)Skrelp or (int)Dragalge; + + /// + /// Checks if the can be fished in both and . + /// + public static bool IsFishingSpeciesXY(ushort species) => species is + (int)Poliwag or (int)Poliwhirl or (int)Poliwrath or (int)Politoed or + (int)Horsea or (int)Seadra or + (int)Goldeen or (int)Seaking or + (int)Magikarp or (int)Gyarados or + (int)Dratini or (int)Dragonair or + (int)Chinchou or (int)Lanturn or + (int)Qwilfish or + (int)Corsola or + (int)Remoraid or (int)Octillery or + (int)Carvanha or (int)Sharpedo or + (int)Barboach or (int)Whiscash or + (int)Corphish or (int)Crawdaunt or + (int)Clamperl or + (int)Relicanth or + (int)Luvdisc or + (int)Basculin or + (int)Alomomola + ; } diff --git a/PKHeX.Core/Legality/Restrictions/Memories/MemoryVariableSet.cs b/PKHeX.Core/Legality/Restrictions/Memories/MemoryVariableSet.cs index db205b268..2dc6cc4a6 100644 --- a/PKHeX.Core/Legality/Restrictions/Memories/MemoryVariableSet.cs +++ b/PKHeX.Core/Legality/Restrictions/Memories/MemoryVariableSet.cs @@ -1,3 +1,5 @@ +using static PKHeX.Core.LegalityCheckStrings; + namespace PKHeX.Core; /// @@ -12,8 +14,8 @@ namespace PKHeX.Core; { public static MemoryVariableSet Read(ITrainerMemories pk, int handler) => handler switch { - 0 => new MemoryVariableSet(LegalityCheckStrings.L_XOT, pk.OT_Memory, pk.OT_TextVar, pk.OT_Intensity, pk.OT_Feeling), // OT - 1 => new MemoryVariableSet(LegalityCheckStrings.L_XHT, pk.HT_Memory, pk.HT_TextVar, pk.HT_Intensity, pk.HT_Feeling), // HT - _ => new MemoryVariableSet(LegalityCheckStrings.L_XOT, 0, 0, 0, 0), + 0 => new(L_XOT, pk.OT_Memory, pk.OT_TextVar, pk.OT_Intensity, pk.OT_Feeling), // OT + 1 => new(L_XHT, pk.HT_Memory, pk.HT_TextVar, pk.HT_Intensity, pk.HT_Feeling), // HT + _ => new(L_XOT, 0, 0, 0, 0), }; } diff --git a/PKHeX.Core/Legality/Restrictions/Vivillon3DS.cs b/PKHeX.Core/Legality/Restrictions/Vivillon3DS.cs index 673c4e3c8..07e9b90e4 100644 --- a/PKHeX.Core/Legality/Restrictions/Vivillon3DS.cs +++ b/PKHeX.Core/Legality/Restrictions/Vivillon3DS.cs @@ -14,8 +14,8 @@ public static class Vivillon3DS /// /// List of valid regions as bitflags indexed by Vivillon form. /// - private static ReadOnlySpan VivillonRegionTable => new[] - { + private static ReadOnlySpan VivillonRegionTable => + [ /* 0 Icy Snow */ Americas | Europe, /* 1 Polar */ Americas | Europe | China, /* 2 Tundra */ Japan | Europe, @@ -34,7 +34,7 @@ public static class Vivillon3DS /*15 Sun */ Americas | Europe, /*16 Ocean */ Americas | Europe, /*17 Jungle */ Americas | Europe, - }; + ]; private static Region3DSFlags GetConsoleRegionFlag(in byte consoleRegion) => (Region3DSFlags)(1 << consoleRegion); @@ -97,20 +97,20 @@ public static byte GetPattern(in byte country, in byte region) } // The game stores an equirectangular projection byte map of forms, laid out over a map of Earth. - // The game then determines form based on the player's selected Country and Region via its latitude and longitude stored in the 3DS' system files. + // The game then determines form based on the player's selected Country and Region via its latitude and longitude stored in the 3DS's system files. // Since we have dumped these country,region->latitude,longitude mappings, we can determine the form that would be obtained in-game. // Using the data from @abcboy101 located here: https://github.com/abcboy101/vivillon/blob/main/data_points.json // Provide efficient and quick lookups for checking if a form can originate from a given country/region. // Reminder: Vivillon form is set when you start the Save File. Changing Country/Region after will update Country/Region for OT, not the form available. // 93 countries have the same form. This is about half the total amount of countries [0,186]. - // Instead of doing a index = lookup(country) -> form[index], can do array[country] with a sentinel to indicate the country is different by region. + // Instead of doing an index = lookup(country) -> form[index], can do array[country] with a sentinel to indicate the country is different by region. // This results in O(1) performance, better than O(log(n)) for the binary search approach. // None of the these countries with same form have form 0, so we can use that as a sentinel value. private const byte XX = 0; - private static ReadOnlySpan SameCountry => new byte[] - { + private static ReadOnlySpan SameCountry => + [ XX, XX, XX, XX, XX, XX, XX, XX, 09, 09, XX, 09, 09, 09, 15, 14, XX, 09, XX, 15, XX, XX, XX, 09, 09, 17, 15, 17, 09, 09, 15, 17, 09, 15, 09, 09, XX, 09, 09, 15, 17, 14, XX, 09, 09, 09, 17, 09, @@ -123,13 +123,13 @@ public static byte GetPattern(in byte country, in byte region) 03, XX, XX, XX, XX, XX, XX, XX, XX, 17, XX, XX, 17, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, 11, XX, XX, XX, XX, XX, 11, XX, XX, XX, XX, XX, XX, XX, XX, XX, 08, 08, 07, - }; + ]; // (country:X2_region:X2) // do it this way instead of region_country so that the byte[] form is better ordered for better file compression :) // 777 entries, so we can use a binary search to find the form. Worst case is log2(777) = 10 comparisons. - private static ReadOnlySpan DiffCountryRegion => new ushort[] - { + private static ReadOnlySpan DiffCountryRegion => + [ 0x0100, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F, 0x0110, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F, 0x0120, 0x0121, 0x0122, 0x0123, 0x0124, 0x0125, 0x0126, 0x0127, 0x0128, 0x0129, 0x012A, 0x012B, 0x012C, 0x012D, 0x012E, 0x012F, 0x0130, @@ -179,10 +179,10 @@ public static byte GetPattern(in byte country, in byte region) 0xA01B, 0xA01D, 0xA01E, 0xA01F, 0xA020, 0xA021, 0xA900, 0xA902, 0xA903, 0xA904, 0xA905, 0xA906, 0xA907, 0xA908, 0xA909, 0xA90A, 0xA90C, 0xA90D, 0xA90E, 0xA90F, 0xA910, 0xA911, 0xA912, 0xA913, 0xA914, 0xA915, 0xA916, 0xA917, 0xA918, 0xA919, 0xA91A, 0xA91C, 0xA91D, 0xA91E, 0xA91F, 0xA920, 0xA921, 0xA922, 0xA923, 0xA924, 0xA925, - }; + ]; - private static ReadOnlySpan DiffForm => new byte[] - { + private static ReadOnlySpan DiffForm => + [ 05, 05, 02, 02, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 03, 05, 05, 05, 05, 13, @@ -232,7 +232,7 @@ public static byte GetPattern(in byte country, in byte region) 03, 13, 10, 03, 10, 13, 13, 13, 13, 13, 13, 03, 13, 13, 03, 03, 17, 13, 13, 13, 13, 13, 13, 13, 13, 03, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 03, 13, - }; + ]; } /// diff --git a/PKHeX.Core/Legality/Structures/LegalInfo.cs b/PKHeX.Core/Legality/Structures/LegalInfo.cs index 52b71f429..2b3cfb14b 100644 --- a/PKHeX.Core/Legality/Structures/LegalInfo.cs +++ b/PKHeX.Core/Legality/Structures/LegalInfo.cs @@ -62,11 +62,11 @@ internal set public bool PIDParsed { get; private set; } private PIDIV _pidiv; - /// Indicates whether or not the can originate from the . + /// Indicates whether the can originate from the . /// This boolean is true until all valid encounters are tested, after which it is false. public bool PIDIVMatches { get; internal set; } = true; - /// Indicates whether or not the can originate from the with explicit RNG matching. + /// Indicates whether the can originate from the with explicit RNG matching. /// This boolean is true until all valid entries are tested for all possible matches, after which it is false. public bool FrameMatches { get; internal set; } = true; diff --git a/PKHeX.Core/Legality/Structures/Severity.cs b/PKHeX.Core/Legality/Structures/Severity.cs index c2bc74298..75b5998cb 100644 --- a/PKHeX.Core/Legality/Structures/Severity.cs +++ b/PKHeX.Core/Legality/Structures/Severity.cs @@ -29,7 +29,7 @@ public enum Severity : sbyte public static partial class Extensions { /// - /// Converts a Check result Severity determination (Valid/Invalid/etc) to the localized string. + /// Converts a Check result Severity determination (Valid/Invalid/etc.) to the localized string. /// /// value to convert to string. /// Localized . diff --git a/PKHeX.Core/Legality/Tables/FormChangeUtil.cs b/PKHeX.Core/Legality/Tables/FormChangeUtil.cs index 9f75e74dd..d5322b46a 100644 --- a/PKHeX.Core/Legality/Tables/FormChangeUtil.cs +++ b/PKHeX.Core/Legality/Tables/FormChangeUtil.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace PKHeX.Core; @@ -18,7 +17,7 @@ public static class FormChangeUtil public static bool ShouldIterateForms(ushort species, byte form, int generation, LearnOption option) { if (option.IsPast()) - return FormChangeMoves.TryGetValue(species, out var func) && func((generation, form)); + return IsFormChangeDifferentMoves(species, generation); return IterateAllForms(species); } @@ -27,34 +26,36 @@ public static bool ShouldIterateForms(ushort species, byte form, int generation, /// /// Species that can change between their forms and get access to form-specific moves. /// - private static ReadOnlySpan FormChangeMovesRetain => new ushort[] - { + private static ReadOnlySpan FormChangeMovesRetain => + [ (int)Species.Deoxys, (int)Species.Giratina, (int)Species.Shaymin, (int)Species.Hoopa, - }; + ]; /// /// Species that can change between their forms and get access to form-specific moves. /// - private static readonly Dictionary> FormChangeMoves = new() + private static bool IsFormChangeDifferentMoves(ushort species, int generation) => species switch { - {(int)Species.Deoxys, g => g.Generation >= 6}, - {(int)Species.Giratina, g => g.Generation >= 6}, - {(int)Species.Shaymin, g => g.Generation >= 6}, - {(int)Species.Rotom, g => g.Generation >= 6}, - {(int)Species.Hoopa, g => g.Generation >= 6}, - {(int)Species.Tornadus, g => g.Generation >= 6}, - {(int)Species.Thundurus,g => g.Generation >= 6}, - {(int)Species.Landorus, g => g.Generation >= 6}, - {(int)Species.Urshifu, g => g.Generation >= 8}, - {(int)Species.Enamorus, g => g.Generation >= 8}, + (int)Species.Deoxys => generation >= 6, + (int)Species.Giratina => generation >= 6, + (int)Species.Shaymin => generation >= 6, + (int)Species.Rotom => generation >= 6, + (int)Species.Hoopa => generation >= 6, + (int)Species.Tornadus => generation >= 6, + (int)Species.Thundurus => generation >= 6, + (int)Species.Landorus => generation >= 6, + (int)Species.Urshifu => generation >= 8, + (int)Species.Enamorus => generation >= 8, // Fuse - {(int)Species.Kyurem, g => g.Generation >= 6}, - {(int)Species.Necrozma, g => g.Generation >= 8}, - {(int)Species.Calyrex, g => g.Generation >= 8}, + (int)Species.Kyurem => generation >= 6, + (int)Species.Necrozma => generation >= 8, + (int)Species.Calyrex => generation >= 8, - {(int)Species.Pikachu, g => g.Generation == 6}, + (int)Species.Pikachu => generation == 6, + + _ => false, }; } diff --git a/PKHeX.Core/Legality/Tables/FormInfo.cs b/PKHeX.Core/Legality/Tables/FormInfo.cs index 60430be57..b244c2715 100644 --- a/PKHeX.Core/Legality/Tables/FormInfo.cs +++ b/PKHeX.Core/Legality/Tables/FormInfo.cs @@ -10,7 +10,7 @@ namespace PKHeX.Core; public static class FormInfo { /// - /// Checks if the form cannot exist outside of a Battle. + /// Checks if the form cannot exist outside a Battle. /// /// Entity species /// Entity form @@ -55,7 +55,7 @@ public static class FormInfo /// Entity form /// Entity form argument /// Current generation format - /// True if it trading should be disallowed. + /// True if trading should be disallowed. public static bool IsUntradable(ushort species, byte form, uint formArg, int format) => species switch { (ushort)Koraidon or (int)Miraidon => formArg == 1, // Ride-able Box Legend @@ -79,7 +79,7 @@ public static class FormInfo _ => false, }; - /// Checks if the form may be different than the original encounter detail. + /// Checks if the form may be different from the original encounter detail. /// Original species /// Original form /// Current form @@ -106,28 +106,28 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm, if (species is (int)Deerling or (int)Sawsbuck) { if (origin == EntityContext.Gen5) - return true; // B/W + return true; // B/W or B2/W2 change via seasons if (current.Generation() >= 8) - return true; // Via S/V + return true; // Via S/V change via in-game province on startup. } return false; } public static bool IsFormChangeEgg(ushort species) => FormChangeEgg.Contains(species); - private static ReadOnlySpan FormChangeEgg => new ushort[] - { + private static ReadOnlySpan FormChangeEgg => + [ (int)Burmy, (int)Furfrou, (int)Oricorio, - }; + ]; /// /// Species that can change between their forms, regardless of origin. /// /// Excludes Zygarde as it has special conditions. Check separately. - private static readonly HashSet FormChange = new() - { + private static readonly HashSet FormChange = + [ (int)Burmy, (int)Furfrou, (int)Oricorio, @@ -153,17 +153,22 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm, (int)Calyrex, (int)Enamorus, (int)Ogerpon, - }; + ]; /// /// Species that have an alternate form that cannot exist outside of battle. /// - private static readonly HashSet BattleForms = new() - { + private static ReadOnlySpan BattleForms => + [ (int)Castform, + (int)Kyogre, + (int)Groudon, + (int)Cherrim, + (int)Darmanitan, (int)Meloetta, + (int)Aegislash, (int)Xerneas, (int)Zygarde, @@ -171,26 +176,26 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm, (int)Wishiwashi, (int)Minior, (int)Mimikyu, + (int)Necrozma, (int)Cramorant, (int)Morpeko, (int)Eiscue, - (int)Zacian, (int)Zamazenta, (int)Eternatus, (int)Palafin, (int)Ogerpon, - }; + ]; /// /// Species that have a mega form that cannot exist outside of battle. /// /// Using a held item to change form during battle, via an in-battle transformation feature. - private static readonly HashSet BattleMegas = new() - { - // XY + private static ReadOnlySpan BattleMegas => + [ + // X/Y (int)Venusaur, (int)Charizard, (int)Blastoise, (int)Alakazam, (int)Gengar, (int)Kangaskhan, (int)Pinsir, (int)Gyarados, (int)Aerodactyl, (int)Mewtwo, @@ -202,7 +207,7 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm, (int)Garchomp, (int)Lucario, (int)Abomasnow, - // AO + // OR/AS (int)Beedrill, (int)Pidgeot, (int)Slowbro, (int)Steelix, @@ -212,21 +217,20 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm, (int)Lopunny, (int)Gallade, (int)Audino, (int)Diancie, - - // USUM - (int)Necrozma, // Ultra Necrozma - }; + ]; private static readonly HashSet BattleOnly = GetBattleFormSet(); private static HashSet GetBattleFormSet() { - var hs = new HashSet(BattleForms); - hs.UnionWith(BattleMegas); - - // Primals - hs.Add((ushort)Kyogre); - hs.Add((ushort)Groudon); + var reg = BattleForms; + var mega = BattleMegas; + var count = reg.Length + mega.Length + 2; + var hs = new HashSet(count); + foreach (var species in reg) + hs.Add(species); + foreach (var species in mega) + hs.Add(species); return hs; } @@ -332,7 +336,7 @@ public static bool IsLordForm(ushort species, byte form, EntityContext context) /// Game specific personal info /// ID /// ID - /// True if has forms that can be provided by , otherwise false for none. + /// True if it has forms that can be provided by , otherwise false for none. public static bool HasFormSelection(IPersonalFormInfo pi, ushort species, int format) { if (format <= 3 && species != (int)Unown) diff --git a/PKHeX.Core/Legality/Tables/FormItem.cs b/PKHeX.Core/Legality/Tables/FormItem.cs index 4d6ed218d..b2eec090a 100644 --- a/PKHeX.Core/Legality/Tables/FormItem.cs +++ b/PKHeX.Core/Legality/Tables/FormItem.cs @@ -8,8 +8,8 @@ namespace PKHeX.Core; /// public static class FormItem { - private static ReadOnlySpan Arceus_PlateIDs => new ushort[] { 303, 306, 304, 305, 309, 308, 310, 313, 298, 299, 301, 300, 307, 302, 311, 312, 644 }; - private static ReadOnlySpan Arceus_ZCrystal => new ushort[] { 782, 785, 783, 784, 788, 787, 789, 792, 777, 778, 780, 779, 786, 781, 790, 791, 793 }; + private static ReadOnlySpan Arceus_PlateIDs => [303, 306, 304, 305, 309, 308, 310, 313, 298, 299, 301, 300, 307, 302, 311, 312, 644]; + private static ReadOnlySpan Arceus_ZCrystal => [782, 785, 783, 784, 788, 787, 789, 792, 777, 778, 780, 779, 786, 781, 790, 791, 793]; /// /// Gets the form for based on the held item. diff --git a/PKHeX.Core/Legality/Tables/MystryMew.cs b/PKHeX.Core/Legality/Tables/MystryMew.cs index 3da065745..ece8e92f9 100644 --- a/PKHeX.Core/Legality/Tables/MystryMew.cs +++ b/PKHeX.Core/Legality/Tables/MystryMew.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// public static class MystryMew { - private static ReadOnlySpan Seeds => new ushort[] - { + private static ReadOnlySpan Seeds => + [ 0x0652, 0x0932, 0x0C13, 0x0D43, 0x0EEE, 0x1263, 0x13C9, 0x1614, 0x1C09, 0x1EA5, 0x20BF, 0x2389, 0x2939, 0x302D, 0x306E, @@ -31,7 +31,7 @@ public static class MystryMew 0xEE7F, 0xEE9F, 0xEFC8, 0xF0E4, 0xFE4E, 0xFE9D, - }; + ]; //private const int FramesPerMew = 5; private const int MewPerRestrictedSeed = 5; diff --git a/PKHeX.Core/Legality/Tables/SpeciesCategory.cs b/PKHeX.Core/Legality/Tables/SpeciesCategory.cs index 42225c865..3461af661 100644 --- a/PKHeX.Core/Legality/Tables/SpeciesCategory.cs +++ b/PKHeX.Core/Legality/Tables/SpeciesCategory.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using static PKHeX.Core.Species; namespace PKHeX.Core; @@ -11,57 +10,50 @@ public static class SpeciesCategory /// /// Checks if a Species is classified as a Mythical Distributions (disallowed species for competitive rulesets) /// - public static bool IsMythical(ushort species) => Mythicals.Contains(species); + public static bool IsMythical(ushort species) => species is + (int)Mew or + (int)Celebi or + (int)Jirachi or (int)Deoxys or + (int)Phione or (int)Manaphy or (int)Darkrai or (int)Shaymin or (int)Arceus or + (int)Victini or (int)Keldeo or (int)Meloetta or (int)Genesect or + (int)Diancie or (int)Hoopa or (int)Volcanion or + (int)Magearna or (int)Marshadow or + (int)Zeraora or (int)Meltan or (int)Melmetal or + (int)Zarude + ; /// /// Checks if a Species is classified as "Legend" by the game code. /// /// Previous games may have included Mythicals in this species list, but that list should be considered separately. - public static bool IsLegendary(ushort species) => Legends.Contains(species); + public static bool IsLegendary(ushort species) => species is + + (int)Mewtwo or + (int)Lugia or (int)HoOh or + (int)Kyogre or (int)Groudon or (int)Rayquaza or + (int)Dialga or (int)Palkia or (int)Giratina or + (int)Reshiram or (int)Zekrom or (int)Kyurem or + (int)Xerneas or (int)Yveltal or (int)Zygarde or + (int)Cosmog or (int)Cosmoem or (int)Solgaleo or (int)Lunala or (int)Necrozma or + (int)Zacian or (int)Zamazenta or (int)Eternatus or (int)Calyrex or + (int)Koraidon or (int)Miraidon + ; /// /// Checks if a Species is classified as "SubLegend" by the game code. /// - public static bool IsSubLegendary(ushort species) => SubLegends.Contains(species); + public static bool IsSubLegendary(ushort species) => species is - private static readonly HashSet Mythicals = new() - { - (int)Mew, - (int)Celebi, - (int)Jirachi, (int)Deoxys, - (int)Phione, (int)Manaphy, (int)Darkrai, (int)Shaymin, (int)Arceus, - (int)Victini, (int)Keldeo, (int)Meloetta, (int)Genesect, - (int)Diancie, (int)Hoopa, (int)Volcanion, - (int)Magearna, (int)Marshadow, - (int)Zeraora, (int)Meltan, (int)Melmetal, - (int)Zarude, - }; - - private static readonly HashSet Legends = new() - { - (int)Mewtwo, - (int)Lugia, (int)HoOh, - (int)Kyogre, (int)Groudon, (int)Rayquaza, - (int)Dialga, (int)Palkia, (int)Giratina, - (int)Reshiram, (int)Zekrom, (int)Kyurem, - (int)Xerneas, (int)Yveltal, (int)Zygarde, - (int)Cosmog, (int)Cosmoem, (int)Solgaleo, (int)Lunala, (int)Necrozma, - (int)Zacian, (int)Zamazenta, (int)Eternatus, (int)Calyrex, - (int)Koraidon, (int)Miraidon, - }; - - private static readonly HashSet SubLegends = new() - { - (int)Articuno, (int)Zapdos, (int)Moltres, - (int)Raikou, (int)Entei, (int)Suicune, - (int)Regirock, (int)Regice, (int)Registeel, (int)Latias, (int)Latios, - (int)Uxie, (int)Mesprit, (int)Azelf, (int)Heatran, (int)Regigigas, (int)Cresselia, - (int)Cobalion, (int)Terrakion, (int)Virizion, (int)Tornadus, (int)Thundurus, (int)Landorus, - (int)TypeNull, (int)Silvally, (int)TapuKoko, (int)TapuLele, (int)TapuBulu, (int)TapuFini, - (int)Kubfu, (int)Urshifu, (int)Regieleki, (int)Regidrago, (int)Glastrier, (int)Spectrier, (int)Enamorus, - (int)WoChien, (int)ChienPao, (int)TingLu, (int)ChiYu, - (int)Okidogi, (int)Munkidori, (int)Fezandipiti, (int)Ogerpon, - }; + (int)Articuno or (int)Zapdos or (int)Moltres or + (int)Raikou or (int)Entei or (int)Suicune or + (int)Regirock or (int)Regice or (int)Registeel or (int)Latias or (int)Latios or + (int)Uxie or (int)Mesprit or (int)Azelf or (int)Heatran or (int)Regigigas or (int)Cresselia or + (int)Cobalion or (int)Terrakion or (int)Virizion or (int)Tornadus or (int)Thundurus or (int)Landorus or + (int)TypeNull or (int)Silvally or (int)TapuKoko or (int)TapuLele or (int)TapuBulu or (int)TapuFini or + (int)Kubfu or (int)Urshifu or (int)Regieleki or (int)Regidrago or (int)Glastrier or (int)Spectrier or (int)Enamorus or + (int)WoChien or (int)ChienPao or (int)TingLu or (int)ChiYu or + (int)Okidogi or (int)Munkidori or (int)Fezandipiti or (int)Ogerpon + ; /// /// Checks if the is an Ultra Beast Pokémon. diff --git a/PKHeX.Core/Legality/Verifiers/Ability/AbilityBreedLegality.cs b/PKHeX.Core/Legality/Verifiers/Ability/AbilityBreedLegality.cs index e314380a4..dbb159828 100644 --- a/PKHeX.Core/Legality/Verifiers/Ability/AbilityBreedLegality.cs +++ b/PKHeX.Core/Legality/Verifiers/Ability/AbilityBreedLegality.cs @@ -8,8 +8,8 @@ namespace PKHeX.Core; /// internal static class AbilityBreedLegality { - private static ReadOnlySpan BanHidden5 => new byte[] - { + private static ReadOnlySpan BanHidden5 => + [ 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x10, 0x20, 0x00, 0x01, 0x11, 0x02, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x90, 0x04, @@ -18,7 +18,7 @@ internal static class AbilityBreedLegality 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x82, 0x24, 0x80, 0x0A, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xA0, 0x84, 0x80, 0x40, 0x08, 0x12, - }; + ]; /// /// Species that cannot be bred with a Hidden Ability originating in diff --git a/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs b/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs index 21fa3dcd5..6b7a2d187 100644 --- a/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/Ability/AbilityVerifier.cs @@ -218,7 +218,7 @@ private AbilityState VerifyAbilityPreCapsule(LegalityAnalysis data, IPersonalAbi // Gen3 origin... a lot of edge cases to check. var pk = data.Entity; var format = pk.Format; - // CXD pokemon can have any ability without matching PID + // CXD Pokémon can have any ability without matching PID if (format == 3) { if (pk.Version == (int)GameVersion.CXD) @@ -235,7 +235,7 @@ private AbilityState VerifyAbilityPreCapsule(LegalityAnalysis data, IPersonalAbi if (g3.Length == 0) return AbilityState.MustMatch; - // Fall through when gen3 pk transferred to gen4/5 + // Fall through when Gen3 pk transferred to Gen4/5 var maxGen3Species = g3[0].Species; return VerifyAbilityGen3Transfer(data, abilities, maxGen3Species); } diff --git a/PKHeX.Core/Legality/Verifiers/Ball/BallContext6.cs b/PKHeX.Core/Legality/Verifiers/Ball/BallContext6.cs index 7d0634d4a..fc24aa986 100644 --- a/PKHeX.Core/Legality/Verifiers/Ball/BallContext6.cs +++ b/PKHeX.Core/Legality/Verifiers/Ball/BallContext6.cs @@ -138,8 +138,8 @@ public BallInheritanceResult CanBreedWithBall(ushort species, byte form, Ball ba _ => BallType.None, }; - public static ReadOnlySpan Permit => new byte[] - { + public static ReadOnlySpan Permit => + [ 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3B, 0x03, 0x03, 0x3B, 0x03, 0x03, 0x2F, 0x03, 0x03, 0x2F, // 000 - 019 0x03, 0x2F, 0x03, 0x2F, 0x03, 0x03, 0x03, 0x2F, 0x03, 0x2F, 0x03, 0x03, 0x2F, 0x03, 0x03, 0x03, 0x03, 0x2B, 0x03, 0x03, // 020 - 039 0x03, 0x2F, 0x03, 0x2F, 0x03, 0x03, 0x3F, 0x03, 0x3F, 0x03, 0x2F, 0x03, 0x2B, 0x03, 0x2F, 0x03, 0x2B, 0x03, 0x2B, 0x03, // 040 - 059 @@ -176,7 +176,7 @@ public BallInheritanceResult CanBreedWithBall(ushort species, byte form, Ball ba 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, // 660 - 679 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x03, 0x00, 0x03, // 680 - 699 0x03, 0x03, 0x03, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, - }; + ]; private enum BallType : byte { diff --git a/PKHeX.Core/Legality/Verifiers/Ball/BallContext7.cs b/PKHeX.Core/Legality/Verifiers/Ball/BallContext7.cs index 909f979d1..b6b38d3f0 100644 --- a/PKHeX.Core/Legality/Verifiers/Ball/BallContext7.cs +++ b/PKHeX.Core/Legality/Verifiers/Ball/BallContext7.cs @@ -169,8 +169,8 @@ public BallInheritanceResult CanBreedWithBall(ushort species, byte form, Ball ba _ => BallType.None, }; - public static ReadOnlySpan Permit => new byte[] - { + public static ReadOnlySpan Permit => + [ 0x00, 0x6B, 0x03, 0x03, 0x6B, 0x03, 0x03, 0x6B, 0x03, 0x03, 0x7B, 0x03, 0x03, 0x7B, 0x03, 0x03, 0x6F, 0x03, 0x03, 0x6F, // 000-019 0x03, 0x6F, 0x03, 0x6F, 0x03, 0x03, 0x03, 0x6F, 0x03, 0x2F, 0x03, 0x03, 0x2F, 0x03, 0x03, 0x03, 0x03, 0x6B, 0x03, 0x4B, // 020-039 0x03, 0x6F, 0x03, 0x2F, 0x03, 0x03, 0x7F, 0x03, 0x3F, 0x03, 0x6F, 0x03, 0x6B, 0x03, 0x6F, 0x03, 0x6B, 0x03, 0x6B, 0x03, // 040-059 @@ -211,7 +211,7 @@ public BallInheritanceResult CanBreedWithBall(ushort species, byte form, Ball ba 0x43, 0x4B, 0x4B, 0x43, 0x4B, 0x43, 0x4B, 0x4B, 0x43, 0x4B, 0x43, 0x4B, 0x43, 0x4B, 0x43, 0x4B, 0x43, 0x4B, 0x43, 0x4B, // 740-759 0x43, 0x4B, 0x43, 0x43, 0x4B, 0x4B, 0x4B, 0x4B, 0x43, 0x4B, 0x43, 0x4B, 0x00, 0x00, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, // 760-779 0x4B, 0x4B, 0x4B, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 780-799 - }; + ]; private enum BallType : byte { diff --git a/PKHeX.Core/Legality/Verifiers/Ball/BallContextHOME.cs b/PKHeX.Core/Legality/Verifiers/Ball/BallContextHOME.cs index 6243f7d3f..17fa827d2 100644 --- a/PKHeX.Core/Legality/Verifiers/Ball/BallContextHOME.cs +++ b/PKHeX.Core/Legality/Verifiers/Ball/BallContextHOME.cs @@ -88,8 +88,8 @@ public static bool IsAbilityPatchPossible(int format, ushort species) _ => BallType.None, }; - public static ReadOnlySpan Permit => new byte[] - { + public static ReadOnlySpan Permit => + [ 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7B, 0x0B, 0x0B, 0x6F, 0x0B, 0x0B, 0x6F, // 000-019 0x0B, 0x6F, 0x0B, 0x6F, 0x6B, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, // 020-039 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x0B, 0x7F, 0x6B, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x6B, 0x6B, 0x7F, 0x7F, // 040-059 @@ -141,7 +141,7 @@ public static bool IsAbilityPatchPossible(int format, ushort species) 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, // 960-979 0x6B, 0x6B, 0x6B, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6B, 0x6B, 0x6B, 0x00, // 980-999 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6B, 0x6B, 0x6B, - }; + ]; private enum BallType : byte { diff --git a/PKHeX.Core/Legality/Verifiers/Ball/BallUseLegality.cs b/PKHeX.Core/Legality/Verifiers/Ball/BallUseLegality.cs index 13793639c..25795b6a1 100644 --- a/PKHeX.Core/Legality/Verifiers/Ball/BallUseLegality.cs +++ b/PKHeX.Core/Legality/Verifiers/Ball/BallUseLegality.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.Ball; namespace PKHeX.Core; @@ -15,7 +14,7 @@ internal static class BallUseLegality /// True if it is impossible to capture in a ball. public static bool IsAlolanCaptureNoHeavyBall(ushort species) => species is (int)Species.Beldum or (int)Species.TapuKoko or (int)Species.TapuLele or (int)Species.TapuBulu or (int)Species.TapuFini; - public static bool IsBallPermitted([ConstantExpected] ulong permit, int ball) + public static bool IsBallPermitted(ulong permit, int ball) { if ((uint)ball >= 64) return false; @@ -84,7 +83,7 @@ public static bool IsBallPermitted([ConstantExpected] ulong permit, int ball) public const ulong DreamWorldBalls = WildPokeBalls5 | WildPokeEnhance5; private const ulong WildPokeballs6 = WildPokeBalls5; // Same as Gen5 - private const ulong WildPokeballs7 = WildPokeBalls4_HGSS | WildPokeEnhance7; // Same as HGSS + Beast + private const ulong WildPokeballs7 = WildPokeBalls4_HGSS | WildPokeEnhance7; // Same as HG/SS + Beast private const ulong WildPokeballs8 = WildPokeballs7 | WildPokeEnhance8; private const ulong WildPokeballs7b = WildPokeRegular | (1 << (int)Premier); diff --git a/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs b/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs index ec3b6c55e..4cd1450b8 100644 --- a/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/Ball/BallVerifier.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using static PKHeX.Core.LegalityCheckStrings; using static PKHeX.Core.Ball; @@ -39,15 +38,15 @@ private CheckResult VerifyBall(LegalityAnalysis data) // Capture / Inherit cases -- can be one of many balls var pk = data.Entity; - if (pk.Species == (int)Species.Shedinja && enc.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada + if (pk.Species == (int)Species.Shedinja && enc.Species != (int)Species.Shedinja) // Shedinja. For Gen3, copy the ball from Nincada { // Only a Gen3 origin Shedinja can copy the wild ball. // Evolution chains will indicate if it could have existed as Shedinja in Gen3. // The special move verifier has a similar check! - if (pk is { HGSS: true, Ball: (int)Sport }) // Can evolve in DP to retain the HG/SS ball (separate byte) -- not able to be captured in any other ball + if (pk is { HGSS: true, Ball: (int)Sport }) // Can evolve in D/P to retain the HG/SS ball (separate byte) -- not able to be captured in any other ball return VerifyBallEquals(data, (int)Sport); if (Info.Generation != 3 || Info.EvoChainsAllGens.Gen3.Length != 2) // not evolved in Gen3 Nincada->Shedinja - return VerifyBallEquals(data, (int)Poke); // Poké ball Only + return VerifyBallEquals(data, (int)Poke); // Poké Ball Only } // Fixed ball cases -- can be only one ball ever @@ -206,7 +205,7 @@ private CheckResult VerifyBallEggGen9(LegalityAnalysis data) } private CheckResult VerifyBallEquals(LegalityAnalysis data, int ball) => GetResult(ball == data.Entity.Ball); - private CheckResult VerifyBallEquals(Ball ball, [ConstantExpected] ulong permit) => GetResult(BallUseLegality.IsBallPermitted(permit, (int)ball)); + private CheckResult VerifyBallEquals(Ball ball, ulong permit) => GetResult(BallUseLegality.IsBallPermitted(permit, (int)ball)); private CheckResult GetResult(bool valid) => valid ? GetValid(LBallEnc) : GetInvalid(LBallEncMismatch); } diff --git a/PKHeX.Core/Legality/Verifiers/EffortValueVerifier.cs b/PKHeX.Core/Legality/Verifiers/EffortValueVerifier.cs index 19daeaad7..97bf3164f 100644 --- a/PKHeX.Core/Legality/Verifiers/EffortValueVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/EffortValueVerifier.cs @@ -23,9 +23,9 @@ public override void Verify(LegalityAnalysis data) return; } - // In Generations I and II, when a Pokémon is taken out of the Day Care, its experience will lower to the minimum value for its current level. + // In Generation 1 & 2, when a Pokémon is taken out of the Day Care, its experience will lower to the minimum value for its current level. int format = pk.Format; - if (format < 3) // can abuse daycare for EV training without EXP gain + if (format < 3) // Can abuse daycare for EV training without EXP gain return; int sum = pk.EVTotal; @@ -35,7 +35,7 @@ public override void Verify(LegalityAnalysis data) var enc = data.EncounterMatch; Span evs = stackalloc int[6]; pk.GetEVs(evs); - if (format >= 6 && evs.IndexOfAny(253, 254, 255) != -1) + if (format >= 6 && evs.ContainsAny(253, 254, 255)) data.AddLine(GetInvalid(LEffortAbove252)); else if (format < 5) // 3/4 VerifyGainedEVs34(data, enc, evs, pk); @@ -45,7 +45,7 @@ public override void Verify(LegalityAnalysis data) data.AddLine(Get(LEffortEXPIncreased, Severity.Fishy)); else if (sum == EffortValues.MaxEffective) data.AddLine(Get(LEffort2Remaining, Severity.Fishy)); - else if (evs[0] != 0 && evs.IndexOfAnyExcept(evs[0]) == -1) + else if (evs[0] != 0 && !evs.ContainsAnyExcept(evs[0])) data.AddLine(Get(LEffortAllEqual, Severity.Fishy)); } @@ -61,7 +61,7 @@ private void VerifyGainedEVs34(LegalityAnalysis data, IEncounterTemplate enc, Sp // EVs can only be increased by vitamins to a max of 100. data.AddLine(GetInvalid(LEffortCap100)); } - else // Check for gained EVs without gaining EXP -- don't check gen5+ which have wings to boost above 100. + else // Check for gained EVs without gaining EXP -- don't check Gen5+ which have wings to boost above 100. { var growth = PersonalTable.HGSS[enc.Species].EXPGrowth; var baseEXP = Experience.GetEXP(enc.LevelMin, growth); diff --git a/PKHeX.Core/Legality/Verifiers/FormArgumentVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormArgumentVerifier.cs index 4dfddb3f2..04dd98a0f 100644 --- a/PKHeX.Core/Legality/Verifiers/FormArgumentVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/FormArgumentVerifier.cs @@ -80,8 +80,8 @@ private CheckResult VerifyFormArgument(LegalityAnalysis data, IFormArgument f) }, Gimmighoul => arg switch { - // Leveling up sets the save file's current coin count to the arg. If 999+, triggers level up. - // Without leveling up, cannot have a form arg value. + // When leveled up, the game copies the save file's current coin count to the arg (clamped to <=999). If >=999, evolution is triggered. + // Without being leveled up at least once, it cannot have a form arg value. >= 999 => GetInvalid(LFormArgumentHigh), 0 => GetValid(LFormArgumentValid), _ => pk.CurrentLevel != pk.Met_Level ? GetValid(LFormArgumentValid) : GetInvalid(LFormArgumentNotAllowed), diff --git a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs index 438dcfdd2..d78749fd7 100644 --- a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs @@ -87,8 +87,8 @@ private CheckResult VerifyForm(LegalityAnalysis data) var arceus = FormItem.GetFormArceus(pk.HeldItem, pk.Format); return arceus != form ? GetInvalid(LFormItemInvalid) : GetValid(LFormItem); case Keldeo when enc.Generation != 5 || pk.Format >= 8: - // can mismatch in gen5 via BW tutor and transfer up - // can mismatch in gen8+ as the form activates in battle when knowing the move; outside of battle can be either state. + // can mismatch in Gen5 via B/W tutor and transfer up + // can mismatch in Gen8+ as the form activates in battle when knowing the move; outside of battle can be either state. // Generation 8 patched out the mismatch; always forced to match moves. bool hasSword = pk.HasMove((int) Move.SecretSword); bool isSword = pk.Form == 1; @@ -101,7 +101,7 @@ private CheckResult VerifyForm(LegalityAnalysis data) case Greninja: if (form > 1) // Ash Battle Bond active return GetInvalid(LFormBattle); - if (form != 0 && enc is not MysteryGift) // Forms are not breedable, MysteryGift already checked + if (form != 0 && enc is not MysteryGift) // Form can not be bred for, MysteryGift already checked return GetInvalid(string.Format(LFormInvalidRange, 0, form)); break; diff --git a/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs b/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs index c69c0d252..24788d7c0 100644 --- a/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/GenderVerifier.cs @@ -15,7 +15,7 @@ public override void Verify(LegalityAnalysis data) var pi = pk.PersonalInfo; if (pi.Genderless != (pk.Gender == 2)) { - // DP/HGSS shedinja glitch -- only generation 4 spawns + // D/P/Pt & HG/SS Shedinja glitch -- only generation 4 spawns bool ignore = pk is { Format: 4, Species: (int)Species.Shedinja } && pk.Met_Level != pk.CurrentLevel; if (!ignore) data.AddLine(GetInvalid(LGenderInvalidNone)); diff --git a/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs b/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs index 4e657124b..e6435dbb1 100644 --- a/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/HistoryVerifier.cs @@ -86,7 +86,7 @@ private void VerifyHandlerState(LegalityAnalysis data, bool neverOT) private static bool IsUntradeableEncounter(IEncounterTemplate enc) => enc switch { EncounterStatic7b { Location: 28 } => true, // LGP/E Starter - EncounterStatic9 { Species: 998 or 999, Level: 68 } => true, // SV Ride legend + EncounterStatic9 { Species: 998 or 999, Level: 68 } => true, // S/V Ride legend _ => false, }; @@ -129,7 +129,7 @@ private void VerifyOTFriendshipVC12(LegalityAnalysis data, PKM pk) // Verify the original friendship value since it cannot change from the value it was assigned in the original generation. // Since some evolutions have different base friendship values, check all possible evolutions for a match. // If none match, then it is not a valid OT friendship. - // VC transfers use SM personal info + // VC transfers use S/M personal info var any = IsMatchFriendship(data.Info.EvoChainsAllGens.Gen7, pk.OT_Friendship); if (!any) data.AddLine(GetInvalid(LMemoryStatFriendshipOTBaseEvent)); @@ -205,7 +205,7 @@ private void VerifyGeoLocationData(LegalityAnalysis data, IGeoTrack t, PKM pk) data.AddLine(GetInvalid(LGeoNoCountryHT)); } - // ORAS contests mistakenly apply 20 affection to the OT instead of the current handler's value + // OR/AS contests mistakenly apply 20 affection to the OT instead of the current handler's value private static bool IsInvalidContestAffection(IAffection pk) => pk.OT_Affection != 255 && pk.OT_Affection % 20 != 0; public static bool GetCanOTHandle(IEncounterTemplate enc, PKM pk, int generation) diff --git a/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs b/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs index 899ae6a02..e6f67bb67 100644 --- a/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/LevelVerifier.cs @@ -96,7 +96,7 @@ public void VerifyG1(LegalityAnalysis data) if (IsTradeEvolutionRequired(data, enc)) { - // Pokemon has been traded illegally between games without evolving. + // Pokémon has been traded illegally between games without evolving. // Trade evolution species IDs for Gen1 are sequential dex numbers. var species = enc.Species; var evolved = ParseSettings.SpeciesStrings[species + 1]; @@ -121,7 +121,7 @@ private static bool IsTradeEvolutionRequired(LegalityAnalysis data, IEncounterTe if (!GBRestrictions.IsTradeEvolution1(enc.Species)) return false; - // Context check is only applicable to gen1/2; transferring to Gen2 is a trade. + // Context check is only applicable to Gen1/2; transferring to Gen2 is a trade. // Stadium 2 can transfer across game/generation boundaries without initiating a trade. // Ignore this check if the environment's loaded trainer is not from Gen1/2 or is from GB Era. if (ParseSettings.ActiveTrainer.Generation >= 3 || ParseSettings.AllowGBStadium2) diff --git a/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs b/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs index eb62c85af..5b8b9b499 100644 --- a/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MarkVerifier.cs @@ -131,7 +131,7 @@ private void VerifyShedinjaAffixed(LegalityAnalysis data, RibbonIndex affix, PKM private static bool IsMoveSetEvolvedShedinja(PKM pk) { - // Check for gen3/4 exclusive moves that are Ninjask glitch only. + // Check for Gen3/4 exclusive moves that are Ninjask glitch only. if (pk.HasMove((int) Move.Screech)) return true; if (pk.HasMove((int) Move.SwordsDance)) diff --git a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs index e09757bff..63484c81c 100644 --- a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs @@ -349,7 +349,7 @@ private void VerifyOTMemory(LegalityAnalysis data) break; // {0} became {1}’s friend when it arrived via Link Trade at... {2}. {4} that {3}. - case 4 when mc.Context == Gen6: // gen8 applies this memory erroneously + case 4 when mc.Context == Gen6: // Gen8 applies this memory erroneously data.AddLine(GetInvalid(string.Format(LMemoryArgBadOTEgg, L_XOT))); return; diff --git a/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs b/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs index 5adc8e3c5..f9ba3b18e 100644 --- a/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs +++ b/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using static PKHeX.Core.ContestStatGranting; namespace PKHeX.Core; @@ -59,10 +61,10 @@ public static void SetMaxContestStats(this PKM pk, IEncounterTemplate enc, Evolu 3 => pk.Format < 6 ? CorrelateSheen : Mixed, 4 => pk.Format < 6 ? CorrelateSheen : Mixed, - 5 => pk.Format < 6 ? None : !h.HasVisitedBDSP ? NoSheen : Mixed, // ORAS Contests + 5 => pk.Format < 6 ? None : !h.HasVisitedBDSP ? NoSheen : Mixed, // OR/AS Contests 6 => pk is { AO: false, IsUntraded: true } ? None : !h.HasVisitedBDSP ? NoSheen : Mixed, - _ => h.HasVisitedBDSP ? CorrelateSheen : None, // BDSP Contests + _ => h.HasVisitedBDSP ? CorrelateSheen : None, // BD/SP Contests }; public static int CalculateMaximumSheen(IContestStatsReadOnly s, int nature, IContestStatsReadOnly initial, bool pokeBlock3) @@ -95,7 +97,7 @@ public static int CalculateMaximumSheen(IContestStatsReadOnly s, int nature, ICo _ => throw new ArgumentOutOfRangeException(nameof(method)), }; - // Slightly better stat:sheen ratio than Gen4; prefer if has visited. + // BD/SP has a slightly better stat:sheen ratio than Gen4; prefer if it has visited. public static int CalculateMinimumSheen8b(IContestStatsReadOnly s, int nature, IContestStatsReadOnly initial) { if (s.IsContestEqual(initial)) @@ -171,20 +173,31 @@ private static int GetAverageFeel(IContestStatsReadOnly s, int nature, IContestS return (int)Math.Ceiling(sum / 5f); } + // Indexes into the NatureAmpTable + private const int AmpIndexCool = 0; // Spicy + private const int AmpIndexTough = 1; // Sour + private const int AmpIndexBeauty = 2; // Dry + private const int AmpIndexSmart = 3; // Bitter + private const int AmpIndexCute = 4; // Sweet + private static int GetGainedSum(IContestStatsReadOnly s, int nature, IContestStatsReadOnly initial) { - var span = NatureAmpTable.Slice(5 * nature, 5); + var span = NatureAmp.GetAmps(nature); int sum = 0; - sum += GetAmpedStat(span, 0, s.CNT_Cool - initial.CNT_Cool); - sum += GetAmpedStat(span, 1, s.CNT_Beauty - initial.CNT_Beauty); - sum += GetAmpedStat(span, 2, s.CNT_Cute - initial.CNT_Cute); - sum += GetAmpedStat(span, 3, s.CNT_Smart - initial.CNT_Smart); - sum += GetAmpedStat(span, 4, s.CNT_Tough - initial.CNT_Tough); + sum += GetAmpedStat(span, AmpIndexCool, s.CNT_Cool, initial.CNT_Cool); + sum += GetAmpedStat(span, AmpIndexTough, s.CNT_Tough, initial.CNT_Tough); + sum += GetAmpedStat(span, AmpIndexBeauty, s.CNT_Beauty, initial.CNT_Beauty); + sum += GetAmpedStat(span, AmpIndexSmart, s.CNT_Smart, initial.CNT_Smart); + sum += GetAmpedStat(span, AmpIndexCute, s.CNT_Cute, initial.CNT_Cute); return sum; } - private static int GetAmpedStat(ReadOnlySpan amps, int index, int gain) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static int GetAmpedStat(ReadOnlySpan amps, [ConstantExpected] int index, byte current, byte initial) { + var gain = current - initial; + if (gain <= 0) + return 0; var amp = amps[index]; if (amp == 0) return gain; @@ -222,34 +235,4 @@ private sealed class DummyContestNone : IContestStatsReadOnly public byte CNT_Tough => 0; public byte CNT_Sheen => 0; } - - private static ReadOnlySpan NatureAmpTable => new sbyte[] - { - // Spicy, Dry, Sweet, Bitter, Sour - 0, 0, 0, 0, 0, // Hardy - 1, 0, 0, 0,-1, // Lonely - 1, 0,-1, 0, 0, // Brave - 1,-1, 0, 0, 0, // Adamant - 1, 0, 0,-1, 0, // Naughty - -1, 0, 0, 0, 1, // Bold - 0, 0, 0, 0, 0, // Docile - 0, 0,-1, 0, 1, // Relaxed - 0,-1, 0, 0, 1, // Impish - 0, 0, 0,-1, 1, // Lax - -1, 0, 1, 0, 0, // Timid - 0, 0, 1, 0,-1, // Hasty - 0, 0, 0, 0, 0, // Serious - 0,-1, 1, 0, 0, // Jolly - 0, 0, 1,-1, 0, // Naive - -1, 1, 0, 0, 0, // Modest - 0, 1, 0, 0,-1, // Mild - 0, 1,-1, 0, 0, // Quiet - 0, 0, 0, 0, 0, // Bashful - 0, 1, 0,-1, 0, // Rash - -1, 0, 0, 1, 0, // Calm - 0, 0, 0, 1,-1, // Gentle - 0, 0,-1, 1, 0, // Sassy - 0,-1, 0, 1, 0, // Careful - 0, 0, 0, 0, 0, // Quirky - }; } diff --git a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs index f5052e79a..50627b648 100644 --- a/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MiscVerifier.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text; using static PKHeX.Core.LegalityCheckStrings; using static PKHeX.Core.CheckIdentifier; @@ -641,20 +640,18 @@ private static void VerifyFullness(LegalityAnalysis data, PKM pk) if (pk.Species != data.EncounterMatch.Species) return; // evolved - if (Unfeedable.Contains(pk.Species)) + if (IsUnfeedable(pk.Species)) data.AddLine(GetInvalid(string.Format(LMemoryStatFullness, "0"), Encounter)); } - private static readonly HashSet Unfeedable = new() - { - (int)Species.Metapod, - (int)Species.Kakuna, - (int)Species.Pineco, - (int)Species.Silcoon, - (int)Species.Cascoon, - (int)Species.Shedinja, - (int)Species.Spewpa, - }; + public static bool IsUnfeedable(ushort species) => species is + (int)Species.Metapod or + (int)Species.Kakuna or + (int)Species.Pineco or + (int)Species.Silcoon or + (int)Species.Cascoon or + (int)Species.Shedinja or + (int)Species.Spewpa; private static void VerifyBelugaStats(LegalityAnalysis data, PB7 pb7) { @@ -827,7 +824,7 @@ private void VerifyStatNature(LegalityAnalysis data, PKM pk) continue; // Calyrex-0 can have TR flags for Calyrex-1/2 after it has force unlearned them. - // Re-fusing can be reacquire the move via relearner, rather than needing another TR. + // Re-fusing can reacquire the move via relearner, rather than needing another TR. // Calyrex-0 cannot reacquire the move via relearner, even though the TR is checked off in the TR list. if (pk.Species == (int)Species.Calyrex) { diff --git a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs index e24102cf4..33b4d311c 100644 --- a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs @@ -37,7 +37,7 @@ public override void Verify(LegalityAnalysis data) return; } - if (pk is { Format: <= 7, IsNicknamed: true }) // can nickname afterwards + if (pk is { Format: <= 7, IsNicknamed: true }) // can nickname afterward { if (pk.VC) VerifyG1NicknameWithinBounds(data, nickname); diff --git a/PKHeX.Core/Legality/Verifiers/ParseSettings.cs b/PKHeX.Core/Legality/Verifiers/ParseSettings.cs index 275a3b520..19efa4a1c 100644 --- a/PKHeX.Core/Legality/Verifiers/ParseSettings.cs +++ b/PKHeX.Core/Legality/Verifiers/ParseSettings.cs @@ -11,12 +11,12 @@ public static class ParseSettings internal static ITrainerInfo ActiveTrainer { get; set; } = new SimpleTrainerInfo(GameVersion.Any) { OT = string.Empty, Language = -1 }; /// - /// Toggles whether or not the word filter should be used when checking the data. + /// Toggles whether the word filter should be used when checking the data. /// public static bool CheckWordFilter { get; set; } = true; /// - /// Setting to specify if an analysis should permit data sourced from the physical cartridge era of GameBoy games. + /// Setting to specify if an analysis should permit data sourced from the physical cartridge era of Game Boy games. /// /// If false, indicates to use Virtual Console rules (which are transferable to Gen7+) public static bool AllowGBCartEra { private get; set; } @@ -50,7 +50,7 @@ public static void ChangeLocalizationStrings(IReadOnlyList moves, IReadO /// /// Checks to see if Crystal is available to visit/originate from. /// - /// Pokemon Crystal was never released in Korea. + /// Pokémon Crystal was never released in Korea. /// Korean data being checked /// True if Crystal data is allowed public static bool AllowGen2Crystal(bool Korean) => !Korean; @@ -65,7 +65,7 @@ public static void ChangeLocalizationStrings(IReadOnlyList moves, IReadO /// /// Checks to see if the Move Reminder (Relearner) is available. /// - /// Pokemon Stadium 2 was never released in Korea. + /// Pokémon Stadium 2 was never released in Korea. /// Data being checked /// True if Crystal data is allowed public static bool AllowGen2MoveReminder(PKM pk) => !pk.Korean && AllowGBStadium2; diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/MarkRules.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/MarkRules.cs index 0f1f8d1d2..6f55a8cbf 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/MarkRules.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/MarkRules.cs @@ -28,7 +28,7 @@ public static bool IsEncounterMarkLost(IEncounterTemplate enc, PKM pk) } /// - /// Checks if a SW/SH mark is valid. + /// Checks if a characteristic encounter mark (only those that were introduced in SW/SH) is valid. /// public static bool IsEncounterMarkValid(RibbonIndex mark, PKM pk, IEncounterTemplate enc) => enc switch { @@ -105,8 +105,7 @@ private static bool IsSlotWeatherPermittedSWSH(AreaWeather8 permit, EncounterSlo { var location = s.Parent.Location; // If it's not in the main table, it can only have Normal weather. - if (!EncounterArea8.WeatherbyArea.TryGetValue(location, out var weather)) - weather = AreaWeather8.Normal; + var weather = EncounterArea8.GetWeather(location); if (weather.HasFlag(permit)) return true; @@ -208,7 +207,7 @@ public static bool IsMarkValidGourmand(EvolutionHistory evos) /// public static bool IsMarkPresentMightiest(IEncounterTemplate enc) { - // 7 star raids only. + // 7-Star raids that can be captured force the mark when obtained. return enc is EncounterMight9 { Stars: 7 }; } diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResult.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResult.cs index 76d20329e..e8fd9610a 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResult.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResult.cs @@ -28,7 +28,7 @@ namespace PKHeX.Core; public bool Equals(RibbonIndex4 index) => Type == Index4 && Value == (byte)index; /// - /// Property Name that the ribbon can be get/set with, or looked up for localization. + /// Property Name of the ribbon based on the source code's getters/setters, allowing lookup for localization. /// public string PropertyName => Type switch { diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs index 5528dd99f..bdefbbc79 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonResultList.cs @@ -5,17 +5,16 @@ namespace PKHeX.Core; /// /// List using a fixed-size span to store results. Only exposes ; the span is hidden, and only accessible if the span was already a known instance. /// -public ref struct RibbonResultList +public ref struct RibbonResultList(Span Span) { - private readonly Span Span; + // ReSharper disable once ReplaceWithPrimaryConstructorParameter + private readonly Span Span = Span; /// /// Count of results that were added to the span. /// public int Count { get; private set; } - public RibbonResultList(Span span) => Span = span; - private void Add(RibbonResult item) => Span[Count++] = item; public void Add(RibbonIndex index, bool missing = false) => Add(new(index, missing)); diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonRules.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonRules.cs index 5c7bc2721..c9dea3d99 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonRules.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonRules.cs @@ -119,7 +119,7 @@ private static bool IsRibbonValidMasterRankSWSH(PKM pk, IEncounterTemplate enc) return false; } - // Series 13 rule-set was the first time Ranked Battles allowed the use of Mythical Pokémon. + // Series 13 rule-set was the first rule-set that Ranked Battles allowed the use of Mythical Pokémon. // All species that can exist in SW/SH can compete in ranked. return true; } @@ -231,8 +231,8 @@ private static bool IsAnyWithoutFootprint8b(EvoCriteria[] evos) // Derived from ROM data: true for all Footprint types besides 5 (5 = no feet). // If true, requires gaining 30 levels to obtain ribbon. If false, can obtain ribbon at any level. - private static ReadOnlySpan HasFootprintBDSP => new[] - { + private static ReadOnlySpan HasFootprintBDSP => + [ true, true, true, true, true, true, true, true, true, true, true, false, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, @@ -283,7 +283,7 @@ private static bool IsAnyWithoutFootprint8b(EvoCriteria[] evos) true, true, true, true, false, true, false, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, - }; + ]; /// /// Checks if the input can receive the ribbon. @@ -401,8 +401,8 @@ public static bool IsAllowedBattleFrontier(ushort species, byte form, EntityCont /// /// Generation 3 & 4 Battle Frontier Species banlist. When referencing this in context to generation 4, be sure to disallow with Form 1 (Spiky). /// - public static readonly HashSet BattleFrontierBanlist = new() - { + public static readonly HashSet BattleFrontierBanlist = + [ (int)Mewtwo, (int)Mew, (int)Lugia, (int)HoOh, (int)Celebi, (int)Kyogre, (int)Groudon, (int)Rayquaza, (int)Jirachi, (int)Deoxys, @@ -412,5 +412,5 @@ public static bool IsAllowedBattleFrontier(ushort species, byte form, EntityCont (int)Cosmog, (int)Cosmoem, (int)Solgaleo, (int)Lunala, (int)Necrozma, (int)Magearna, (int)Marshadow, (int)Zeraora, (int)Meltan, (int)Melmetal, (int)Koraidon, (int)Miraidon, - }; + ]; } diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonStrings.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonStrings.cs index 3f717e71d..c21873b74 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonStrings.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonStrings.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; /// public static class RibbonStrings { - private static readonly Dictionary RibbonNames = new(); + private static readonly Dictionary RibbonNames = []; /// /// Resets the Ribbon Dictionary to use the supplied set of Ribbon (Property) Names. diff --git a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierCommon4.cs b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierCommon4.cs index d92e35198..f1722b9c8 100644 --- a/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierCommon4.cs +++ b/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierCommon4.cs @@ -21,8 +21,8 @@ public static void Parse(this IRibbonSetCommon4 r, RibbonVerifierArguments args, bool bdsp = evos.HasVisitedBDSP; bool oras6 = gen6 && pk is not { IsUntraded: true, XY: true }; bool sinnoh4 = gen4 && args.Encounter is not EncounterStatic4 { Species: (int)Species.Pichu, Form: 1 }; - bool sinnohChamp = sinnoh4 || bdsp; // no gen4 hg/ss - bool cosmetic = sinnoh4 || oras6 || bdsp; // no gen4 hg/ss + bool sinnohChamp = sinnoh4 || bdsp; // no Gen4 HG/SS + bool cosmetic = sinnoh4 || oras6 || bdsp; // no Gen4 HG/SS bool daily = gen4 || gen6 || bdsp; if (r.RibbonLegend && !gen4) @@ -33,7 +33,7 @@ public static void Parse(this IRibbonSetCommon4 r, RibbonVerifierArguments args, FlagDaily(r, ref list); // Gen6 can get individual ribbons via Ritzy Ribbon Retail -- OR/AS - // Gen4 Ribbon Syndicate is sequential purchase (prerequisite ribbon cannot be disjointed) -- DP/Pt + // Gen4 Ribbon Syndicate is sequential purchase (prerequisite ribbon cannot be disjointed) -- D/P/Pt // Gen8 Ribbon Syndicate is sequential purchase (prerequisite ribbon cannot be disjointed) -- BD/SP if (!cosmetic) FlagCosmetic(r, ref list); diff --git a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs index b2e518fe9..ad869a129 100644 --- a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs @@ -11,10 +11,10 @@ public sealed class TrainerNameVerifier : Verifier protected override CheckIdentifier Identifier => CheckIdentifier.Trainer; private static readonly string[] SuspiciousOTNames = - { + [ "PKHeX", "PKHeX", - }; + ]; public override void Verify(LegalityAnalysis data) { diff --git a/PKHeX.Core/Moves/MoveInfo.cs b/PKHeX.Core/Moves/MoveInfo.cs index eb05ebfbe..85b39cdd8 100644 --- a/PKHeX.Core/Moves/MoveInfo.cs +++ b/PKHeX.Core/Moves/MoveInfo.cs @@ -53,7 +53,7 @@ public static byte GetPP(EntityContext context, ushort move) Gen8a => MoveInfo8a.DummiedMoves, Gen8b => MoveInfo8b.DummiedMoves, Gen9 => MoveInfo9.DummiedMoves, - _ => default, + _ => [], }; /// @@ -137,7 +137,7 @@ public static bool IsDummiedMoveAny(PKM pk) /// /// Move ID /// Generation to check - /// True if can be sketched, false if not available. + /// True if the move can be sketched, false if not possible. public static bool IsSketchValid(ushort move, EntityContext context) { if (move > GetMaxMoveID(context)) diff --git a/PKHeX.Core/Moves/MoveInfo1.cs b/PKHeX.Core/Moves/MoveInfo1.cs index 16342430e..b7628ec75 100644 --- a/PKHeX.Core/Moves/MoveInfo1.cs +++ b/PKHeX.Core/Moves/MoveInfo1.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo1 { - public static ReadOnlySpan MovePP_RBY => new byte[] - { + public static ReadOnlySpan MovePP_RBY => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -18,10 +18,10 @@ internal static class MoveInfo1 05, 10, 30, 20, 20, 20, 05, 15, 10, 20, 15, 15, 35, 20, 15, 10, 20, 30, 15, 40, 20, 15, 10, 05, 10, 30, 10, 15, 20, 15, 40, 40, 10, 05, 15, 10, 10, 10, 15, 30, 30, 10, 10, 20, 10, 10, - }; + ]; - public static ReadOnlySpan MoveType_RBY => new byte[] - { + public static ReadOnlySpan MoveType_RBY => + [ 00, 00, 00, 00, 00, 00, 00, 09, 14, 12, 00, 00, 00, 00, 00, 00, 00, 02, 00, 02, 00, 00, 11, 00, 01, 00, 01, 01, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 03, 06, 06, 00, 00, 00, 00, 00, 00, 00, 00, 03, 09, 09, 14, 10, 10, 10, 14, 14, @@ -31,5 +31,5 @@ internal static class MoveInfo1 00, 00, 07, 03, 03, 04, 09, 10, 10, 00, 00, 00, 00, 13, 13, 00, 01, 00, 13, 03, 00, 06, 00, 02, 00, 10, 00, 11, 00, 13, 00, 03, 10, 00, 00, 04, 13, 05, 00, 00, 00, 00, 00, 00, 00, 00, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo2.cs b/PKHeX.Core/Moves/MoveInfo2.cs index 354740457..1fdf13f7b 100644 --- a/PKHeX.Core/Moves/MoveInfo2.cs +++ b/PKHeX.Core/Moves/MoveInfo2.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo2 { - public static ReadOnlySpan MovePP_GSC => new byte[] - { + public static ReadOnlySpan MovePP_GSC => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -22,5 +22,5 @@ internal static class MoveInfo2 15, 10, 05, 10, 20, 20, 40, 15, 10, 20, 20, 25, 05, 15, 10, 05, 20, 15, 20, 25, 20, 05, 30, 05, 10, 20, 40, 05, 20, 40, 20, 15, 35, 10, 05, 05, 05, 15, 05, 20, 05, 05, 15, 20, 10, 05, 05, 15, 15, 15, 15, 10, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo3.cs b/PKHeX.Core/Moves/MoveInfo3.cs index 3a9122951..f5e7ffc89 100644 --- a/PKHeX.Core/Moves/MoveInfo3.cs +++ b/PKHeX.Core/Moves/MoveInfo3.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo3 { - public static ReadOnlySpan MovePP_RS => new byte[] - { + public static ReadOnlySpan MovePP_RS => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 10, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -27,5 +27,5 @@ internal static class MoveInfo3 15, 20, 15, 10, 10, 15, 10, 05, 05, 10, 15, 10, 05, 20, 25, 05, 40, 10, 05, 40, 15, 20, 20, 05, 15, 20, 30, 15, 15, 05, 10, 30, 20, 30, 15, 05, 40, 15, 05, 20, 05, 15, 25, 40, 15, 20, 15, 20, 15, 20, 10, 20, 20, 05, 05, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo4.cs b/PKHeX.Core/Moves/MoveInfo4.cs index 896865844..9d4b5f7b9 100644 --- a/PKHeX.Core/Moves/MoveInfo4.cs +++ b/PKHeX.Core/Moves/MoveInfo4.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo4 { - public static ReadOnlySpan MovePP_DP => new byte[] - { + public static ReadOnlySpan MovePP_DP => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 15, 20, 30, 05, 25, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 20, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -33,5 +33,5 @@ internal static class MoveInfo4 30, 15, 15, 15, 15, 30, 10, 20, 15, 10, 10, 20, 15, 05, 05, 15, 15, 05, 10, 05, 20, 05, 15, 20, 05, 20, 20, 20, 20, 10, 20, 10, 15, 20, 15, 10, 10, 05, 10, 05, 05, 10, 05, 05, 10, 05, 05, 05, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo5.cs b/PKHeX.Core/Moves/MoveInfo5.cs index aed220744..7af71b62c 100644 --- a/PKHeX.Core/Moves/MoveInfo5.cs +++ b/PKHeX.Core/Moves/MoveInfo5.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo5 { - public static ReadOnlySpan MovePP_BW => new byte[] - { + public static ReadOnlySpan MovePP_BW => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 30, 30, 35, 35, 20, 15, 20, 20, 15, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -37,10 +37,10 @@ internal static class MoveInfo5 10, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 05, 05, 15, 05, 10, 10, 10, 20, 20, 20, 10, 10, 30, 15, 15, 10, 15, 25, 10, 20, 10, 10, 10, 20, 10, 10, 10, 10, 10, 15, 15, 05, 05, 10, 10, 10, 05, 05, 10, 05, 05, 15, 10, 05, 05, 05, - }; + ]; - public static ReadOnlySpan MoveType_BW => new byte[] - { + public static ReadOnlySpan MoveType_BW => + [ 00, 00, 01, 00, 00, 00, 00, 09, 14, 12, 00, 00, 00, 00, 00, 00, 02, 02, 00, 02, 00, 00, 11, 00, 01, 00, 01, 01, 04, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 03, 06, 06, 00, 16, 00, 00, 00, 00, 00, 00, 03, 09, 09, 14, 10, 10, 10, 14, 14, @@ -69,5 +69,5 @@ internal static class MoveInfo5 13, 01, 13, 10, 00, 13, 07, 02, 08, 01, 09, 16, 02, 00, 00, 01, 00, 09, 10, 09, 11, 12, 06, 04, 14, 15, 00, 12, 12, 04, 15, 13, 11, 01, 10, 09, 11, 06, 11, 16, 13, 00, 02, 00, 08, 09, 00, 00, 01, 14, 12, 09, 09, 14, 14, 16, 14, 09, 09, 12, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo6.cs b/PKHeX.Core/Moves/MoveInfo6.cs index bf136caed..8f50f3d2f 100644 --- a/PKHeX.Core/Moves/MoveInfo6.cs +++ b/PKHeX.Core/Moves/MoveInfo6.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo6 { - public static ReadOnlySpan MovePP => new byte[] - { + public static ReadOnlySpan MovePP => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -41,5 +41,5 @@ internal static class MoveInfo6 10, 10, 20, 10, 30, 15, 10, 10, 10, 20, 20, 05, 05, 05, 20, 10, 10, 20, 15, 20, 20, 10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05, 05, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo7.cs b/PKHeX.Core/Moves/MoveInfo7.cs index 9743d6ac8..e741e12c0 100644 --- a/PKHeX.Core/Moves/MoveInfo7.cs +++ b/PKHeX.Core/Moves/MoveInfo7.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo7 { - public static ReadOnlySpan MovePP_SM => new byte[] - { + public static ReadOnlySpan MovePP_SM => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -46,5 +46,5 @@ internal static class MoveInfo7 15, 10, 05, 10, 10, 20, 15, 10, 15, 15, 15, 05, 15, 20, 20, 01, 01, 01, 01, 01, 01, 01, 01, 01, 05, 05, 10, 10, 10, 20, 10, 10, 10, 05, 05, 20, 10, 10, 10, 01, 05, 15, 05, 01, 01, 01, 01, 01, 01, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo7b.cs b/PKHeX.Core/Moves/MoveInfo7b.cs index b55b3da02..7e8cbba29 100644 --- a/PKHeX.Core/Moves/MoveInfo7b.cs +++ b/PKHeX.Core/Moves/MoveInfo7b.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo7b { - public static ReadOnlySpan MovePP_GG => new byte[] - { + public static ReadOnlySpan MovePP_GG => + [ // Absorb: 25 -> 15 (damage buffed from 20->40) // Mega Drain: 15 -> 10 (damage buffed from 40->75) @@ -50,12 +50,12 @@ internal static class MoveInfo7b 01, 01, 01, 01, 05, 05, 10, 10, 10, 20, 10, 10, 10, 05, 05, 20, 10, 10, 10, 01, 05, 15, 05, 01, 01, 01, 01, 01, 01, 15, 15, 15, 20, 15, 15, 15, 15, 15, 15, 15, 15, 20, 05, - }; + ]; public static bool IsAllowedMoveGG(ushort move) => AllowedMovesGG.BinarySearch(move) >= 0; - private static ReadOnlySpan AllowedMovesGG => new ushort[] - { + private static ReadOnlySpan AllowedMovesGG => + [ 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, @@ -81,5 +81,5 @@ internal static class MoveInfo7b 503, 504, 525, 529, 583, 585, 603, 605, 606, 607, 729, 730, 731, 733, 734, 735, 736, 737, 738, 739, 740, 742, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo8.cs b/PKHeX.Core/Moves/MoveInfo8.cs index d79a26250..e244c4e04 100644 --- a/PKHeX.Core/Moves/MoveInfo8.cs +++ b/PKHeX.Core/Moves/MoveInfo8.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo8 { - public static ReadOnlySpan MovePP_SWSH => new byte[] - { + public static ReadOnlySpan MovePP_SWSH => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -51,7 +51,7 @@ internal static class MoveInfo8 05, 05, 05, 10, 15, 40, 10, 10, 10, 15, 10, 10, 10, 10, 05, 05, 05, 10, 05, 20, 10, 10, 05, 20, 20, 10, 10, 05, 05, 05, 40, 10, 20, 10, 10, 10, 10, 05, 05, 15, 05, 10, 10, 10, 05, 05, 05, - }; + ]; /// /// Bitflag indexes of moves that are not usable in game. @@ -60,8 +60,8 @@ internal static class MoveInfo8 /// This is a bitflag array, where each bit represents a move. If the bit is set, the move is not usable in game. /// Instead of allocating a hashset, this is a more efficient method (no allocation) with O(1) lookup (faster than HashSet's O(1) lookup). /// - public static ReadOnlySpan DummiedMoves => new byte[] // 144 moves (288 bytes) => 93 bytes. - { + public static ReadOnlySpan DummiedMoves => // 144 moves (288 bytes) => 93 bytes. + [ 0x1C, 0x20, 0x00, 0x0C, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00, 0xA1, 0x22, 0x59, 0x10, 0x36, 0x80, 0x00, 0x0A, 0x00, 0x02, 0x02, 0x00, 0x00, 0x45, 0x10, 0x20, @@ -72,5 +72,5 @@ internal static class MoveInfo8 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x00, 0x00, 0x80, 0xFF, 0x00, 0x80, 0xF8, 0xFF, 0x3F, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo8a.cs b/PKHeX.Core/Moves/MoveInfo8a.cs index d6372cee8..320f08eac 100644 --- a/PKHeX.Core/Moves/MoveInfo8a.cs +++ b/PKHeX.Core/Moves/MoveInfo8a.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo8a { - public static ReadOnlySpan MovePP_LA => new byte[] - { + public static ReadOnlySpan MovePP_LA => + [ 00, 35, 25, 10, 15, 20, 20, 10, 10, 10, 35, 30, 05, 10, 20, 30, 25, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 30, 15, 20, 20, 10, 05, 30, 20, 20, 20, 30, 20, 40, 20, 15, 20, 20, 20, 30, 25, 10, 30, 25, 05, 15, 10, 05, @@ -52,7 +52,7 @@ internal static class MoveInfo8a 10, 10, 05, 20, 20, 10, 10, 05, 05, 05, 40, 10, 20, 10, 10, 10, 10, 05, 05, 15, 05, 10, 10, 10, 05, 05, 35, 15, 10, 10, 15, 05, 10, 10, 10, 05, 05, 10, 05, 15, 10, 15, 10, 15, 15, 15, 05, 05, 05, 10, 10, - }; + ]; /// /// Bitflag indexes of moves that are not usable in game. @@ -61,8 +61,8 @@ internal static class MoveInfo8a /// This is a bitflag array, where each bit represents a move. If the bit is set, the move is not usable in game. /// Instead of allocating a hashset, this is a more efficient method (no allocation) with O(1) lookup (faster than HashSet's O(1) lookup). /// - public static ReadOnlySpan DummiedMoves => new byte[] // 673 moves (1346 bytes) => 104 bytes. - { + public static ReadOnlySpan DummiedMoves => // 673 moves (1346 bytes) => 104 bytes. + [ 0x7E, 0xBC, 0xFE, 0xFF, 0xBD, 0xEA, 0xCF, 0x72, 0x7F, 0x1F, 0x0E, 0x1F, 0xAB, 0xFD, 0xEF, 0xBE, 0x7D, 0xD7, 0x35, 0xCF, 0xD5, 0xEF, 0x5F, 0x0F, 0xEF, 0x9E, 0xFD, 0xFF, 0x7E, 0x5F, @@ -74,5 +74,5 @@ internal static class MoveInfo8a 0xFF, 0xFF, 0xFF, 0xB7, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0x07, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo8b.cs b/PKHeX.Core/Moves/MoveInfo8b.cs index a4f7fccd1..c929b3edb 100644 --- a/PKHeX.Core/Moves/MoveInfo8b.cs +++ b/PKHeX.Core/Moves/MoveInfo8b.cs @@ -14,8 +14,8 @@ internal static class MoveInfo8b /// This is a bitflag array, where each bit represents a move. If the bit is set, the move is not usable in game. /// Instead of allocating a hashset, this is a more efficient method (no allocation) with O(1) lookup (faster than HashSet's O(1) lookup). /// - public static ReadOnlySpan DummiedMoves => new byte[] // 314 moves (628 bytes) => 104 bytes. - { + public static ReadOnlySpan DummiedMoves => // 314 moves (628 bytes) => 104 bytes. + [ 0x1C, 0x20, 0x00, 0x0C, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00, 0xA1, 0x22, 0x19, 0x10, 0x26, 0xC0, 0x00, 0x0A, 0x00, 0x02, 0x02, 0x00, 0x00, 0x45, 0x10, 0x00, @@ -27,5 +27,5 @@ internal static class MoveInfo8b 0xFF, 0xFF, 0xFF, 0xA7, 0x74, 0xEB, 0xAF, 0xFF, 0xB7, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, - }; + ]; } diff --git a/PKHeX.Core/Moves/MoveInfo9.cs b/PKHeX.Core/Moves/MoveInfo9.cs index 0754b7ac8..92cb300d9 100644 --- a/PKHeX.Core/Moves/MoveInfo9.cs +++ b/PKHeX.Core/Moves/MoveInfo9.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// internal static class MoveInfo9 { - public static ReadOnlySpan MovePP_SV => new byte[] - { + public static ReadOnlySpan MovePP_SV => + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, @@ -55,10 +55,10 @@ internal static class MoveInfo9 10, 15, 05, 01, 15, 10, 15, 10, 10, 10, 10, 10, 10, 10, 05, 15, 15, 10, 05, 05, 10, 10, 10, 10, 20, 20, 20, 05, 10, 10, 05, 10, 05, 05, 10, 20, 10, 10, 10, 10, 10, 05, 15, 10, 10, - }; + ]; - public static ReadOnlySpan MoveType_SV => new byte[] - { + public static ReadOnlySpan MoveType_SV => + [ 00, 00, 01, 00, 00, 00, 00, 09, 14, 12, 00, 00, 00, 00, 00, 00, 02, 02, 00, 02, 00, 00, 11, 00, 01, 00, 01, 01, 04, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 03, 06, 06, 00, 16, 00, 00, 00, 00, 00, 00, 03, 09, 09, 14, 10, 10, 10, 14, 14, @@ -105,7 +105,7 @@ internal static class MoveInfo9 00, 14, 15, 00, 05, 10, 03, 00, 00, 16, 11, 09, 10, 00, 08, 13, 10, 16, 01, 12, 00, 14, 00, 14, 06, 11, 10, 00, 13, 07, 09, 09, 12, 08, 16, 10, 09, 16, 03, 01, 17, 00, 11, 11, 11, - }; + ]; /// /// Bitflag indexes of moves that are not usable in game. @@ -114,8 +114,8 @@ internal static class MoveInfo9 /// This is a bitflag array, where each bit represents a move. If the bit is set, the move is not usable in game. /// Instead of allocating a hashset, this is a more efficient method (no allocation) with O(1) lookup (faster than HashSet's O(1) lookup). /// - public static ReadOnlySpan DummiedMoves => new byte[] // 251 moves (502 bytes) => 100 bytes - { + public static ReadOnlySpan DummiedMoves => // 251 moves (502 bytes) => 100 bytes + [ 0x1C, 0x20, 0x00, 0x0C, 0x00, 0x02, 0x02, 0x00, 0x04, 0x00, 0x04, 0x00, 0x09, 0x00, 0xA1, 0x22, 0x5D, 0x50, 0x36, 0xC8, 0xC1, 0x0E, 0x03, 0x42, 0x02, 0x00, 0x00, 0x65, 0x10, 0x22, @@ -126,5 +126,5 @@ internal static class MoveInfo9 0x8A, 0x02, 0x4D, 0x10, 0x80, 0x03, 0xF0, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x85, 0x26, 0xA0, 0x94, 0xFF, 0x91, 0xE7, 0xFF, 0xFF, 0xFF, 0x00, 0xEE, 0xFF, 0x7F, 0x0A, 0x00, 0x0D, - }; + ]; } diff --git a/PKHeX.Core/MysteryGifts/DataMysteryGift.cs b/PKHeX.Core/MysteryGifts/DataMysteryGift.cs index b2624a2b2..e1ae18f1c 100644 --- a/PKHeX.Core/MysteryGifts/DataMysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/DataMysteryGift.cs @@ -5,14 +5,12 @@ namespace PKHeX.Core; /// /// Mystery Gift backed by serialized fields from ROM/SAV data, rather than observed specifications. /// -public abstract class DataMysteryGift : MysteryGift +public abstract class DataMysteryGift(byte[] Data) : MysteryGift { - public readonly byte[] Data; - - protected DataMysteryGift(byte[] data) => Data = data; + public readonly byte[] Data = Data; /// - /// Returns an array for exporting outside the program (to disk, etc). + /// Returns an array for exporting outside the program (to disk, etc.). /// public virtual byte[] Write() => Data; @@ -35,5 +33,5 @@ public override MysteryGift Clone() return result; } - public override bool Empty => Data.AsSpan().IndexOfAnyExcept(0) == -1; + public override bool Empty => !Data.AsSpan().ContainsAnyExcept(0); } diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index 662e98e23..43cf9c2ff 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -10,13 +9,17 @@ namespace PKHeX.Core; public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, ITrainerID32, IFatefulEncounterReadOnly, IEncounterMatch { /// - /// Determines whether or not the given length of bytes is valid for a mystery gift. + /// Determines whether the given length of bytes is valid for a mystery gift. /// /// Length, in bytes, of the data of which to determine validity. - /// A boolean indicating whether or not the given length is valid for a mystery gift. - public static bool IsMysteryGift(long len) => Sizes.Contains((int)len); - - private static readonly HashSet Sizes = new() { WA8.Size, WB8.Size, WC8.Size, WC6Full.Size, WC6.Size, PGF.Size, PGT.Size, PCD.Size }; + /// A boolean indicating whether the given length is valid for a mystery gift. + public static bool IsMysteryGift(long len) => len is + // WC9.Size or SAME AS WA8 + WA8.Size or WB8.Size or WC8.Size or + WC6Full.Size or WC6.Size or + PGF.Size or PGT.Size or + PCD.Size + ; /// /// Converts the given data to a . @@ -65,12 +68,12 @@ public abstract class MysteryGift : IEncounterable, IMoveset, IRelearn, ITrainer // WC8/WC5Full: WC8 0x2CF always 0, WC5Full 0x2CF contains card checksum WC8.Size => data[0x2CF] == 0 ? new WC8(data) : new PGF(data), - // WA8/WC9: WA8 CardType >0 for wa8, 0 for wc9. + // WA8/WC9: WA8 CardType >0 for WA8, 0 for WC9. WA8.Size => data[0xF] > 0 ? new WA8(data) : new WC9(data), // WC6/WC7: Check year WC6.Size => ReadUInt32LittleEndian(data.AsSpan(0x4C)) / 10000 < 2000 ? new WC7(data) : new WC6(data), - // WC6Full/WC7Full: 0x205 has 3 * 0x46 for gen6, now only 2. + // WC6Full/WC7Full: 0x205 has 3 * 0x46 for Gen6, now only 2. WC6Full.Size => data[0x205] == 0 ? new WC7Full(data).Gift : new WC6Full(data).Gift, _ => null, }; @@ -142,7 +145,7 @@ public virtual GameVersion Version // Search Properties public virtual Moveset Moves { get => default; set { } } public virtual Moveset Relearn { get => default; set { } } - public virtual int[] IVs { get => Array.Empty(); set { } } + public virtual int[] IVs { get => []; set { } } public virtual bool HasFixedIVs => true; public virtual void GetIVs(Span value) { } public virtual bool IsShiny => false; diff --git a/PKHeX.Core/MysteryGifts/MysteryUtil.cs b/PKHeX.Core/MysteryGifts/MysteryUtil.cs index 8e4922451..4db0ba14e 100644 --- a/PKHeX.Core/MysteryGifts/MysteryUtil.cs +++ b/PKHeX.Core/MysteryGifts/MysteryUtil.cs @@ -89,7 +89,7 @@ public static IEnumerable GetDescription(this MysteryGift gift, IBasicSt return result; } - private static void AddLinesItem(MysteryGift gift, IBasicStrings strings, ICollection result) + private static void AddLinesItem(MysteryGift gift, IBasicStrings strings, List result) { result.Add($"Item: {strings.Item[gift.ItemID]} (Quantity: {gift.Quantity})"); if (gift is not WC7 wc7) @@ -101,7 +101,7 @@ private static void AddLinesItem(MysteryGift gift, IBasicStrings strings, IColle } } - private static void AddLinesPKM(MysteryGift gift, IBasicStrings strings, ICollection result) + private static void AddLinesPKM(MysteryGift gift, IBasicStrings strings, List result) { var id = gift.Generation < 7 ? $"{gift.TID16:D5}/{gift.SID16:D5}" : $"[{gift.TrainerSID7:D4}]{gift.TrainerTID7:D6}"; diff --git a/PKHeX.Core/MysteryGifts/PCD.cs b/PKHeX.Core/MysteryGifts/PCD.cs index f0af32bdb..3e160edae 100644 --- a/PKHeX.Core/MysteryGifts/PCD.cs +++ b/PKHeX.Core/MysteryGifts/PCD.cs @@ -12,8 +12,11 @@ namespace PKHeX.Core; /// https://projectpokemon.org/home/forums/topic/5870-pok%C3%A9mon-mystery-gift-editor-v143-now-with-bw-support/ /// See also: http://tccphreak.shiny-clique.net/debugger/pcdfiles.htm /// -public sealed class PCD : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, IRestrictVersion, IRandomCorrelation +public sealed class PCD(byte[] Data) + : DataMysteryGift(Data), IRibbonSetEvent3, IRibbonSetEvent4, IRestrictVersion, IRandomCorrelation { + public PCD() : this(new byte[Size]) { } + public const int Size = 0x358; // 856 public override int Generation => 4; public override EntityContext Context => EntityContext.Gen4; @@ -32,9 +35,6 @@ public override int Ball set => Gift.Ball = value; } - public PCD() : this(new byte[Size]) { } - public PCD(byte[] data) : base(data) { } - public override byte[] Write() { // Ensure PGT content is encrypted @@ -46,7 +46,7 @@ public override byte[] Write() public PGT Gift { - get => _gift ??= new PGT(Data.Slice(0, PGT.Size)); + get => _gift ??= new PGT(Data[..PGT.Size]); set => (_gift = value).Data.CopyTo(Data, 0); } diff --git a/PKHeX.Core/MysteryGifts/PGF.cs b/PKHeX.Core/MysteryGifts/PGF.cs index 05bc94c09..798aa946f 100644 --- a/PKHeX.Core/MysteryGifts/PGF.cs +++ b/PKHeX.Core/MysteryGifts/PGF.cs @@ -6,17 +6,17 @@ namespace PKHeX.Core; /// /// Generation 5 Mystery Gift Template File /// -public sealed class PGF : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILangNick, IContestStats, INature, IRestrictVersion +public sealed class PGF(byte[] Data) : DataMysteryGift(Data), IRibbonSetEvent3, IRibbonSetEvent4, ILangNick, + IContestStats, INature, IRestrictVersion { + public PGF() : this(new byte[Size]) { } + public const int Size = 0xCC; public const int SizeFull = 0x2D0; public override int Generation => 5; public override EntityContext Context => EntityContext.Gen5; public override bool FatefulEncounter => true; - public PGF() : this(new byte[Size]) { } - public PGF(byte[] data) : base(data) { } - public override uint ID32 { get => ReadUInt32LittleEndian(Data.AsSpan(0x00)); set => WriteUInt32LittleEndian(Data.AsSpan(0x00), value); } public override ushort TID16 { get => ReadUInt16LittleEndian(Data.AsSpan(0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(0x00), value); } public override ushort SID16 { get => ReadUInt16LittleEndian(Data.AsSpan(0x02)); set => WriteUInt16LittleEndian(Data.AsSpan(0x02), value); } @@ -149,10 +149,11 @@ public override int CardID // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; } @@ -289,7 +290,7 @@ private int GetVersion(ITrainerInfo tr, Random rnd) return OriginGame; if (tr.Generation <= 5) return tr.Game; - // Gen6+, give random gen5 game + // Gen6+, give random Gen5 game var bias = rnd.Next(4); for (int i = 0; i < 4; i++) { diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs index 4784fbf5e..e4f720869 100644 --- a/PKHeX.Core/MysteryGifts/PGT.cs +++ b/PKHeX.Core/MysteryGifts/PGT.cs @@ -6,8 +6,10 @@ namespace PKHeX.Core; /// /// Generation 4 Mystery Gift Template File (Inner Gift Data, no card data) /// -public sealed class PGT : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, IRandomCorrelation +public sealed class PGT(byte[] Data) : DataMysteryGift(Data), IRibbonSetEvent3, IRibbonSetEvent4, IRandomCorrelation { + public PGT() : this(new byte[Size]) { } + public const int Size = 0x104; // 260 public override int Generation => 4; public override EntityContext Context => EntityContext.Gen4; @@ -50,9 +52,6 @@ private enum GiftType public override bool GiftUsed { get => false; set { } } public override Shiny Shiny => IsEgg ? Shiny.Random : PK.PID == 1 ? Shiny.Never : IsShiny ? Shiny.Always : Shiny.Never; - public PGT() : this(new byte[Size]) { } - public PGT(byte[] data) : base(data) { } - public byte CardType { get => Data[0]; set => Data[0] = value; } // Unused 0x01 public byte Slot { get => Data[2]; set => Data[2] = value; } @@ -61,7 +60,7 @@ private enum GiftType public PK4 PK { - get => _pk ??= new PK4(Data.Slice(8, PokeCrypto.SIZE_4PARTY)); + get => _pk ??= new PK4(Data.AsSpan(8, PokeCrypto.SIZE_4PARTY).ToArray()); set { _pk = value; @@ -84,7 +83,7 @@ public override byte[] Write() private PK4? _pk; /// - /// Double checks the encryption of the gift data for Pokemon data. + /// Double-checks the encryption of the gift data for Pokémon data. /// /// True if data was encrypted, false if the data was not modified. public bool VerifyPKEncryption() diff --git a/PKHeX.Core/MysteryGifts/PL6.cs b/PKHeX.Core/MysteryGifts/PL6.cs index cd7514e77..8ed7aa12d 100644 --- a/PKHeX.Core/MysteryGifts/PL6.cs +++ b/PKHeX.Core/MysteryGifts/PL6.cs @@ -45,12 +45,12 @@ public byte Flags public uint Flags_6 { get => ReadUInt32LittleEndian(Data.AsSpan(0x3E1)); set => WriteUInt32LittleEndian(Data.AsSpan(0x3E1), value); } // Pokémon - public PL6_PKM Poke_1 { get => new(Data.Slice(0x09D, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x09D); } - public PL6_PKM Poke_2 { get => new(Data.Slice(0x145, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x145); } - public PL6_PKM Poke_3 { get => new(Data.Slice(0x1ED, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x1ED); } - public PL6_PKM Poke_4 { get => new(Data.Slice(0x295, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x295); } - public PL6_PKM Poke_5 { get => new(Data.Slice(0x33D, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x33D); } - public PL6_PKM Poke_6 { get => new(Data.Slice(0x3E5, PL6_PKM.Size)); set => value.Data.CopyTo(Data, 0x3E5); } + public PL6_PKM Poke_1 { get => new(Data.AsSpan(0x09D, PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x09D); } + public PL6_PKM Poke_2 { get => new(Data.AsSpan(0x145, PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x145); } + public PL6_PKM Poke_3 { get => new(Data.AsSpan(0x1ED, PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x1ED); } + public PL6_PKM Poke_4 { get => new(Data.AsSpan(0x295, PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x295); } + public PL6_PKM Poke_5 { get => new(Data.AsSpan(0x33D, PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x33D); } + public PL6_PKM Poke_6 { get => new(Data.AsSpan(0x3E5, PL6_PKM.Size).ToArray()); set => value.Data.CopyTo(Data, 0x3E5); } // Item Properties public int Item_1 { get => ReadUInt16LittleEndian(Data.AsSpan(0x489)); set => WriteUInt16LittleEndian(Data.AsSpan(0x489), (ushort)value); } @@ -71,20 +71,20 @@ public byte Flags } /// -/// Pokemon Link Gift Template +/// Pokémon Link Gift Template /// /// /// This Template object is very similar to the structure and similar objects, in that the structure offsets are ordered the same. /// This template object is only present in Generation 6 save files. /// -public sealed class PL6_PKM : IRibbonSetEvent3, IRibbonSetEvent4, IEncounterInfo, IMoveset, IRelearn, IContestStats, IMemoryOT, ITrainerID32 +public sealed class PL6_PKM(byte[] Data) : IRibbonSetEvent3, IRibbonSetEvent4, IEncounterInfo, IMoveset, IRelearn, + IContestStats, IMemoryOT, ITrainerID32 { internal const int Size = 0xA0; - public readonly byte[] Data; + public readonly byte[] Data = Data; public PL6_PKM() : this(new byte[Size]) { } - public PL6_PKM(byte[] data) => Data = data; public TrainerIDFormat TrainerIDDisplayFormat => TrainerIDFormat.SixteenBit; diff --git a/PKHeX.Core/MysteryGifts/WA8.cs b/PKHeX.Core/MysteryGifts/WA8.cs index 387af2e4e..f07532eba 100644 --- a/PKHeX.Core/MysteryGifts/WA8.cs +++ b/PKHeX.Core/MysteryGifts/WA8.cs @@ -7,10 +7,14 @@ namespace PKHeX.Core; /// /// Generation 8 Mystery Gift Template File, same as with fields at the end. /// -public sealed class WA8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDynamaxLevel, IRibbonIndex, IMemoryOT, IEncounterServerDate, +public sealed class WA8(byte[] Data) : DataMysteryGift(Data), ILangNick, INature, IGigantamax, IDynamaxLevel, + IRibbonIndex, IMemoryOT, IEncounterServerDate, ILangNicknamedTemplate, IGanbaru, IAlpha, - IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMark8 + IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, + IRibbonSetCommon8, IRibbonSetMark8 { + public WA8() : this(new byte[Size]) { } + public const int Size = 0x2C8; public override int Generation => 8; @@ -25,9 +29,6 @@ public enum GiftType : byte Clothing = 3, } - public WA8() : this(new byte[Size]) { } - public WA8(byte[] data) : base(data) { } - public bool CanBeReceivedByVersion(int v, PKM pk) => v is (int) GameVersion.PLA || (pk is PK8 && v is (int)GameVersion.SW); public bool IsDateRestricted => true; public bool IsEquivalentFixedECPID => EncryptionConstant != 0 && PIDType == ShinyType8.FixedValue && PID == EncryptionConstant; @@ -259,7 +260,7 @@ public void SetRibbonAtIndex(int byteIndex, byte ribbonIndex) // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value.Length != 6) @@ -283,7 +284,7 @@ public override void GetIVs(Span value) public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { if (value.Length != 6) diff --git a/PKHeX.Core/MysteryGifts/WB7.cs b/PKHeX.Core/MysteryGifts/WB7.cs index 08d53f34c..5af9c4c9c 100644 --- a/PKHeX.Core/MysteryGifts/WB7.cs +++ b/PKHeX.Core/MysteryGifts/WB7.cs @@ -6,8 +6,11 @@ namespace PKHeX.Core; /// /// Generation 7 Mystery Gift Template File (LGP/E) /// -public sealed class WB7 : DataMysteryGift, ILangNick, IAwakened, INature, ILangNicknamedTemplate, IRestrictVersion +public sealed class WB7(byte[] Data) + : DataMysteryGift(Data), ILangNick, IAwakened, INature, ILangNicknamedTemplate, IRestrictVersion { + public WB7() : this(new byte[SizeFull]) { } + public const int Size = 0x108; public const int SizeFull = 0x310; private const int CardStart = SizeFull - Size; @@ -15,10 +18,6 @@ public sealed class WB7 : DataMysteryGift, ILangNick, IAwakened, INature, ILangN public override int Generation => 7; public override EntityContext Context => EntityContext.Gen7b; - - public WB7() : this(new byte[SizeFull]) { } - public WB7(byte[] data) : base(data) { } - public override GameVersion Version { get => GameVersion.GG; set { } } public byte RestrictVersion { get => Data[0]; set => Data[0] = value; } @@ -242,7 +241,7 @@ public override int Ball // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value.Length != 6) return; diff --git a/PKHeX.Core/MysteryGifts/WB8.cs b/PKHeX.Core/MysteryGifts/WB8.cs index 397bfd0c9..8d20f7ec7 100644 --- a/PKHeX.Core/MysteryGifts/WB8.cs +++ b/PKHeX.Core/MysteryGifts/WB8.cs @@ -7,9 +7,14 @@ namespace PKHeX.Core; /// /// Generation 8b Mystery Gift Template File /// -public sealed class WB8 : DataMysteryGift, ILangNick, INature, IRibbonIndex, IContestStatsReadOnly, ILangNicknamedTemplate, IEncounterServerDate, - IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMark8 +public sealed class WB8(byte[] Data) : DataMysteryGift(Data), + ILangNick, INature, IRibbonIndex, IContestStatsReadOnly, + ILangNicknamedTemplate, IEncounterServerDate, + IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, + IRibbonSetCommon8, IRibbonSetMark8 { + public WB8() : this(new byte[Size]) { } + public const int Size = 0x2DC; public const int CardStart = 0x0; @@ -31,9 +36,6 @@ public enum GiftType : byte UnderGroundItem = 6, } - public WB8() : this(new byte[Size]) { } - public WB8(byte[] data) : base(data) { } - // TODO: public byte RestrictVersion? public bool CanBeReceivedByVersion(int v, PKM pk) => v is (int) GameVersion.BD or (int) GameVersion.SP || (pk is PK8 && LocationsHOME.IsValidMetBDSP((ushort)pk.Met_Location, pk.Version)); @@ -253,7 +255,7 @@ public void SetRibbonAtIndex(int byteIndex, byte ribbonIndex) // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value.Length != 6) return; @@ -276,10 +278,11 @@ public override void GetIVs(Span value) public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2]; EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5]; } diff --git a/PKHeX.Core/MysteryGifts/WC3.cs b/PKHeX.Core/MysteryGifts/WC3.cs index 7136fe64e..4479e2b9a 100644 --- a/PKHeX.Core/MysteryGifts/WC3.cs +++ b/PKHeX.Core/MysteryGifts/WC3.cs @@ -9,12 +9,11 @@ namespace PKHeX.Core; /// This is fabricated data built to emulate the future generation Mystery Gift objects. /// Data here is not stored in any save file and cannot be naturally exported. /// -public sealed class WC3 : MysteryGift, IRibbonSetEvent3, ILangNicknamedTemplate, IRandomCorrelation +public sealed class WC3(bool Fateful = false) + : MysteryGift, IRibbonSetEvent3, ILangNicknamedTemplate, IRandomCorrelation { public override MysteryGift Clone() => (WC3)MemberwiseClone(); - public WC3(bool fateful = false) => FatefulEncounter = fateful; - /// /// Matched Type /// @@ -47,7 +46,7 @@ public bool IsCompatible(PIDType type, PKM pk) public override Moveset Moves { get; set; } public bool NotDistributed { get; init; } public override Shiny Shiny { get; init; } - public override bool FatefulEncounter { get; } // Obedience Flag + public override bool FatefulEncounter { get; } = Fateful; // Obedience Flag // Mystery Gift Properties public override int Generation => 3; diff --git a/PKHeX.Core/MysteryGifts/WC6.cs b/PKHeX.Core/MysteryGifts/WC6.cs index c58007967..ec2f3c694 100644 --- a/PKHeX.Core/MysteryGifts/WC6.cs +++ b/PKHeX.Core/MysteryGifts/WC6.cs @@ -6,16 +6,15 @@ namespace PKHeX.Core; /// /// Generation 6 Mystery Gift Template File /// -public sealed class WC6 : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILangNick, IContestStats, INature, IMemoryOT, IRestrictVersion +public sealed class WC6(byte[] Data) : DataMysteryGift(Data), IRibbonSetEvent3, IRibbonSetEvent4, ILangNick, IContestStats, INature, IMemoryOT, IRestrictVersion { + public WC6() : this(new byte[Size]) { } + public const int Size = 0x108; public const uint EonTicketConst = 0x225D73C2; public override int Generation => 6; public override EntityContext Context => EntityContext.Gen6; - public override bool FatefulEncounter => !IsLinkGift; // Link gifts do not set fateful encounter; - - public WC6() : this(new byte[Size]) { } - public WC6(byte[] data) : base(data) { } + public override bool FatefulEncounter => !IsLinkGift; // Link gifts do not set fateful encounter public int RestrictLanguage { get; set; } // None public byte RestrictVersion { get; set; } // Permit All @@ -244,10 +243,11 @@ public override string OT_Name // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; } @@ -255,10 +255,11 @@ public override int[] IVs public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2]; EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5]; } @@ -524,7 +525,7 @@ public override bool IsMatchExact(PKM pk, EvoCriteria evo) { if (OTGender != 3) { - // Skip ID check if ORASDEMO Simulated wc6 + // Skip ID check if it is an OR/AS Demo Simulated wc6 if (CardID != 0) { if (SID16 != pk.SID16) return false; diff --git a/PKHeX.Core/MysteryGifts/WC7.cs b/PKHeX.Core/MysteryGifts/WC7.cs index afc285a77..25a7bcac9 100644 --- a/PKHeX.Core/MysteryGifts/WC7.cs +++ b/PKHeX.Core/MysteryGifts/WC7.cs @@ -6,16 +6,16 @@ namespace PKHeX.Core; /// /// Generation 7 Mystery Gift Template File /// -public sealed class WC7 : DataMysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILangNick, IContestStats, INature, IMemoryOT, IRestrictVersion +public sealed class WC7(byte[] Data) : DataMysteryGift(Data), IRibbonSetEvent3, IRibbonSetEvent4, ILangNick, + IContestStats, INature, IMemoryOT, IRestrictVersion { + public WC7() : this(new byte[Size]) { } + public const int Size = 0x108; public override int Generation => 7; public override EntityContext Context => EntityContext.Gen7; public override bool FatefulEncounter => true; - public WC7() : this(new byte[Size]) { } - public WC7(byte[] data) : base(data) { } - public int RestrictLanguage { get; set; } // None public byte RestrictVersion { get; set; } // Permit All @@ -294,10 +294,11 @@ public override string OT_Name // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; } @@ -317,10 +318,11 @@ public override void GetIVs(Span value) public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2]; EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5]; } @@ -615,7 +617,7 @@ public override bool IsMatchExact(PKM pk, EvoCriteria evo) if (CardID is 1122 or 1133 && !CanBeReceivedByVersion(pk.Version)) return false; // Each version pair has a separate card -- since we aren't using deferral/partial match logic to reorder, just return false. if (CardID == 2046) // Greninja WC has variant PID and can arrive @ 36 or 37 - return pk.SM; // not USUM + return pk.SM; // not US/UM return PIDType != 0 || pk.PID == PID; } diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs index ec61c587e..19c5d0e0f 100644 --- a/PKHeX.Core/MysteryGifts/WC8.cs +++ b/PKHeX.Core/MysteryGifts/WC8.cs @@ -7,9 +7,11 @@ namespace PKHeX.Core; /// /// Generation 8 Mystery Gift Template File /// -public sealed class WC8 : DataMysteryGift, ILangNick, INature, IGigantamax, IDynamaxLevel, IRibbonIndex, IMemoryOT, ILangNicknamedTemplate, IEncounterServerDate, IRestrictVersion, +public sealed class WC8(byte[] Data) : DataMysteryGift(Data), ILangNick, INature, IGigantamax, IDynamaxLevel, IRibbonIndex, IMemoryOT, ILangNicknamedTemplate, IEncounterServerDate, IRestrictVersion, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMark8 { + public WC8() : this(new byte[Size]) { } + public const int Size = 0x2D0; public const int CardStart = 0x0; @@ -26,9 +28,6 @@ public enum GiftType : byte Clothing = 4, } - public WC8() : this(new byte[Size]) { } - public WC8(byte[] data) : base(data) { } - public byte RestrictVersion { get => Data[0xE]; set => Data[0xE] = value; } public bool CanBeReceivedByVersion(int v) => RestrictVersion switch @@ -253,10 +252,11 @@ public void SetRibbonAtIndex(int byteIndex, byte ribbonIndex) // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; } @@ -276,10 +276,11 @@ public override void GetIVs(Span value) public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2]; EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5]; } diff --git a/PKHeX.Core/MysteryGifts/WC9.cs b/PKHeX.Core/MysteryGifts/WC9.cs index 75507f250..caefec3d8 100644 --- a/PKHeX.Core/MysteryGifts/WC9.cs +++ b/PKHeX.Core/MysteryGifts/WC9.cs @@ -7,9 +7,13 @@ namespace PKHeX.Core; /// /// Generation 9 Mystery Gift Template File /// -public sealed class WC9 : DataMysteryGift, ILangNick, INature, ITeraType, IRibbonIndex, IMemoryOT, ILangNicknamedTemplate, IEncounterServerDate, - IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMark8, IRibbonSetCommon9, IRibbonSetMark9, IEncounterMarkExtra +public sealed class WC9(byte[] Data) : DataMysteryGift(Data), ILangNick, INature, ITeraType, IRibbonIndex, IMemoryOT, + ILangNicknamedTemplate, IEncounterServerDate, + IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, + IRibbonSetCommon8, IRibbonSetMark8, IRibbonSetCommon9, IRibbonSetMark9, IEncounterMarkExtra { + public WC9() : this(new byte[Size]) { } + public const int Size = 0x2C8; public const int CardStart = 0x0; @@ -26,9 +30,6 @@ public enum GiftType : byte Clothing = 4, } - public WC9() : this(new byte[Size]) { } - public WC9(byte[] data) : base(data) { } - public byte RestrictVersion { get => Data[0xE]; set => Data[0xE] = value; } public bool CanBeReceivedByVersion(PKM pk) => RestrictVersion switch @@ -287,10 +288,11 @@ public void SetRibbonAtIndex(int byteIndex, byte ribbonIndex) // Meta Accessible Properties public override int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; } @@ -310,10 +312,11 @@ public override void GetIVs(Span value) public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { - if (value.Length != 6) return; + if (value.Length != 6) + return; EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2]; EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5]; } diff --git a/PKHeX.Core/MysteryGifts/WR7.cs b/PKHeX.Core/MysteryGifts/WR7.cs index 09ac3ced3..af585ac51 100644 --- a/PKHeX.Core/MysteryGifts/WR7.cs +++ b/PKHeX.Core/MysteryGifts/WR7.cs @@ -10,8 +10,10 @@ namespace PKHeX.Core; /// A full is not stored in the structure, as it is immediately converted to upon receiving from server. /// The save file just stores a summary of the received data for the user to look back at. /// -public sealed class WR7 : DataMysteryGift +public sealed class WR7(byte[] Data) : DataMysteryGift(Data) { + public WR7() : this(new byte[Size]) { } + public const int Size = 0x140; public override int Generation => 7; public override EntityContext Context => EntityContext.Gen7; @@ -19,9 +21,6 @@ public sealed class WR7 : DataMysteryGift public override GameVersion Version { get => GameVersion.GG; set { } } - public WR7() : this(new byte[Size]) { } - public WR7(byte[] data) : base(data) { } - public override AbilityPermission Ability => AbilityPermission.Any12H; // undefined public long Epoch @@ -66,7 +65,7 @@ public override ushort Species public override bool GiftUsed { get; set; } - public override byte Level // are moves stored? mew has '1' but this could be move + public override byte Level // are moves stored? mew has '1' but this could be storing a Move ID... { get => Data[0x10E]; set => Data[0x10E] = value; diff --git a/PKHeX.Core/PKHeX.Core.csproj b/PKHeX.Core/PKHeX.Core.csproj index adb4d8a21..0f21cdd92 100644 --- a/PKHeX.Core/PKHeX.Core.csproj +++ b/PKHeX.Core/PKHeX.Core.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 Pokémon C# Class Library PKHeX.Core diff --git a/PKHeX.Core/PKM/BK4.cs b/PKHeX.Core/PKM/BK4.cs index 083b90936..3da2cbf81 100644 --- a/PKHeX.Core/PKM/BK4.cs +++ b/PKHeX.Core/PKM/BK4.cs @@ -11,10 +11,10 @@ namespace PKHeX.Core; /// public sealed class BK4 : G4PKM { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87, - }; + ]; public override int SIZE_PARTY => PokeCrypto.SIZE_4STORED; public override int SIZE_STORED => PokeCrypto.SIZE_4STORED; diff --git a/PKHeX.Core/PKM/CK3.cs b/PKHeX.Core/PKM/CK3.cs index 0f459cd32..e22bd3b90 100644 --- a/PKHeX.Core/PKM/CK3.cs +++ b/PKHeX.Core/PKM/CK3.cs @@ -4,10 +4,12 @@ namespace PKHeX.Core; /// Generation 3 format, exclusively for Pokémon Colosseum. -public sealed class CK3 : G3PKM, IShadowCapture +public sealed class CK3(byte[] Data) : G3PKM(Data), IShadowCapture { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public CK3() : this(new byte[PokeCrypto.SIZE_3CSTORED]) { } + + public override ReadOnlySpan ExtraBytes => + [ 0x11, 0x12, 0x13, 0x61, 0x62, 0x63, 0x64, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xDA, 0xDB, @@ -15,14 +17,12 @@ public sealed class CK3 : G3PKM, IShadowCapture 0xFB, // not fateful -- what is it? 0xD7, // index within party // 0xFC onwards unused? no, it's some pointers and values used by the game? - }; + ]; public override int SIZE_PARTY => PokeCrypto.SIZE_3CSTORED; public override int SIZE_STORED => PokeCrypto.SIZE_3CSTORED; public override EntityContext Context => EntityContext.Gen3; public override PersonalInfo3 PersonalInfo => PersonalTable.RS[Species]; - public CK3(byte[] data) : base(data) { } - public CK3() : this(new byte[PokeCrypto.SIZE_3CSTORED]) { } public override CK3 Clone() => new((byte[])Data.Clone()); // Trash Bytes diff --git a/PKHeX.Core/PKM/Enums/GroundTileType.cs b/PKHeX.Core/PKM/Enums/GroundTileType.cs index 03374efd4..b36838356 100644 --- a/PKHeX.Core/PKM/Enums/GroundTileType.cs +++ b/PKHeX.Core/PKM/Enums/GroundTileType.cs @@ -24,7 +24,7 @@ public enum GroundTileType : byte Building = 09, Marsh = 10, Bridge = 11, // No encounters from this tile type - Max_DP = 12, // Unspecific, catch-all for DP undefined tiles. + Max_DP = 12, // Unspecific, catch-all for D/P undefined tiles. // added tile types in Pt // no encounters from these tile types @@ -48,8 +48,8 @@ public static class GroundTileTypeExtensions { public static bool IsObtainable(this GroundTileType type) => ((0b_1_10000000_00010110_10110111 >> (int) type) & 1) == 1; - public static ReadOnlySpan ValidTileTypes => new[] - { + public static ReadOnlySpan ValidTileTypes => + [ (byte)None, (byte)Sand, (byte)Grass, (byte)Rock, (byte)Cave, (byte)Water, (byte)Building, (byte)Marsh, (byte)Max_DP, (byte)Distortion, (byte)Max_Pt, - }; + ]; } diff --git a/PKHeX.Core/PKM/HOME/GameDataPA8.cs b/PKHeX.Core/PKM/HOME/GameDataPA8.cs index 741fa52d3..4606c0e47 100644 --- a/PKHeX.Core/PKM/HOME/GameDataPA8.cs +++ b/PKHeX.Core/PKM/HOME/GameDataPA8.cs @@ -50,13 +50,13 @@ public sealed class GameDataPA8 : HomeOptional1, IGameDataSide, IScaledSize private Span PurchasedRecord => Data.Slice(0x28, 8); public bool GetPurchasedRecordFlag(int index) => FlagUtil.GetFlag(PurchasedRecord, index >> 3, index & 7); public void SetPurchasedRecordFlag(int index, bool value) => FlagUtil.SetFlag(PurchasedRecord, index >> 3, index & 7, value); - public bool GetPurchasedRecordFlagAny() => PurchasedRecord.IndexOfAnyExcept(0) >= 0; + public bool GetPurchasedRecordFlagAny() => PurchasedRecord.ContainsAnyExcept(0); public int GetPurchasedCount() => System.Numerics.BitOperations.PopCount(ReadUInt64LittleEndian(PurchasedRecord)); private Span MasteredRecord => Data.Slice(0x30, 8); public bool GetMasteredRecordFlag(int index) => FlagUtil.GetFlag(MasteredRecord, index >> 3, index & 7); public void SetMasteredRecordFlag(int index, bool value) => FlagUtil.SetFlag(MasteredRecord, index >> 3, index & 7, value); - public bool GetMasteredRecordFlagAny() => MasteredRecord.IndexOfAnyExcept(0) >= 0; + public bool GetMasteredRecordFlagAny() => MasteredRecord.ContainsAnyExcept(0); public int Egg_Location { get => ReadUInt16LittleEndian(Data[0x38..]); set => WriteUInt16LittleEndian(Data[0x38..], (ushort)value); } public int Met_Location { get => ReadUInt16LittleEndian(Data[0x3A..]); set => WriteUInt16LittleEndian(Data[0x3A..], (ushort)value); } diff --git a/PKHeX.Core/PKM/HOME/GameDataPB8.cs b/PKHeX.Core/PKM/HOME/GameDataPB8.cs index 170c4ba24..316bb85b8 100644 --- a/PKHeX.Core/PKM/HOME/GameDataPB8.cs +++ b/PKHeX.Core/PKM/HOME/GameDataPB8.cs @@ -41,7 +41,7 @@ public sealed class GameDataPB8 : HomeOptional1, IGameDataSide, IGameDataSp private Span RecordFlag => Data.Slice(0x18, 14); public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlag, index >> 3, index & 7); public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlag, index >> 3, index & 7, value); - public bool GetMoveRecordFlagAny() => RecordFlag.IndexOfAnyExcept(0) >= 0; + public bool GetMoveRecordFlagAny() => RecordFlag.ContainsAnyExcept(0); public void ClearMoveRecordFlags() => RecordFlag.Clear(); public int Ball { get => Data[0x26]; set => Data[0x26] = (byte)value; } diff --git a/PKHeX.Core/PKM/HOME/GameDataPK8.cs b/PKHeX.Core/PKM/HOME/GameDataPK8.cs index a944fafbb..39ccb8241 100644 --- a/PKHeX.Core/PKM/HOME/GameDataPK8.cs +++ b/PKHeX.Core/PKM/HOME/GameDataPK8.cs @@ -45,7 +45,7 @@ public sealed class GameDataPK8 : HomeOptional1, IGameDataSide, IGigantamax private Span PokeJob => Data.Slice(0x1E, 14); public bool GetPokeJobFlag(int index) => FlagUtil.GetFlag(PokeJob, index >> 3, index & 7); public void SetPokeJobFlag(int index, bool value) => FlagUtil.SetFlag(PokeJob, index >> 3, index & 7, value); - public bool GetPokeJobFlagAny() => PokeJob.IndexOfAnyExcept(0) >= 0; + public bool GetPokeJobFlagAny() => PokeJob.ContainsAnyExcept(0); public void ClearPokeJobFlags() => PokeJob.Clear(); public byte Fullness { get => Data[0x2C]; set => Data[0x2C] = value; } @@ -53,7 +53,7 @@ public sealed class GameDataPK8 : HomeOptional1, IGameDataSide, IGigantamax private Span RecordFlags => Data.Slice(0x2D, 14); public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlags, index >> 3, index & 7); public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlags, index >> 3, index & 7, value); - public bool GetMoveRecordFlagAny() => RecordFlags.IndexOfAnyExcept(0) >= 0; + public bool GetMoveRecordFlagAny() => RecordFlags.ContainsAnyExcept(0); public void ClearMoveRecordFlags() => RecordFlags.Clear(); public int Palma { get => ReadInt32LittleEndian(Data[0x3B..]); set => WriteInt32LittleEndian(Data[0x3B..], value); } @@ -171,7 +171,7 @@ private static GameDataPK8 Create(IGameDataSide side, PKH pkh) public void InitializeFrom(IGameDataSide side, PKH pkh) { - // BDSP->SWSH: Set the Met Location to the magic Location, set the Egg Location to 0 if -1, otherwise BDSPEgg + // BD/SP->SW/SH: Set the Met Location to the magic Location, set the Egg Location to 0 if -1, otherwise BDSPEgg // (0 is a valid location, but no eggs can be EggMet there -- only hatched.) // PLA->SWSH: Set the Met Location to the magic Location, set the Egg Location to 0 (no eggs in game). var ver = pkh.Version; diff --git a/PKHeX.Core/PKM/HOME/GameDataPK9.cs b/PKHeX.Core/PKM/HOME/GameDataPK9.cs index 7b19ec398..d372e5033 100644 --- a/PKHeX.Core/PKM/HOME/GameDataPK9.cs +++ b/PKHeX.Core/PKM/HOME/GameDataPK9.cs @@ -99,8 +99,8 @@ private void SetMoveRecordFlagDLC(bool value, int index) } public bool GetMoveRecordFlagAny() => GetMoveRecordFlagAnyBase() || GetMoveRecordFlagAnyDLC(); - private bool GetMoveRecordFlagAnyBase() => RecordFlagsBase.IndexOfAnyExcept(0) >= 0; - private bool GetMoveRecordFlagAnyDLC() => RecordFlagsDLC.IndexOfAnyExcept(0) >= 0; + private bool GetMoveRecordFlagAnyBase() => RecordFlagsBase.ContainsAnyExcept(0); + private bool GetMoveRecordFlagAnyDLC() => RecordFlagsDLC.ContainsAnyExcept(0); public void ClearMoveRecordFlags() { diff --git a/PKHeX.Core/PKM/HOME/HomeCrypto.cs b/PKHeX.Core/PKM/HOME/HomeCrypto.cs index 60454c47b..b3fe06a43 100644 --- a/PKHeX.Core/PKM/HOME/HomeCrypto.cs +++ b/PKHeX.Core/PKM/HOME/HomeCrypto.cs @@ -186,7 +186,7 @@ private static bool IsEncryptedCore2(ReadOnlySpan data) private static bool IsEncryptedCore3(ReadOnlySpan data) => IsEncryptedCore2(data); // Same struct as Core version 2. /// - /// Gets the checksum of an Pokémon's AES-encrypted data. + /// Gets the checksum of a Pokémon's AES-encrypted data. /// /// AES-Encrypted Pokémon data. public static uint GetCHK(ReadOnlySpan data) diff --git a/PKHeX.Core/PKM/HOME/HomeOptional1.cs b/PKHeX.Core/PKM/HOME/HomeOptional1.cs index d8802a383..adca032e8 100644 --- a/PKHeX.Core/PKM/HOME/HomeOptional1.cs +++ b/PKHeX.Core/PKM/HOME/HomeOptional1.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core; /// -/// Side game data base class for data transferred into HOME. +/// Base class for Side-game data used to store data transferred into HOME. /// public abstract class HomeOptional1 { diff --git a/PKHeX.Core/PKM/HOME/PKH.cs b/PKHeX.Core/PKM/HOME/PKH.cs index 157603868..e57404002 100644 --- a/PKHeX.Core/PKM/HOME/PKH.cs +++ b/PKHeX.Core/PKM/HOME/PKH.cs @@ -188,7 +188,7 @@ private static byte[] DecryptHome(byte[] data) public override uint PSV => ((PID >> 16) ^ (PID & 0xFFFF)) >> 4; public override uint TSV => (uint)(TID16 ^ SID16) >> 4; - public override int Characteristic => EntityCharacteristic.GetCharacteristic(EncryptionConstant, stackalloc int[] {IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD}); + public override int Characteristic => EntityCharacteristic.GetCharacteristic(EncryptionConstant, [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]); #endregion diff --git a/PKHeX.Core/PKM/Interfaces/IFormArgument.cs b/PKHeX.Core/PKM/Interfaces/IFormArgument.cs index c20f24c71..160159eb1 100644 --- a/PKHeX.Core/PKM/Interfaces/IFormArgument.cs +++ b/PKHeX.Core/PKM/Interfaces/IFormArgument.cs @@ -9,7 +9,7 @@ namespace PKHeX.Core; /// /// How long (days) the form can last before reverting to Form-0 (5 days max) /// : How long (days) the form can last before reverting to Form-0 (3 days max) -/// : Topping (Strawberry, Star, etc); [0,7] +/// : Topping (Strawberry, Star, etc.); [0,7] /// How much damage the Pokémon has taken as Yamask-1 [0,9999]. /// How much damage the Pokémon has taken as Yamask-1 [0,9999]. /// How many times the Pokémon has used Psyshield Bash in the Agile Style [0,9999]. @@ -19,8 +19,8 @@ namespace PKHeX.Core; /// How many Bisharp that head up a group of Pawniard have been KOed [0,9999]. /// How many Gimmighoul Coins were in the player's Bag after last leveling up [0,998]. /// How many Gimmighoul Coins were used on Gimmighoul to evolve into this Pokémon. -/// Flags whether or not this Pokémon was originally in its Ride Form (0/1). -/// Flags whether or not this Pokémon was originally in its Ride Form (0/1). +/// Flags whether this Pokémon was originally in its Ride Form (0/1). +/// Flags whether this Pokémon was originally in its Ride Form (0/1). /// public interface IFormArgument { @@ -46,7 +46,7 @@ public interface IFormArgument } /// -/// Logic for mutating an object. +/// Logic for mutating objects. /// public static class FormArgumentUtil { @@ -61,7 +61,7 @@ public static void SetSuggestedFormArgument(this PKM pk, ushort originalSpecies ? GetFormArgumentMax(pk.Species, pk.Form, pk.Context) : GetFormArgumentMinEvolution(pk.Species, originalSpecies); if (pk.Species is (int)Hoopa && pk.Format >= 8) - value = 0; // SV does not set the argument for Hoopa + value = 0; // S/V does not set the argument for Hoopa pk.ChangeFormArgument(value); } diff --git a/PKHeX.Core/PKM/Interfaces/IGanbaru.cs b/PKHeX.Core/PKM/Interfaces/IGanbaru.cs index 6aebafef8..69c28cb5d 100644 --- a/PKHeX.Core/PKM/Interfaces/IGanbaru.cs +++ b/PKHeX.Core/PKM/Interfaces/IGanbaru.cs @@ -22,7 +22,7 @@ public static class GanbaruExtensions /// public const byte TrueMax = 10; - private static ReadOnlySpan GanbaruMultiplier => new byte[] { 0, 2, 3, 4, 7, 8, 9, 14, 15, 16, 25 }; + private static ReadOnlySpan GanbaruMultiplier => [ 0, 2, 3, 4, 7, 8, 9, 14, 15, 16, 25 ]; /// /// Gets the max possible value that can be legally stored for the specific stat . diff --git a/PKHeX.Core/PKM/Interfaces/IGeoTrack.cs b/PKHeX.Core/PKM/Interfaces/IGeoTrack.cs index 1e37042b1..a6a13163c 100644 --- a/PKHeX.Core/PKM/Interfaces/IGeoTrack.cs +++ b/PKHeX.Core/PKM/Interfaces/IGeoTrack.cs @@ -98,8 +98,6 @@ public static void SanitizeGeoLocationData(this IGeoTrack g) /// /// Checks if all Geolocation tuples are valid. /// - /// - /// public static bool GetIsValid(this IGeoTrack g) => g.GetValidity() == GeoValid.Valid; /// diff --git a/PKHeX.Core/PKM/Interfaces/ITrainerMemories.cs b/PKHeX.Core/PKM/Interfaces/ITrainerMemories.cs index d28a3bf38..51fa7c48c 100644 --- a/PKHeX.Core/PKM/Interfaces/ITrainerMemories.cs +++ b/PKHeX.Core/PKM/Interfaces/ITrainerMemories.cs @@ -3,6 +3,4 @@ namespace PKHeX.Core; /// /// Combined interface for OT and HT memories. /// -public interface ITrainerMemories : IMemoryOT, IMemoryHT -{ -} +public interface ITrainerMemories : IMemoryOT, IMemoryHT; diff --git a/PKHeX.Core/PKM/Interfaces/Metadata/ISpeciesForm.cs b/PKHeX.Core/PKM/Interfaces/Metadata/ISpeciesForm.cs index 33fbe03d7..8d6af39ba 100644 --- a/PKHeX.Core/PKM/Interfaces/Metadata/ISpeciesForm.cs +++ b/PKHeX.Core/PKM/Interfaces/Metadata/ISpeciesForm.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Simple identification values for an Pokémon Entity. +/// Simple identification values for a Pokémon Entity. /// public interface ISpeciesForm { diff --git a/PKHeX.Core/PKM/Interfaces/Templates/IContestStatsReadOnly.cs b/PKHeX.Core/PKM/Interfaces/Templates/IContestStatsReadOnly.cs index e7cf5b3c1..7c5125f31 100644 --- a/PKHeX.Core/PKM/Interfaces/Templates/IContestStatsReadOnly.cs +++ b/PKHeX.Core/PKM/Interfaces/Templates/IContestStatsReadOnly.cs @@ -19,7 +19,7 @@ public static partial class Extensions /// Checks if any contest stat value is nonzero. /// /// Object containing contest stat data. - /// True if has any nonzero contest stat, false if all are zero. + /// True if it has any nonzero contest stat, false if all are zero. public static bool HasContestStats(this IContestStatsReadOnly stats) { if (stats.CNT_Cool != 0) diff --git a/PKHeX.Core/PKM/PA8.cs b/PKHeX.Core/PKM/PA8.cs index ec539ed43..3274f637b 100644 --- a/PKHeX.Core/PKM/PA8.cs +++ b/PKHeX.Core/PKM/PA8.cs @@ -10,8 +10,8 @@ public sealed class PA8 : PKM, ISanityChecksum, IGanbaru, IAlpha, INoble, ITechRecord, ISociability, IMoveShop8Mastery, IContestStats, IHyperTrain, IScaledSizeValue, IScaledSize3, IGigantamax, IFavorite, IDynamaxLevel, IHandlerLanguage, IFormArgument, IHomeTrack, IBattleVersion, ITrainerMemories, IPokerusStatus, IRibbonIndex, IRibbonSetAffixed, IRibbonSetRibbons, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetMemory6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMarks, IRibbonSetMark8, IRibbonSetCommon9, IRibbonSetMark9 { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x17, 0x1A, 0x1B, 0x23, 0x33, 0x4C, 0x4D, 0x4E, 0x4F, 0x53, @@ -26,7 +26,7 @@ public sealed class PA8 : PKM, ISanityChecksum, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x018, 0x109, 0x10A, 0x10B, 0x10C, 0x10D, 0x10E, 0x10F, 0x12D, 0x13C, - }; + ]; public override PersonalInfo8LA PersonalInfo => PersonalTable.LA.GetFormEntry(Species, Form); public IPermitRecord Permit => PersonalInfo; @@ -475,10 +475,10 @@ public void SetMoveRecordFlag(int index, bool value = true) FlagUtil.SetFlag(Data, 0x13F + ofs, index & 7, value); } - public bool GetMoveRecordFlagAny() => Data.AsSpan(0x13F, 14).IndexOfAnyExcept(0) >= 0; - public void ClearMoveRecordFlags() => Data.AsSpan(0x13F, 14).Clear(); + public Span MoveRecordFlags => Data.AsSpan(0x13F, 14); + public bool GetMoveRecordFlagAny() => MoveRecordFlags.ContainsAnyExcept(0); + public void ClearMoveRecordFlags() => MoveRecordFlags.Clear(); - // Why did you mis-align this field, GameFreak? public ulong Tracker { get => ReadUInt64LittleEndian(Data.AsSpan(0x14D)); @@ -488,13 +488,13 @@ public ulong Tracker public Span PurchasedRecord => Data.AsSpan(0x155, 8); public bool GetPurchasedRecordFlag(int index) => FlagUtil.GetFlag(PurchasedRecord, index >> 3, index & 7); public void SetPurchasedRecordFlag(int index, bool value) => FlagUtil.SetFlag(PurchasedRecord, index >> 3, index & 7, value); - public bool GetPurchasedRecordFlagAny() => PurchasedRecord.IndexOfAnyExcept(0) >= 0; + public bool GetPurchasedRecordFlagAny() => PurchasedRecord.ContainsAnyExcept(0); public int GetPurchasedCount() => BitOperations.PopCount(ReadUInt64LittleEndian(PurchasedRecord)); public Span MasteredRecord => Data.AsSpan(0x15D, 8); public bool GetMasteredRecordFlag(int index) => FlagUtil.GetFlag(MasteredRecord, index >> 3, index & 7); public void SetMasteredRecordFlag(int index, bool value) => FlagUtil.SetFlag(MasteredRecord, index >> 3, index & 7, value); - public bool GetMasteredRecordFlagAny() => MasteredRecord.IndexOfAnyExcept(0) >= 0; + public bool GetMasteredRecordFlagAny() => MasteredRecord.ContainsAnyExcept(0); #endregion #region Battle Stats @@ -537,52 +537,9 @@ public static int GetStatHp(int baseStat, int level) public static int GetStat(int baseStat, int level, int nature, int statIndex) { var initial = (int)((((level / 50.0f) + 1.0f) * baseStat) / 1.5f); - return AmplifyStat(nature, statIndex, initial); + return NatureAmp.AmplifyStat(nature, statIndex, initial); } - private static int AmplifyStat(int nature, int index, int initial) => GetNatureAmp(nature, index) switch - { - 1 => 110 * initial / 100, // 110% - -1 => 90 * initial / 100, // 90% - _ => initial, - }; - - private static sbyte GetNatureAmp(int nature, int index) - { - if ((uint)nature >= 25) - return -1; - return NatureAmpTable[(5 * nature) + index]; - } - - private static ReadOnlySpan NatureAmpTable => new sbyte[] - { - 0, 0, 0, 0, 0, // Hardy - 1,-1, 0, 0, 0, // Lonely - 1, 0, 0, 0,-1, // Brave - 1, 0,-1, 0, 0, // Adamant - 1, 0, 0,-1, 0, // Naughty - -1, 1, 0, 0, 0, // Bold - 0, 0, 0, 0, 0, // Docile - 0, 1, 0, 0,-1, // Relaxed - 0, 1,-1, 0, 0, // Impish - 0, 1, 0,-1, 0, // Lax - -1, 0, 0, 0, 1, // Timid - 0,-1, 0, 0, 1, // Hasty - 0, 0, 0, 0, 0, // Serious - 0, 0,-1, 0, 1, // Jolly - 0, 0, 0,-1, 1, // Naive - -1, 0, 1, 0, 0, // Modest - 0,-1, 1, 0, 0, // Mild - 0, 0, 1, 0,-1, // Quiet - 0, 0, 0, 0, 0, // Bashful - 0, 0, 1,-1, 0, // Rash - -1, 0, 0, 1, 0, // Calm - 0,-1, 0, 1, 0, // Gentle - 0, 0, 0, 1,-1, // Sassy - 0, 0,-1, 1, 0, // Careful - 0, 0, 0, 0, 0, // Quirky - }; - public override int MarkingCount => 6; public override int GetMarking(int index) diff --git a/PKHeX.Core/PKM/PB7.cs b/PKHeX.Core/PKM/PB7.cs index 74502c6f1..0ab0346b6 100644 --- a/PKHeX.Core/PKM/PB7.cs +++ b/PKHeX.Core/PKM/PB7.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; /// Generation 7 format used for . public sealed class PB7 : G6PKM, IHyperTrain, IAwakened, IScaledSizeValue, ICombatPower, IFavorite, IFormArgument { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x2A, // Old Marking Value (PelagoEventStatus) 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, // Unused Ribbons 0x58, 0x59, // Nickname Terminator @@ -18,7 +18,7 @@ public sealed class PB7 : G6PKM, IHyperTrain, IAwakened, IScaledSizeValue, IComb 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, // Fatigue, no GUI editing 0xC8, 0xC9, // OT Terminator - }; + ]; public override int SIZE_PARTY => SIZE; public override int SIZE_STORED => SIZE; @@ -396,52 +396,9 @@ public override void LoadStats(IBaseStat p, Span stats) private static int GetStat(int baseStat, int iv, int level, int nature, int statIndex) { int initial = GetStat(baseStat, iv, level) + 5; - return AmplifyStat(nature, statIndex, initial); + return NatureAmp.AmplifyStat(nature, statIndex, initial); } - private static int AmplifyStat(int nature, int index, int initial) => GetNatureAmp(nature, index) switch - { - 1 => 110 * initial / 100, // 110% - -1 => 90 * initial / 100, // 90% - _ => initial, - }; - - private static sbyte GetNatureAmp(int nature, int index) - { - if ((uint)nature >= 25) - return -1; - return NatureAmpTable[(5 * nature) + index]; - } - - private static ReadOnlySpan NatureAmpTable => new sbyte[] - { - 0, 0, 0, 0, 0, // Hardy - 1,-1, 0, 0, 0, // Lonely - 1, 0, 0, 0,-1, // Brave - 1, 0,-1, 0, 0, // Adamant - 1, 0, 0,-1, 0, // Naughty - -1, 1, 0, 0, 0, // Bold - 0, 0, 0, 0, 0, // Docile - 0, 1, 0, 0,-1, // Relaxed - 0, 1,-1, 0, 0, // Impish - 0, 1, 0,-1, 0, // Lax - -1, 0, 0, 0, 1, // Timid - 0,-1, 0, 0, 1, // Hasty - 0, 0, 0, 0, 0, // Serious - 0, 0,-1, 0, 1, // Jolly - 0, 0, 0,-1, 1, // Naive - -1, 0, 1, 0, 0, // Modest - 0,-1, 1, 0, 0, // Mild - 0, 0, 1, 0,-1, // Quiet - 0, 0, 0, 0, 0, // Bashful - 0, 0, 1,-1, 0, // Rash - -1, 0, 0, 1, 0, // Calm - 0,-1, 0, 1, 0, // Gentle - 0, 0, 0, 1,-1, // Sassy - 0, 0,-1, 1, 0, // Careful - 0, 0, 0, 0, 0, // Quirky - }; - public int CalcCP => Math.Min(10000, AwakeCP + BaseCP); public int BaseCP @@ -591,7 +548,7 @@ public static int GetRandomIndex(int bits, int characterIndex, int nature) return GetRandomIndex(characterIndex); if (bits is 0) return 0; - var amps = NatureAmpTable.Slice(5 * nature, 5); + var amps = NatureAmp.GetAmps(nature); if (amps[bits - 1] != -1) // not a negative stat return bits; diff --git a/PKHeX.Core/PKM/PB8.cs b/PKHeX.Core/PKM/PB8.cs index ff2d3dce5..0f00707af 100644 --- a/PKHeX.Core/PKM/PB8.cs +++ b/PKHeX.Core/PKM/PB8.cs @@ -5,8 +5,8 @@ namespace PKHeX.Core; /// Generation 8 format. public sealed class PB8 : G8PKM { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ // Alignment bytes 0x17, 0x1A, 0x1B, 0x23, 0x33, 0x3E, 0x3F, 0x4C, 0x4D, 0x4E, 0x4F, @@ -23,7 +23,7 @@ public sealed class PB8 : G8PKM 0x13D, 0x13E, 0x13F, 0x140, 0x141, 0x142, 0x143, 0x144, 0x145, 0x146, 0x147, - }; + ]; public override PersonalInfo8BDSP PersonalInfo => PersonalTable.BDSP.GetFormEntry(Species, Form); public override IPermitRecord Permit => PersonalInfo; @@ -49,11 +49,11 @@ public void Trade(ITrainerInfo tr, int Day = 1, int Month = 1, int Year = 2015) { if (IsEgg) { - // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc) + // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc.) if ((tr.TID16 != TID16) || (tr.SID16 != SID16) || (tr.Gender != OT_Gender) || (tr.OT != OT_Name)) SetLinkTradeEgg(Day, Month, Year, Locations.LinkTrade6NPC); - // Unfortunately, BDSP doesn't return if it's an egg, and can update the HT details & handler. + // Unfortunately, BD/SP doesn't return if it's an egg, and can update the HT details & handler. // Continue to the rest of the method. // return; } diff --git a/PKHeX.Core/PKM/PK3.cs b/PKHeX.Core/PKM/PK3.cs index e44bbf312..1ac02b9b1 100644 --- a/PKHeX.Core/PKM/PK3.cs +++ b/PKHeX.Core/PKM/PK3.cs @@ -7,10 +7,7 @@ namespace PKHeX.Core; /// Generation 3 format. public sealed class PK3 : G3PKM, ISanityChecksum { - public override ReadOnlySpan ExtraBytes => new ushort[] - { - 0x2A, 0x2B, - }; + public override ReadOnlySpan ExtraBytes => [0x2A, 0x2B]; public override int SIZE_PARTY => PokeCrypto.SIZE_3PARTY; public override int SIZE_STORED => PokeCrypto.SIZE_3STORED; diff --git a/PKHeX.Core/PKM/PK4.cs b/PKHeX.Core/PKM/PK4.cs index 568c241fd..a04730d70 100644 --- a/PKHeX.Core/PKM/PK4.cs +++ b/PKHeX.Core/PKM/PK4.cs @@ -7,10 +7,10 @@ namespace PKHeX.Core; /// Generation 4 format. public sealed class PK4 : G4PKM { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87, - }; + ]; public override int SIZE_PARTY => PokeCrypto.SIZE_4PARTY; public override int SIZE_STORED => PokeCrypto.SIZE_4STORED; @@ -341,7 +341,7 @@ public PK5 ConvertToPK5() pk5.Nature = Nature; // Delete Platinum/HGSS Met Location Data - WriteUInt32LittleEndian(pk5.Data.AsSpan(0x44), 0); + pk5.Data.AsSpan(0x44, 4).Clear(); // Met / Crown Data Detection pk5.Met_Location = PK5.GetTransferMetLocation4(pk5); @@ -349,8 +349,8 @@ public PK5 ConvertToPK5() // Egg Location is not modified; when clearing Pt/HGSS egg data, the location will revert to Faraway Place // pk5.Egg_Location = Egg_Location; - // Delete HGSS Data - WriteUInt16LittleEndian(pk5.Data.AsSpan(0x86), 0); + // Delete HG/S Data + pk5.Data.AsSpan(0x86, 2).Clear(); pk5.Ball = Ball; // Transfer Nickname and OT Name, update encoding @@ -361,7 +361,7 @@ public PK5 ConvertToPK5() pk5.Met_Level = pk5.CurrentLevel; // Remove HM moves; Defog should be kept if both are learned. - // if has defog, remove whirlpool. + // If it has Defog, remove Whirlpool. bool hasDefog = HasMove((int) Move.Defog); var banned = LearnSource4.GetPreferredTransferHMs(hasDefog); if (banned.Contains(Move1)) pk5.Move1 = 0; diff --git a/PKHeX.Core/PKM/PK5.cs b/PKHeX.Core/PKM/PK5.cs index 283d2ad85..83cbd14cc 100644 --- a/PKHeX.Core/PKM/PK5.cs +++ b/PKHeX.Core/PKM/PK5.cs @@ -9,15 +9,15 @@ public sealed class PK5 : PKM, ISanityChecksum, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetUnique3, IRibbonSetUnique4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetRibbons, IContestStats, IGroundTile { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x43, 0x44, 0x45, 0x46, 0x47, 0x5E, // unused 0x63, // last 8 bits of a 32bit ribbonset 0x64, 0x65, 0x66, 0x67, // unused 32bit ribbonset? 0x86, // unused 0x87, // PokeStar Fame - }; + ]; public override int SIZE_PARTY => PokeCrypto.SIZE_5PARTY; public override int SIZE_STORED => PokeCrypto.SIZE_5STORED; diff --git a/PKHeX.Core/PKM/PK6.cs b/PKHeX.Core/PKM/PK6.cs index b13093600..7212a36bf 100644 --- a/PKHeX.Core/PKM/PK6.cs +++ b/PKHeX.Core/PKM/PK6.cs @@ -8,11 +8,11 @@ namespace PKHeX.Core; public sealed class PK6 : G6PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetMemory6, IRibbonSetRibbons, IContestStats, IGeoTrack, ISuperTrain, IFormArgument, ITrainerMemories, IAffection, IGroundTile { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x36, 0x37, // Unused Ribbons 0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7, - }; + ]; public override EntityContext Context => EntityContext.Gen6; public override PersonalInfo6AO PersonalInfo => PersonalTable.AO.GetFormEntry(Species, Form); @@ -443,7 +443,7 @@ protected override void TradeHT(ITrainerInfo tr) CurrentHandler = 1; HT_Gender = tr.Gender; - // Make a memory if no memory already exists. Pretty terrible way of doing this but I'd rather not overwrite existing memories. + // Make a memory if no memory already exists. Pretty terrible way of doing this, but I'd rather not overwrite existing memories. if (HT_Memory == 0) this.SetTradeMemoryHT6(false); } @@ -487,18 +487,14 @@ public PK7 ConvertToPK7() pk7.SetMarking(i, GetMarking(i)); var an = AbilityNumber; - switch (an) + if (an is 1 or 2 or 4) // Valid Ability Numbers { - case 1 or 2 or 4: // Valid Ability Numbers - int index = an >> 1; - - var abilities = (IPersonalAbility12H)PersonalInfo; - if (abilities.GetAbilityAtIndex(index) == Ability) // correct pair - pk7.Ability = pk7.PersonalInfo.GetAbilityAtIndex(index); - break; + int index = an >> 1; + if (PersonalInfo.GetAbilityAtIndex(index) == Ability) // correct pair + pk7.Ability = pk7.PersonalInfo.GetAbilityAtIndex(index); } - pk7.SetTradeMemoryHT6(true); // oh no, memories on gen7 pk + pk7.SetTradeMemoryHT6(true); // oh no, memories on Gen7 pk RecentTrainerCache.SetFirstCountryRegion(pk7); // Bank-accurate data zeroing diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs index 487df6734..2415fe9d1 100644 --- a/PKHeX.Core/PKM/PK7.cs +++ b/PKHeX.Core/PKM/PK7.cs @@ -8,12 +8,12 @@ namespace PKHeX.Core; public sealed class PK7 : G6PKM, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetMemory6, IRibbonSetCommon7, IRibbonSetRibbons, IContestStats, IHyperTrain, IGeoTrack, ISuperTrain, IFormArgument, ITrainerMemories, IAffection, IPokerusStatus { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x2A, // Old Marking Value (PelagoEventStatus) // 0x36, 0x37, // Unused Ribbons 0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7, - }; + ]; public override EntityContext Context => EntityContext.Gen7; public override PersonalInfo7 PersonalInfo => PersonalTable.USUM.GetFormEntry(Species, Form); @@ -241,8 +241,12 @@ public override string Nickname get => StringConverter7.GetString(Nickname_Trash); set { + // For Pokémon with no nickname, and match their Chinese species name, we need to use the private codepoint range instead of unicode. + // Can't use the stored language as it might have been traded & evolved -> mismatch; Gen8+ will match the origin language, not Gen7 :( if (!IsNicknamed) { + // Detect the language of the species name. + // If the species name is the same for Traditional and Simplified Chinese, we prefer the saved language. int lang = SpeciesName.GetSpeciesNameLanguage(Species, Language, value, 7); if (lang is (int)LanguageID.ChineseS or (int)LanguageID.ChineseT) { @@ -458,8 +462,8 @@ public void FixMemories() if (Generation < 7) // must be transferred via bank, and must have memories { - this.SetTradeMemoryHT6(true); // oh no, memories on gen7 pk - // georegions cleared on 6->7, no need to set + this.SetTradeMemoryHT6(true); // oh no, memories on Gen7 pk + // geolocations cleared on 6->7, no need to set } } @@ -501,7 +505,7 @@ protected override void TradeHT(ITrainerInfo tr) internal void SetTransferLocale(int lang) { - this.SetTradeMemoryHT6(bank: true); // oh no, memories on gen7 pk + this.SetTradeMemoryHT6(bank: true); // oh no, memories on Gen7 pk RecentTrainerCache.SetConsoleRegionData3DS(this); RecentTrainerCache.SetFirstCountryRegion(this); if (lang == 1 && Country != 1) // Japan Only diff --git a/PKHeX.Core/PKM/PK8.cs b/PKHeX.Core/PKM/PK8.cs index d66c2ee2d..3dc393fd3 100644 --- a/PKHeX.Core/PKM/PK8.cs +++ b/PKHeX.Core/PKM/PK8.cs @@ -6,8 +6,8 @@ namespace PKHeX.Core; /// Generation 8 format. public sealed class PK8 : G8PKM { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ // Alignment bytes 0x17, 0x1A, 0x1B, 0x23, 0x33, 0x3E, 0x3F, 0x4C, 0x4D, 0x4E, 0x4F, @@ -24,7 +24,7 @@ public sealed class PK8 : G8PKM 0x13D, 0x13E, 0x13F, 0x140, 0x141, 0x142, 0x143, 0x144, 0x145, 0x146, 0x147, - }; + ]; public override PersonalInfo8SWSH PersonalInfo => PersonalTable.SWSH.GetFormEntry(Species, Form); public override IPermitRecord Permit => PersonalInfo; @@ -40,7 +40,7 @@ public void Trade(ITrainerInfo tr, int Day = 1, int Month = 1, int Year = 2015) if (IsEgg) { // Eggs do not have any modifications done if they are traded - // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc) + // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc.) if ((tr.TID16 != TID16) || (tr.SID16 != SID16) || (tr.Gender != OT_Gender) || (tr.OT != OT_Name)) SetLinkTradeEgg(Day, Month, Year, Locations.LinkTrade6); return; diff --git a/PKHeX.Core/PKM/PK9.cs b/PKHeX.Core/PKM/PK9.cs index ff02e2e12..f4aa7ab69 100644 --- a/PKHeX.Core/PKM/PK9.cs +++ b/PKHeX.Core/PKM/PK9.cs @@ -9,8 +9,8 @@ public sealed class PK9 : PKM, ISanityChecksum, ITeraType, ITechRecord, IObedien IContestStats, IHyperTrain, IScaledSize, IScaledSize3, IFavorite, IHandlerLanguage, IFormArgument, IHomeTrack, IBattleVersion, ITrainerMemories, IRibbonIndex, IRibbonSetAffixed, IRibbonSetRibbons, IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetMemory6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetCommon9, IRibbonSetMarks, IRibbonSetMark8, IRibbonSetMark9 { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x17, 0x1A, 0x1B, 0x23, @@ -22,7 +22,7 @@ public sealed class PK9 : PKM, ISanityChecksum, ITeraType, ITechRecord, IObedien 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0x115, - }; + ]; public override PersonalInfo9SV PersonalInfo => PersonalTable.SV.GetFormEntry(Species, Form); public IPermitRecord Permit => PersonalInfo; @@ -488,8 +488,8 @@ private void SetMoveRecordFlagDLC(bool value, int index) } public bool GetMoveRecordFlagAny() => GetMoveRecordFlagAnyBase() || GetMoveRecordFlagAnyDLC(); - private bool GetMoveRecordFlagAnyBase() => RecordFlagsBase.IndexOfAnyExcept(0) >= 0; - private bool GetMoveRecordFlagAnyDLC() => RecordFlagsDLC.IndexOfAnyExcept(0) >= 0; + private bool GetMoveRecordFlagAnyBase() => RecordFlagsBase.ContainsAnyExcept(0); + private bool GetMoveRecordFlagAnyDLC() => RecordFlagsDLC.ContainsAnyExcept(0); public void ClearMoveRecordFlags() { @@ -549,7 +549,7 @@ public void Trade(ITrainerInfo tr, int Day = 1, int Month = 1, int Year = 2015) if (Egg_Location == 60005 && tr.Gender == OT_Gender && tr.Language == Language && tr.OT == OT_Name) return; // Jacq gift, don't change. - // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc) + // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc.) // If not matching the trainer details, mark as a traded egg. if (!IsTradedEgg && tr.Gender == OT_Gender && tr.Language == Language && tr.OT == OT_Name) { diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 7af38d98e..61cd10f05 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -21,7 +21,7 @@ public abstract class PKM : ISpeciesForm, ITrainerID32, IGeneration, IShiny, ILa public abstract int SIZE_STORED { get; } public string Extension => GetType().Name.ToLowerInvariant(); public abstract PersonalInfo PersonalInfo { get; } - public virtual ReadOnlySpan ExtraBytes => Array.Empty(); + public virtual ReadOnlySpan ExtraBytes => []; // Internal Attributes set on creation public readonly byte[] Data; // Raw Storage @@ -42,7 +42,7 @@ public abstract class PKM : ISpeciesForm, ITrainerID32, IGeneration, IShiny, ILa // Trash Bytes public abstract Span Nickname_Trash { get; } public abstract Span OT_Trash { get; } - public virtual Span HT_Trash => Span.Empty; + public virtual Span HT_Trash => []; protected abstract byte[] Encrypt(); public abstract EntityContext Context { get; } @@ -357,7 +357,7 @@ public int FlawlessIVCount public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set => SetIVs(value); } @@ -427,7 +427,7 @@ public void SetEVs(ReadOnlySpan value) public int[] Stats { - get => new[] { Stat_HPCurrent, Stat_ATK, Stat_DEF, Stat_SPE, Stat_SPA, Stat_SPD }; + get => [Stat_HPCurrent, Stat_ATK, Stat_DEF, Stat_SPE, Stat_SPA, Stat_SPD]; set { if (value.Length != 6) @@ -439,7 +439,7 @@ public int[] Stats public ushort[] Moves { - get => new[] { Move1, Move2, Move3, Move4 }; + get => [Move1, Move2, Move3, Move4]; set => SetMoves(value); } @@ -490,7 +490,7 @@ public void SetMoves(ReadOnlySpan value) public ushort[] RelearnMoves { - get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 }; + get => [RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4]; set => SetRelearnMoves(value); } @@ -658,7 +658,7 @@ private void ReorderMoves() public virtual void RefreshAbility(int n) { AbilityNumber = 1 << n; - IPersonalAbility pi = PersonalInfo; + var pi = PersonalInfo; if ((uint)n < pi.AbilityCount) Ability = pi.GetAbilityAtIndex(n); } diff --git a/PKHeX.Core/PKM/RK4.cs b/PKHeX.Core/PKM/RK4.cs index 1e512caa5..0eda12e87 100644 --- a/PKHeX.Core/PKM/RK4.cs +++ b/PKHeX.Core/PKM/RK4.cs @@ -10,10 +10,10 @@ namespace PKHeX.Core; /// public sealed class RK4 : G4PKM { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x42, 0x43, 0x5E, 0x63, 0x64, 0x65, 0x66, 0x67, 0x87, - }; + ]; public override int SIZE_PARTY => PokeCrypto.SIZE_4RSTORED; public override int SIZE_STORED => PokeCrypto.SIZE_4RSTORED; @@ -25,8 +25,8 @@ public sealed class RK4 : G4PKM private static byte[] Decrypt(byte[] data) { - byte[] pkData = data.Slice(0, PokeCrypto.SIZE_4STORED); - PokeCrypto.DecryptIfEncrypted45(ref pkData); + data = data[..PokeCrypto.SIZE_4STORED]; + PokeCrypto.DecryptIfEncrypted45(ref data); return data; } @@ -331,7 +331,7 @@ protected override byte[] Encrypt() RefreshChecksum(); byte[] data = (byte[])Data.Clone(); - byte[] pkData = data.Slice(0, PokeCrypto.SIZE_4STORED); + byte[] pkData = data[..PokeCrypto.SIZE_4STORED]; pkData = PokeCrypto.EncryptArray45(pkData); pkData.CopyTo(data, 0); return data; diff --git a/PKHeX.Core/PKM/SK2.cs b/PKHeX.Core/PKM/SK2.cs index f28d6f66d..6e5d1eac6 100644 --- a/PKHeX.Core/PKM/SK2.cs +++ b/PKHeX.Core/PKM/SK2.cs @@ -187,13 +187,13 @@ private static bool IsJapanese(ReadOnlySpan data) const byte terminator = StringConverter12.G1TerminatorCode; var ot = data.Slice(0x30, StringLength); - if (ot[6..].IndexOfAnyExcept(empty, terminator) != -1) + if (ot[6..].ContainsAnyExcept(empty, terminator)) return false; if (!StringConverter12.GetIsG1Japanese(ot)) return false; var nick = data.Slice(0x24, StringLength); - if (nick[6..].IndexOfAnyExcept(empty, terminator) != -1) + if (nick[6..].ContainsAnyExcept(empty, terminator)) return false; if (!StringConverter12.GetIsG1Japanese(nick)) return false; diff --git a/PKHeX.Core/PKM/Searching/SearchSettings.cs b/PKHeX.Core/PKM/Searching/SearchSettings.cs index 5dbceafe8..bb7843df6 100644 --- a/PKHeX.Core/PKM/Searching/SearchSettings.cs +++ b/PKHeX.Core/PKM/Searching/SearchSettings.cs @@ -34,17 +34,17 @@ public sealed class SearchSettings public CloneDetectionMethod SearchClones { get; set; } public string BatchInstructions { get; init; } = string.Empty; - private IReadOnlyList BatchFilters { get; set; } = Array.Empty(); - private IReadOnlyList BatchFiltersMeta { get; set; } = Array.Empty(); + private IReadOnlyList BatchFilters { get; set; } = []; + private IReadOnlyList BatchFiltersMeta { get; set; } = []; - public readonly List Moves = new(); + public readonly List Moves = []; // ReSharper disable once CollectionNeverUpdated.Global /// /// Extra Filters to be checked after all other filters have been checked. /// /// Collection is iterated right before clones are checked. - public List> ExtraFilters { get; } = new(); + public List> ExtraFilters { get; } = []; /// /// Adds a move to the required move list. @@ -213,9 +213,9 @@ public IReadOnlyList GetVersions(SaveFile sav, GameVersion fallback return Generation switch { - 1 when !ParseSettings.AllowGen1Tradeback => new[] {RD, BU, GN, YW}, - 2 when sav is SAV2 {Korean: true} => new[] {GD, SI}, - 1 or 2 => new[] {RD, BU, GN, YW, /* */ GD, SI, C}, + 1 when !ParseSettings.AllowGen1Tradeback => [RD, BU, GN, YW], + 2 when sav is SAV2 {Korean: true} => [GD, SI], + 1 or 2 => [RD, BU, GN, YW, /* */ GD, SI, C], _ when fallback.GetGeneration() == Generation => GameUtil.GetVersionsWithinRange(sav, Generation).ToArray(), _ => GameUtil.GameVersions, diff --git a/PKHeX.Core/PKM/Searching/SearchUtil.cs b/PKHeX.Core/PKM/Searching/SearchUtil.cs index f5aca6132..eb951df7e 100644 --- a/PKHeX.Core/PKM/Searching/SearchUtil.cs +++ b/PKHeX.Core/PKM/Searching/SearchUtil.cs @@ -88,7 +88,7 @@ public static bool SatisfiesFilterBatchInstruction(PKM pk, IReadOnlyList $"{pk.Species:0000}{pk.PID:X8}{GetIVString(pk)}{pk.Form:00}", }; - // use a space so we don't merge single digit IVs and potentially get incorrect collisions + // Use a space as our separator -- don't merge single digit IVs and potentially get incorrect collisions private static string GetIVString(PKM pk) => $"{pk.IV_HP} {pk.IV_ATK} {pk.IV_DEF} {pk.IV_SPE} {pk.IV_SPA} {pk.IV_SPD}"; public static string HashByPID(PKM pk) => pk switch @@ -122,10 +122,8 @@ public static IEnumerable GetExtraClones(IEnumerable db, Func (uint)value <= (uint)max ? (byte)value : (byte)Core.Ball.Poke; - // Ball to display in DPPt + // Ball to display in D/P/Pt BallDPPt = Clamp(value, Core.Ball.Cherish); // Only set the HG/SS value if it originated in HG/SS and was not an event. @@ -280,7 +280,7 @@ public bool Trade(string SAV_Trainer, uint savID32, int SAV_GENDER, int Day = 1, return false; } - // Enforce DP content only (no PtHGSS) + // Enforce D/P content only (no Pt or HG/SS) protected void StripPtHGSSContent(PKM pk) { if (Form != 0 && !PersonalTable.DP[Species].HasForms && Species != 201) diff --git a/PKHeX.Core/PKM/Shared/G6PKM.cs b/PKHeX.Core/PKM/Shared/G6PKM.cs index 07e35531f..409bbc21f 100644 --- a/PKHeX.Core/PKM/Shared/G6PKM.cs +++ b/PKHeX.Core/PKM/Shared/G6PKM.cs @@ -84,7 +84,7 @@ public void Trade(ITrainerInfo tr, int Day = 1, int Month = 1, int Year = 2015) if (IsEgg) { // Eggs do not have any modifications done if they are traded - // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc) + // Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc.) if ((tr.TID16 != TID16) || (tr.SID16 != SID16) || (tr.Gender != OT_Gender) || (tr.OT != OT_Name)) SetLinkTradeEgg(Day, Month, Year, Locations.LinkTrade6); return; diff --git a/PKHeX.Core/PKM/Shared/G8PKM.cs b/PKHeX.Core/PKM/Shared/G8PKM.cs index ba98fcef3..7dc65e8d8 100644 --- a/PKHeX.Core/PKM/Shared/G8PKM.cs +++ b/PKHeX.Core/PKM/Shared/G8PKM.cs @@ -377,7 +377,7 @@ public override string HT_Name public Span PokeJob => Data.AsSpan(0xCE, 14); public bool GetPokeJobFlag(int index) => FlagUtil.GetFlag(PokeJob, index >> 3, index & 7); public void SetPokeJobFlag(int index, bool value) => FlagUtil.SetFlag(PokeJob, index >> 3, index & 7, value); - public bool GetPokeJobFlagAny() => PokeJob.IndexOfAnyExcept(0) >= 0; + public bool GetPokeJobFlagAny() => PokeJob.ContainsAnyExcept(0); public void ClearPokeJobFlags() => PokeJob.Clear(); public override byte Fullness { get => Data[0xDC]; set => Data[0xDC] = value; } @@ -432,7 +432,7 @@ public override string OT_Name public Span RecordFlags => Data.AsSpan(0x127, 14); public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlags, index >> 3, index & 7); public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlags, index >> 3, index & 7, value); - public bool GetMoveRecordFlagAny() => RecordFlags.IndexOfAnyExcept(0) >= 0; + public bool GetMoveRecordFlagAny() => RecordFlags.ContainsAnyExcept(0); public void ClearMoveRecordFlags() => RecordFlags.Clear(); // Why did you mis-align this field, GameFreak? diff --git a/PKHeX.Core/PKM/Shared/GBPKM.cs b/PKHeX.Core/PKM/Shared/GBPKM.cs index 3821ec4e0..0744392f0 100644 --- a/PKHeX.Core/PKM/Shared/GBPKM.cs +++ b/PKHeX.Core/PKM/Shared/GBPKM.cs @@ -18,7 +18,7 @@ public abstract class GBPKM : PKM public sealed override int MaxIV => 15; public sealed override int MaxEV => EffortValues.Max12; - public sealed override ReadOnlySpan ExtraBytes => ReadOnlySpan.Empty; + public sealed override ReadOnlySpan ExtraBytes => []; protected GBPKM([ConstantExpected] int size) : base(size) { } protected GBPKM(byte[] data) : base(data) { } @@ -135,12 +135,9 @@ public sealed override int Gender public sealed override int HPType { - get => ((IV_ATK & 3) << 2) | (IV_DEF & 3); - set - { - IV_DEF = ((IV_DEF >> 2) << 2) | (value & 3); - IV_DEF = ((IV_ATK >> 2) << 2) | ((value >> 2) & 3); - } + // Get and set values directly without multiple calls to DV16. + get => HiddenPower.GetTypeGB(DV16); + set => DV16 = HiddenPower.SetTypeGB(value, DV16); } public sealed override byte Form @@ -228,10 +225,10 @@ public override void LoadStats(IBaseStat p, Span stats) protected static ushort GetStat(int baseStat, int iv, int effort, int level) { - // The games store a precomputed ushort[256] i*i table for all ushort->byte square root calcs. + // The games store a precomputed ushort[256] i^2 table for all ushort->byte square root calculations. // The game then iterates to find the lowest index with a value >= input (effort). // With modern CPUs we can just call sqrt->ceil directly. - // ceil(sqrt(65535)) evals to 256, but we're clamped to byte only. + // ceil(sqrt(65535)) evaluates to 256, but we're clamped to byte only. byte firstSquare = (byte)Math.Min(255, Math.Ceiling(Math.Sqrt(effort))); effort = firstSquare >> 2; diff --git a/PKHeX.Core/PKM/Shared/GBPKML.cs b/PKHeX.Core/PKM/Shared/GBPKML.cs index 9d10027c4..1ce3a2493 100644 --- a/PKHeX.Core/PKM/Shared/GBPKML.cs +++ b/PKHeX.Core/PKM/Shared/GBPKML.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace PKHeX.Core; @@ -21,7 +22,7 @@ public abstract class GBPKML : GBPKM public sealed override Span Nickname_Trash => RawNickname; public sealed override Span OT_Trash => RawOT; - protected GBPKML(int size, bool jp = false) : base(size) + protected GBPKML([ConstantExpected] int size, bool jp = false) : base(size) { int strLen = jp ? StringLengthJapanese : StringLengthNotJapan; diff --git a/PKHeX.Core/PKM/Shared/PokeListGB.cs b/PKHeX.Core/PKM/Shared/PokeListGB.cs index 772207eb8..860f7d19f 100644 --- a/PKHeX.Core/PKM/Shared/PokeListGB.cs +++ b/PKHeX.Core/PKM/Shared/PokeListGB.cs @@ -17,7 +17,7 @@ public abstract class PokeListGB where T : GBPKML // // where, // - str has variable size (jp/int) - // - pkx is different size for gen1/gen2 + // - pkx is different size for Gen1/Gen2 private readonly int StringLength; private readonly byte[] Data; @@ -140,7 +140,7 @@ private T GetEntry(int base_ofs, int index) int otOfs = GetOffsetPKMOT(base_ofs, index); int nkOfs = GetOffsetPKMNickname(base_ofs, index); - var dat = Data.Slice(pkOfs, Entry_Size); + var dat = Data.AsSpan(pkOfs, Entry_Size).ToArray(); var otname = Data.AsSpan(otOfs, StringLength); var nick = Data.AsSpan(nkOfs, StringLength); diff --git a/PKHeX.Core/PKM/Strings/StringConverter12.cs b/PKHeX.Core/PKM/Strings/StringConverter12.cs index 5543468d1..a41f28873 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter12.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter12.cs @@ -183,8 +183,8 @@ public static int LoadString(ReadOnlySpan data, Span result, bool jp private const char LEA = '%'; // é for Box private const char DOT = '․'; // Not . - public static ReadOnlySpan TableEN => new[] - { + public static ReadOnlySpan TableEN => + [ NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 00-0F NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 10-1F NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 20-2F @@ -201,10 +201,10 @@ public static int LoadString(ReadOnlySpan data, Span result, bool jp 'ì', 'í', 'ñ', 'ò', 'ó', 'ú', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, '←', '\'', // D0-DF '’', LPK, LMN, '-', NUL, NUL, '?', '!', '.', '&', LEA, '→', '▷', '▶', '▼', '♂', // E0-EF MNY, '×', DOT, '/', ',', '♀', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // F0-FF - }; + ]; - public static ReadOnlySpan TableJP => new[] - { + public static ReadOnlySpan TableJP => + [ NUL, NUL, NUL, NUL, NUL, 'ガ', 'ギ', 'グ', 'ゲ', 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', 'ゾ', 'ダ', // 00-0F 'ヂ', 'ヅ', 'デ', 'ド', NUL, NUL, NUL, NUL, NUL, 'バ', 'ビ', 'ブ', 'ボ', NUL, NUL, NUL, // 10-1F NUL, NUL, NUL, NUL, NUL, NUL, 'が', 'ぎ', 'ぐ', 'げ', 'ご', 'ざ', 'じ', 'ず', 'ぜ', 'ぞ', // 20-2F @@ -221,7 +221,7 @@ public static int LoadString(ReadOnlySpan data, Span result, bool jp 'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'リ', 'る', 'れ', 'ろ', 'わ', 'を', 'ん', 'っ', // D0-DF 'ゃ', 'ゅ', 'ょ', 'ー', '゚', '゙', '?', '!', '。', 'ァ', 'ゥ', 'ェ', NUL, NUL, NUL, '♂', // E0-EF MNY, NUL, '.', '/', 'ォ', '♀', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // F0-FF - }; + ]; #endregion } diff --git a/PKHeX.Core/PKM/Strings/StringConverter12Transporter.cs b/PKHeX.Core/PKM/Strings/StringConverter12Transporter.cs index 3ee77c235..237e19091 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter12Transporter.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter12Transporter.cs @@ -66,10 +66,7 @@ private static void CheckKata(Span chars) /// /// Checks if any char is from the clashing Katakana range. /// - private static bool IsAnyKataRemap(ReadOnlySpan chars) - { - return chars.IndexOfAny(Katakana) != -1; - } + private static bool IsAnyKataRemap(ReadOnlySpan chars) => chars.ContainsAny(Katakana); private static bool IsAnyKataOnly(ReadOnlySpan chars) { @@ -97,8 +94,8 @@ private static bool IsAnyKataOnly(ReadOnlySpan chars) ///
0xCD at arr[0xC9] = Í (Spanish In-game Trade Shuckle, MANÍA)
///
All other new language sensitive re-mapping (or lack thereof) are inaccessible via the character entry screen.
/// - private static ReadOnlySpan CharTableINT => new ushort[] - { + private static ReadOnlySpan CharTableINT => + [ 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // 0 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // 1 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // 2 @@ -115,14 +112,14 @@ private static bool IsAnyKataOnly(ReadOnlySpan chars) 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // D 0x0020, 0x0050, 0x004D, 0x002D, 0x0020, 0x0020, 0x003F, 0x0021, 0x002D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0xE08E, // E 0x0020, 0x0078, 0x002E, 0x002F, 0x002C, 0xE08F, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // F - }; + ]; /// /// Japanese 1/2->7 character translation table /// /// Full-width 0-9 removed from the Japanese table as these glyphs are inaccessible via the character entry screen. - private static ReadOnlySpan CharTableJPN => new ushort[] - { + private static ReadOnlySpan CharTableJPN => + [ 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30AC, 0x30AE, 0x30B0, 0x30B2, 0x30B4, 0x30B6, 0x30B8, 0x30BA, 0x30BC, 0x30BE, 0x30C0, // 0 0x30C2, 0x30C5, 0x30C7, 0x30C9, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30D0, 0x30D3, 0x30D6, 0x30DC, 0x3000, 0x3000, 0x3000, // 1 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x304C, 0x304E, 0x3050, 0x3052, 0x3054, 0x3056, 0x3058, 0x305A, 0x305C, 0x305E, // 2 @@ -139,7 +136,7 @@ private static bool IsAnyKataOnly(ReadOnlySpan chars) 0x307F, 0x3080, 0x3081, 0x3082, 0x3084, 0x3086, 0x3088, 0x3089, 0x30EA, 0x308B, 0x308C, 0x308D, 0x308F, 0x3092, 0x3093, 0x3063, // D 0x3083, 0x3085, 0x3087, 0x30FC, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x30A1, 0x30A5, 0x30A7, 0x3000, 0x3000, 0x3000, 0x2642, // E 0x3000, 0x3000, 0x3000, 0x3000, 0x30A9, 0x2640, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, // F - }; + ]; public static string GetTradeNameGen1(int language) => language switch { diff --git a/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs b/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs index 6e279cba7..cea3501a7 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter2KOR.cs @@ -95,7 +95,7 @@ public static int LoadString(ReadOnlySpan data, Span result) if (value.Length == 0) return 0; - // Can't get Gen1 In-Game trades with this char, but handle it anyways since the game can handle it. + // Can't get Gen1 In-Game trades with this char, but handle it anyway since the game can handle it. if (value[0] == G1TradeOT) // Handle "[TRAINER]" { destBuffer[0] = G1TradeOTCode; @@ -198,8 +198,8 @@ public static void LocalizeKOR2(ushort species, ref string nick) _ => throw new ArgumentOutOfRangeException(nameof(table)), }; - private static ReadOnlySpan Table1 => new[] - { + private static ReadOnlySpan Table1 => + [ NULL, '가', '각', '간', '갇', '갈', '갉', '갊', '감', '갑', '값', '갓', '갔', '강', '갖', '갗', '같', '갚', '갛', '개', '객', '갠', '갤', '갬', '갭', '갯', '갰', '갱', '갸', '갹', '갼', '걀', '걋', '걍', '걔', '걘', '걜', '거', '걱', '건', '걷', '걸', '걺', '검', '겁', '것', '겄', '겅', @@ -216,10 +216,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) NULL, '깹', '깻', '깼', '깽', '꺄', '꺅', '꺌', '꺼', '꺽', '꺾', '껀', '껄', '껌', '껍', '껏', '껐', '껑', '께', '껙', '껜', '껨', '껫', '껭', '껴', '껸', '껼', '꼇', '꼈', '꼍', '꼐', '꼬', '꼭', '꼰', '꼲', '꼴', '꼼', '꼽', '꼿', '꽁', '꽂', '꽃', '꽈', '꽉', '꽐', '꽜', '꽝', '꽤', - }; + ]; - private static ReadOnlySpan Table2 => new[] - { + private static ReadOnlySpan Table2 => + [ '꽥', '꽹', '꾀', '꾄', '꾈', '꾐', '꾑', '꾕', '꾜', '꾸', '꾹', '꾼', '꿀', '꿇', '꿈', '꿉', '꿋', '꿍', '꿎', '꿔', '꿜', '꿨', '꿩', '꿰', '꿱', '꿴', '꿸', '뀀', '뀁', '뀄', '뀌', '뀐', '뀔', '뀜', '뀝', '뀨', '끄', '끅', '끈', '끊', '끌', '끎', '끓', '끔', '끕', '끗', '끙', NULL, @@ -236,10 +236,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) '닉', '닌', '닐', '닒', '님', '닙', '닛', '닝', '닢', '다', '닥', '닦', '단', '닫', '달', '닭', '닮', '닯', '닳', '담', '답', '닷', '닸', '당', '닺', '닻', '닿', '대', '댁', '댄', '댈', '댐', '댑', '댓', '댔', '댕', NULL, '더', '덕', '덖', '던', '덛', '덜', '덞', '덟', '덤', '덥', NULL, - }; + ]; - private static ReadOnlySpan Table3 => new[] - { + private static ReadOnlySpan Table3 => + [ NULL, '덧', '덩', '덫', '덮', '데', '덱', '덴', '델', '뎀', '뎁', '뎃', '뎄', '뎅', '뎌', '뎐', '뎔', '뎠', '뎡', '뎨', '뎬', '도', '독', '돈', '돋', '돌', '돎', NULL, '돔', '돕', '돗', '동', '돛', '돝', '돠', '돤', '돨', '돼', '됐', '되', '된', '될', '됨', '됩', '됫', '됴', '두', '둑', @@ -256,10 +256,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) '뢔', '래', '랙', '랜', '랠', '램', '랩', '랫', '랬', '랭', '랴', '략', '랸', '럇', '량', '러', '럭', '런', '럴', '럼', '럽', '럿', '렀', '렁', '렇', '레', '렉', '렌', '렐', '렘', '렙', '렛', '렝', '려', '력', '련', '렬', '렴', '렵', '렷', '렸', '령', '례', '롄', '롑', '롓', '로', '록', - }; + ]; - private static ReadOnlySpan Table4 => new[] - { + private static ReadOnlySpan Table4 => + [ '론', '롤', '롬', '롭', '롯', '롱', '롸', '롼', '뢍', '뢨', '뢰', '뢴', '뢸', '룀', '룁', '룃', '룅', '료', '룐', '룔', '룝', '룟', '룡', '루', '룩', '룬', '룰', '룸', '룹', '룻', '룽', '뤄', '뤘', '뤠', '뤼', '뤽', '륀', '륄', '륌', '륏', '륑', '류', '륙', '륜', '률', '륨', '륩', NULL, @@ -276,10 +276,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) '밀', '밂', '밈', '밉', '밋', '밌', '밍', '및', '밑', '바', '박', '밖', '밗', '반', '받', '발', '밝', '밞', '밟', '밤', '밥', '밧', '방', '밭', '배', '백', '밴', '밸', '뱀', '뱁', '뱃', '뱄', '뱅', '뱉', '뱌', '뱍', '뱐', '뱝', '버', '벅', '번', '벋', '벌', '벎', '범', '법', '벗', NULL, - }; + ]; - private static ReadOnlySpan Table5 => new[] - { + private static ReadOnlySpan Table5 => + [ NULL, '벙', '벚', '베', '벡', '벤', '벧', '벨', '벰', '벱', '벳', '벴', '벵', '벼', '벽', '변', '별', '볍', '볏', '볐', '병', '볕', '볘', '볜', '보', '복', '볶', '본', '볼', '봄', '봅', '봇', '봉', '봐', '봔', '봤', '봬', '뵀', '뵈', '뵉', '뵌', '뵐', '뵘', '뵙', '뵤', '뵨', '부', '북', @@ -296,10 +296,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) NULL, '샥', '샨', '샬', '샴', '샵', '샷', '샹', '섀', '섄', '섈', '섐', '섕', '서', '석', '섞', '섟', '선', '섣', '설', '섦', '섧', '섬', '섭', '섯', '섰', '성', '섶', '세', '섹', '센', '셀', '셈', '셉', '셋', '셌', '셍', '셔', '셕', '션', '셜', '셤', '셥', '셧', '셨', '셩', '셰', '셴', - }; + ]; - private static ReadOnlySpan Table6 => new[] - { + private static ReadOnlySpan Table6 => + [ '셸', '솅', '소', '속', '솎', '손', '솔', '솖', '솜', '솝', '솟', '송', '솥', '솨', '솩', '솬', '솰', '솽', '쇄', '쇈', '쇌', '쇔', '쇗', '쇘', '쇠', '쇤', '쇨', '쇰', '쇱', '쇳', '쇼', '쇽', '숀', '숄', '숌', '숍', '숏', '숑', '수', '숙', '순', '숟', '술', '숨', '숩', '숫', '숭', '쌰', @@ -316,10 +316,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) '압', '앗', '았', '앙', '앝', '앞', '애', '액', '앤', '앨', '앰', '앱', '앳', '앴', '앵', '야', '약', '얀', '얄', '얇', '얌', '얍', '얏', '양', '얕', '얗', '얘', '얜', '얠', '얩', '어', '억', '언', '얹', '얻', '얼', '얽', '얾', '엄', '업', '없', '엇', '었', '엉', '엊', '엌', '엎', NULL, - }; + ]; - private static ReadOnlySpan Table7 => new[] - { + private static ReadOnlySpan Table7 => + [ NULL, '에', '엑', '엔', '엘', '엠', '엡', '엣', '엥', '여', '역', '엮', '연', '열', '엶', '엷', '염', '엽', '엾', '엿', '였', '영', '옅', '옆', '옇', '예', '옌', '옐', '옘', '옙', '옛', '옜', '오', '옥', '온', '올', '옭', '옮', '옰', '옳', '옴', '옵', '옷', '옹', '옻', '와', '왁', '완', @@ -336,10 +336,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) NULL, '점', '접', '젓', '정', '젖', '제', '젝', '젠', '젤', '젬', '젭', '젯', '젱', '져', '젼', '졀', '졈', '졉', '졌', '졍', '졔', '조', '족', '존', '졸', '졺', '좀', '좁', '좃', '종', '좆', '좇', '좋', '좌', '좍', '좔', '좝', '좟', '좡', '좨', '좼', '좽', '죄', '죈', '죌', '죔', '죕', - }; + ]; - private static ReadOnlySpan Table8 => new[] - { + private static ReadOnlySpan Table8 => + [ '죗', '죙', '죠', '죡', '죤', '죵', '주', '죽', '준', '줄', '줅', '줆', '줌', '줍', '줏', '중', '줘', '줬', '줴', '쥐', '쥑', '쥔', '쥘', '쥠', '쥡', '쥣', '쥬', '쥰', '쥴', '쥼', '즈', '즉', '즌', '즐', '즘', '즙', '즛', '증', '지', '직', '진', '짇', '질', '짊', '짐', '집', '짓', NULL, @@ -356,10 +356,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) '촛', '총', '촤', '촨', '촬', '촹', '최', '쵠', '쵤', '쵬', '쵭', '쵯', '쵱', '쵸', '춈', '추', '축', '춘', '출', '춤', '춥', '춧', '충', '춰', '췄', '췌', '췐', '취', '췬', '췰', '췸', '췹', '췻', '췽', '츄', '츈', '츌', '츔', '츙', '츠', '측', '츤', '츨', '츰', '츱', '츳', '층', NULL, - }; + ]; - private static ReadOnlySpan Table9 => new[] - { + private static ReadOnlySpan Table9 => + [ NULL, '치', '칙', '친', '칟', '칠', '칡', '침', '칩', '칫', '칭', '카', '칵', '칸', '칼', '캄', '캅', '캇', '캉', '캐', '캑', '캔', '캘', '캠', '캡', '캣', '캤', '캥', '캬', '캭', '컁', '커', '컥', '컨', '컫', '컬', '컴', '컵', '컷', '컸', '컹', '케', '켁', '켄', '켈', '켐', '켑', '켓', @@ -376,10 +376,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) NULL, '퉤', '튀', '튁', '튄', '튈', '튐', '튑', '튕', '튜', '튠', '튤', '튬', '튱', '트', '특', '튼', '튿', '틀', '틂', '틈', '틉', '틋', '틔', '틘', '틜', '틤', '틥', '티', '틱', '틴', '틸', '팀', '팁', '팃', '팅', '파', '팍', '팎', '판', '팔', '팖', '팜', '팝', '팟', '팠', '팡', '팥', - }; + ]; - private static ReadOnlySpan TableA => new[] - { + private static ReadOnlySpan TableA => + [ '패', '팩', '팬', '팰', '팸', '팹', '팻', '팼', '팽', '퍄', '퍅', '퍼', '퍽', '펀', '펄', '펌', '펍', '펏', '펐', '펑', '페', '펙', '펜', '펠', '펨', '펩', '펫', '펭', '펴', '편', '펼', '폄', '폅', '폈', '평', '폐', '폘', '폡', '폣', '포', '폭', '폰', '폴', '폼', '폽', '폿', '퐁', NULL, @@ -396,10 +396,10 @@ public static void LocalizeKOR2(ushort species, ref string nick) '훵', '훼', '훽', '휀', '휄', '휑', '휘', '휙', '휜', '휠', '휨', '휩', '휫', '휭', '휴', '휵', '휸', '휼', '흄', '흇', '흉', '흐', '흑', '흔', '흖', '흗', '흘', '흙', '흠', '흡', '흣', '흥', '흩', '희', '흰', '흴', '흼', '흽', '힁', '히', '힉', '힌', '힐', '힘', '힙', '힛', '힝', NULL, - }; + ]; - private static ReadOnlySpan TableB => new[] - { + private static ReadOnlySpan TableB => + [ 'ㄱ', 'ㄴ', 'ㄷ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅅ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', 'ㄲ', 'ㄸ', 'ㅃ', 'ㅆ', 'ㅉ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'ㅏ', 'ㅑ', 'ㅓ', 'ㅕ', 'ㅗ', 'ㅛ', 'ㅜ', 'ㅠ', 'ㅡ', 'ㅣ', 'ㅐ', 'ㅒ', 'ㅔ', 'ㅖ', 'ㅘ', 'ㅙ', @@ -416,12 +416,12 @@ public static void LocalizeKOR2(ushort species, ref string nick) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, ' ', - }; + ]; // In transporter's code, none of these glyphs are legitimately accessible via keyboard. private const char NUL = NULL; - private static ReadOnlySpan Table0 => new[] - { + private static ReadOnlySpan Table0 => + [ NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, @@ -438,7 +438,7 @@ public static void LocalizeKOR2(ushort species, ref string nick) NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, '♂', NUL, '×', NUL, '/', NUL, '♀', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - }; + ]; #endregion } diff --git a/PKHeX.Core/PKM/Strings/StringConverter3.cs b/PKHeX.Core/PKM/Strings/StringConverter3.cs index 6668a258f..ebb03873f 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter3.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter3.cs @@ -109,8 +109,8 @@ public static byte SetG3Char(char chr, bool jp) return (byte)index; } - private static ReadOnlySpan G3_EN => new[] - { + private static ReadOnlySpan G3_EN => + [ ' ', 'À', 'Á', 'Â', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'こ', 'Î', 'Ï', 'Ò', 'Ó', 'Ô', // 0 'Œ', 'Ù', 'Ú', 'Û', 'Ñ', 'ß', 'à', 'á', 'ね', 'Ç', 'È', 'é', 'ê', 'ë', 'ì', 'í', // 1 'î', 'ï', 'ò', 'ó', 'ô', 'œ', 'ù', 'ú', 'û', 'ñ', 'º', 'ª', '⒅', '&', '+', 'あ', // 2 @@ -130,10 +130,10 @@ public static byte SetG3Char(char chr, bool jp) // Make the total length 256 so that any byte access is always within the array Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, - }; + ]; - private static ReadOnlySpan G3_JP => new[] - { + private static ReadOnlySpan G3_JP => + [ ' ', 'あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す', 'せ', 'そ', // 0 'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の', 'は', 'ひ', 'ふ', 'へ', 'ほ', 'ま', // 1 'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ', 'を', 'ん', 'ぁ', // 2 @@ -153,5 +153,5 @@ public static byte SetG3Char(char chr, bool jp) // Make the total length 256 so that any byte access is always within the array Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, Terminator, - }; + ]; } diff --git a/PKHeX.Core/PKM/Strings/StringConverter345.cs b/PKHeX.Core/PKM/Strings/StringConverter345.cs index 41832325b..9c3cb2baa 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter345.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter345.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -10,31 +9,20 @@ namespace PKHeX.Core; public static class StringConverter345 { /// - /// Trash Bytes for Generation 3->4 + /// Trash Bytes for Generation 3->4 based on transfer to Diamond/Pearl. /// /// String buffers are reused, data is not cleared which yields the trash bytes. - private static ReadOnlySpan G4TransferTrashBytes => new byte[] + /// The first 4 bytes are undocumented, as transferred Gen3 strings will always have at least 2 chars. + public static ReadOnlySpan GetTrashBytes(int language) => language switch { - 0x18, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xA1, 0x0C, 0x02, 0xE0, 0xFF, // 2 - 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF, // 3 - 0x54, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0xA1, 0x0C, 0x02, 0xE0, 0xFF, // 4 - 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF, // 5 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 6 - 0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF, // 7 + 2 => [0x18, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xA1, 0x0C, 0x02, 0xE0, 0xFF], + 3 => [0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF], + 4 => [0x54, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0xA1, 0x0C, 0x02, 0xE0, 0xFF], + 5 => [0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF], + 7 => [0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1, 0x0C, 0x02, 0xE0, 0xFF], + _ => [], // No Trash Bytes }; - private const int TrashByteLanguages = 6; // rows - private const int TrashByteLayerWidth = 18; // columns - - public static ReadOnlySpan GetTrashBytes(int language) - { - language -= 2; - if ((uint)language >= TrashByteLanguages) - return ReadOnlySpan.Empty; - var offset = language * TrashByteLayerWidth; - return G4TransferTrashBytes.Slice(offset, TrashByteLayerWidth); - } - /// /// Remaps Gen5 Glyphs to unicode codepoint. /// @@ -42,36 +30,78 @@ public static ReadOnlySpan GetTrashBytes(int language) /// Remapped string public static void TransferGlyphs56(Span buffer) { - var table = Glyph56; for (int i = 0; i < buffer.Length; i += 2) { - var c = (char)ReadUInt16LittleEndian(buffer[i..]); - if (table.TryGetValue(c, out c)) - WriteUInt16LittleEndian(buffer[i..], c); + var span = buffer[i..]; + var c = ReadUInt16LittleEndian(span); + if (IsPrivateUseChar(c)) + WriteUInt16LittleEndian(span, GetMigratedPrivateChar(c)); } } - private static readonly Dictionary Glyph56 = new() + /// + /// Remaps private use unicode codepoint back to Gen5 private use codepoint. + /// + /// Input characters to transfer in place + /// Remapped string + public static void TransferGlyphs65(Span buffer) { - {'\u2467', '\u00d7'}, // × - {'\u2468', '\u00f7'}, // ÷ + for (int i = 0; i < buffer.Length; i += 2) + { + var span = buffer[i..]; + var c = ReadUInt16LittleEndian(span); + if (IsPrivateUseCharUnicode(c)) + WriteUInt16LittleEndian(span, GetUnmigratedPrivateChar(c)); + } + } - {'\u246c', '\uE08D'}, // … - {'\u246d', '\uE08E'}, // ♂ - {'\u246e', '\uE08F'}, // ♀ - {'\u246f', '\uE090'}, // ♠ - {'\u2470', '\uE091'}, // ♣ - {'\u2471', '\uE092'}, // ♥ - {'\u2472', '\uE093'}, // ♦ - {'\u2473', '\uE094'}, // ★ - {'\u2474', '\uE095'}, // ◎ - {'\u2475', '\uE096'}, // ○ - {'\u2476', '\uE097'}, // □ - {'\u2477', '\uE098'}, // △ - {'\u2478', '\uE099'}, // ◇ - {'\u2479', '\uE09A'}, // ♪ - {'\u247a', '\uE09B'}, // ☀ - {'\u247b', '\uE09C'}, // ☁ - {'\u247d', '\uE09D'}, // ☂ - }; + // Nonstandard characters for Gen 5 are stored at 0x2460 instead of the reserved section. + // We could ignore inaccessible indexes, but we'll just remap them in bulk. + private const ushort PrivateUseStartGlyph = 0x2460; + private const ushort PrivateUseEndGlyph = 0x2487; + private const ushort PrivateUseGlyphCount = PrivateUseEndGlyph - PrivateUseStartGlyph + 1; + // 0xE000 is the first private use character in the unicode fonts. + // The 3DS uses 0xE000-0xE080 for system characters, so any migrated glyph will be 0xE081 onwards. + private const ushort PrivateUseStartUnicode = 0xE081; + private const ushort PrivateUseEndUnicode = PrivateUseStartUnicode + PrivateUseGlyphCount - 1; + + /// + /// Checks if the glyph is a private use character for Generation5 games. + /// + /// Codepoint glyph stored in data. + /// True if it needs to be remapped when converting to unicode. + public static bool IsPrivateUseChar(ushort glyph) + => glyph is (>= PrivateUseStartGlyph and <= PrivateUseEndGlyph); + + /// + /// Checks if the glyph is a private use character for unicode compatible to Gen5 games. + /// + /// Codepoint glyph stored in data. + /// True if it needs to be remapped when converting from unicode. + /// + /// Use two comparisons instead of one-after-subtraction. + /// Most players never select these special characters, so the hot path will be almost always false. + /// + public static bool IsPrivateUseCharUnicode(ushort glyph) + => glyph is (>= PrivateUseStartUnicode and <= PrivateUseEndUnicode); + + /// + /// Converts a Generation5 private use character to a unicode private use codepoint. + /// + /// Codepoint glyph stored in data. + /// Unicode private use codepoint. + /// + /// Use two comparisons instead of one-after-subtraction. + /// Most players never select these special characters, so the hot path will be almost always false. + /// + public static ushort GetMigratedPrivateChar(ushort glyph) => + (ushort)(glyph - PrivateUseStartGlyph + PrivateUseStartUnicode); + + /// + /// Converts a unicode private use codepoint to a Generation 4/5 private use character. + /// + /// Codepoint glyph stored in data. + /// Gen5 private use codepoint. + public static ushort GetUnmigratedPrivateChar(ushort glyph) => + (ushort)(glyph - PrivateUseStartUnicode + PrivateUseStartGlyph); } diff --git a/PKHeX.Core/PKM/Strings/StringConverter4.cs b/PKHeX.Core/PKM/Strings/StringConverter4.cs index f0edbf40f..b93797e49 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter4.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter4.cs @@ -10,7 +10,6 @@ namespace PKHeX.Core; public static class StringConverter4 { private const ushort Terminator = 0xFFFF; - private const char TerminatorChar = (char)Terminator; /// Converts Generation 4 encoded data to decoded string. /// Encoded data @@ -35,8 +34,6 @@ public static int LoadString(ReadOnlySpan data, Span result) if (value == Terminator) break; char chr = (char)ConvertValue2CharG4(value); - if (chr == TerminatorChar) - break; chr = StringConverter.SanitizeChar(chr); result[i/2] = chr; } diff --git a/PKHeX.Core/PKM/Strings/StringConverter4GC.cs b/PKHeX.Core/PKM/Strings/StringConverter4GC.cs index 3435a331d..b65b17db9 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter4GC.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter4GC.cs @@ -37,8 +37,6 @@ public static int LoadString(ReadOnlySpan data, Span result) if (value == Terminator) break; char chr = (char)ConvertValue2CharG4(value); - if (chr == TerminatorChar) - break; chr = StringConverter.SanitizeChar(chr); result[i/2] = chr; } diff --git a/PKHeX.Core/PKM/Strings/StringConverter4Util.cs b/PKHeX.Core/PKM/Strings/StringConverter4Util.cs index ddbc532ca..950c58f69 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter4Util.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter4Util.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace PKHeX.Core; @@ -15,8 +14,11 @@ public static class StringConverter4Util /// Decoded value (unicode). public static ushort ConvertValue2CharG4(ushort val) { - return G4ValueId.TryGetValue(val, out int index) - ? G4Chars[index] : '?'; + if (val <= TableINTEnd) + return TableINT[val]; + if (val is <= TableKOREnd and >= TableKORStart) + return TableKOR[val - TableKORStart]; + return NUL; } /// @@ -26,16 +28,22 @@ public static ushort ConvertValue2CharG4(ushort val) /// Encoded value. public static ushort ConvertChar2ValueG4(ushort chr) { - return G4CharId.TryGetValue(chr, out int index) - ? G4Values[index] : (ushort)00428; // '?' + var c = (char)chr; + var index = TableINT.IndexOf(c); + if (index >= 0) + return (ushort)index; + index = TableKOR.IndexOf(c); + if (index >= 0) + return (ushort)(index + TableKORStart); + return SaveInvalidAs; } /// - /// Strips diacritics on gen1-4 french pk names + /// Strips diacritics on Gen1-4 French species names. /// /// String to clean /// Cleaned string - /// Only 4 characters are accented in gen1-4 + /// Only 4 characters are accented in Gen1-4 public static void StripDiacriticsFR4(Span input) { foreach (ref var c in input) @@ -55,390 +63,208 @@ public static void StripDiacriticsFR4(Span input) #region Conversion Data - /// - /// Values (stored value) - /// - private static ReadOnlySpan G4Values => new ushort[] - { - 00001, 00002, 00003, 00004, 00005, 00006, 00007, 00008, 00009, 00010, 00011, 00012, 00013, 00014, 00015, 00016, - 00017, 00018, 00019, 00020, 00021, 00022, 00023, 00024, 00025, 00026, 00027, 00028, 00029, 00030, 00031, 00032, - 00033, 00034, 00035, 00036, 00037, 00038, 00039, 00040, 00041, 00042, 00043, 00044, 00045, 00046, 00047, 00048, - 00049, 00050, 00051, 00052, 00053, 00054, 00055, 00056, 00057, 00058, 00059, 00060, 00061, 00062, 00063, 00064, - 00065, 00066, 00067, 00068, 00069, 00070, 00071, 00072, 00073, 00074, 00075, 00076, 00077, 00078, 00079, 00080, - 00081, 00082, 00083, 00084, 00085, 00086, 00087, 00088, 00089, 00090, 00091, 00092, 00093, 00094, 00095, 00096, - 00097, 00098, 00099, 00100, 00101, 00102, 00103, 00104, 00105, 00106, 00107, 00108, 00109, 00110, 00111, 00112, - 00113, 00114, 00115, 00116, 00117, 00118, 00119, 00120, 00121, 00122, 00123, 00124, 00125, 00126, 00127, 00128, - 00129, 00130, 00131, 00132, 00133, 00134, 00135, 00136, 00137, 00138, 00139, 00140, 00141, 00142, 00143, 00144, - 00145, 00146, 00147, 00148, 00149, 00150, 00151, 00152, 00153, 00154, 00155, 00156, 00157, 00158, 00159, 00160, - 00161, 00162, 00163, 00164, 00165, 00166, 00167, 00168, 00169, 00170, 00171, 00172, 00173, 00174, 00175, 00176, - 00177, 00178, 00179, 00180, 00181, 00182, 00183, 00184, 00185, 00186, 00187, 00188, 00189, 00190, 00191, 00192, - 00193, 00194, 00195, 00196, 00197, 00198, 00199, 00200, 00201, 00202, 00203, 00204, 00205, 00206, 00207, 00208, - 00209, 00210, 00211, 00212, 00213, 00214, 00215, 00216, 00217, 00218, 00219, 00220, 00221, 00222, 00223, 00225, - 00226, 00227, 00228, 00229, 00230, 00231, 00232, 00233, 00234, 00235, 00236, 00237, 00238, 00239, 00240, 00241, - 00242, 00243, 00244, 00245, 00246, 00247, 00248, 00249, 00250, 00251, 00252, 00253, 00254, 00255, 00256, 00257, - 00258, 00259, 00260, 00261, 00262, 00263, 00264, 00265, 00266, 00267, 00268, 00269, 00270, 00271, 00272, 00273, - 00275, 00276, 00277, 00278, 00279, 00280, 00281, 00282, 00283, 00284, 00285, 00286, 00287, 00288, 00289, - 00290, 00291, 00292, 00293, 00294, 00295, 00296, 00297, 00298, 00299, 00300, 00301, 00302, 00303, 00304, 00305, - 00306, 00307, 00308, 00309, 00310, 00311, 00312, 00313, 00314, 00315, 00316, 00317, 00318, 00319, 00320, 00321, - 00322, 00323, 00324, 00325, 00326, 00327, 00328, 00329, 00330, 00331, 00332, 00333, 00334, 00335, 00336, 00337, - 00338, 00339, 00340, 00341, 00342, 00343, 00344, 00345, 00346, 00347, 00348, 00349, 00350, 00351, 00352, 00353, - 00354, 00355, 00356, 00357, 00358, 00359, 00360, 00361, 00362, 00363, 00364, 00365, 00366, 00367, 00368, 00369, - 00370, 00371, 00372, 00373, 00374, 00375, 00376, 00377, 00378, 00379, 00380, 00381, 00382, 00383, 00384, 00385, - 00386, 00387, 00388, 00389, 00390, 00391, 00392, 00393, 00394, 00395, 00396, 00397, 00398, 00399, 00400, 00401, - 00402, 00403, 00404, 00405, 00406, 00407, 00408, 00409, 00410, 00411, 00412, 00413, 00414, 00415, 00416, 00417, - 00418, 00419, 00420, 00421, 00422, 00423, 00424, 00425, 00426, 00427, 00428, 00429, 00430, 00431, 00432, 00433, - 00434, 00435, 00436, 00437, 00438, 00439, 00440, 00441, 00442, 00443, 00444, 00445, 00446, 00447, 00448, 00449, - 00450, 00451, 00452, 00453, 00454, 00455, 00456, 00457, 00458, 00459, 00460, 00461, 00462, 00463, 00464, 00465, - 00466, 00467, 00468, 00469, 00470, 00471, 00472, 00473, 00474, 00475, 00476, 00477, 00478, - 01025, 01026, 01027, 01028, 01029, 01030, 01031, 01032, 01033, 01034, 01035, 01036, 01037, - 01038, 01039, 01040, 01041, 01042, 01043, 01044, 01045, 01046, 01047, 01048, 01049, 01050, 01051, 01052, 01053, - 01054, 01055, 01056, 01057, 01058, 01059, 01060, 01061, 01062, 01063, 01064, 01065, 01066, 01067, 01068, 01069, - 01070, 01071, 01072, 01073, 01074, 01075, 01076, 01077, 01078, 01079, 01080, 01081, 01082, 01083, 01084, 01085, - 01086, 01087, 01088, 01089, 01090, 01091, 01092, 01093, 01094, 01095, 01096, 01097, 01098, 01099, 01100, 01101, - 01102, 01103, 01104, 01105, 01106, 01107, 01108, 01109, 01110, 01111, 01112, 01113, 01114, 01115, 01116, 01117, - 01118, 01119, 01120, 01121, 01122, 01123, 01124, 01125, 01126, 01127, 01128, 01129, 01130, 01131, 01132, 01133, - 01134, 01135, 01136, 01137, 01138, 01139, 01140, 01141, 01142, 01143, 01144, 01145, 01146, 01147, 01148, 01149, - 01150, 01151, 01152, 01153, 01154, 01155, 01156, 01157, 01158, 01159, 01160, 01161, 01162, 01163, 01164, 01165, - 01166, 01167, 01168, 01169, 01170, 01171, 01172, 01173, 01174, 01175, 01176, 01177, 01178, 01179, 01180, 01181, - 01182, 01183, 01184, 01185, 01186, 01187, 01188, 01189, 01190, 01191, 01192, 01193, 01194, 01195, 01196, 01197, - 01198, 01199, 01200, 01201, 01202, 01203, 01204, 01205, 01206, 01207, 01208, 01209, 01210, 01211, 01212, 01213, - 01214, 01215, 01216, 01217, 01218, 01219, 01220, 01221, 01222, 01223, 01224, 01225, 01226, 01227, 01228, 01229, - 01230, 01231, 01232, 01233, 01234, 01235, 01236, 01237, 01238, 01239, 01240, 01241, 01242, 01243, 01244, 01245, - 01246, 01247, 01248, 01249, 01250, 01251, 01252, 01253, 01254, 01255, 01256, 01257, 01258, 01259, 01260, 01261, - 01262, 01263, 01264, 01265, 01266, 01267, 01268, 01269, 01270, 01271, 01272, 01273, 01274, 01275, 01276, 01277, - 01278, 01279, 01280, 01281, 01282, 01283, 01284, 01285, 01286, 01287, 01288, 01289, 01290, 01291, 01292, 01293, - 01294, 01295, 01296, 01297, 01298, 01299, 01300, 01301, 01302, 01303, 01304, 01305, 01306, 01307, 01308, 01309, - 01310, 01311, 01312, 01313, 01314, 01315, 01316, 01317, 01318, 01319, 01320, 01321, 01322, 01323, 01324, 01325, - 01326, 01327, 01328, 01329, 01330, 01331, 01332, 01333, 01334, 01335, 01336, 01337, 01338, 01339, 01340, 01341, - 01342, 01343, 01344, 01345, 01346, 01347, 01348, 01349, 01350, 01351, 01352, 01353, 01354, 01355, 01356, 01357, - 01358, 01359, 01360, 01361, 01362, 01363, 01364, 01365, 01366, 01367, 01368, 01369, 01370, 01371, 01372, 01373, - 01374, 01375, 01376, 01377, 01378, 01379, 01380, 01381, 01382, 01383, 01384, 01385, 01386, 01387, 01388, 01389, - 01390, 01391, 01392, 01393, 01394, 01395, 01396, 01397, 01398, 01399, 01400, 01401, 01402, 01403, 01404, 01405, - 01406, 01407, 01408, 01409, 01410, 01411, 01412, 01413, 01414, 01415, 01416, 01417, 01418, 01419, 01420, 01421, - 01422, 01423, 01424, 01425, 01426, 01427, 01428, 01429, 01430, 01431, 01432, 01433, 01434, 01435, 01436, 01437, - 01438, 01439, 01440, 01441, 01442, 01443, 01444, 01445, 01446, 01447, 01448, 01449, 01450, 01451, 01452, 01453, - 01454, 01455, 01456, 01457, 01458, 01459, 01460, 01461, 01462, 01463, 01464, 01465, 01466, 01467, 01468, 01469, - 01470, 01471, 01472, 01473, 01474, 01475, 01476, 01477, 01478, 01479, 01480, 01481, 01482, 01483, 01484, 01485, - 01486, 01487, 01488, 01489, 01490, 01491, 01492, 01493, 01494, 01495, 01496, 01497, 01498, 01499, 01500, 01501, - 01502, 01503, 01504, 01505, 01506, 01507, 01508, 01509, 01510, 01511, 01512, 01513, 01514, 01515, 01516, 01517, - 01518, 01519, 01520, 01521, 01522, 01523, 01524, 01525, 01526, 01527, 01528, 01529, 01530, 01531, 01532, 01533, - 01534, 01535, 01536, 01537, 01538, 01539, 01540, 01541, 01542, 01543, 01544, 01545, 01546, 01547, 01548, 01549, - 01550, 01551, 01552, 01553, 01554, 01555, 01556, 01557, 01558, 01559, 01560, 01561, 01562, 01563, 01564, 01565, - 01566, 01567, 01568, 01569, 01570, 01571, 01572, 01573, 01574, 01575, 01576, 01577, 01578, 01579, 01580, 01581, - 01582, 01583, 01584, 01585, 01586, 01587, 01588, 01589, 01590, 01591, 01592, 01593, 01594, 01595, 01596, 01597, - 01598, 01599, 01600, 01601, 01602, 01603, 01604, 01605, 01606, 01607, 01608, 01609, 01610, 01611, 01612, 01613, - 01614, 01615, 01616, 01617, 01618, 01619, 01620, 01621, 01622, 01623, 01624, 01625, 01626, 01627, 01628, 01629, - 01630, 01631, 01632, 01633, 01634, 01635, 01636, 01637, 01638, 01639, 01640, 01641, 01642, 01643, 01644, 01645, - 01646, 01647, 01648, 01649, 01650, 01651, 01652, 01653, 01654, 01655, 01656, 01657, 01658, 01659, 01660, 01661, - 01662, 01663, 01664, 01665, 01666, 01667, 01668, 01669, 01670, 01671, 01672, 01673, 01674, 01675, 01676, 01677, - 01678, 01679, 01680, 01681, 01682, 01683, 01684, 01685, 01686, 01687, 01688, 01689, 01690, 01691, 01692, 01693, - 01694, 01695, 01696, 01697, 01698, 01699, 01700, 01701, 01702, 01703, 01704, 01705, 01706, 01707, 01708, 01709, - 01710, 01711, 01712, 01713, 01714, 01715, 01716, 01717, 01718, 01719, 01720, 01721, 01722, 01723, 01724, 01725, - 01726, 01727, 01728, 01729, 01730, 01731, 01732, 01733, 01734, 01735, 01736, 01737, 01738, 01739, 01740, 01741, - 01742, 01743, 01744, 01745, 01746, 01747, 01748, 01749, 01750, 01751, 01752, 01753, 01754, 01755, 01756, 01757, - 01758, 01759, 01760, 01761, 01762, 01763, 01764, 01765, 01766, 01767, 01768, 01769, 01770, 01771, 01772, 01773, - 01774, 01775, 01776, 01777, 01778, 01779, 01780, 01781, 01782, 01783, 01784, 01785, 01786, 01787, 01788, 01789, - 01790, 01791, 01792, 01793, 01794, 01795, 01796, 01797, 01798, 01799, 01800, 01801, 01802, 01803, 01804, 01805, - 01806, 01807, 01808, 01809, 01810, 01811, 01812, 01813, 01814, 01815, 01816, 01817, 01818, 01819, 01820, 01821, - 01822, 01823, 01824, 01825, 01826, 01827, 01828, 01829, 01830, 01831, 01832, 01833, 01834, 01835, 01836, 01837, - 01838, 01839, 01840, 01841, 01842, 01843, 01844, 01845, 01846, 01847, 01848, 01849, 01850, 01851, 01852, 01853, - 01854, 01855, 01856, 01857, 01858, 01859, 01860, 01861, 01862, 01863, 01864, 01865, 01866, 01867, 01868, 01869, - 01870, 01871, 01872, 01873, 01874, 01875, 01876, 01877, 01878, 01879, 01880, 01881, 01882, 01883, 01884, 01885, - 01886, 01887, 01888, 01889, 01890, 01891, 01892, 01893, 01894, 01895, 01896, 01897, 01898, 01899, 01900, 01901, - 01902, 01903, 01904, 01905, 01906, 01907, 01908, 01909, 01910, 01911, 01912, 01913, 01914, 01915, 01916, 01917, - 01918, 01919, 01920, 01921, 01922, 01923, 01924, 01925, 01926, 01927, 01928, 01929, 01930, 01931, 01932, 01933, - 01934, 01935, 01936, 01937, 01938, 01939, 01940, 01941, 01942, 01943, 01944, 01945, 01946, 01947, 01948, 01949, - 01950, 01951, 01952, 01953, 01954, 01955, 01956, 01957, 01958, 01959, 01960, 01961, 01962, 01963, 01964, 01965, - 01966, 01967, 01968, 01969, 01970, 01971, 01972, 01973, 01974, 01975, 01976, 01977, 01978, 01979, 01980, 01981, - 01982, 01983, 01984, 01985, 01986, 01987, 01988, 01989, 01990, 01991, 01992, 01993, 01994, 01995, 01996, 01997, - 01998, 01999, 02000, 02001, 02002, 02003, 02004, 02005, 02006, 02007, 02008, 02009, 02010, 02011, 02012, 02013, - 02014, 02015, 02016, 02017, 02018, 02019, 02020, 02021, 02022, 02023, 02024, 02025, 02026, 02027, 02028, 02029, - 02030, 02031, 02032, 02033, 02034, 02035, 02036, 02037, 02038, 02039, 02040, 02041, 02042, 02043, 02044, 02045, - 02046, 02047, 02048, 02049, 02050, 02051, 02052, 02053, 02054, 02055, 02056, 02057, 02058, 02059, 02060, 02061, - 02062, 02063, 02064, 02065, 02066, 02067, 02068, 02069, 02070, 02071, 02072, 02073, 02074, 02075, 02076, 02077, - 02078, 02079, 02080, 02081, 02082, 02083, 02084, 02085, 02086, 02087, 02088, 02089, 02090, 02091, 02092, 02093, - 02094, 02095, 02096, 02097, 02098, 02099, 02100, 02101, 02102, 02103, 02104, 02105, 02106, 02107, 02108, 02109, - 02110, 02111, 02112, 02113, 02114, 02115, 02116, 02117, 02118, 02119, 02120, 02121, 02122, 02123, 02124, 02125, - 02126, 02127, 02128, 02129, 02130, 02131, 02132, 02133, 02134, 02135, 02136, 02137, 02138, 02139, 02140, 02141, - 02142, 02143, 02144, 02145, 02146, 02147, 02148, 02149, 02150, 02151, 02152, 02153, 02154, 02155, 02156, 02157, - 02158, 02159, 02160, 02161, 02162, 02163, 02164, 02165, 02166, 02167, 02168, 02169, 02170, 02171, 02172, 02173, - 02174, 02175, 02176, 02177, 02178, 02179, 02180, 02181, 02182, 02183, 02184, 02185, 02186, 02187, 02188, 02189, - 02190, 02191, 02192, 02193, 02194, 02195, 02196, 02197, 02198, 02199, 02200, 02201, 02202, 02203, 02204, 02205, - 02206, 02207, 02208, 02209, 02210, 02211, 02212, 02213, 02214, 02215, 02216, 02217, 02218, 02219, 02220, 02221, - 02222, 02223, 02224, 02225, 02226, 02227, 02228, 02229, 02230, 02231, 02232, 02233, 02234, 02235, 02236, 02237, - 02238, 02239, 02240, 02241, 02242, 02243, 02244, 02245, 02246, 02247, 02248, 02249, 02250, 02251, 02252, 02253, - 02254, 02255, 02256, 02257, 02258, 02259, 02260, 02261, 02262, 02263, 02264, 02265, 02266, 02267, 02268, 02269, - 02270, 02271, 02272, 02273, 02274, 02275, 02276, 02277, 02278, 02279, 02280, 02281, 02282, 02283, 02284, 02285, - 02286, 02287, 02288, 02289, 02290, 02291, 02292, 02293, 02294, 02295, 02296, 02297, 02298, 02299, 02300, 02301, - 02302, 02303, 02304, 02305, 02306, 02307, 02308, 02309, 02310, 02311, 02312, 02313, 02314, 02315, 02316, 02317, - 02318, 02319, 02320, 02321, 02322, 02323, 02324, 02325, 02326, 02327, 02328, 02329, 02330, 02331, 02332, 02333, - 02334, 02335, 02336, 02337, 02338, 02339, 02340, 02341, 02342, 02343, 02344, 02345, 02346, 02347, 02348, 02349, - 02350, 02351, 02352, 02353, 02354, 02355, 02356, 02357, 02358, 02359, 02360, 02361, 02362, 02363, 02364, 02365, - 02366, 02367, 02368, 02369, 02370, 02371, 02372, 02373, 02374, 02375, 02376, 02377, 02378, 02379, 02380, 02381, - 02382, 02383, 02384, 02385, 02386, 02387, 02388, 02389, 02390, 02391, 02392, 02393, 02394, 02395, 02396, 02397, - 02398, 02399, 02400, 02401, 02402, 02403, 02404, 02405, 02406, 02407, 02408, 02409, 02410, 02411, 02412, 02413, - 02414, 02415, 02416, 02417, 02418, 02419, 02420, 02421, 02422, 02423, 02424, 02425, 02426, 02427, 02428, 02429, - 02430, 02431, 02432, 02433, 02434, 02435, 02436, 02437, 02438, 02439, 02440, 02441, 02442, 02443, 02444, 02445, - 02446, 02447, 02448, 02449, 02450, 02451, 02452, 02453, 02454, 02455, 02456, 02457, 02458, 02459, 02460, 02461, - 02462, 02463, 02464, 02465, 02466, 02467, 02468, 02469, 02470, 02471, 02472, 02473, 02474, 02475, 02476, 02477, - 02478, 02479, 02480, 02481, 02482, 02483, 02484, 02485, 02486, 02487, 02488, 02489, 02490, 02491, 02492, 02493, - 02494, 02495, 02496, 02497, 02498, 02499, 02500, 02501, 02502, 02503, 02504, 02505, 02506, 02507, 02508, 02509, - 02510, 02511, 02512, 02513, 02514, 02515, 02516, 02517, 02518, 02519, 02520, 02521, 02522, 02523, 02524, 02525, - 02526, 02527, 02528, 02529, 02530, 02531, 02532, 02533, 02534, 02535, 02536, 02537, 02538, 02539, 02540, 02541, - 02542, 02543, 02544, 02545, 02546, 02547, 02548, 02549, 02550, 02551, 02552, 02553, 02554, 02555, 02556, 02557, - 02558, 02559, 02560, 02561, 02562, 02563, 02564, 02565, 02566, 02567, 02568, 02569, 02570, 02571, 02572, 02573, - 02574, 02575, 02576, 02577, 02578, 02579, 02580, 02581, 02582, 02583, 02584, 02585, 02586, 02587, 02588, 02589, - 02590, 02591, 02592, 02593, 02594, 02595, 02596, 02597, 02598, 02599, 02600, 02601, 02602, 02603, 02604, 02605, - 02606, 02607, 02608, 02609, 02610, 02611, 02612, 02613, 02614, 02615, 02616, 02617, 02618, 02619, 02620, 02621, - 02622, 02623, 02624, 02625, 02626, 02627, 02628, 02629, 02630, 02631, 02632, 02633, 02634, 02635, 02636, 02637, - 02638, 02639, 02640, 02641, 02642, 02643, 02644, 02645, 02646, 02647, 02648, 02649, 02650, 02651, 02652, 02653, - 02654, 02655, 02656, 02657, 02658, 02659, 02660, 02661, 02662, 02663, 02664, 02665, 02666, 02667, 02668, 02669, - 02670, 02671, 02672, 02673, 02674, 02675, 02676, 02677, 02678, 02679, 02680, 02681, 02682, 02683, 02684, 02685, - 02686, 02687, 02688, 02689, 02690, 02691, 02692, 02693, 02694, 02695, 02696, 02697, 02698, 02699, 02700, 02701, - 02702, 02703, 02704, 02705, 02706, 02707, 02708, 02709, 02710, 02711, 02712, 02713, 02714, 02715, 02716, 02717, - 02718, 02719, 02720, 02721, 02722, 02723, 02724, 02725, 02726, 02727, 02728, 02729, 02730, 02731, 02732, 02733, - 02734, 02735, 02736, 02737, 02738, 02739, 02740, 02741, 02742, 02743, 02744, 02745, 02746, 02747, 02748, 02749, - 02750, 02751, 02752, 02753, 02754, 02755, 02756, 02757, 02758, 02759, 02760, 02761, 02762, 02763, 02764, 02765, - 02766, 02767, 02768, 02769, 02770, 02771, 02772, 02773, 02774, 02775, 02776, 02777, 02778, 02779, 02780, 02781, - 02782, 02783, 02784, 02785, 02786, 02787, 02788, 02789, 02790, 02791, 02792, 02793, 02794, 02795, 02796, 02797, - 02798, 02799, 02800, 02801, 02802, 02803, 02804, 02805, 02806, 02807, 02808, 02809, 02810, 02811, 02812, 02813, - 02814, 02815, 02816, 02817, 02818, 02819, 02820, 02821, 02822, 02823, 02824, 02825, 02826, 02827, 02828, 02829, - 02830, 02831, 02832, 02833, 02834, 02835, 02836, 02837, 02838, 02839, 02840, 02841, 02842, 02843, 02844, 02845, - 02846, 02847, 02848, 02849, 02850, 02851, 02852, 02853, 02854, 02855, 02856, 02857, 02858, 02859, 02860, 02861, - 02862, 02863, 02864, 02865, 02866, 02867, 02868, 02869, 02870, 02871, 02872, 02873, 02874, 02875, 02876, 02877, - 02878, 02879, 02880, 02881, 02882, 02883, 02884, 02885, 02886, 02887, 02888, 02889, 02890, 02891, 02892, 02893, - 02894, 02895, 02896, 02897, 02898, 02899, 02900, 02901, 02902, 02903, 02904, 02905, 02906, 02907, 02908, 02909, - 02910, 02911, 02912, 02913, 02914, 02915, 02916, 02917, 02918, 02919, 02920, 02921, 02922, 02923, 02924, 02925, - 02926, 02927, 02928, 02929, 02930, 02931, 02932, 02933, 02934, 02935, 02936, 02937, 02938, 02939, 02940, 02941, - 02942, 02943, 02944, 02945, 02946, 02947, 02948, 02949, 02950, 02951, 02952, 02953, 02954, 02955, 02956, 02957, - 02958, 02959, 02960, 02961, 02962, 02963, 02964, 02965, 02966, 02967, 02968, 02969, 02970, 02971, 02972, 02973, - 02974, 02975, 02976, 02977, 02978, 02979, 02980, 02981, 02982, 02983, 02984, 02985, 02986, 02987, 02988, 02989, - 02990, 02991, 02992, 02993, 02994, 02995, 02996, 02997, 02998, 02999, 03000, 03001, 03002, 03003, 03004, 03005, - 03006, 03007, 03008, 03009, 03010, 03011, 03012, 03013, 03014, 03015, 03016, 03017, 03018, 03019, 03020, 03021, - 03022, 03023, 03024, 03025, 03026, 03027, 03028, 03029, 03030, 03031, 03032, 03033, 03034, 03035, 03036, 03037, - 03038, 03039, 03040, 03041, 03042, 03043, 03044, 03045, 03046, 03047, 03048, 03049, 03050, 03051, 03052, 03053, - 03054, 03055, 03056, 03057, 03058, 03059, 03060, 03061, 03062, 03063, 03064, 03065, 03066, 03067, 03068, 03069, - 03070, 03071, 03072, 03073, 03074, 03075, 03076, 03077, 03078, 03079, 03080, 03081, 03082, 03083, 03084, 03085, - 03086, 03087, 03088, 03089, 03090, 03091, 03092, 03093, 03094, 03095, 03096, 03097, 03098, 03099, 03100, 03101, - 03102, 03103, 03104, 03105, 03106, 03107, 03108, 03109, 03110, 03111, 03112, 03113, 03114, 03115, 03116, 03117, - 03118, 03119, 03120, 03121, 03122, 03123, 03124, 03125, 03126, 03127, 03128, 03129, 03130, 03131, 03132, 03133, - 03134, 03135, 03136, 03137, 03138, 03139, 03140, 03141, 03142, 03143, 03144, 03145, 03146, 03147, 03148, 03149, - 03150, 03151, 03152, 03153, 03154, 03155, 03156, 03157, 03158, 03159, 03160, 03161, 03162, 03163, 03164, 03165, - 03166, 03167, 03168, 03169, 03170, 03171, 03172, 03173, 03174, 03175, 03176, 03177, 03178, 03179, 03180, 03181, - 03182, 03183, 03184, 03185, 03186, 03187, 03188, 03189, 03190, 03191, 03192, 03193, 03194, 03195, 03196, 03197, - 03198, 03199, 03200, 03201, 03202, 03203, 03204, 03205, 03206, 03207, 03208, 03209, 03210, 03211, 03212, 03213, - 03214, 03215, 03216, 03217, 03218, 03219, 03220, 03221, 03222, 03223, 03224, 03225, 03226, 03227, 03228, 03229, - 03230, 03231, 03232, 03233, 03234, 03235, 03236, 03237, 03238, 03239, 03240, 03241, 03242, 03243, 03244, 03245, - 03246, 03247, 03248, 03249, 03250, 03251, 03252, 03253, 03254, 03255, 03256, 03257, 03258, 03259, 03260, 03261, - 03262, 03263, 03264, 03265, 03266, 03267, 03268, 03269, 03270, 03271, 03272, 03273, 03274, 03275, 03276, 03277, - 03278, 03279, 03280, 03281, 03282, 03283, 03284, 03285, 03286, 03287, 03288, 03289, 03290, 03291, 03292, 03293, - 03294, 03295, 03296, 03297, 03298, 03299, 03300, 03301, 03302, 03303, 03304, 03305, 03306, 03307, 03308, 03309, - 03310, 03311, 03312, 03313, 03314, 03315, 03316, 03317, 03318, 03319, 03320, 03321, 03322, 03323, 03324, 03325, - 03326, 03327, 03328, 03329, 03330, 03331, 03332, 03333, 03334, 03335, 03336, 03337, 03338, 03339, 03340, 03341, - 03342, 03343, 03344, 03345, 03346, 03347, 03348, 03349, 03350, 03351, 03352, 03353, 03354, 03355, 03356, 03357, - 03358, 03359, 03360, 03361, 03362, 03363, 03364, 03365, 03366, 03367, 03368, 03369, 03370, 03371, 03372, 03373, - 03374, 03377, 03378, 03379, 03380, 03381, 03382, 03383, 03384, 03385, 03386, 03387, 03388, 03389, 03390, 03391, - 03392, 03393, 03394, 03395, 03396, 03397, 03398, 03399, 03400, 03401, 03402, 03403, 03404, 03405, 03406, 03407, - 03408, 03409, 03425, 03426, 03427, 03428, 03429, 65535, - }; + private const int TableINTEnd = 0x01DE; // Ignore chars that can't be entered. - /// - /// Characters (Unicode representation) - /// - private static ReadOnlySpan G4Chars => new ushort[] - { - 12288, 12353, 12354, 12355, 12356, 12357, 12358, 12359, 12360, 12361, 12362, 12363, 12364, 12365, 12366, 12367, - 12368, 12369, 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, - 12384, 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12397, 12398, 12399, - 12400, 12401, 12402, 12403, 12404, 12405, 12406, 12407, 12408, 12409, 12410, 12411, 12412, 12413, 12414, 12415, - 12416, 12417, 12418, 12419, 12420, 12421, 12422, 12423, 12424, 12425, 12426, 12427, 12428, 12429, 12431, 12434, - 12435, 12449, 12450, 12451, 12452, 12453, 12454, 12455, 12456, 12457, 12458, 12459, 12460, 12461, 12462, 12463, - 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, - 12480, 12481, 12482, 12483, 12484, 12485, 12486, 12487, 12488, 12489, 12490, 12491, 12492, 12493, 12494, 12495, - 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12511, - 12512, 12513, 12514, 12515, 12516, 12517, 12518, 12519, 12520, 12521, 12522, 12523, 12524, 12525, 12527, 12530, - 12531, 65296, 65297, 65298, 65299, 65300, 65301, 65302, 65303, 65304, 65305, 65313, 65314, 65315, 65316, 65317, - 65318, 65319, 65320, 65321, 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, 65332, 65333, - 65334, 65335, 65336, 65337, 65338, 65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, - 65356, 65357, 65358, 65359, 65360, 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, 65281, - 65311, 12289, 12290, 08943, 12539, 65295, 12300, 12301, 12302, 12303, 65288, 65289, 09325, 09326, 65291, 12540, - 09319, 09320, 65309, 65374, 65306, 65307, 65294, 65292, 09824, 09827, 09829, 09830, 09733, 09678, 09675, 09633, - 09651, 09671, 65312, 09834, 65285, 09728, 09729, 09730, 09731, 09312, 09313, 09314, 09738, 09316, 09317, 09318, - 09800, 09801, 09802, 09803, 09804, 09805, 09806, 09807, 08592, 08593, 08595, 08594, 08227, 65286, 00048, - 00049, 00050, 00051, 00052, 00053, 00054, 00055, 00056, 00057, 00065, 00066, 00067, 00068, 00069, 00070, 00071, - 00072, 00073, 00074, 00075, 00076, 00077, 00078, 00079, 00080, 00081, 00082, 00083, 00084, 00085, 00086, 00087, - 00088, 00089, 00090, 00097, 00098, 00099, 00100, 00101, 00102, 00103, 00104, 00105, 00106, 00107, 00108, 00109, - 00110, 00111, 00112, 00113, 00114, 00115, 00116, 00117, 00118, 00119, 00120, 00121, 00122, 00192, 00193, 00194, - 00195, 00196, 00197, 00198, 00199, 00200, 00201, 00202, 00203, 00204, 00205, 00206, 00207, 00208, 00209, 00210, - 00211, 00212, 00213, 00214, 00215, 00216, 00217, 00218, 00219, 00220, 00221, 00222, 00223, 00224, 00225, 00226, - 00227, 00228, 00229, 00230, 00231, 00232, 00233, 00234, 00235, 00236, 00237, 00238, 00239, 00240, 00241, 00242, - 00243, 00244, 00245, 00246, 00247, 00248, 00249, 00250, 00251, 00252, 00253, 00254, 00255, 00338, 00339, 00350, - 00351, 00170, 00186, 00185, 00178, 00179, 00036, 00161, 00191, 00033, 00063, 00044, 00046, 09324, 65381, 00047, - 08216, 08217, 08220, 08221, 08222, 12298, 12299, 00040, 00041, 09794, 09792, 00043, 00045, 00042, 00035, 00061, - 00038, 00126, 00058, 00059, 09327, 09328, 09329, 09330, 09331, 09332, 09333, 09334, 09335, 09336, 00064, 09337, - 00037, 09338, 09339, 09340, 09341, 09342, 09343, 09344, 09345, 09346, 09347, 09348, 00032, - 44032, 44033, 44036, 44039, 44040, 44041, 44042, 44048, 44049, 44050, 44051, 44052, 44053, - 44054, 44055, 44057, 44058, 44059, 44060, 44061, 44064, 44068, 44076, 44077, 44079, 44080, 44081, 44088, 44089, - 44092, 44096, 44107, 44109, 44116, 44120, 44124, 44144, 44145, 44148, 44151, 44152, 44154, 44160, 44161, 44163, - 44164, 44165, 44166, 44169, 44170, 44171, 44172, 44176, 44180, 44188, 44189, 44191, 44192, 44193, 44200, 44201, - 44202, 44204, 44207, 44208, 44216, 44217, 44219, 44220, 44221, 44225, 44228, 44232, 44236, 44245, 44247, 44256, - 44257, 44260, 44263, 44264, 44266, 44268, 44271, 44272, 44273, 44275, 44277, 44278, 44284, 44285, 44288, 44292, - 44294, 44300, 44301, 44303, 44305, 44312, 44316, 44320, 44329, 44332, 44333, 44340, 44341, 44344, 44348, 44356, - 44357, 44359, 44361, 44368, 44372, 44376, 44385, 44387, 44396, 44397, 44400, 44403, 44404, 44405, 44406, 44411, - 44412, 44413, 44415, 44417, 44418, 44424, 44425, 44428, 44432, 44444, 44445, 44452, 44471, 44480, 44481, 44484, - 44488, 44496, 44497, 44499, 44508, 44512, 44516, 44536, 44537, 44540, 44543, 44544, 44545, 44552, 44553, 44555, - 44557, 44564, 44592, 44593, 44596, 44599, 44600, 44602, 44608, 44609, 44611, 44613, 44614, 44618, 44620, 44621, - 44622, 44624, 44628, 44630, 44636, 44637, 44639, 44640, 44641, 44645, 44648, 44649, 44652, 44656, 44664, 44665, - 44667, 44668, 44669, 44676, 44677, 44684, 44732, 44733, 44734, 44736, 44740, 44748, 44749, 44751, 44752, 44753, - 44760, 44761, 44764, 44776, 44779, 44781, 44788, 44792, 44796, 44807, 44808, 44813, 44816, 44844, 44845, 44848, - 44850, 44852, 44860, 44861, 44863, 44865, 44866, 44867, 44872, 44873, 44880, 44892, 44893, 44900, 44901, 44921, - 44928, 44932, 44936, 44944, 44945, 44949, 44956, 44984, 44985, 44988, 44992, 44999, 45000, 45001, 45003, 45005, - 45006, 45012, 45020, 45032, 45033, 45040, 45041, 45044, 45048, 45056, 45057, 45060, 45068, 45072, 45076, 45084, - 45085, 45096, 45124, 45125, 45128, 45130, 45132, 45134, 45139, 45140, 45141, 45143, 45145, 45149, 45180, 45181, - 45184, 45188, 45196, 45197, 45199, 45201, 45208, 45209, 45210, 45212, 45215, 45216, 45217, 45218, 45224, 45225, - 45227, 45228, 45229, 45230, 45231, 45233, 45235, 45236, 45237, 45240, 45244, 45252, 45253, 45255, 45256, 45257, - 45264, 45265, 45268, 45272, 45280, 45285, 45320, 45321, 45323, 45324, 45328, 45330, 45331, 45336, 45337, 45339, - 45340, 45341, 45347, 45348, 45349, 45352, 45356, 45364, 45365, 45367, 45368, 45369, 45376, 45377, 45380, 45384, - 45392, 45393, 45396, 45397, 45400, 45404, 45408, 45432, 45433, 45436, 45440, 45442, 45448, 45449, 45451, 45453, - 45458, 45459, 45460, 45464, 45468, 45480, 45516, 45520, 45524, 45532, 45533, 45535, 45544, 45545, 45548, 45552, - 45561, 45563, 45565, 45572, 45573, 45576, 45579, 45580, 45588, 45589, 45591, 45593, 45600, 45620, 45628, 45656, - 45660, 45664, 45672, 45673, 45684, 45685, 45692, 45700, 45701, 45705, 45712, 45713, 45716, 45720, 45721, 45722, - 45728, 45729, 45731, 45733, 45734, 45738, 45740, 45744, 45748, 45768, 45769, 45772, 45776, 45778, 45784, 45785, - 45787, 45789, 45794, 45796, 45797, 45798, 45800, 45803, 45804, 45805, 45806, 45807, 45811, 45812, 45813, 45815, - 45816, 45817, 45818, 45819, 45823, 45824, 45825, 45828, 45832, 45840, 45841, 45843, 45844, 45845, 45852, 45908, - 45909, 45910, 45912, 45915, 45916, 45918, 45919, 45924, 45925, 45927, 45929, 45931, 45934, 45936, 45937, 45940, - 45944, 45952, 45953, 45955, 45956, 45957, 45964, 45968, 45972, 45984, 45985, 45992, 45996, 46020, 46021, 46024, - 46027, 46028, 46030, 46032, 46036, 46037, 46039, 46041, 46043, 46045, 46048, 46052, 46056, 46076, 46096, 46104, - 46108, 46112, 46120, 46121, 46123, 46132, 46160, 46161, 46164, 46168, 46176, 46177, 46179, 46181, 46188, 46208, - 46216, 46237, 46244, 46248, 46252, 46261, 46263, 46265, 46272, 46276, 46280, 46288, 46293, 46300, 46301, 46304, - 46307, 46308, 46310, 46316, 46317, 46319, 46321, 46328, 46356, 46357, 46360, 46363, 46364, 46372, 46373, 46375, - 46376, 46377, 46378, 46384, 46385, 46388, 46392, 46400, 46401, 46403, 46404, 46405, 46411, 46412, 46413, 46416, - 46420, 46428, 46429, 46431, 46432, 46433, 46496, 46497, 46500, 46504, 46506, 46507, 46512, 46513, 46515, 46516, - 46517, 46523, 46524, 46525, 46528, 46532, 46540, 46541, 46543, 46544, 46545, 46552, 46572, 46608, 46609, 46612, - 46616, 46629, 46636, 46644, 46664, 46692, 46696, 46748, 46749, 46752, 46756, 46763, 46764, 46769, 46804, 46832, - 46836, 46840, 46848, 46849, 46853, 46888, 46889, 46892, 46895, 46896, 46904, 46905, 46907, 46916, 46920, 46924, - 46932, 46933, 46944, 46948, 46952, 46960, 46961, 46963, 46965, 46972, 46973, 46976, 46980, 46988, 46989, 46991, - 46992, 46993, 46994, 46998, 46999, 47000, 47001, 47004, 47008, 47016, 47017, 47019, 47020, 47021, 47028, 47029, - 47032, 47047, 47049, 47084, 47085, 47088, 47092, 47100, 47101, 47103, 47104, 47105, 47111, 47112, 47113, 47116, - 47120, 47128, 47129, 47131, 47133, 47140, 47141, 47144, 47148, 47156, 47157, 47159, 47160, 47161, 47168, 47172, - 47185, 47187, 47196, 47197, 47200, 47204, 47212, 47213, 47215, 47217, 47224, 47228, 47245, 47272, 47280, 47284, - 47288, 47296, 47297, 47299, 47301, 47308, 47312, 47316, 47325, 47327, 47329, 47336, 47337, 47340, 47344, 47352, - 47353, 47355, 47357, 47364, 47384, 47392, 47420, 47421, 47424, 47428, 47436, 47439, 47441, 47448, 47449, 47452, - 47456, 47464, 47465, 47467, 47469, 47476, 47477, 47480, 47484, 47492, 47493, 47495, 47497, 47498, 47501, 47502, - 47532, 47533, 47536, 47540, 47548, 47549, 47551, 47553, 47560, 47561, 47564, 47566, 47567, 47568, 47569, 47570, - 47576, 47577, 47579, 47581, 47582, 47585, 47587, 47588, 47589, 47592, 47596, 47604, 47605, 47607, 47608, 47609, - 47610, 47616, 47617, 47624, 47637, 47672, 47673, 47676, 47680, 47682, 47688, 47689, 47691, 47693, 47694, 47699, - 47700, 47701, 47704, 47708, 47716, 47717, 47719, 47720, 47721, 47728, 47729, 47732, 47736, 47747, 47748, 47749, - 47751, 47756, 47784, 47785, 47787, 47788, 47792, 47794, 47800, 47801, 47803, 47805, 47812, 47816, 47832, 47833, - 47868, 47872, 47876, 47885, 47887, 47889, 47896, 47900, 47904, 47913, 47915, 47924, 47925, 47926, 47928, 47931, - 47932, 47933, 47934, 47940, 47941, 47943, 47945, 47949, 47951, 47952, 47956, 47960, 47969, 47971, 47980, 48008, - 48012, 48016, 48036, 48040, 48044, 48052, 48055, 48064, 48068, 48072, 48080, 48083, 48120, 48121, 48124, 48127, - 48128, 48130, 48136, 48137, 48139, 48140, 48141, 48143, 48145, 48148, 48149, 48150, 48151, 48152, 48155, 48156, - 48157, 48158, 48159, 48164, 48165, 48167, 48169, 48173, 48176, 48177, 48180, 48184, 48192, 48193, 48195, 48196, - 48197, 48201, 48204, 48205, 48208, 48221, 48260, 48261, 48264, 48267, 48268, 48270, 48276, 48277, 48279, 48281, - 48282, 48288, 48289, 48292, 48295, 48296, 48304, 48305, 48307, 48308, 48309, 48316, 48317, 48320, 48324, 48333, - 48335, 48336, 48337, 48341, 48344, 48348, 48372, 48373, 48374, 48376, 48380, 48388, 48389, 48391, 48393, 48400, - 48404, 48420, 48428, 48448, 48456, 48457, 48460, 48464, 48472, 48473, 48484, 48488, 48512, 48513, 48516, 48519, - 48520, 48521, 48522, 48528, 48529, 48531, 48533, 48537, 48538, 48540, 48548, 48560, 48568, 48596, 48597, 48600, - 48604, 48617, 48624, 48628, 48632, 48640, 48643, 48645, 48652, 48653, 48656, 48660, 48668, 48669, 48671, 48708, - 48709, 48712, 48716, 48718, 48724, 48725, 48727, 48729, 48730, 48731, 48736, 48737, 48740, 48744, 48746, 48752, - 48753, 48755, 48756, 48757, 48763, 48764, 48765, 48768, 48772, 48780, 48781, 48783, 48784, 48785, 48792, 48793, - 48808, 48848, 48849, 48852, 48855, 48856, 48864, 48867, 48868, 48869, 48876, 48897, 48904, 48905, 48920, 48921, - 48923, 48924, 48925, 48960, 48961, 48964, 48968, 48976, 48977, 48981, 49044, 49072, 49093, 49100, 49101, 49104, - 49108, 49116, 49119, 49121, 49212, 49233, 49240, 49244, 49248, 49256, 49257, 49296, 49297, 49300, 49304, 49312, - 49313, 49315, 49317, 49324, 49325, 49327, 49328, 49331, 49332, 49333, 49334, 49340, 49341, 49343, 49344, 49345, - 49349, 49352, 49353, 49356, 49360, 49368, 49369, 49371, 49372, 49373, 49380, 49381, 49384, 49388, 49396, 49397, - 49399, 49401, 49408, 49412, 49416, 49424, 49429, 49436, 49437, 49438, 49439, 49440, 49443, 49444, 49446, 49447, - 49452, 49453, 49455, 49456, 49457, 49462, 49464, 49465, 49468, 49472, 49480, 49481, 49483, 49484, 49485, 49492, - 49493, 49496, 49500, 49508, 49509, 49511, 49512, 49513, 49520, 49524, 49528, 49541, 49548, 49549, 49550, 49552, - 49556, 49558, 49564, 49565, 49567, 49569, 49573, 49576, 49577, 49580, 49584, 49597, 49604, 49608, 49612, 49620, - 49623, 49624, 49632, 49636, 49640, 49648, 49649, 49651, 49660, 49661, 49664, 49668, 49676, 49677, 49679, 49681, - 49688, 49689, 49692, 49695, 49696, 49704, 49705, 49707, 49709, 49711, 49713, 49714, 49716, 49736, 49744, 49745, - 49748, 49752, 49760, 49765, 49772, 49773, 49776, 49780, 49788, 49789, 49791, 49793, 49800, 49801, 49808, 49816, - 49819, 49821, 49828, 49829, 49832, 49836, 49837, 49844, 49845, 49847, 49849, 49884, 49885, 49888, 49891, 49892, - 49899, 49900, 49901, 49903, 49905, 49910, 49912, 49913, 49915, 49916, 49920, 49928, 49929, 49932, 49933, 49939, - 49940, 49941, 49944, 49948, 49956, 49957, 49960, 49961, 49989, 50024, 50025, 50028, 50032, 50034, 50040, 50041, - 50044, 50045, 50052, 50056, 50060, 50112, 50136, 50137, 50140, 50143, 50144, 50146, 50152, 50153, 50157, 50164, - 50165, 50168, 50184, 50192, 50212, 50220, 50224, 50228, 50236, 50237, 50248, 50276, 50277, 50280, 50284, 50292, - 50293, 50297, 50304, 50324, 50332, 50360, 50364, 50409, 50416, 50417, 50420, 50424, 50426, 50431, 50432, 50433, - 50444, 50448, 50452, 50460, 50472, 50473, 50476, 50480, 50488, 50489, 50491, 50493, 50500, 50501, 50504, 50505, - 50506, 50508, 50509, 50510, 50515, 50516, 50517, 50519, 50520, 50521, 50525, 50526, 50528, 50529, 50532, 50536, - 50544, 50545, 50547, 50548, 50549, 50556, 50557, 50560, 50564, 50567, 50572, 50573, 50575, 50577, 50581, 50583, - 50584, 50588, 50592, 50601, 50612, 50613, 50616, 50617, 50619, 50620, 50621, 50622, 50628, 50629, 50630, 50631, - 50632, 50633, 50634, 50636, 50638, 50640, 50641, 50644, 50648, 50656, 50657, 50659, 50661, 50668, 50669, 50670, - 50672, 50676, 50678, 50679, 50684, 50685, 50686, 50687, 50688, 50689, 50693, 50694, 50695, 50696, 50700, 50704, - 50712, 50713, 50715, 50716, 50724, 50725, 50728, 50732, 50733, 50734, 50736, 50739, 50740, 50741, 50743, 50745, - 50747, 50752, 50753, 50756, 50760, 50768, 50769, 50771, 50772, 50773, 50780, 50781, 50784, 50796, 50799, 50801, - 50808, 50809, 50812, 50816, 50824, 50825, 50827, 50829, 50836, 50837, 50840, 50844, 50852, 50853, 50855, 50857, - 50864, 50865, 50868, 50872, 50873, 50874, 50880, 50881, 50883, 50885, 50892, 50893, 50896, 50900, 50908, 50909, - 50912, 50913, 50920, 50921, 50924, 50928, 50936, 50937, 50941, 50948, 50949, 50952, 50956, 50964, 50965, 50967, - 50969, 50976, 50977, 50980, 50984, 50992, 50993, 50995, 50997, 50999, 51004, 51005, 51008, 51012, 51018, 51020, - 51021, 51023, 51025, 51026, 51027, 51028, 51029, 51030, 51031, 51032, 51036, 51040, 51048, 51051, 51060, 51061, - 51064, 51068, 51069, 51070, 51075, 51076, 51077, 51079, 51080, 51081, 51082, 51086, 51088, 51089, 51092, 51094, - 51095, 51096, 51098, 51104, 51105, 51107, 51108, 51109, 51110, 51116, 51117, 51120, 51124, 51132, 51133, 51135, - 51136, 51137, 51144, 51145, 51148, 51150, 51152, 51160, 51165, 51172, 51176, 51180, 51200, 51201, 51204, 51208, - 51210, 51216, 51217, 51219, 51221, 51222, 51228, 51229, 51232, 51236, 51244, 51245, 51247, 51249, 51256, 51260, - 51264, 51272, 51273, 51276, 51277, 51284, 51312, 51313, 51316, 51320, 51322, 51328, 51329, 51331, 51333, 51334, - 51335, 51339, 51340, 51341, 51348, 51357, 51359, 51361, 51368, 51388, 51389, 51396, 51400, 51404, 51412, 51413, - 51415, 51417, 51424, 51425, 51428, 51445, 51452, 51453, 51456, 51460, 51461, 51462, 51468, 51469, 51471, 51473, - 51480, 51500, 51508, 51536, 51537, 51540, 51544, 51552, 51553, 51555, 51564, 51568, 51572, 51580, 51592, 51593, - 51596, 51600, 51608, 51609, 51611, 51613, 51648, 51649, 51652, 51655, 51656, 51658, 51664, 51665, 51667, 51669, - 51670, 51673, 51674, 51676, 51677, 51680, 51682, 51684, 51687, 51692, 51693, 51695, 51696, 51697, 51704, 51705, - 51708, 51712, 51720, 51721, 51723, 51724, 51725, 51732, 51736, 51753, 51788, 51789, 51792, 51796, 51804, 51805, - 51807, 51808, 51809, 51816, 51837, 51844, 51864, 51900, 51901, 51904, 51908, 51916, 51917, 51919, 51921, 51923, - 51928, 51929, 51936, 51948, 51956, 51976, 51984, 51988, 51992, 52000, 52001, 52033, 52040, 52041, 52044, 52048, - 52056, 52057, 52061, 52068, 52088, 52089, 52124, 52152, 52180, 52196, 52199, 52201, 52236, 52237, 52240, 52244, - 52252, 52253, 52257, 52258, 52263, 52264, 52265, 52268, 52270, 52272, 52280, 52281, 52283, 52284, 52285, 52286, - 52292, 52293, 52296, 52300, 52308, 52309, 52311, 52312, 52313, 52320, 52324, 52326, 52328, 52336, 52341, 52376, - 52377, 52380, 52384, 52392, 52393, 52395, 52396, 52397, 52404, 52405, 52408, 52412, 52420, 52421, 52423, 52425, - 52432, 52436, 52452, 52460, 52464, 52481, 52488, 52489, 52492, 52496, 52504, 52505, 52507, 52509, 52516, 52520, - 52524, 52537, 52572, 52576, 52580, 52588, 52589, 52591, 52593, 52600, 52616, 52628, 52629, 52632, 52636, 52644, - 52645, 52647, 52649, 52656, 52676, 52684, 52688, 52712, 52716, 52720, 52728, 52729, 52731, 52733, 52740, 52744, - 52748, 52756, 52761, 52768, 52769, 52772, 52776, 52784, 52785, 52787, 52789, 52824, 52825, 52828, 52831, 52832, - 52833, 52840, 52841, 52843, 52845, 52852, 52853, 52856, 52860, 52868, 52869, 52871, 52873, 52880, 52881, 52884, - 52888, 52896, 52897, 52899, 52900, 52901, 52908, 52909, 52929, 52964, 52965, 52968, 52971, 52972, 52980, 52981, - 52983, 52984, 52985, 52992, 52993, 52996, 53000, 53008, 53009, 53011, 53013, 53020, 53024, 53028, 53036, 53037, - 53039, 53040, 53041, 53048, 53076, 53077, 53080, 53084, 53092, 53093, 53095, 53097, 53104, 53105, 53108, 53112, - 53120, 53125, 53132, 53153, 53160, 53168, 53188, 53216, 53217, 53220, 53224, 53232, 53233, 53235, 53237, 53244, - 53248, 53252, 53265, 53272, 53293, 53300, 53301, 53304, 53308, 53316, 53317, 53319, 53321, 53328, 53332, 53336, - 53344, 53356, 53357, 53360, 53364, 53372, 53373, 53377, 53412, 53413, 53416, 53420, 53428, 53429, 53431, 53433, - 53440, 53441, 53444, 53448, 53449, 53456, 53457, 53459, 53460, 53461, 53468, 53469, 53472, 53476, 53484, 53485, - 53487, 53488, 53489, 53496, 53517, 53552, 53553, 53556, 53560, 53562, 53568, 53569, 53571, 53572, 53573, 53580, - 53581, 53584, 53588, 53596, 53597, 53599, 53601, 53608, 53612, 53628, 53636, 53640, 53664, 53665, 53668, 53672, - 53680, 53681, 53683, 53685, 53690, 53692, 53696, 53720, 53748, 53752, 53767, 53769, 53776, 53804, 53805, 53808, - 53812, 53820, 53821, 53823, 53825, 53832, 53852, 53860, 53888, 53889, 53892, 53896, 53904, 53905, 53909, 53916, - 53920, 53924, 53932, 53937, 53944, 53945, 53948, 53951, 53952, 53954, 53960, 53961, 53963, 53972, 53976, 53980, - 53988, 53989, 54000, 54001, 54004, 54008, 54016, 54017, 54019, 54021, 54028, 54029, 54030, 54032, 54036, 54038, - 54044, 54045, 54047, 54048, 54049, 54053, 54056, 54057, 54060, 54064, 54072, 54073, 54075, 54076, 54077, 54084, - 54085, 54140, 54141, 54144, 54148, 54156, 54157, 54159, 54160, 54161, 54168, 54169, 54172, 54176, 54184, 54185, - 54187, 54189, 54196, 54200, 54204, 54212, 54213, 54216, 54217, 54224, 54232, 54241, 54243, 54252, 54253, 54256, - 54260, 54268, 54269, 54271, 54273, 54280, 54301, 54336, 54340, 54364, 54368, 54372, 54381, 54383, 54392, 54393, - 54396, 54399, 54400, 54402, 54408, 54409, 54411, 54413, 54420, 54441, 54476, 54480, 54484, 54492, 54495, 54504, - 54508, 54512, 54520, 54523, 54525, 54532, 54536, 54540, 54548, 54549, 54551, 54588, 54589, 54592, 54596, 54604, - 54605, 54607, 54609, 54616, 54617, 54620, 54624, 54629, 54632, 54633, 54635, 54637, 54644, 54645, 54648, 54652, - 54660, 54661, 54663, 54664, 54665, 54672, 54693, 54728, 54729, 54732, 54736, 54738, 54744, 54745, 54747, 54749, - 54756, 54757, 54760, 54764, 54772, 54773, 54775, 54777, 54784, 54785, 54788, 54792, 54800, 54801, 54803, 54804, - 54805, 54812, 54816, 54820, 54829, 54840, 54841, 54844, 54848, 54853, 54856, 54857, 54859, 54861, 54865, 54868, - 54869, 54872, 54876, 54887, 54889, 54896, 54897, 54900, 54915, 54917, 54924, 54925, 54928, 54932, 54941, 54943, - 54945, 54952, 54956, 54960, 54969, 54971, 54980, 54981, 54984, 54988, 54993, 54996, 54999, 55001, 55008, 55012, - 55016, 55024, 55029, 55036, 55037, 55040, 55044, 55057, 55064, 55065, 55068, 55072, 55080, 55081, 55083, 55085, - 55092, 55093, 55096, 55100, 55108, 55111, 55113, 55120, 55121, 55124, 55126, 55127, 55128, 55129, 55136, 55137, - 55139, 55141, 55145, 55148, 55152, 55156, 55164, 55165, 55169, 55176, 55177, 55180, 55184, 55192, 55193, 55195, - 55197, 04352, 04353, 04354, 04355, 04356, 04357, 04358, 04359, 04360, 04361, 04362, 04363, 04364, 04365, 04366, - 04367, 04368, 04369, 04370, 04449, 04450, 04451, 04452, 04453, 04454, 04455, 04456, 04457, 04461, 04462, 04466, - 04467, 04469, 47252, 49968, 50108, 50388, 52012, 65535, - }; + private const int TableKORStart = 0x400; + private const int TableKOREnd = 0xD65; - private static readonly Dictionary G4ValueId = GetDictionary(G4Values); - private static readonly Dictionary G4CharId = GetDictionary(G4Chars); + private const ushort SaveInvalidAs = 0x0428; // '?' + private const char NUL = '?'; + private const char EMP = NUL; // Empty, not available on keyboard. + private const char YEN = NUL; // Yen, not available on keyboard. - private static Dictionary GetDictionary(ReadOnlySpan arr) - { - var result = new Dictionary(arr.Length); - for (int i = 0; i < arr.Length; i++) - result[arr[i]] = i; - return result; - } + public static ReadOnlySpan TableINT => + [ + NUL, ' ', 'ぁ', 'あ', 'ぃ', 'い', 'ぅ', 'う', 'ぇ', 'え', 'ぉ', 'お', 'か', 'が', 'き', 'ぎ', // 000-00F + 'く', 'ぐ', 'け', 'げ', 'こ', 'ご', 'さ', 'ざ', 'し', 'じ', 'す', 'ず', 'せ', 'ぜ', 'そ', 'ぞ', // 010-01F + 'た', 'だ', 'ち', 'ぢ', 'っ', 'つ', 'づ', 'て', 'で', 'と', 'ど', 'な', 'に', 'ぬ', 'ね', 'の', // 020-02F + 'は', 'ば', 'ぱ', 'ひ', 'び', 'ぴ', 'ふ', 'ぶ', 'ぷ', 'へ', 'べ', 'ぺ', 'ほ', 'ぼ', 'ぽ', 'ま', // 030-03F + 'み', 'む', 'め', 'も', 'ゃ', 'や', 'ゅ', 'ゆ', 'ょ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ', // 040-04F + 'を', 'ん', 'ァ', 'ア', 'ィ', 'イ', 'ゥ', 'ウ', 'ェ', 'エ', 'ォ', 'オ', 'カ', 'ガ', 'キ', 'ギ', // 050-05F + 'ク', 'グ', 'ケ', 'ゲ', 'コ', 'ゴ', 'サ', 'ザ', 'シ', 'ジ', 'ス', 'ズ', 'セ', 'ゼ', 'ソ', 'ゾ', // 060-06F + 'タ', 'ダ', 'チ', 'ヂ', 'ッ', 'ツ', 'ヅ', 'テ', 'デ', 'ト', 'ド', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', // 070-07F + 'ハ', 'バ', 'パ', 'ヒ', 'ビ', 'ピ', 'フ', 'ブ', 'プ', 'ヘ', 'ベ', 'ペ', 'ホ', 'ボ', 'ポ', 'マ', // 080-08F + 'ミ', 'ム', 'メ', 'モ', 'ャ', 'ヤ', 'ュ', 'ユ', 'ョ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', // 090-09F + 'ヲ', 'ン', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', // 0A0-0AF + 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', // 0B0-0BF + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', // 0C0-0CF + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', // 0D0-0DF + EMP, '!', '?', '、', '。', '⋯', '・', '/', '「', '」', '『', '』', '(', ')', '⑭', '⑮', // 0E0-0EF + '+', 'ー', '⑧', '⑨', '=', '~', ':', ';', '.', ',', '♠', '♣', '♥', '♦', '★', '◎', // 0F0-0FF + '○', '□', '△', '◇', '@', '♪', '%', '☀', '☁', '☂', '☃', '①', '②', '③', '☊', '⑤', // 100-10F + '⑥', '⑦', YEN, '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '←', '↑', '↓', '→', '‣', // 110-11F + '&', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', // 120-12F + 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', // 130-13F + 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', // 140-14F + 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'À', // 150-15F + 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', // 160-16F + 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', // 170-17F + 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', // 180-18F + 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'Œ', // 190-19F + 'œ', 'Ş', 'ş', 'ª', 'º', '¹', '²', '³', '$', '¡', '¿', '!', '?', ',', '.', '⑬', // 1A0-1AF + '・', '/', '‘', '’', '“', '”', '„', '《', '》', '(', ')', '♂', '♀', '+', '-', '*', // 1B0-1BF + '#', '=', '&', '~', ':', ';', '⑯', '⑰', '⑱', '⑲', '⑳', '⑴', '⑵', '⑶', '⑷', '⑸', // 1C0-1CF + '@', '⑹', '%', '⑺', '⑻', '⑼', '⑽', '⑾', '⑿', '⒀', '⒁', '⒂', '⒃', '⒄', ' ', // 1D0-1DE* + ]; + + public static ReadOnlySpan TableKOR => + [ + NUL, '가', '각', '간', '갇', '갈', '갉', '갊', '감', '갑', '값', '갓', '갔', '강', '갖', '갗', // 400-40F + '같', '갚', '갛', '개', '객', '갠', '갤', '갬', '갭', '갯', '갰', '갱', '갸', '갹', '갼', '걀', // 410-41F + '걋', '걍', '걔', '걘', '걜', '거', '걱', '건', '걷', '걸', '걺', '검', '겁', '것', '겄', '겅', // 420-42F + '겆', '겉', '겊', '겋', '게', '겐', '겔', '겜', '겝', '겟', '겠', '겡', '겨', '격', '겪', '견', // 430-43F + '겯', '결', '겸', '겹', '겻', '겼', '경', '곁', '계', '곈', '곌', '곕', '곗', '고', '곡', '곤', // 440-44F + '곧', '골', '곪', '곬', '곯', '곰', '곱', '곳', '공', '곶', '과', '곽', '관', '괄', '괆', '괌', // 450-45F + '괍', '괏', '광', '괘', '괜', '괠', '괩', '괬', '괭', '괴', '괵', '괸', '괼', '굄', '굅', '굇', // 460-46F + '굉', '교', '굔', '굘', '굡', '굣', '구', '국', '군', '굳', '굴', '굵', '굶', '굻', '굼', '굽', // 470-47F + '굿', '궁', '궂', '궈', '궉', '권', '궐', '궜', '궝', '궤', '궷', '귀', '귁', '귄', '귈', '귐', // 480-48F + '귑', '귓', '규', '균', '귤', '그', '극', '근', '귿', '글', '긁', '금', '급', '긋', '긍', '긔', // 490-49F + '기', '긱', '긴', '긷', '길', '긺', '김', '깁', '깃', '깅', '깆', '깊', '까', '깍', '깎', '깐', // 4A0-4AF + '깔', '깖', '깜', '깝', '깟', '깠', '깡', '깥', '깨', '깩', '깬', '깰', '깸', '깹', '깻', '깼', // 4B0-4BF + '깽', '꺄', '꺅', '꺌', '꺼', '꺽', '꺾', '껀', '껄', '껌', '껍', '껏', '껐', '껑', '께', '껙', // 4C0-4CF + '껜', '껨', '껫', '껭', '껴', '껸', '껼', '꼇', '꼈', '꼍', '꼐', '꼬', '꼭', '꼰', '꼲', '꼴', // 4D0-4DF + '꼼', '꼽', '꼿', '꽁', '꽂', '꽃', '꽈', '꽉', '꽐', '꽜', '꽝', '꽤', '꽥', '꽹', '꾀', '꾄', // 4E0-4EF + '꾈', '꾐', '꾑', '꾕', '꾜', '꾸', '꾹', '꾼', '꿀', '꿇', '꿈', '꿉', '꿋', '꿍', '꿎', '꿔', // 4F0-4FF + '꿜', '꿨', '꿩', '꿰', '꿱', '꿴', '꿸', '뀀', '뀁', '뀄', '뀌', '뀐', '뀔', '뀜', '뀝', '뀨', // 500-50F + '끄', '끅', '끈', '끊', '끌', '끎', '끓', '끔', '끕', '끗', '끙', '끝', '끼', '끽', '낀', '낄', // 510-51F + '낌', '낍', '낏', '낑', '나', '낙', '낚', '난', '낟', '날', '낡', '낢', '남', '납', '낫', '났', // 520-52F + '낭', '낮', '낯', '낱', '낳', '내', '낵', '낸', '낼', '냄', '냅', '냇', '냈', '냉', '냐', '냑', // 530-53F + '냔', '냘', '냠', '냥', '너', '넉', '넋', '넌', '널', '넒', '넓', '넘', '넙', '넛', '넜', '넝', // 540-54F + '넣', '네', '넥', '넨', '넬', '넴', '넵', '넷', '넸', '넹', '녀', '녁', '년', '녈', '념', '녑', // 550-55F + '녔', '녕', '녘', '녜', '녠', '노', '녹', '논', '놀', '놂', '놈', '놉', '놋', '농', '높', '놓', // 560-56F + '놔', '놘', '놜', '놨', '뇌', '뇐', '뇔', '뇜', '뇝', '뇟', '뇨', '뇩', '뇬', '뇰', '뇹', '뇻', // 570-57F + '뇽', '누', '눅', '눈', '눋', '눌', '눔', '눕', '눗', '눙', '눠', '눴', '눼', '뉘', '뉜', '뉠', // 580-58F + '뉨', '뉩', '뉴', '뉵', '뉼', '늄', '늅', '늉', '느', '늑', '는', '늘', '늙', '늚', '늠', '늡', // 590-59F + '늣', '능', '늦', '늪', '늬', '늰', '늴', '니', '닉', '닌', '닐', '닒', '님', '닙', '닛', '닝', // 5A0-5AF + '닢', '다', '닥', '닦', '단', '닫', '달', '닭', '닮', '닯', '닳', '담', '답', '닷', '닸', '당', // 5B0-5BF + '닺', '닻', '닿', '대', '댁', '댄', '댈', '댐', '댑', '댓', '댔', '댕', '댜', '더', '덕', '덖', // 5C0-5CF + '던', '덛', '덜', '덞', '덟', '덤', '덥', '덧', '덩', '덫', '덮', '데', '덱', '덴', '델', '뎀', // 5D0-5DF + '뎁', '뎃', '뎄', '뎅', '뎌', '뎐', '뎔', '뎠', '뎡', '뎨', '뎬', '도', '독', '돈', '돋', '돌', // 5E0-5EF + '돎', '돐', '돔', '돕', '돗', '동', '돛', '돝', '돠', '돤', '돨', '돼', '됐', '되', '된', '될', // 5F0-5FF + '됨', '됩', '됫', '됴', '두', '둑', '둔', '둘', '둠', '둡', '둣', '둥', '둬', '뒀', '뒈', '뒝', // 600-60F + '뒤', '뒨', '뒬', '뒵', '뒷', '뒹', '듀', '듄', '듈', '듐', '듕', '드', '득', '든', '듣', '들', // 610-61F + '듦', '듬', '듭', '듯', '등', '듸', '디', '딕', '딘', '딛', '딜', '딤', '딥', '딧', '딨', '딩', // 620-62F + '딪', '따', '딱', '딴', '딸', '땀', '땁', '땃', '땄', '땅', '땋', '때', '땍', '땐', '땔', '땜', // 630-63F + '땝', '땟', '땠', '땡', '떠', '떡', '떤', '떨', '떪', '떫', '떰', '떱', '떳', '떴', '떵', '떻', // 640-64F + '떼', '떽', '뗀', '뗄', '뗌', '뗍', '뗏', '뗐', '뗑', '뗘', '뗬', '또', '똑', '똔', '똘', '똥', // 650-65F + '똬', '똴', '뙈', '뙤', '뙨', '뚜', '뚝', '뚠', '뚤', '뚫', '뚬', '뚱', '뛔', '뛰', '뛴', '뛸', // 660-66F + '뜀', '뜁', '뜅', '뜨', '뜩', '뜬', '뜯', '뜰', '뜸', '뜹', '뜻', '띄', '띈', '띌', '띔', '띕', // 670-67F + '띠', '띤', '띨', '띰', '띱', '띳', '띵', '라', '락', '란', '랄', '람', '랍', '랏', '랐', '랑', // 680-68F + '랒', '랖', '랗', '래', '랙', '랜', '랠', '램', '랩', '랫', '랬', '랭', '랴', '략', '랸', '럇', // 690-69F + '량', '러', '럭', '런', '럴', '럼', '럽', '럿', '렀', '렁', '렇', '레', '렉', '렌', '렐', '렘', // 6A0-6AF + '렙', '렛', '렝', '려', '력', '련', '렬', '렴', '렵', '렷', '렸', '령', '례', '롄', '롑', '롓', // 6B0-6BF + '로', '록', '론', '롤', '롬', '롭', '롯', '롱', '롸', '롼', '뢍', '뢨', '뢰', '뢴', '뢸', '룀', // 6C0-6CF + '룁', '룃', '룅', '료', '룐', '룔', '룝', '룟', '룡', '루', '룩', '룬', '룰', '룸', '룹', '룻', // 6D0-6DF + '룽', '뤄', '뤘', '뤠', '뤼', '뤽', '륀', '륄', '륌', '륏', '륑', '류', '륙', '륜', '률', '륨', // 6E0-6EF + '륩', '륫', '륭', '르', '륵', '른', '를', '름', '릅', '릇', '릉', '릊', '릍', '릎', '리', '릭', // 6F0-6FF + '린', '릴', '림', '립', '릿', '링', '마', '막', '만', '많', '맏', '말', '맑', '맒', '맘', '맙', // 700-70F + '맛', '망', '맞', '맡', '맣', '매', '맥', '맨', '맬', '맴', '맵', '맷', '맸', '맹', '맺', '먀', // 710-71F + '먁', '먈', '먕', '머', '먹', '먼', '멀', '멂', '멈', '멉', '멋', '멍', '멎', '멓', '메', '멕', // 720-72F + '멘', '멜', '멤', '멥', '멧', '멨', '멩', '며', '멱', '면', '멸', '몃', '몄', '명', '몇', '몌', // 730-73F + '모', '목', '몫', '몬', '몰', '몲', '몸', '몹', '못', '몽', '뫄', '뫈', '뫘', '뫙', '뫼', '묀', // 740-74F + '묄', '묍', '묏', '묑', '묘', '묜', '묠', '묩', '묫', '무', '묵', '묶', '문', '묻', '물', '묽', // 750-75F + '묾', '뭄', '뭅', '뭇', '뭉', '뭍', '뭏', '뭐', '뭔', '뭘', '뭡', '뭣', '뭬', '뮈', '뮌', '뮐', // 760-76F + '뮤', '뮨', '뮬', '뮴', '뮷', '므', '믄', '믈', '믐', '믓', '미', '믹', '민', '믿', '밀', '밂', // 770-77F + '밈', '밉', '밋', '밌', '밍', '및', '밑', '바', '박', '밖', '밗', '반', '받', '발', '밝', '밞', // 780-78F + '밟', '밤', '밥', '밧', '방', '밭', '배', '백', '밴', '밸', '뱀', '뱁', '뱃', '뱄', '뱅', '뱉', // 790-79F + '뱌', '뱍', '뱐', '뱝', '버', '벅', '번', '벋', '벌', '벎', '범', '법', '벗', '벙', '벚', '베', // 7A0-7AF + '벡', '벤', '벧', '벨', '벰', '벱', '벳', '벴', '벵', '벼', '벽', '변', '별', '볍', '볏', '볐', // 7B0-7BF + '병', '볕', '볘', '볜', '보', '복', '볶', '본', '볼', '봄', '봅', '봇', '봉', '봐', '봔', '봤', // 7C0-7CF + '봬', '뵀', '뵈', '뵉', '뵌', '뵐', '뵘', '뵙', '뵤', '뵨', '부', '북', '분', '붇', '불', '붉', // 7D0-7DF + '붊', '붐', '붑', '붓', '붕', '붙', '붚', '붜', '붤', '붰', '붸', '뷔', '뷕', '뷘', '뷜', '뷩', // 7E0-7EF + '뷰', '뷴', '뷸', '븀', '븃', '븅', '브', '븍', '븐', '블', '븜', '븝', '븟', '비', '빅', '빈', // 7F0-7FF + '빌', '빎', '빔', '빕', '빗', '빙', '빚', '빛', '빠', '빡', '빤', '빨', '빪', '빰', '빱', '빳', // 800-80F + '빴', '빵', '빻', '빼', '빽', '뺀', '뺄', '뺌', '뺍', '뺏', '뺐', '뺑', '뺘', '뺙', '뺨', '뻐', // 810-81F + '뻑', '뻔', '뻗', '뻘', '뻠', '뻣', '뻤', '뻥', '뻬', '뼁', '뼈', '뼉', '뼘', '뼙', '뼛', '뼜', // 820-82F + '뼝', '뽀', '뽁', '뽄', '뽈', '뽐', '뽑', '뽕', '뾔', '뾰', '뿅', '뿌', '뿍', '뿐', '뿔', '뿜', // 830-83F + '뿟', '뿡', '쀼', '쁑', '쁘', '쁜', '쁠', '쁨', '쁩', '삐', '삑', '삔', '삘', '삠', '삡', '삣', // 840-84F + '삥', '사', '삭', '삯', '산', '삳', '살', '삵', '삶', '삼', '삽', '삿', '샀', '상', '샅', '새', // 850-85F + '색', '샌', '샐', '샘', '샙', '샛', '샜', '생', '샤', '샥', '샨', '샬', '샴', '샵', '샷', '샹', // 860-86F + '섀', '섄', '섈', '섐', '섕', '서', '석', '섞', '섟', '선', '섣', '설', '섦', '섧', '섬', '섭', // 870-87F + '섯', '섰', '성', '섶', '세', '섹', '센', '셀', '셈', '셉', '셋', '셌', '셍', '셔', '셕', '션', // 880-88F + '셜', '셤', '셥', '셧', '셨', '셩', '셰', '셴', '셸', '솅', '소', '속', '솎', '손', '솔', '솖', // 890-89F + '솜', '솝', '솟', '송', '솥', '솨', '솩', '솬', '솰', '솽', '쇄', '쇈', '쇌', '쇔', '쇗', '쇘', // 8A0-8AF + '쇠', '쇤', '쇨', '쇰', '쇱', '쇳', '쇼', '쇽', '숀', '숄', '숌', '숍', '숏', '숑', '수', '숙', // 8B0-8BF + '순', '숟', '술', '숨', '숩', '숫', '숭', '숯', '숱', '숲', '숴', '쉈', '쉐', '쉑', '쉔', '쉘', // 8C0-8CF + '쉠', '쉥', '쉬', '쉭', '쉰', '쉴', '쉼', '쉽', '쉿', '슁', '슈', '슉', '슐', '슘', '슛', '슝', // 8D0-8DF + '스', '슥', '슨', '슬', '슭', '슴', '습', '슷', '승', '시', '식', '신', '싣', '실', '싫', '심', // 8E0-8EF + '십', '싯', '싱', '싶', '싸', '싹', '싻', '싼', '쌀', '쌈', '쌉', '쌌', '쌍', '쌓', '쌔', '쌕', // 8F0-8FF + '쌘', '쌜', '쌤', '쌥', '쌨', '쌩', '썅', '써', '썩', '썬', '썰', '썲', '썸', '썹', '썼', '썽', // 900-90F + '쎄', '쎈', '쎌', '쏀', '쏘', '쏙', '쏜', '쏟', '쏠', '쏢', '쏨', '쏩', '쏭', '쏴', '쏵', '쏸', // 910-91F + '쐈', '쐐', '쐤', '쐬', '쐰', '쐴', '쐼', '쐽', '쑈', '쑤', '쑥', '쑨', '쑬', '쑴', '쑵', '쑹', // 920-92F + '쒀', '쒔', '쒜', '쒸', '쒼', '쓩', '쓰', '쓱', '쓴', '쓸', '쓺', '쓿', '씀', '씁', '씌', '씐', // 930-93F + '씔', '씜', '씨', '씩', '씬', '씰', '씸', '씹', '씻', '씽', '아', '악', '안', '앉', '않', '알', // 940-94F + '앍', '앎', '앓', '암', '압', '앗', '았', '앙', '앝', '앞', '애', '액', '앤', '앨', '앰', '앱', // 950-95F + '앳', '앴', '앵', '야', '약', '얀', '얄', '얇', '얌', '얍', '얏', '양', '얕', '얗', '얘', '얜', // 960-96F + '얠', '얩', '어', '억', '언', '얹', '얻', '얼', '얽', '얾', '엄', '업', '없', '엇', '었', '엉', // 970-97F + '엊', '엌', '엎', '에', '엑', '엔', '엘', '엠', '엡', '엣', '엥', '여', '역', '엮', '연', '열', // 980-98F + '엶', '엷', '염', '엽', '엾', '엿', '였', '영', '옅', '옆', '옇', '예', '옌', '옐', '옘', '옙', // 990-99F + '옛', '옜', '오', '옥', '온', '올', '옭', '옮', '옰', '옳', '옴', '옵', '옷', '옹', '옻', '와', // 9A0-9AF + '왁', '완', '왈', '왐', '왑', '왓', '왔', '왕', '왜', '왝', '왠', '왬', '왯', '왱', '외', '왹', // 9B0-9BF + '왼', '욀', '욈', '욉', '욋', '욍', '요', '욕', '욘', '욜', '욤', '욥', '욧', '용', '우', '욱', // 9C0-9CF + '운', '울', '욹', '욺', '움', '웁', '웃', '웅', '워', '웍', '원', '월', '웜', '웝', '웠', '웡', // 9D0-9DF + '웨', '웩', '웬', '웰', '웸', '웹', '웽', '위', '윅', '윈', '윌', '윔', '윕', '윗', '윙', '유', // 9E0-9EF + '육', '윤', '율', '윰', '윱', '윳', '융', '윷', '으', '윽', '은', '을', '읊', '음', '읍', '읏', // 9F0-9FF + '응', '읒', '읓', '읔', '읕', '읖', '읗', '의', '읜', '읠', '읨', '읫', '이', '익', '인', '일', // A00-A0F + '읽', '읾', '잃', '임', '입', '잇', '있', '잉', '잊', '잎', '자', '작', '잔', '잖', '잗', '잘', // A10-A1F + '잚', '잠', '잡', '잣', '잤', '장', '잦', '재', '잭', '잰', '잴', '잼', '잽', '잿', '쟀', '쟁', // A20-A2F + '쟈', '쟉', '쟌', '쟎', '쟐', '쟘', '쟝', '쟤', '쟨', '쟬', '저', '적', '전', '절', '젊', '점', // A30-A3F + '접', '젓', '정', '젖', '제', '젝', '젠', '젤', '젬', '젭', '젯', '젱', '져', '젼', '졀', '졈', // A40-A4F + '졉', '졌', '졍', '졔', '조', '족', '존', '졸', '졺', '좀', '좁', '좃', '종', '좆', '좇', '좋', // A50-A5F + '좌', '좍', '좔', '좝', '좟', '좡', '좨', '좼', '좽', '죄', '죈', '죌', '죔', '죕', '죗', '죙', // A60-A6F + '죠', '죡', '죤', '죵', '주', '죽', '준', '줄', '줅', '줆', '줌', '줍', '줏', '중', '줘', '줬', // A70-A7F + '줴', '쥐', '쥑', '쥔', '쥘', '쥠', '쥡', '쥣', '쥬', '쥰', '쥴', '쥼', '즈', '즉', '즌', '즐', // A80-A8F + '즘', '즙', '즛', '증', '지', '직', '진', '짇', '질', '짊', '짐', '집', '짓', '징', '짖', '짙', // A90-A9F + '짚', '짜', '짝', '짠', '짢', '짤', '짧', '짬', '짭', '짯', '짰', '짱', '째', '짹', '짼', '쨀', // AA0-AAF + '쨈', '쨉', '쨋', '쨌', '쨍', '쨔', '쨘', '쨩', '쩌', '쩍', '쩐', '쩔', '쩜', '쩝', '쩟', '쩠', // AB0-ABF + '쩡', '쩨', '쩽', '쪄', '쪘', '쪼', '쪽', '쫀', '쫄', '쫌', '쫍', '쫏', '쫑', '쫓', '쫘', '쫙', // AC0-ACF + '쫠', '쫬', '쫴', '쬈', '쬐', '쬔', '쬘', '쬠', '쬡', '쭁', '쭈', '쭉', '쭌', '쭐', '쭘', '쭙', // AD0-ADF + '쭝', '쭤', '쭸', '쭹', '쮜', '쮸', '쯔', '쯤', '쯧', '쯩', '찌', '찍', '찐', '찔', '찜', '찝', // AE0-AEF + '찡', '찢', '찧', '차', '착', '찬', '찮', '찰', '참', '찹', '찻', '찼', '창', '찾', '채', '책', // AF0-AFF + '챈', '챌', '챔', '챕', '챗', '챘', '챙', '챠', '챤', '챦', '챨', '챰', '챵', '처', '척', '천', // B00-B0F + '철', '첨', '첩', '첫', '첬', '청', '체', '첵', '첸', '첼', '쳄', '쳅', '쳇', '쳉', '쳐', '쳔', // B10-B1F + '쳤', '쳬', '쳰', '촁', '초', '촉', '촌', '촐', '촘', '촙', '촛', '총', '촤', '촨', '촬', '촹', // B20-B2F + '최', '쵠', '쵤', '쵬', '쵭', '쵯', '쵱', '쵸', '춈', '추', '축', '춘', '출', '춤', '춥', '춧', // B30-B3F + '충', '춰', '췄', '췌', '췐', '취', '췬', '췰', '췸', '췹', '췻', '췽', '츄', '츈', '츌', '츔', // B40-B4F + '츙', '츠', '측', '츤', '츨', '츰', '츱', '츳', '층', '치', '칙', '친', '칟', '칠', '칡', '침', // B50-B5F + '칩', '칫', '칭', '카', '칵', '칸', '칼', '캄', '캅', '캇', '캉', '캐', '캑', '캔', '캘', '캠', // B60-B6F + '캡', '캣', '캤', '캥', '캬', '캭', '컁', '커', '컥', '컨', '컫', '컬', '컴', '컵', '컷', '컸', // B70-B7F + '컹', '케', '켁', '켄', '켈', '켐', '켑', '켓', '켕', '켜', '켠', '켤', '켬', '켭', '켯', '켰', // B80-B8F + '켱', '켸', '코', '콕', '콘', '콜', '콤', '콥', '콧', '콩', '콰', '콱', '콴', '콸', '쾀', '쾅', // B90-B9F + '쾌', '쾡', '쾨', '쾰', '쿄', '쿠', '쿡', '쿤', '쿨', '쿰', '쿱', '쿳', '쿵', '쿼', '퀀', '퀄', // BA0-BAF + '퀑', '퀘', '퀭', '퀴', '퀵', '퀸', '퀼', '큄', '큅', '큇', '큉', '큐', '큔', '큘', '큠', '크', // BB0-BBF + '큭', '큰', '클', '큼', '큽', '킁', '키', '킥', '킨', '킬', '킴', '킵', '킷', '킹', '타', '탁', // BC0-BCF + '탄', '탈', '탉', '탐', '탑', '탓', '탔', '탕', '태', '택', '탠', '탤', '탬', '탭', '탯', '탰', // BD0-BDF + '탱', '탸', '턍', '터', '턱', '턴', '털', '턺', '텀', '텁', '텃', '텄', '텅', '테', '텍', '텐', // BE0-BEF + '텔', '템', '텝', '텟', '텡', '텨', '텬', '텼', '톄', '톈', '토', '톡', '톤', '톨', '톰', '톱', // BF0-BFF + '톳', '통', '톺', '톼', '퇀', '퇘', '퇴', '퇸', '툇', '툉', '툐', '투', '툭', '툰', '툴', '툼', // C00-C0F + '툽', '툿', '퉁', '퉈', '퉜', '퉤', '튀', '튁', '튄', '튈', '튐', '튑', '튕', '튜', '튠', '튤', // C10-C1F + '튬', '튱', '트', '특', '튼', '튿', '틀', '틂', '틈', '틉', '틋', '틔', '틘', '틜', '틤', '틥', // C20-C2F + '티', '틱', '틴', '틸', '팀', '팁', '팃', '팅', '파', '팍', '팎', '판', '팔', '팖', '팜', '팝', // C30-C3F + '팟', '팠', '팡', '팥', '패', '팩', '팬', '팰', '팸', '팹', '팻', '팼', '팽', '퍄', '퍅', '퍼', // C40-C4F + '퍽', '펀', '펄', '펌', '펍', '펏', '펐', '펑', '페', '펙', '펜', '펠', '펨', '펩', '펫', '펭', // C50-C5F + '펴', '편', '펼', '폄', '폅', '폈', '평', '폐', '폘', '폡', '폣', '포', '폭', '폰', '폴', '폼', // C60-C6F + '폽', '폿', '퐁', '퐈', '퐝', '푀', '푄', '표', '푠', '푤', '푭', '푯', '푸', '푹', '푼', '푿', // C70-C7F + '풀', '풂', '품', '풉', '풋', '풍', '풔', '풩', '퓌', '퓐', '퓔', '퓜', '퓟', '퓨', '퓬', '퓰', // C80-C8F + '퓸', '퓻', '퓽', '프', '픈', '플', '픔', '픕', '픗', '피', '픽', '핀', '필', '핌', '핍', '핏', // C90-C9F + '핑', '하', '학', '한', '할', '핥', '함', '합', '핫', '항', '해', '핵', '핸', '핼', '햄', '햅', // CA0-CAF + '햇', '했', '행', '햐', '향', '허', '헉', '헌', '헐', '헒', '험', '헙', '헛', '헝', '헤', '헥', // CB0-CBF + '헨', '헬', '헴', '헵', '헷', '헹', '혀', '혁', '현', '혈', '혐', '협', '혓', '혔', '형', '혜', // CC0-CCF + '혠', '혤', '혭', '호', '혹', '혼', '홀', '홅', '홈', '홉', '홋', '홍', '홑', '화', '확', '환', // CD0-CDF + '활', '홧', '황', '홰', '홱', '홴', '횃', '횅', '회', '획', '횐', '횔', '횝', '횟', '횡', '효', // CE0-CEF + '횬', '횰', '횹', '횻', '후', '훅', '훈', '훌', '훑', '훔', '훗', '훙', '훠', '훤', '훨', '훰', // CF0-CFF + '훵', '훼', '훽', '휀', '휄', '휑', '휘', '휙', '휜', '휠', '휨', '휩', '휫', '휭', '휴', '휵', // D00-D0F + '휸', '휼', '흄', '흇', '흉', '흐', '흑', '흔', '흖', '흗', '흘', '흙', '흠', '흡', '흣', '흥', // D10-D1F + '흩', '희', '흰', '흴', '흼', '흽', '힁', '히', '힉', '힌', '힐', '힘', '힙', '힛', '힝', NUL, // D20-D2F + + // 33 Jamo characters + NUL, 'ᄀ', 'ᄁ', 'ᄂ', 'ᄃ', 'ᄄ', 'ᄅ', 'ᄆ', 'ᄇ', 'ᄈ', 'ᄉ', 'ᄊ', 'ᄋ', 'ᄌ', 'ᄍ', 'ᄎ', // D30-D3F + 'ᄏ', 'ᄐ', 'ᄑ', 'ᄒ', 'ᅡ', 'ᅢ', 'ᅣ', 'ᅤ', 'ᅥ', 'ᅦ', 'ᅧ', 'ᅨ', 'ᅩ', 'ᅭ', 'ᅮ', 'ᅲ', // D40-D4F + 'ᅳ', 'ᅵ', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // D50-D5F + + // 5 additional syllables + NUL, '뢔', '쌰', '쎼', '쓔', '쬬', // D60-D65 + ]; #endregion } diff --git a/PKHeX.Core/PKM/Strings/StringConverter7.cs b/PKHeX.Core/PKM/Strings/StringConverter7.cs index df376cb1d..c8a8d0418 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter7.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter7.cs @@ -47,7 +47,7 @@ public static int LoadString(ReadOnlySpan data, Span result) /// Maximum length of the input /// Language specific conversion (Chinese) /// Buffer pre-formatting option - /// Chinese string remapping should be attempted + /// Chinese string remapping should be attempted (only Pokémon names, without Nickname flag set) /// Encoded data. public static int SetString(Span destBuffer, ReadOnlySpan value, int maxLength, int language, StringConverterOption option = StringConverterOption.ClearZero, bool chinese = false) @@ -58,7 +58,6 @@ public static int LoadString(ReadOnlySpan data, Span result) if (option is StringConverterOption.ClearZero) destBuffer.Clear(); - bool trad = StringConverter7ZH.IsTraditional(value, language); bool isFullWidth = StringConverter.GetIsFullWidthString(value); for (int i = 0; i < value.Length; i++) { @@ -66,7 +65,7 @@ public static int LoadString(ReadOnlySpan data, Span result) if (!isFullWidth) c = StringConverter.UnSanitizeChar(c); if (chinese) - c = StringConverter7ZH.ConvertString2BinG7_zh(c, trad); + c = StringConverter7ZH.GetPrivateChar(c, language == (int)LanguageID.ChineseT); WriteUInt16LittleEndian(destBuffer[(i * 2)..], c); } diff --git a/PKHeX.Core/PKM/Strings/StringConverter7ZH.cs b/PKHeX.Core/PKM/Strings/StringConverter7ZH.cs index 46e43e678..28a1300f7 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter7ZH.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter7ZH.cs @@ -1,83 +1,55 @@ using System; -using System.Collections.Generic; namespace PKHeX.Core; /// /// Logic for remapping reserved Chinese characters to and from Unicode, used by Generation 7 3DS games. /// +/// +/// GameFreak chose to unify both Traditional and Simplified fonts, and thus mapped un-nicknamed species name chars to private use characters. +/// This allowed them to use the same font for all languages, and the display names would show uniquely. +/// Future games use separate fonts for Traditional and Simplified, and thus do not need to display both fonts via private use characters. +/// public static class StringConverter7ZH { - // To accommodate for Chinese characters in Generation 7 3DS games, GameFreak has allocated a list of used ones in the unused 0xE800 region. - // Why? Dunno, cuz Unicode has these already. - // Maybe they wanted a quick way to sanity check Chinese strings, only allowing within the 0xE800 range. - #region Gen 7 Chinese Character Tables - public const string Gen7_ZHRaw = "蛋妙蛙种子草花小火龙恐喷杰尼龟卡咪水箭绿毛虫铁甲蛹巴大蝶独角壳针蜂波比鸟拉达烈雀嘴阿柏蛇怪皮丘雷穿山鼠王多兰娜后朗力诺可西六尾九胖丁超音蝠走路臭霸派斯特球摩鲁蛾地三喵猫老鸭哥猴暴蒂狗风速蚊香蝌蚪君泳士凯勇基胡腕豪喇叭芽口呆食玛瑙母毒刺拳石隆岩马焰兽磁合一葱嘟利海狮白泥舌贝鬼通耿催眠貘引梦人钳蟹巨霹雳电顽弹椰树嘎啦飞腿郎快头瓦双犀牛钻吉蔓藤袋墨金鱼星宝魔墙偶天螳螂迷唇姐击罗肯泰鲤普百变伊布边菊化盔镰刀翼急冻闪你哈克幻叶月桂竺葵锯鳄蓝立咕夜鹰芭瓢安圆丝蛛叉字灯笼古然咩羊茸美丽露才皇毽棉长手向日蜻蜓乌沼太阳亮黑暗鸦妖未知图腾果翁麒麟奇榛佛托土弟蝎钢千壶赫狃熊圈熔蜗猪珊瑚炮章桶信使翅戴加象顿Ⅱ惊鹿犬无畏战舞娃奶罐幸福公炎帝幼沙班洛亚凤时木守宫森林蜥蜴稚鸡壮跃狼纹直冲茧狩猎盾粉莲童帽乐河橡实鼻狡猾傲骨燕鸥莉奈朵溜糖雨蘑菇斗笠懒獭过动猿请假居忍面者脱妞吼爆幕下掌朝北优雅勾魂眼那恰姆落正拍负萤甜蔷薇溶吞牙鲨鲸驼煤炭跳噗晃斑颚蚁漠仙歌青绵七夕鼬斩饭匙鳅鲶虾兵螯秤念触摇篮羽丑纳飘浮泡隐怨影诅咒巡灵彷徨热带铃勃梭雪冰护豹珍珠樱空棘爱心哑属艾欧盖固坐祈代希苗台猛曼拿儿狸法师箱蟀勒伦琴含羞苞槌城结贵妇绅蜜女帕兹潜兔随卷耳魅东施铛响坦铜镜钟盆聒噪陆尖咬不良骷荧光霓虹自舔狂远Z由卢席恩骑色霏莱谢米尔宙提主暖炒武刃丸剑探步哨约扒酷冷蚀豆鸽高雉幔庞滚蝙螺钉差搬运匠修建蟾蜍投摔打包保足蜈蚣车轮精根裙野蛮鲈混流氓红倒狒殿滑巾征哭具死神棺原肋始祖破灰尘索沫栗德单卵细胞造鹅倍四季萌哎呀败轻蜘坚齿组麻鳗宇烛幽晶斧嚏几何敏捷功夫父赤驹劈司令炸雄秃丫首恶燃烧毕云酋迪耶塔赛里狐呱贺掘彩蓓洁能鞘芳芙妮好鱿贼脚铠垃藻臂枪伞咚碎黏钥朽南瓜嗡哲裴格枭狙射炽咆哮虎漾壬笃啄铳少强锹农胜虻鬃弱坏驴仔重挽滴伪睡罩盗着竹疗环智挥猩掷胆噬堡爷参性:银伴陨枕戈谜拟Q磨舵鳞杖璞・鸣哞鳍科莫迦虚吾肌费束辉纸御机夏蛋妙蛙種子草花小火龍恐噴傑尼龜卡咪水箭綠毛蟲鐵甲蛹巴大蝶獨角殼針蜂波比鳥拉達烈雀嘴阿柏蛇怪皮丘雷穿山鼠王多蘭娜后朗力諾可西六尾九胖丁超音蝠走路臭霸派斯特球摩魯蛾地三喵貓老鴨哥猴爆蒂狗風速蚊香蝌蚪君泳士凱勇基胡腕豪喇叭芽口呆食瑪瑙母毒刺拳石隆岩馬焰獸磁合一蔥嘟利海獅白泥舌貝鬼通耿催眠貘引夢人鉗蟹巨霹靂電頑彈椰樹嘎啦飛腿郎快頭瓦雙犀牛鑽吉蔓藤袋墨金魚星寶魔牆偶天螳螂迷唇姐擊羅肯泰鯉暴普百變伊布邊菊化盔鐮刀翼急凍閃你哈克幻葉月桂竺葵鋸鱷藍立咕夜鷹芭瓢安圓絲蛛叉字燈籠古然咩羊茸美麗露才皇毽棉長手向日蜻蜓烏沼太陽亮黑暗鴉妖未知圖騰果翁麒麟奇榛佛托土弟蠍鋼千壺赫狃熊圈熔蝸豬珊瑚炮章桶信使翅戴加象頓Ⅱ驚鹿犬無畏戰舞娃奶罐幸福公炎帝幼沙班洛亞鳳時木守宮森林蜥蜴稚雞壯躍狼紋直衝繭狩獵盾粉蓮童帽樂河橡實鼻狡猾傲骨燕鷗莉奈朵溜糖雨蘑菇斗笠懶獺過動猿請假居忍面者脫妞吼幕下掌朝北優雅勾魂眼那恰姆落正拍負螢甜薔薇溶吞牙鯊鯨駝煤炭跳噗晃斑顎蟻漠仙歌青綿七夕鼬斬飯匙鰍鯰蝦兵螯秤念觸搖籃羽醜納飄浮泡隱怨影詛咒巡靈彷徨熱帶鈴勃梭雪冰護豹珍珠櫻空棘愛心啞屬艾歐蓋固坐祈代希苗台猛曼拿兒狸法師箱蟀勒倫琴含羞苞槌城結貴婦紳蜜女帕茲潛兔隨捲耳魅東施鐺響坦銅鏡鐘盆聒噪陸尖咬不良骷光霓虹自舔狂遠Z由盧席恩騎色霏萊謝米爾宙提主暖炒武刃丸劍探步哨約扒酷冷蝕豆鴿高雉幔龐滾蝙螺釘差搬運匠修建蟾蜍投摔打包保足蜈蚣車輪毬精根裙野蠻鱸混流氓紅倒狒殿滑巾徵哭具死神棺原肋始祖破灰塵索沫栗德單卵細胞造鵝倍四季萌哎呀敗輕蜘堅齒組麻鰻宇燭幽晶斧嚏幾何敏捷功夫父赤駒劈司令炸雄禿丫首惡燃燒畢雲酋迪耶塔賽里狐呱賀掘彩蓓潔能鞘芳芙妮好魷賊腳鎧垃藻臂槍傘咚碎黏鑰朽南瓜嗡哲裴格梟狙射熾咆哮虎漾壬篤啄銃少強鍬農勝虻鬃弱壞驢仔重挽滴偽睡罩盜著竹療環智揮猩擲膽噬堡爺參性:銀伴隕枕戈謎擬Q磨舵鱗杖璞・鳴哞鰭科莫迦虛吾肌費束輝紙御機夏垒磊砰奥壘磊砰丑奧"; - public const int Gen7_ZHLength = 0x627; + private static bool IsPrivateChar(ushort glyph) => glyph is >= Start and <= End; + private static char GetUnicodeChar(char glyph) => Table[glyph - Start]; - private const char Gen7_ZH_Ofs = '\uE800'; - private const ushort SM_ZHCharTable_Size = 0x30F; - private const ushort USUM_CHS_Size = 0x4; - private static bool GetisG7CHSChar(int idx) => idx is < SM_ZHCharTable_Size or (>= SM_ZHCharTable_Size * 2 and < (SM_ZHCharTable_Size * 2) + USUM_CHS_Size); + public static bool IsTraditional(ushort glyph) => glyph is (>= StartTraditional and <= EndTraditional) or (>= StartTraditionalUSUM and <= EndTraditionalUSUM); + public static bool IsSimplified(ushort glyph) => glyph is (>= StartSimplified and <= EndSimplified) or (>= StartSimplifiedUSUM and <= EndSimplifiedUSUM); - // Unicode -> u16 conversion - private static readonly Dictionary G7_CHS = GetRemapper(true); - private static readonly Dictionary G7_CHT = GetRemapper(false); - - private static Dictionary GetRemapper(bool simplified) - { - const string raw = Gen7_ZHRaw; - var result = new Dictionary(788); // raw.Length - for (int i = 0; i < raw.Length; i++) - { - var isCHS = GetisG7CHSChar(i); - if (isCHS != simplified) - continue; - - var c = raw[i]; - result.Add(c, (char)(Gen7_ZH_Ofs + i)); - } - return result; - } - #endregion + public static bool IsTraditional(char glyph) => Traditional.Contains(glyph) || TraditionalUSUM.Contains(glyph); + public static bool IsSimplified(char glyph) => Simplified.Contains(glyph) || SimplifiedUSUM.Contains(glyph); /// - /// Converts a Unicode string to Generation 7 in-game Chinese string. + /// Converts a Unicode character to Generation 7 in-game Chinese codepoint. /// /// Unicode character. /// Detection of language for Traditional Chinese check /// In-game Chinese string. - internal static char ConvertString2BinG7_zh(char chr, bool traditional) + internal static char GetPrivateChar(char chr, bool traditional) { - var table = traditional ? G7_CHT : G7_CHS; - - if (table.TryGetValue(chr, out var remap)) - return remap; + if (traditional) + { + var index = Traditional.IndexOf(chr); + if (index >= 0) + return (char)(StartTraditional + index); + index = TraditionalUSUM.IndexOf(chr); + if (index >= 0) + return (char)(StartTraditionalUSUM + index); + } + else + { + var index = Simplified.IndexOf(chr); + if (index >= 0) + return (char)(StartSimplified + index); + index = SimplifiedUSUM.IndexOf(chr); + if (index >= 0) + return (char)(StartSimplifiedUSUM + index); + } return chr; } - public static bool IsTraditional(ReadOnlySpan input, int lang) - { - // A string cannot contain a mix of CHS and CHT characters. - foreach (var chr in input) - { - if (G7_CHT.ContainsKey(chr) && !G7_CHS.ContainsKey(chr)) - return true; - } - - if (lang != (int)LanguageID.ChineseT) - return false; - - // CHS and CHT have the same display name - foreach (var chr in input) - { - if (G7_CHT.ContainsKey(chr) != G7_CHS.ContainsKey(chr)) - return true; - } - - return false; - } - /// /// Converts a Generation 7 in-game Chinese string to Unicode string. /// @@ -87,10 +59,139 @@ internal static void RemapChineseGlyphsBin2String(Span input) { for (int i = 0; i < input.Length; i++) { - char val = input[i]; - var unmap = (uint)val - Gen7_ZH_Ofs; - if (unmap < Gen7_ZHLength) - input[i] = Gen7_ZHRaw[(int)unmap]; + var val = input[i]; + if (IsPrivateChar(val)) + input[i] = GetUnicodeChar(val); } } + + #region Gen 7 Chinese Character Table + private const ushort Start = 0xE800; + + // S/M + private const ushort StartTraditional = 0xE800; + private const ushort EndTraditional = 0xEB0E; // 0xE800-0xEB0E + private const ushort StartSimplified = 0xEB0F; + private const ushort EndSimplified = 0xEE1D; // 0xEB0F-0xEE1D + // US/UM: A few more characters at the end. + private const ushort StartTraditionalUSUM = 0xEE1E; + private const ushort EndTraditionalUSUM = 0xEE21; // 0xEE1E-0xEE21 + private const ushort StartSimplifiedUSUM = 0xEE22; + private const ushort EndSimplifiedUSUM = 0xEE26; // 0xEE22-0xEE26 + + private const int TraditionalCount = EndTraditional - StartTraditional + 1; + private const int SimplifiedCount = EndSimplified - StartSimplified + 1; + private const int TraditionalCountUSUM = EndTraditionalUSUM - StartTraditionalUSUM + 1; + private const int SimplifiedCountUSUM = EndSimplifiedUSUM - StartSimplifiedUSUM + 1; + + private const ushort End = EndSimplifiedUSUM; + + private static ReadOnlySpan Table => + [ + '蛋', '妙', '蛙', '种', '子', '草', '花', '小', '火', '龙', '恐', '喷', '杰', '尼', '龟', '卡', // E800-E80F + '咪', '水', '箭', '绿', '毛', '虫', '铁', '甲', '蛹', '巴', '大', '蝶', '独', '角', '壳', '针', // E810-E81F + '蜂', '波', '比', '鸟', '拉', '达', '烈', '雀', '嘴', '阿', '柏', '蛇', '怪', '皮', '丘', '雷', // E820-E82F + '穿', '山', '鼠', '王', '多', '兰', '娜', '后', '朗', '力', '诺', '可', '西', '六', '尾', '九', // E830-E83F + '胖', '丁', '超', '音', '蝠', '走', '路', '臭', '霸', '派', '斯', '特', '球', '摩', '鲁', '蛾', // E840-E84F + '地', '三', '喵', '猫', '老', '鸭', '哥', '猴', '暴', '蒂', '狗', '风', '速', '蚊', '香', '蝌', // E850-E85F + '蚪', '君', '泳', '士', '凯', '勇', '基', '胡', '腕', '豪', '喇', '叭', '芽', '口', '呆', '食', // E860-E86F + '玛', '瑙', '母', '毒', '刺', '拳', '石', '隆', '岩', '马', '焰', '兽', '磁', '合', '一', '葱', // E870-E87F + '嘟', '利', '海', '狮', '白', '泥', '舌', '贝', '鬼', '通', '耿', '催', '眠', '貘', '引', '梦', // E880-E88F + '人', '钳', '蟹', '巨', '霹', '雳', '电', '顽', '弹', '椰', '树', '嘎', '啦', '飞', '腿', '郎', // E890-E89F + '快', '头', '瓦', '双', '犀', '牛', '钻', '吉', '蔓', '藤', '袋', '墨', '金', '鱼', '星', '宝', // E8A0-E8AF + '魔', '墙', '偶', '天', '螳', '螂', '迷', '唇', '姐', '击', '罗', '肯', '泰', '鲤', '普', '百', // E8B0-E8BF + '变', '伊', '布', '边', '菊', '化', '盔', '镰', '刀', '翼', '急', '冻', '闪', '你', '哈', '克', // E8C0-E8CF + '幻', '叶', '月', '桂', '竺', '葵', '锯', '鳄', '蓝', '立', '咕', '夜', '鹰', '芭', '瓢', '安', // E8D0-E8DF + '圆', '丝', '蛛', '叉', '字', '灯', '笼', '古', '然', '咩', '羊', '茸', '美', '丽', '露', '才', // E8E0-E8EF + '皇', '毽', '棉', '长', '手', '向', '日', '蜻', '蜓', '乌', '沼', '太', '阳', '亮', '黑', '暗', // E8F0-E8FF + '鸦', '妖', '未', '知', '图', '腾', '果', '翁', '麒', '麟', '奇', '榛', '佛', '托', '土', '弟', // E900-E90F + '蝎', '钢', '千', '壶', '赫', '狃', '熊', '圈', '熔', '蜗', '猪', '珊', '瑚', '炮', '章', '桶', // E910-E91F + '信', '使', '翅', '戴', '加', '象', '顿', 'Ⅱ', '惊', '鹿', '犬', '无', '畏', '战', '舞', '娃', // E920-E92F + '奶', '罐', '幸', '福', '公', '炎', '帝', '幼', '沙', '班', '洛', '亚', '凤', '时', '木', '守', // E930-E93F + '宫', '森', '林', '蜥', '蜴', '稚', '鸡', '壮', '跃', '狼', '纹', '直', '冲', '茧', '狩', '猎', // E940-E94F + '盾', '粉', '莲', '童', '帽', '乐', '河', '橡', '实', '鼻', '狡', '猾', '傲', '骨', '燕', '鸥', // E950-E95F + '莉', '奈', '朵', '溜', '糖', '雨', '蘑', '菇', '斗', '笠', '懒', '獭', '过', '动', '猿', '请', // E960-E96F + '假', '居', '忍', '面', '者', '脱', '妞', '吼', '爆', '幕', '下', '掌', '朝', '北', '优', '雅', // E970-E97F + '勾', '魂', '眼', '那', '恰', '姆', '落', '正', '拍', '负', '萤', '甜', '蔷', '薇', '溶', '吞', // E980-E98F + '牙', '鲨', '鲸', '驼', '煤', '炭', '跳', '噗', '晃', '斑', '颚', '蚁', '漠', '仙', '歌', '青', // E990-E99F + '绵', '七', '夕', '鼬', '斩', '饭', '匙', '鳅', '鲶', '虾', '兵', '螯', '秤', '念', '触', '摇', // E9A0-E9AF + '篮', '羽', '丑', '纳', '飘', '浮', '泡', '隐', '怨', '影', '诅', '咒', '巡', '灵', '彷', '徨', // E9B0-E9BF + '热', '带', '铃', '勃', '梭', '雪', '冰', '护', '豹', '珍', '珠', '樱', '空', '棘', '爱', '心', // E9C0-E9CF + '哑', '属', '艾', '欧', '盖', '固', '坐', '祈', '代', '希', '苗', '台', '猛', '曼', '拿', '儿', // E9D0-E9DF + '狸', '法', '师', '箱', '蟀', '勒', '伦', '琴', '含', '羞', '苞', '槌', '城', '结', '贵', '妇', // E9E0-E9EF + '绅', '蜜', '女', '帕', '兹', '潜', '兔', '随', '卷', '耳', '魅', '东', '施', '铛', '响', '坦', // E9F0-E9FF + '铜', '镜', '钟', '盆', '聒', '噪', '陆', '尖', '咬', '不', '良', '骷', '荧', '光', '霓', '虹', // EA00-EA0F + '自', '舔', '狂', '远', 'Z', '由', '卢', '席', '恩', '骑', '色', '霏', '莱', '谢', '米', '尔', // EA10-EA1F + '宙', '提', '主', '暖', '炒', '武', '刃', '丸', '剑', '探', '步', '哨', '约', '扒', '酷', '冷', // EA20-EA2F + '蚀', '豆', '鸽', '高', '雉', '幔', '庞', '滚', '蝙', '螺', '钉', '差', '搬', '运', '匠', '修', // EA30-EA3F + '建', '蟾', '蜍', '投', '摔', '打', '包', '保', '足', '蜈', '蚣', '车', '轮', '精', '根', '裙', // EA40-EA4F + '野', '蛮', '鲈', '混', '流', '氓', '红', '倒', '狒', '殿', '滑', '巾', '征', '哭', '具', '死', // EA50-EA5F + '神', '棺', '原', '肋', '始', '祖', '破', '灰', '尘', '索', '沫', '栗', '德', '单', '卵', '细', // EA60-EA6F + '胞', '造', '鹅', '倍', '四', '季', '萌', '哎', '呀', '败', '轻', '蜘', '坚', '齿', '组', '麻', // EA70-EA7F + '鳗', '宇', '烛', '幽', '晶', '斧', '嚏', '几', '何', '敏', '捷', '功', '夫', '父', '赤', '驹', // EA80-EA8F + '劈', '司', '令', '炸', '雄', '秃', '丫', '首', '恶', '燃', '烧', '毕', '云', '酋', '迪', '耶', // EA90-EA9F + '塔', '赛', '里', '狐', '呱', '贺', '掘', '彩', '蓓', '洁', '能', '鞘', '芳', '芙', '妮', '好', // EAA0-EAAF + '鱿', '贼', '脚', '铠', '垃', '藻', '臂', '枪', '伞', '咚', '碎', '黏', '钥', '朽', '南', '瓜', // EAB0-EABF + '嗡', '哲', '裴', '格', '枭', '狙', '射', '炽', '咆', '哮', '虎', '漾', '壬', '笃', '啄', '铳', // EAC0-EACF + '少', '强', '锹', '农', '胜', '虻', '鬃', '弱', '坏', '驴', '仔', '重', '挽', '滴', '伪', '睡', // EAD0-EADF + '罩', '盗', '着', '竹', '疗', '环', '智', '挥', '猩', '掷', '胆', '噬', '堡', '爷', '参', '性', // EAE0-EAEF + ':', '银', '伴', '陨', '枕', '戈', '谜', '拟', 'Q', '磨', '舵', '鳞', '杖', '璞', '・', '鸣', // EAF0-EAFF + '哞', '鳍', '科', '莫', '迦', '虚', '吾', '肌', '费', '束', '辉', '纸', '御', '机', '夏', '蛋', // EB00-EB0F + '妙', '蛙', '種', '子', '草', '花', '小', '火', '龍', '恐', '噴', '傑', '尼', '龜', '卡', '咪', // EB10-EB1F + '水', '箭', '綠', '毛', '蟲', '鐵', '甲', '蛹', '巴', '大', '蝶', '獨', '角', '殼', '針', '蜂', // EB20-EB2F + '波', '比', '鳥', '拉', '達', '烈', '雀', '嘴', '阿', '柏', '蛇', '怪', '皮', '丘', '雷', '穿', // EB30-EB3F + '山', '鼠', '王', '多', '蘭', '娜', '后', '朗', '力', '諾', '可', '西', '六', '尾', '九', '胖', // EB40-EB4F + '丁', '超', '音', '蝠', '走', '路', '臭', '霸', '派', '斯', '特', '球', '摩', '魯', '蛾', '地', // EB50-EB5F + '三', '喵', '貓', '老', '鴨', '哥', '猴', '爆', '蒂', '狗', '風', '速', '蚊', '香', '蝌', '蚪', // EB60-EB6F + '君', '泳', '士', '凱', '勇', '基', '胡', '腕', '豪', '喇', '叭', '芽', '口', '呆', '食', '瑪', // EB70-EB7F + '瑙', '母', '毒', '刺', '拳', '石', '隆', '岩', '馬', '焰', '獸', '磁', '合', '一', '蔥', '嘟', // EB80-EB8F + '利', '海', '獅', '白', '泥', '舌', '貝', '鬼', '通', '耿', '催', '眠', '貘', '引', '夢', '人', // EB90-EB9F + '鉗', '蟹', '巨', '霹', '靂', '電', '頑', '彈', '椰', '樹', '嘎', '啦', '飛', '腿', '郎', '快', // EBA0-EBAF + '頭', '瓦', '雙', '犀', '牛', '鑽', '吉', '蔓', '藤', '袋', '墨', '金', '魚', '星', '寶', '魔', // EBB0-EBBF + '牆', '偶', '天', '螳', '螂', '迷', '唇', '姐', '擊', '羅', '肯', '泰', '鯉', '暴', '普', '百', // EBC0-EBCF + '變', '伊', '布', '邊', '菊', '化', '盔', '鐮', '刀', '翼', '急', '凍', '閃', '你', '哈', '克', // EBD0-EBDF + '幻', '葉', '月', '桂', '竺', '葵', '鋸', '鱷', '藍', '立', '咕', '夜', '鷹', '芭', '瓢', '安', // EBE0-EBEF + '圓', '絲', '蛛', '叉', '字', '燈', '籠', '古', '然', '咩', '羊', '茸', '美', '麗', '露', '才', // EBF0-EBFF + '皇', '毽', '棉', '長', '手', '向', '日', '蜻', '蜓', '烏', '沼', '太', '陽', '亮', '黑', '暗', // EC00-EC0F + '鴉', '妖', '未', '知', '圖', '騰', '果', '翁', '麒', '麟', '奇', '榛', '佛', '托', '土', '弟', // EC10-EC1F + '蠍', '鋼', '千', '壺', '赫', '狃', '熊', '圈', '熔', '蝸', '豬', '珊', '瑚', '炮', '章', '桶', // EC20-EC2F + '信', '使', '翅', '戴', '加', '象', '頓', 'Ⅱ', '驚', '鹿', '犬', '無', '畏', '戰', '舞', '娃', // EC30-EC3F + '奶', '罐', '幸', '福', '公', '炎', '帝', '幼', '沙', '班', '洛', '亞', '鳳', '時', '木', '守', // EC40-EC4F + '宮', '森', '林', '蜥', '蜴', '稚', '雞', '壯', '躍', '狼', '紋', '直', '衝', '繭', '狩', '獵', // EC50-EC5F + '盾', '粉', '蓮', '童', '帽', '樂', '河', '橡', '實', '鼻', '狡', '猾', '傲', '骨', '燕', '鷗', // EC60-EC6F + '莉', '奈', '朵', '溜', '糖', '雨', '蘑', '菇', '斗', '笠', '懶', '獺', '過', '動', '猿', '請', // EC70-EC7F + '假', '居', '忍', '面', '者', '脫', '妞', '吼', '幕', '下', '掌', '朝', '北', '優', '雅', '勾', // EC80-EC8F + '魂', '眼', '那', '恰', '姆', '落', '正', '拍', '負', '螢', '甜', '薔', '薇', '溶', '吞', '牙', // EC90-EC9F + '鯊', '鯨', '駝', '煤', '炭', '跳', '噗', '晃', '斑', '顎', '蟻', '漠', '仙', '歌', '青', '綿', // ECA0-ECAF + '七', '夕', '鼬', '斬', '飯', '匙', '鰍', '鯰', '蝦', '兵', '螯', '秤', '念', '觸', '搖', '籃', // ECB0-ECBF + '羽', '醜', '納', '飄', '浮', '泡', '隱', '怨', '影', '詛', '咒', '巡', '靈', '彷', '徨', '熱', // ECC0-ECCF + '帶', '鈴', '勃', '梭', '雪', '冰', '護', '豹', '珍', '珠', '櫻', '空', '棘', '愛', '心', '啞', // ECD0-ECDF + '屬', '艾', '歐', '蓋', '固', '坐', '祈', '代', '希', '苗', '台', '猛', '曼', '拿', '兒', '狸', // ECE0-ECEF + '法', '師', '箱', '蟀', '勒', '倫', '琴', '含', '羞', '苞', '槌', '城', '結', '貴', '婦', '紳', // ECF0-ECFF + '蜜', '女', '帕', '茲', '潛', '兔', '隨', '捲', '耳', '魅', '東', '施', '鐺', '響', '坦', '銅', // ED00-ED0F + '鏡', '鐘', '盆', '聒', '噪', '陸', '尖', '咬', '不', '良', '骷', '光', '霓', '虹', '自', '舔', // ED10-ED1F + '狂', '遠', 'Z', '由', '盧', '席', '恩', '騎', '色', '霏', '萊', '謝', '米', '爾', '宙', '提', // ED20-ED2F + '主', '暖', '炒', '武', '刃', '丸', '劍', '探', '步', '哨', '約', '扒', '酷', '冷', '蝕', '豆', // ED30-ED3F + '鴿', '高', '雉', '幔', '龐', '滾', '蝙', '螺', '釘', '差', '搬', '運', '匠', '修', '建', '蟾', // ED40-ED4F + '蜍', '投', '摔', '打', '包', '保', '足', '蜈', '蚣', '車', '輪', '毬', '精', '根', '裙', '野', // ED50-ED5F + '蠻', '鱸', '混', '流', '氓', '紅', '倒', '狒', '殿', '滑', '巾', '徵', '哭', '具', '死', '神', // ED60-ED6F + '棺', '原', '肋', '始', '祖', '破', '灰', '塵', '索', '沫', '栗', '德', '單', '卵', '細', '胞', // ED70-ED7F + '造', '鵝', '倍', '四', '季', '萌', '哎', '呀', '敗', '輕', '蜘', '堅', '齒', '組', '麻', '鰻', // ED80-ED8F + '宇', '燭', '幽', '晶', '斧', '嚏', '幾', '何', '敏', '捷', '功', '夫', '父', '赤', '駒', '劈', // ED90-ED9F + '司', '令', '炸', '雄', '禿', '丫', '首', '惡', '燃', '燒', '畢', '雲', '酋', '迪', '耶', '塔', // EDA0-EDAF + '賽', '里', '狐', '呱', '賀', '掘', '彩', '蓓', '潔', '能', '鞘', '芳', '芙', '妮', '好', '魷', // EDB0-EDBF + '賊', '腳', '鎧', '垃', '藻', '臂', '槍', '傘', '咚', '碎', '黏', '鑰', '朽', '南', '瓜', '嗡', // EDC0-EDCF + '哲', '裴', '格', '梟', '狙', '射', '熾', '咆', '哮', '虎', '漾', '壬', '篤', '啄', '銃', '少', // EDD0-EDDF + '強', '鍬', '農', '勝', '虻', '鬃', '弱', '壞', '驢', '仔', '重', '挽', '滴', '偽', '睡', '罩', // EDE0-EDEF + '盜', '著', '竹', '療', '環', '智', '揮', '猩', '擲', '膽', '噬', '堡', '爺', '參', '性', ':', // EDF0-EDFF + '銀', '伴', '隕', '枕', '戈', '謎', '擬', 'Q', '磨', '舵', '鱗', '杖', '璞', '・', '鳴', '哞', // EE00-EE0F + '鰭', '科', '莫', '迦', '虛', '吾', '肌', '費', '束', '輝', '紙', '御', '機', '夏', '垒', '磊', // EE10-EE1F + '砰', '奥', '壘', '磊', '砰', '丑', '奧', // EE20-EE26 + ]; + + private static ReadOnlySpan Traditional => Table[..TraditionalCount]; + private static ReadOnlySpan Simplified => Table.Slice(TraditionalCount, SimplifiedCount); + private static ReadOnlySpan TraditionalUSUM => Table.Slice(TraditionalCount + SimplifiedCount, TraditionalCountUSUM); + private static ReadOnlySpan SimplifiedUSUM => Table.Slice(TraditionalCount + SimplifiedCount + TraditionalCountUSUM, SimplifiedCountUSUM); + #endregion } diff --git a/PKHeX.Core/PKM/Util/Conversion/EntityConverter.cs b/PKHeX.Core/PKM/Util/Conversion/EntityConverter.cs index 6ae34b16d..230d0cc36 100644 --- a/PKHeX.Core/PKM/Util/Conversion/EntityConverter.cs +++ b/PKHeX.Core/PKM/Util/Conversion/EntityConverter.cs @@ -34,7 +34,7 @@ public static class EntityConverter /// /// /// - /// True if can be converted to the requested format value. + /// True if it can be converted to the requested format value. public static bool IsConvertibleToFormat(PKM pk, int format) { if (pk.Format >= 3 && pk.Format > format && format < 8) @@ -208,7 +208,7 @@ private static EntityConverterResult CheckTransferInbound(PKM pk, Type destType) /// If the PKM is compatible, some properties may be forced to sanitized values. /// PKM input that is to be sanity checked. /// Value clamps for the destination format - /// Indication whether or not the PKM is compatible. + /// Indication whether the PKM is compatible. public static bool IsCompatibleWithModifications(PKM pk, IGameValueLimit limit) { if (pk.Species > limit.MaxSpeciesID) diff --git a/PKHeX.Core/PKM/Util/Conversion/FormConverter.cs b/PKHeX.Core/PKM/Util/Conversion/FormConverter.cs index 17272aaf2..9a46ef71f 100644 --- a/PKHeX.Core/PKM/Util/Conversion/FormConverter.cs +++ b/PKHeX.Core/PKM/Util/Conversion/FormConverter.cs @@ -45,7 +45,7 @@ public static string[] GetFormList(ushort species, IReadOnlyList types, private static bool IsMegaGeneration(this EntityContext context) => context is Gen6 or Gen7 or Gen7b; - private static readonly string[] EMPTY = { string.Empty }; + private static readonly string[] EMPTY = [string.Empty]; private const string Starter = nameof(Starter); private static string[] GetFormsGen1(ushort species, IReadOnlyList types, IReadOnlyList forms, EntityContext context) @@ -54,11 +54,11 @@ private static string[] GetFormsGen1(ushort species, IReadOnlyList types return (Species)species switch { Charizard or Mewtwo when context.IsMegaGeneration() => GetMegaXY(types, forms), - Eevee when context is Gen7b => new[] - { + Eevee when context is Gen7b => + [ types[0], // Normal Starter, - }, + ], Pikachu => GetFormsPikachu(context, types, forms), Slowbro when generation >= 8 => GetFormsGalarSlowbro(types, forms), @@ -89,22 +89,22 @@ private static string[] GetFormsGen3(ushort species, IReadOnlyList types return (Species)species switch { Zigzagoon or Linoone when generation >= 8 => GetFormsGalar(types, forms), - Castform => new[] { + Castform => [ types[0], // Normal forms[889], // Sunny forms[890], // Rainy forms[891], // Snowy - }, - Kyogre or Groudon when generation < 8 => new[] { + ], + Kyogre or Groudon when generation < 8 => [ types[0], // Normal forms[899], // Primal - }, - Deoxys => new[] { + ], + Deoxys => [ types[0], // Normal forms[902], // Attack forms[903], // Defense forms[904], // Speed - }, + ], _ => EMPTY, }; } @@ -113,39 +113,39 @@ private static string[] GetFormsGen4(ushort species, IReadOnlyList types { return (Species)species switch { - Burmy or Wormadam or Mothim => new[] { + Burmy or Wormadam or Mothim => [ forms[(int)Burmy], // Plant forms[905], // Sandy forms[906], // Trash - }, - Cherrim => new[] { + ], + Cherrim => [ forms[(int)Cherrim], // Overcast forms[909], // Sunshine - }, - Shellos or Gastrodon => new[] { + ], + Shellos or Gastrodon => [ forms[(int)Shellos], // West forms[911], // East - }, - Rotom => new[] { + ], + Rotom => [ types[0], // Normal forms[917], // Heat forms[918], // Wash forms[919], // Frost forms[920], // Fan forms[921], // Mow - }, - Dialga or Palkia when generation >= 8 => new[] { + ], + Dialga or Palkia when generation >= 8 => [ types[0], // Normal forms[922], // Origin - }, - Giratina => new[] { + ], + Giratina => [ forms[(int)Giratina], // Altered forms[922], // Origin - }, - Shaymin => new[] { + ], + Shaymin => [ forms[(int)Shaymin], // Land forms[923], // Sky - }, + ], Arceus => GetFormsArceus(species, generation, types, forms), _ => EMPTY, }; @@ -156,56 +156,56 @@ private static string[] GetFormsGen5(ushort species, IReadOnlyList types return (Species)species switch { Samurott or Lilligant or Zorua or Zoroark or Braviary when generation >= 8 => GetFormsHisui(species, generation, types, forms), - Basculin when generation >= 8 => new[] { + Basculin when generation >= 8 => [ forms[(int)Basculin], // Red forms[942], // Blue forms[989], // White - }, - Basculin => new[] { + ], + Basculin => [ forms[(int)Basculin], // Red forms[942], // Blue - }, + ], Darumaka or Stunfisk or Yamask when generation >= 8 => GetFormsGalar(types, forms), - Darmanitan when generation >= 8 => new[] { + Darmanitan when generation >= 8 => [ forms[(int)Darmanitan], // Standard forms[943], // Zen forms[Galarian], // Standard forms[Galarian] + " " + forms[943], // Zen - }, - Darmanitan => new[] { + ], + Darmanitan => [ forms[(int)Darmanitan], // Standard forms[943], // Zen - }, - Deerling or Sawsbuck => new[] { + ], + Deerling or Sawsbuck => [ forms[(int)Deerling], // Spring forms[947], // Summer forms[948], // Autumn forms[949], // Winter - }, - Tornadus or Thundurus or Landorus => new[] { + ], + Tornadus or Thundurus or Landorus => [ forms[(int)Tornadus], // Incarnate forms[952], // Therian - }, - Kyurem => new[] { + ], + Kyurem => [ types[0], // Normal forms[953], // White forms[954], // Black - }, - Keldeo => new[] { + ], + Keldeo => [ forms[(int)Keldeo], // Ordinary forms[955], // Resolute - }, - Meloetta => new[] { + ], + Meloetta => [ forms[(int)Meloetta], // Aria forms[956], // Pirouette - }, - Genesect => new[] { + ], + Genesect => [ types[0], // Normal types[010], // Douse (Water) types[012], // Shock (Electric) types[009], // Burn (Fire) types[014], // Chill (Ice) - }, + ], _ => EMPTY, }; } @@ -214,16 +214,16 @@ private static string[] GetFormsGen6(ushort species, IReadOnlyList types { return (Species)species switch { - Greninja when generation < 9 => new[] { + Greninja when generation < 9 => [ types[0], // Normal forms[962], // Ash forms[1012], // "Bonded" - Active - }, - Greninja => new[] { + ], + Greninja => [ types[0], // Normal forms[962], // Ash - }, - Scatterbug or Spewpa or Vivillon => new[] { + ], + Scatterbug or Spewpa or Vivillon => [ forms[(int)Vivillon], // Icy Snow forms[963], // Polar forms[964], // Tundra @@ -244,23 +244,23 @@ private static string[] GetFormsGen6(ushort species, IReadOnlyList types forms[979], // Jungle forms[980], // Fancy forms[981], // Poké Ball - }, - Floette when generation < 9 => new[] { + ], + Floette when generation < 9 => [ forms[(int)Floette], // Red forms[986], // Yellow forms[987], // Orange forms[988], // Blue forms[989], // White forms[990], // Eternal - }, - Flabébé or Floette or Florges => new[] { + ], + Flabébé or Floette or Florges => [ forms[(int)Flabébé], // Red forms[986], // Yellow forms[987], // Orange forms[988], // Blue forms[989], // White - }, - Furfrou => new[] { + ], + Furfrou => [ forms[(int)Furfrou], // Natural forms[995], // Heart forms[996], // Star @@ -271,37 +271,37 @@ private static string[] GetFormsGen6(ushort species, IReadOnlyList types forms[1001], // La Reine forms[1002], // Kabuki forms[1003], // Pharaoh - }, - Meowstic => new[] { + ], + Meowstic => [ genders[000], // Male genders[001], // Female - }, - Aegislash => new[] { + ], + Aegislash => [ forms[(int)Aegislash], // Shield forms[1005], // Blade - }, + ], Sliggoo or Goodra or Avalugg when generation >= 8 => GetFormsHisui(species, generation, types, forms), - Pumpkaboo or Gourgeist => new[] { + Pumpkaboo or Gourgeist => [ forms[(int)Pumpkaboo], // Average forms[1006], // Small forms[1007], // Large forms[1008], // Super - }, - Xerneas => new[] { + ], + Xerneas => [ forms[(int)Xerneas], // Neutral forms[1012], // Active - }, - Hoopa => new[] { + ], + Hoopa => [ forms[(int)Hoopa], // Confined forms[1018], // Unbound - }, - Zygarde => new[] { + ], + Zygarde => [ forms[(int)Zygarde], // 50% (Aura Break) forms[1013], // 10% (Aura Break) forms[1014] + "-C", // 10% Cell (Power Construct) forms[1015] + "-C", // 50% Cell (Power Construct) forms[1016], // 100% Cell (Power Construct) - }, + ], _ => EMPTY, }; } @@ -311,27 +311,27 @@ private static string[] GetFormsGen7(ushort species, IReadOnlyList types return (Species)species switch { Decidueye when generation >= 8 => GetFormsHisui(species, generation, types, forms), - Oricorio => new[] { + Oricorio => [ forms[(int)Oricorio], // "RED" - Baile forms[1021], // "YLW" - Pom-Pom forms[1022], // "PNK" - Pa'u forms[1023], // "BLU" - Sensu - }, - Rockruff => new[] { + ], + Rockruff => [ types[0], // Normal forms[1064], // Dusk - }, - Lycanroc => new[] { + ], + Lycanroc => [ forms[(int)Lycanroc], // Midday forms[1024], // Midnight forms[1064], // Dusk - }, - Wishiwashi => new[] { + ], + Wishiwashi => [ forms[(int)Wishiwashi], forms[1025], // School - }, + ], Silvally => GetFormsArceus(species, 7, types, forms), - Minior => new[] { + Minior => [ forms[(int)Minior], // "R-Meteor", // Meteor Red forms[1045], // "O-Meteor", // Meteor Orange forms[1046], // "Y-Meteor", // Meteor Yellow @@ -346,21 +346,21 @@ private static string[] GetFormsGen7(ushort species, IReadOnlyList types forms[1055], // "B-Core", // Core Blue forms[1056], // "I-Core", // Core Indigo forms[1057], // "V-Core", // Core Violet - }, - Mimikyu => new[] { + ], + Mimikyu => [ forms[(int)Mimikyu], // Disguised forms[1058], // Busted - }, - Necrozma => new[] { + ], + Necrozma => [ types[0], // Normal forms[1065], // Dusk Mane forms[1066], // Dawn Wings forms[1067], // Ultra Necrozma - }, - Magearna => new[] { + ], + Magearna => [ types[0], forms[1062], // Original - }, + ], _ => EMPTY, }; } @@ -369,24 +369,24 @@ private static string[] GetFormsGen8(ushort species, int generation, IReadOnlyLi { return (Species)species switch { - Cramorant => new[] { + Cramorant => [ types[0], // Normal forms[Gulping], forms[Gorging], - }, - Toxtricity => new[] { + ], + Toxtricity => [ forms[(int)Toxtricity], // Amped forms[LowKey], - }, - Indeedee or Basculegion => new[] { + ], + Indeedee or Basculegion => [ genders[000], // Male genders[001], // Female - }, - Sinistea or Polteageist => new[] { + ], + Sinistea or Polteageist => [ forms[Phony], forms[Antique], - }, - Alcremie => new[] { + ], + Alcremie => [ forms[(int)Alcremie], // Vanilla Cream forms[RubyCream], forms[MatchaCream], @@ -396,48 +396,48 @@ private static string[] GetFormsGen8(ushort species, int generation, IReadOnlyLi forms[RubySwirl], forms[CaramelSwirl], forms[RainbowSwirl], - }, - Morpeko => new[] { + ], + Morpeko => [ forms[FullBellyMode], forms[HangryMode], - }, - Eiscue => new[] { + ], + Eiscue => [ forms[IceFace], forms[NoiceFace], - }, - Zacian or Zamazenta => new[] { + ], + Zacian or Zamazenta => [ forms[HeroOfManyBattles], forms[Crowned], - }, - Eternatus when generation == 8 => new[] { + ], + Eternatus when generation == 8 => [ types[0], // Normal forms[Eternamax], - }, - Urshifu => new[] { + ], + Urshifu => [ forms[SingleStrike], forms[RapidStrike], - }, - Zarude => new[] { + ], + Zarude => [ types[0], // Normal forms[Dada], - }, - Calyrex => new[] { + ], + Calyrex => [ types[0], // Normal forms[CalyIce], forms[CalyGhost], - }, - Kleavor when generation == 8 => new[] { + ], + Kleavor when generation == 8 => [ types[0], forms[Lord], - }, - Ursaluna when generation >= 9 => new[] { + ], + Ursaluna when generation >= 9 => [ types[0], forms[Bloodmoon], - }, - Enamorus => new[] { + ], + Enamorus => [ forms[641], // Incarnate forms[952], // Therian - }, + ], _ => EMPTY, }; } @@ -446,52 +446,52 @@ private static string[] GetFormsGen9(ushort species, int generation, IReadOnlyLi { return (Species)species switch { - Oinkologne => new[] { + Oinkologne => [ genders[000], // Male genders[001], // Female - }, - Dudunsparce => new[] { + ], + Dudunsparce => [ forms[TwoSegment], forms[ThreeSegment], - }, - Palafin => new[] { + ], + Palafin => [ forms[Zero], forms[HeroPalafin], - }, - Maushold => new[] { + ], + Maushold => [ forms[FamilyOfThree], forms[FamilyOfFour], - }, - Tatsugiri => new[] { + ], + Tatsugiri => [ forms[Curly], forms[Droopy], forms[Stretchy], - }, - Squawkabilly => new[] { + ], + Squawkabilly => [ forms[Green], forms[988], // Blue forms[986], // Yellow forms[989], // White - }, - Gimmighoul => new[] { + ], + Gimmighoul => [ forms[Chest], forms[Roaming], - }, - Koraidon => new[] { + ], + Koraidon => [ forms[Apex], forms[Limited], forms[Sprinting], forms[Swimming], forms[Gliding], - }, - Miraidon => new[] { + ], + Miraidon => [ forms[Ultimate], forms[LowPower], forms[Drive], forms[Aquatic], forms[Glide], - }, - Ogerpon => new[] { + ], + Ogerpon => [ forms[MaskTeal], forms[MaskWellspring], forms[MaskHearthflame], @@ -500,15 +500,15 @@ private static string[] GetFormsGen9(ushort species, int generation, IReadOnlyLi $"*{forms[MaskWellspring]}", $"*{forms[MaskHearthflame]}", $"*{forms[MaskCornerstone]}", - }, - Poltchageist => new[] { + ], + Poltchageist => [ forms[Counterfeit], forms[Artisan], - }, - Sinistcha => new[] { + ], + Sinistcha => [ forms[Unremarkable], forms[Masterpiece], - }, + ], _ => EMPTY, }; } @@ -521,11 +521,11 @@ private static string[] GetFormsAlolan(EntityContext context, IReadOnlyList= 8 => new[] { + Meowth when generation >= 8 => [ types[0], forms[810], // Alolan forms[Galarian], // Galarian - }, + ], // Only reached when Gen8+, as Totem logic picks up Gen7 earlier. Rattata or Raticate @@ -537,10 +537,10 @@ or Raichu or Geodude or Graveler or Golem or Grimer or Muk or Exeggutor - or Marowak => new[] { + or Marowak => [ types[0], forms[810], // Alolan - }, + ], _ => EMPTY, }; } @@ -550,7 +550,7 @@ private static string[] GetFormsPikachu(EntityContext context, IReadOnlyList new[] { + 6 => [ types[0], // Normal forms[729], // Rockstar forms[730], // Belle @@ -558,8 +558,8 @@ private static string[] GetFormsPikachu(EntityContext context, IReadOnlyList new[] { + ], + 7 when context is Gen7b => [ types[0], // Normal forms[813], // Original forms[814], // Hoenn @@ -569,8 +569,8 @@ private static string[] GetFormsPikachu(EntityContext context, IReadOnlyList new[] { + ], + 7 => [ types[0], // Normal forms[813], // Original forms[814], // Hoenn @@ -579,8 +579,8 @@ private static string[] GetFormsPikachu(EntityContext context, IReadOnlyList new[] { + ], + 8 or 9 => [ types[0], // Normal forms[813], // Original forms[814], // Hoenn @@ -591,25 +591,25 @@ private static string[] GetFormsPikachu(EntityContext context, IReadOnlyList EMPTY, }; } private static string[] GetFormsPichu(IReadOnlyList types, IReadOnlyList forms) { - return new[] - { + return + [ types[0], // Normal forms[000], // Spiky - }; + ]; } private static string[] GetFormsArceus(ushort species, int generation, IReadOnlyList types, IReadOnlyList forms) { return generation switch { - 4 => new[] { + 4 => [ types[00], // Normal types[01], // Fighting types[02], // Flying @@ -628,8 +628,8 @@ private static string[] GetFormsArceus(ushort species, int generation, IReadOnly types[14], types[15], types[16], // No Fairy Type - }, - 5 => new[] { + ], + 5 => [ types[00], // Normal types[01], // Fighting types[02], // Flying @@ -647,9 +647,9 @@ private static string[] GetFormsArceus(ushort species, int generation, IReadOnly types[14], types[15], types[16], // No Fairy type - }, - 8 when (Species)species is Arceus => new[] - { + ], + 8 when (Species)species is Arceus => + [ types[00], // Normal types[01], // Fighting types[02], // Flying @@ -669,8 +669,8 @@ private static string[] GetFormsArceus(ushort species, int generation, IReadOnly types[16], types[17], forms[Legend], - }, - _ => new[] { + ], + _ => [ types[00], // Normal types[01], // Fighting types[02], // Flying @@ -689,36 +689,36 @@ private static string[] GetFormsArceus(ushort species, int generation, IReadOnly types[15], types[16], types[17], - }, + ], }; } private static string[] GetFormsTotem(ushort species, IReadOnlyList types, IReadOnlyList forms) => species switch { - (int)Mimikyu => new[] - { + (int)Mimikyu => + [ forms[(int)Mimikyu], // Disguised forms[1058], // Busted forms[1007], // Large "*" + forms[1058], // Busted - }, - (int)Raticate or (int)Marowak => new[] - { + ], + (int)Raticate or (int)Marowak => + [ types[0], // Normal forms[810], // Alolan forms[1007], // Large - }, - _ => new[] - { + ], + _ => + [ types[0], // Normal forms[1007], // Large - }, + ], }; private static string[] GetFormsUnown(int generation) => generation switch { - 2 => new[] - { + 2 => + [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", @@ -726,9 +726,9 @@ private static string[] GetFormsArceus(ushort species, int generation, IReadOnly "U", "V", "W", "X", "Y", "Z", // "!", "?", not in Gen2 - }, - _ => new[] - { + ], + _ => + [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", @@ -736,101 +736,100 @@ private static string[] GetFormsArceus(ushort species, int generation, IReadOnly "U", "V", "W", "X", "Y", "Z", "!", "?", - }, + ], }; - private static bool IsFormListSingleMega(ushort species) => Mega_6_Single.Contains(species); - - private static readonly HashSet Mega_6_Single = new() - { + private static bool IsFormListSingleMega(ushort species) => species is // XY - 003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, - 380, 381, 445, 448, 460, + 003 or 009 or 065 or 094 or 115 or 127 or 130 or 142 or 181 or 212 or + 214 or 229 or 248 or 257 or 282 or 303 or 306 or 308 or 310 or 354 or + 359 or 380 or 381 or 445 or 448 or 460 or // AO - 015, 018, 080, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 384, 428, 475, 531, 719, - }; + 015 or 018 or 080 or 208 or 254 or 260 or 302 or 319 or 323 or 334 or + 362 or 373 or 376 or 384 or 428 or 475 or 531 or 719 + ; private static string[] GetMegaSingle(IReadOnlyList types, IReadOnlyList forms) { - return new[] - { + return + [ types[0], // Normal forms[804], // Mega - }; + ]; } private static string[] GetMegaXY(IReadOnlyList types, IReadOnlyList forms) { - return new[] - { + return + [ types[0], // Normal forms[805], // Mega X forms[806], // Mega Y - }; + ]; } private static string[] GetFormsGalar(IReadOnlyList types, IReadOnlyList forms) { - return new[] - { + return + [ types[0], // Normal forms[Galarian], // Galarian - }; + ]; } private static string[] GetFormsHisui(ushort species, int generation, IReadOnlyList types, IReadOnlyList forms) => generation switch { 8 => (Species)species switch { - Lilligant => new[] - { + Lilligant => + [ types[0], // Normal forms[Hisuian], forms[Lady], - }, - Arcanine or Electrode or Avalugg => new[] - { + ], + Arcanine or Electrode or Avalugg => + [ types[0], // Normal forms[Hisuian], forms[Lord], - }, - _ => new[] - { + ], + _ => + [ types[0], // Normal forms[Hisuian], - }, + ], }, - _ => new[] - { + _ => + [ types[0], // Normal forms[Hisuian], - }, + ], }; private static string[] GetFormsPaldea(ushort species, IReadOnlyList types, IReadOnlyList forms) => (Species)species switch { - Tauros => new[] { + Tauros => [ types[0], // Normal $"{forms[Paldean]} {forms[PaldeanCombat]}", $"{forms[Paldean]} {forms[PaldeanBlaze]}", $"{forms[Paldean]} {forms[PaldeanAqua]}", - }, - _ => new[] - { + ], + _ => + [ types[0], // Normal forms[Paldean], - }, + ], }; private static string[] GetFormsGalarSlowbro(IReadOnlyList types, IReadOnlyList forms) { - return new[] - { + return + [ types[0], // Normal forms[804], // Mega forms[Galarian], // Galarian - }; + ]; } private const int Galarian = 1068; diff --git a/PKHeX.Core/PKM/Util/Conversion/IEntityRejuvenator.cs b/PKHeX.Core/PKM/Util/Conversion/IEntityRejuvenator.cs index cc1a6fe16..d16ee7aca 100644 --- a/PKHeX.Core/PKM/Util/Conversion/IEntityRejuvenator.cs +++ b/PKHeX.Core/PKM/Util/Conversion/IEntityRejuvenator.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; public interface IEntityRejuvenator { /// - /// After converting, the method will attempt to auto-fill missing properties. + /// After converting, the method will attempt to autofill missing properties. /// /// Output data after conversion /// Input data prior to conversion diff --git a/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs b/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs index 4e256727c..5fd6169a9 100644 --- a/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs +++ b/PKHeX.Core/PKM/Util/Conversion/ItemConverter.cs @@ -59,8 +59,8 @@ private static byte GetItemOld2(ushort item) #region Item Mapping Tables /// Gen2 items (index) and their corresponding Gen4 item ID (value) - private static ReadOnlySpan arr2 => new ushort[] - { + private static ReadOnlySpan arr2 => + [ 000, 001, 002, 213, 003, 004, NaN, 450, 081, 018, // 0 019, 020, 021, 022, 023, 024, 025, 026, 017, 078, // 1 079, 041, 082, 083, 084, NaN, 045, 046, 047, 048, // 2 @@ -87,11 +87,11 @@ private static byte GetItemOld2(ushort item) 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, // 23 375, 376, 377, 420, 421, 422, 423, 424, 425, 426, // 24 427, NaN, NaN, NaN, NaN, NaN, - }; + ]; /// Gen3 items (index) and their corresponding Gen4 item ID (value) - private static ReadOnlySpan arr3 => new ushort[] - { + private static ReadOnlySpan arr3 => + [ 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, @@ -127,7 +127,7 @@ private static byte GetItemOld2(ushort item) 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, - }; + ]; #endregion /// @@ -185,7 +185,8 @@ internal static int GetItemForFormat(int srcItem, EntityContext srcFormat, Entit if (destFormat > srcFormat) // can't set past gen items return 0; - // ShowdownSet checks gen3 then gen2. For gen2 collisions (if any?) remap 3->4->2. + // ShowdownSet checks Gen3 then Gen2. + // For Gen2 collisions (if any?) remap 3->4->2. srcItem = GetItemFuture3((ushort)srcItem); srcItem = GetItemOld2((ushort)srcItem); if (srcItem <= 0) diff --git a/PKHeX.Core/PKM/Util/Conversion/SpeciesConverter.cs b/PKHeX.Core/PKM/Util/Conversion/SpeciesConverter.cs index 9c078170e..268bc7e2b 100644 --- a/PKHeX.Core/PKM/Util/Conversion/SpeciesConverter.cs +++ b/PKHeX.Core/PKM/Util/Conversion/SpeciesConverter.cs @@ -81,8 +81,8 @@ public static ushort GetNational9(ushort raw) } // both tables are 0x100 bytes to eliminate bounds checks when requesting byte indexes - private static ReadOnlySpan Table1NationalToInternal => new byte[] { 0x00, 0x99, 0x09, 0x9A, 0xB0, 0xB2, 0xB4, 0xB1, 0xB3, 0x1C, 0x7B, 0x7C, 0x7D, 0x70, 0x71, 0x72, 0x24, 0x96, 0x97, 0xA5, 0xA6, 0x05, 0x23, 0x6C, 0x2D, 0x54, 0x55, 0x60, 0x61, 0x0F, 0xA8, 0x10, 0x03, 0xA7, 0x07, 0x04, 0x8E, 0x52, 0x53, 0x64, 0x65, 0x6B, 0x82, 0xB9, 0xBA, 0xBB, 0x6D, 0x2E, 0x41, 0x77, 0x3B, 0x76, 0x4D, 0x90, 0x2F, 0x80, 0x39, 0x75, 0x21, 0x14, 0x47, 0x6E, 0x6F, 0x94, 0x26, 0x95, 0x6A, 0x29, 0x7E, 0xBC, 0xBD, 0xBE, 0x18, 0x9B, 0xA9, 0x27, 0x31, 0xA3, 0xA4, 0x25, 0x08, 0xAD, 0x36, 0x40, 0x46, 0x74, 0x3A, 0x78, 0x0D, 0x88, 0x17, 0x8B, 0x19, 0x93, 0x0E, 0x22, 0x30, 0x81, 0x4E, 0x8A, 0x06, 0x8D, 0x0C, 0x0A, 0x11, 0x91, 0x2B, 0x2C, 0x0B, 0x37, 0x8F, 0x12, 0x01, 0x28, 0x1E, 0x02, 0x5C, 0x5D, 0x9D, 0x9E, 0x1B, 0x98, 0x2A, 0x1A, 0x48, 0x35, 0x33, 0x1D, 0x3C, 0x85, 0x16, 0x13, 0x4C, 0x66, 0x69, 0x68, 0x67, 0xAA, 0x62, 0x63, 0x5A, 0x5B, 0xAB, 0x84, 0x4A, 0x4B, 0x49, 0x58, 0x59, 0x42, 0x83, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - private static ReadOnlySpan Table1InternalToNational => new byte[] { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + private static ReadOnlySpan Table1NationalToInternal => [ 0x00, 0x99, 0x09, 0x9A, 0xB0, 0xB2, 0xB4, 0xB1, 0xB3, 0x1C, 0x7B, 0x7C, 0x7D, 0x70, 0x71, 0x72, 0x24, 0x96, 0x97, 0xA5, 0xA6, 0x05, 0x23, 0x6C, 0x2D, 0x54, 0x55, 0x60, 0x61, 0x0F, 0xA8, 0x10, 0x03, 0xA7, 0x07, 0x04, 0x8E, 0x52, 0x53, 0x64, 0x65, 0x6B, 0x82, 0xB9, 0xBA, 0xBB, 0x6D, 0x2E, 0x41, 0x77, 0x3B, 0x76, 0x4D, 0x90, 0x2F, 0x80, 0x39, 0x75, 0x21, 0x14, 0x47, 0x6E, 0x6F, 0x94, 0x26, 0x95, 0x6A, 0x29, 0x7E, 0xBC, 0xBD, 0xBE, 0x18, 0x9B, 0xA9, 0x27, 0x31, 0xA3, 0xA4, 0x25, 0x08, 0xAD, 0x36, 0x40, 0x46, 0x74, 0x3A, 0x78, 0x0D, 0x88, 0x17, 0x8B, 0x19, 0x93, 0x0E, 0x22, 0x30, 0x81, 0x4E, 0x8A, 0x06, 0x8D, 0x0C, 0x0A, 0x11, 0x91, 0x2B, 0x2C, 0x0B, 0x37, 0x8F, 0x12, 0x01, 0x28, 0x1E, 0x02, 0x5C, 0x5D, 0x9D, 0x9E, 0x1B, 0x98, 0x2A, 0x1A, 0x48, 0x35, 0x33, 0x1D, 0x3C, 0x85, 0x16, 0x13, 0x4C, 0x66, 0x69, 0x68, 0x67, 0xAA, 0x62, 0x63, 0x5A, 0x5B, 0xAB, 0x84, 0x4A, 0x4B, 0x49, 0x58, 0x59, 0x42, 0x83, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]; + private static ReadOnlySpan Table1InternalToNational => [ 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]; // Use a static span to avoid allocations -- these delta tables shift between the two representations. // Since most values are A<->A, we only need to store table values for those that are non-zero delta values. @@ -95,8 +95,8 @@ public static ushort GetNational9(ushort raw) /// /// Difference of National Dex IDs (index) and the associated Gen3 Species IDs (value) /// - private static ReadOnlySpan Table3NationalToInternal => new sbyte[] - { + private static ReadOnlySpan Table3NationalToInternal => + [ 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 025, 028, 028, 031, 031, @@ -111,13 +111,13 @@ public static ushort GetNational9(ushort raw) 000, -15, -15, -22, -22, -22, 007, 007, 007, 012, -45, 024, 024, 024, 024, 024, 024, 024, 024, 024, 027, 027, 022, 022, 022, 024, 024, - }; + ]; /// /// Difference of Gen3 Species IDs (index) and the associated National Dex IDs (value) /// - private static ReadOnlySpan Table3InternalToNational => new sbyte[] - { + private static ReadOnlySpan Table3InternalToNational => + [ -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, @@ -133,13 +133,13 @@ public static ushort GetNational9(ushort raw) -43, -43,-112,-112,-112, -24, -24, -24, -24, -24, -24, -24, -24, -24, -22, -22, -22, -27, -27, -24, -24, -53, - }; + ]; /// /// Difference of National Dex IDs (index) and the associated Gen9 Species IDs (value) /// - private static ReadOnlySpan Table9NationalToInternal => new sbyte[] - { + private static ReadOnlySpan Table9NationalToInternal => + [ 001, 001, 001, 001, 033, 033, 033, 021, 021, 044, 044, 007, 007, 007, 029, 031, 031, 031, 068, 068, 068, 002, 002, @@ -152,15 +152,15 @@ public static ushort GetNational9(ushort raw) -23, -05, -07, -09, -07, -20, -13, -09, -09, -29, -23, 001, 012, 012, 000, 000, 000, -06, UNK, UNK, UNK, UNK, UNK, UNK, UNK, UNK, - }; + ]; private const sbyte UNK = 111; /// /// Difference of Gen9 Species IDs (index) and the associated National Dex IDs (value) /// - private static ReadOnlySpan Table9InternalToNational => new sbyte[] - { + private static ReadOnlySpan Table9InternalToNational => + [ 065, -01, -01, -01, -01, 031, 031, 047, 047, 029, 029, 053, 031, 031, 046, 044, 030, 030, -07, -07, -07, 013, 013, @@ -173,5 +173,5 @@ public static ushort GetNational9(ushort raw) -43, -43, -43, -68, -68, -68, -58, -58, -25, -29, -31, 006, -01, UNK, 000, 000, 000, UNK, UNK, UNK, UNK, UNK, UNK, UNK, -12, -12, - }; + ]; } diff --git a/PKHeX.Core/PKM/Util/EntityDetection.cs b/PKHeX.Core/PKM/Util/EntityDetection.cs index 4e2608da2..88f05a2ba 100644 --- a/PKHeX.Core/PKM/Util/EntityDetection.cs +++ b/PKHeX.Core/PKM/Util/EntityDetection.cs @@ -1,31 +1,28 @@ using System; -using System.Collections.Generic; using static System.Buffers.Binary.BinaryPrimitives; +using static PKHeX.Core.PokeCrypto; namespace PKHeX.Core; public static class EntityDetection { - private static readonly HashSet Sizes = new() - { - PokeCrypto.SIZE_1JLIST, PokeCrypto.SIZE_1ULIST, - PokeCrypto.SIZE_2ULIST, PokeCrypto.SIZE_2JLIST, PokeCrypto.SIZE_2STADIUM, - PokeCrypto.SIZE_3STORED, PokeCrypto.SIZE_3PARTY, - PokeCrypto.SIZE_3CSTORED, PokeCrypto.SIZE_3XSTORED, - PokeCrypto.SIZE_4STORED, PokeCrypto.SIZE_4PARTY, PokeCrypto.SIZE_4RSTORED, - PokeCrypto.SIZE_5PARTY, - PokeCrypto.SIZE_6STORED, PokeCrypto.SIZE_6PARTY, - PokeCrypto.SIZE_8STORED, PokeCrypto.SIZE_8PARTY, - PokeCrypto.SIZE_8ASTORED, PokeCrypto.SIZE_8APARTY, - PokeCrypto.SIZE_9STORED, PokeCrypto.SIZE_9PARTY, - }; - /// /// Determines if the given length is valid for a . /// /// Data length of the file/array. - /// A indicating whether or not the length is valid for a . - public static bool IsSizePlausible(long len) => Sizes.Contains((int)len); + /// A indicating whether the length is valid for a . + public static bool IsSizePlausible(long len) => len is + SIZE_1JLIST or SIZE_1ULIST or + SIZE_2ULIST or SIZE_2JLIST or SIZE_2STADIUM or + SIZE_3STORED or SIZE_3PARTY or + SIZE_3CSTORED or SIZE_3XSTORED or + SIZE_4STORED or SIZE_4PARTY or SIZE_4RSTORED or + SIZE_5PARTY or + SIZE_6STORED or SIZE_6PARTY or + SIZE_8STORED or SIZE_8PARTY or + SIZE_8ASTORED or SIZE_8APARTY or + SIZE_9STORED or SIZE_9PARTY + ; public static bool IsPresentGB(ReadOnlySpan data) => data[0] != 0; // Species non-zero public static bool IsPresentGC(ReadOnlySpan data) => ReadUInt16BigEndian(data) != 0; // Species non-zero @@ -51,7 +48,7 @@ public static bool IsPresent(ReadOnlySpan data) return x => IsPresent(x); if (blank.Format <= 2) return x => IsPresentGB(x); - if (blank.Data.Length <= PokeCrypto.SIZE_3PARTY) + if (blank.Data.Length <= SIZE_3PARTY) return x => IsPresentGBA(x); return x => IsPresentGC(x); } diff --git a/PKHeX.Core/PKM/Util/EntityFileExtension.cs b/PKHeX.Core/PKM/Util/EntityFileExtension.cs index 123f7598c..10d131918 100644 --- a/PKHeX.Core/PKM/Util/EntityFileExtension.cs +++ b/PKHeX.Core/PKM/Util/EntityFileExtension.cs @@ -16,7 +16,7 @@ public static class EntityFileExtension private const string ExtensionPA8 = "pa8"; private const int CountExtra = 8; - public static IReadOnlyList Extensions7b => new[] { ExtensionPB7 }; + public static IReadOnlyList Extensions7b => [ExtensionPB7]; /// /// Gets an array of valid file extensions. @@ -50,7 +50,7 @@ public static string[] GetExtensions(int maxGeneration = PKX.Generation) if (maxGeneration >= 8) result.Add(ExtensionPA8); // Legends: Arceus - return result.ToArray(); + return [.. result]; } /// diff --git a/PKHeX.Core/PKM/Util/EntityFormat.cs b/PKHeX.Core/PKM/Util/EntityFormat.cs index da8778b91..e7c4d3f83 100644 --- a/PKHeX.Core/PKM/Util/EntityFormat.cs +++ b/PKHeX.Core/PKM/Util/EntityFormat.cs @@ -8,9 +8,9 @@ namespace PKHeX.Core; public static class EntityFormat { /// - /// Gets the generation of the Pokemon data. + /// Gets the generation of the Pokémon data. /// - /// Raw data representing a Pokemon. + /// Raw data representing a Pokémon. /// Enum indicating the generation of the PKM file, or if the data is invalid. public static EntityFormatDetected GetFormat(ReadOnlySpan data) { @@ -50,8 +50,8 @@ private static bool IsFormat67(ReadOnlySpan data) if (ReadUInt16LittleEndian(data[0x04..]) != 0) // Bad Sanity? return false; // PGT with non-zero ItemID - // PGT files have the last 0x10 bytes 00; PK6/etc will have data here. - if (data[..^0x10].IndexOfAnyExcept(0) != -1) + // PGT files have the last 0x10 bytes 00; PK6/etc. will have data here. + if (data[..^0x10].ContainsAnyExcept(0)) return true; if (ReadUInt16LittleEndian(data[0x06..]) == Checksums.Add16(data[8..SIZE_6STORED])) @@ -67,7 +67,7 @@ private static EntityFormatDetected GetFormat45(ReadOnlySpan data) if (ReadUInt16LittleEndian(data[0x4..]) != 0) return FormatBK4; // BK4 non-zero sanity if (data[0x5F] < 0x10 && ReadUInt16LittleEndian(data[0x80..]) < 0x3333) - return FormatPK4; // gen3/4 version origin, not Transporter + return FormatPK4; // Gen3/4 version origin, not Transporter if (ReadUInt16LittleEndian(data[0x46..]) != 0) return FormatPK4; // PK4.Met_LocationExtended (unused in PK5) return FormatPK5; @@ -106,7 +106,7 @@ private static bool IsFormatReally9(PK8 pk) /// /// Creates an instance of from the given data. /// - /// Raw data of the Pokemon file. + /// Raw data of the Pokémon file. /// Optional identifier for the preferred generation. Usually the generation of the destination save file. /// An instance of created from the given , or null if is invalid. public static PKM? GetFromBytes(byte[] data, EntityContext prefer = EntityContext.None) @@ -176,7 +176,7 @@ private static EntityFormatDetected IsFormatReally7(PK6 pk) if (!pk.Gen4) // can't have GroundTile return FormatPK7; - if (et > GroundTileType.Max_Pt) // invalid gen4 GroundTile + if (et > GroundTileType.Max_Pt) // invalid Gen4 GroundTile return FormatPK7; } diff --git a/PKHeX.Core/PKM/Util/EntitySorting.cs b/PKHeX.Core/PKM/Util/EntitySorting.cs index a92db5572..58ef917af 100644 --- a/PKHeX.Core/PKM/Util/EntitySorting.cs +++ b/PKHeX.Core/PKM/Util/EntitySorting.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -175,7 +175,7 @@ public static IEnumerable OrderByCustom(this IEnumerable list, params /// /// Sorts an list of objects in reverse. /// - /// Source list to revese sort + /// Source list to reverse sort /// Enumerable list that is sorted public static IEnumerable ReverseSort(this IEnumerable list) { diff --git a/PKHeX.Core/PKM/Util/Experience.cs b/PKHeX.Core/PKM/Util/Experience.cs index 646332323..44bb560bf 100644 --- a/PKHeX.Core/PKM/Util/Experience.cs +++ b/PKHeX.Core/PKM/Util/Experience.cs @@ -97,8 +97,8 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) #region ExpTable - private static ReadOnlySpan Growth0 => new uint[] - { + private static ReadOnlySpan Growth0 => + [ 0000000, 0000008, 0000027, 0000064, 0000125, 0000216, 0000343, 0000512, 0000729, 0001000, 0001331, 0001728, 0002197, 0002744, 0003375, 0004096, 0004913, 0005832, 0006859, 0008000, 0009261, 0010648, 0012167, 0013824, 0015625, 0017576, 0019683, 0021952, 0024389, 0027000, @@ -109,10 +109,10 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) 0357911, 0373248, 0389017, 0405224, 0421875, 0438976, 0456533, 0474552, 0493039, 0512000, 0531441, 0551368, 0571787, 0592704, 0614125, 0636056, 0658503, 0681472, 0704969, 0729000, 0753571, 0778688, 0804357, 0830584, 0857375, 0884736, 0912673, 0941192, 0970299, 1000000, - }; + ]; - private static ReadOnlySpan Growth1 => new uint[] - { + private static ReadOnlySpan Growth1 => + [ 0000000, 0000015, 0000052, 0000122, 0000237, 0000406, 0000637, 0000942, 0001326, 0001800, 0002369, 0003041, 0003822, 0004719, 0005737, 0006881, 0008155, 0009564, 0011111, 0012800, 0014632, 0016610, 0018737, 0021012, 0023437, 0026012, 0028737, 0031610, 0034632, 0037800, @@ -123,10 +123,10 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) 0286328, 0296358, 0305767, 0316074, 0326531, 0336255, 0346965, 0357812, 0367807, 0378880, 0390077, 0400293, 0411686, 0423190, 0433572, 0445239, 0457001, 0467489, 0479378, 0491346, 0501878, 0513934, 0526049, 0536557, 0548720, 0560922, 0571333, 0583539, 0591882, 0600000, - }; + ]; - private static ReadOnlySpan Growth2 => new uint[] - { + private static ReadOnlySpan Growth2 => + [ 0000000, 0000004, 0000013, 0000032, 0000065, 0000112, 0000178, 0000276, 0000393, 0000540, 0000745, 0000967, 0001230, 0001591, 0001957, 0002457, 0003046, 0003732, 0004526, 0005440, 0006482, 0007666, 0009003, 0010506, 0012187, 0014060, 0016140, 0018439, 0020974, 0023760, @@ -137,10 +137,10 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) 0479600, 0507617, 0529063, 0559209, 0582187, 0614566, 0639146, 0673863, 0700115, 0737280, 0765275, 0804997, 0834809, 0877201, 0908905, 0954084, 0987754, 1035837, 1071552, 1122660, 1160499, 1214753, 1254796, 1312322, 1354652, 1415577, 1460276, 1524731, 1571884, 1640000, - }; + ]; - private static ReadOnlySpan Growth3 => new uint[] - { + private static ReadOnlySpan Growth3 => + [ 0000000, 0000009, 0000057, 0000096, 0000135, 0000179, 0000236, 0000314, 0000419, 0000560, 0000742, 0000973, 0001261, 0001612, 0002035, 0002535, 0003120, 0003798, 0004575, 0005460, 0006458, 0007577, 0008825, 0010208, 0011735, 0013411, 0015244, 0017242, 0019411, 0021760, @@ -151,10 +151,10 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) 0360838, 0377197, 0394045, 0411388, 0429235, 0447591, 0466464, 0485862, 0505791, 0526260, 0547274, 0568841, 0590969, 0613664, 0636935, 0660787, 0685228, 0710266, 0735907, 0762160, 0789030, 0816525, 0844653, 0873420, 0902835, 0932903, 0963632, 0995030, 1027103, 1059860, - }; + ]; - private static ReadOnlySpan Growth4 => new uint[] - { + private static ReadOnlySpan Growth4 => + [ 0000000, 0000006, 0000021, 0000051, 0000100, 0000172, 0000274, 0000409, 0000583, 0000800, 0001064, 0001382, 0001757, 0002195, 0002700, 0003276, 0003930, 0004665, 0005487, 0006400, 0007408, 0008518, 0009733, 0011059, 0012500, 0014060, 0015746, 0017561, 0019511, 0021600, @@ -165,10 +165,10 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) 0286328, 0298598, 0311213, 0324179, 0337500, 0351180, 0365226, 0379641, 0394431, 0409600, 0425152, 0441094, 0457429, 0474163, 0491300, 0508844, 0526802, 0545177, 0563975, 0583200, 0602856, 0622950, 0643485, 0664467, 0685900, 0707788, 0730138, 0752953, 0776239, 0800000, - }; + ]; - private static ReadOnlySpan Growth5 => new uint[] - { + private static ReadOnlySpan Growth5 => + [ 0000000, 0000010, 0000033, 0000080, 0000156, 0000270, 0000428, 0000640, 0000911, 0001250, 0001663, 0002160, 0002746, 0003430, 0004218, 0005120, 0006141, 0007290, 0008573, 0010000, 0011576, 0013310, 0015208, 0017280, 0019531, 0021970, 0024603, 0027440, 0030486, 0033750, @@ -179,7 +179,7 @@ public static double GetEXPToLevelUpPercentage(int level, uint exp, byte growth) 0447388, 0466560, 0486271, 0506530, 0527343, 0548720, 0570666, 0593190, 0616298, 0640000, 0664301, 0689210, 0714733, 0740880, 0767656, 0795070, 0823128, 0851840, 0881211, 0911250, 0941963, 0973360, 1005446, 1038230, 1071718, 1105920, 1140841, 1176490, 1212873, 1250000, - }; + ]; #endregion } diff --git a/PKHeX.Core/PKM/Util/GameConsole.cs b/PKHeX.Core/PKM/Util/GameConsole.cs index d7e1c21e0..0947d2154 100644 --- a/PKHeX.Core/PKM/Util/GameConsole.cs +++ b/PKHeX.Core/PKM/Util/GameConsole.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core; /// /// /// Related to ; no need to specify side-game consoles like the N64 as they're tied to the mainline console. -/// Console revisions (like GameBoy Color) or 3DS-XL are not included, again, only care about console limitations that run the games. +/// Console revisions (like Game Boy Color) or 3DS-XL are not included, again, only care about console limitations that run the games. /// public enum GameConsole : byte { diff --git a/PKHeX.Core/PKM/Util/Language.cs b/PKHeX.Core/PKM/Util/Language.cs index 393f65e36..8295bf56e 100644 --- a/PKHeX.Core/PKM/Util/Language.cs +++ b/PKHeX.Core/PKM/Util/Language.cs @@ -8,8 +8,8 @@ namespace PKHeX.Core; /// public static class Language { - private static ReadOnlySpan Languages => new[] - { + private static ReadOnlySpan Languages => + [ (byte)Japanese, (byte)English, (byte)French, @@ -22,7 +22,7 @@ public static class Language (byte)ChineseS, (byte)ChineseT, - }; + ]; // check Korean for the VC case, never possible to match string outside of this case private static ReadOnlySpan Languages_GB => Languages[..7]; // [..KOR] diff --git a/PKHeX.Core/PKM/Util/PokeCrypto.cs b/PKHeX.Core/PKM/Util/PokeCrypto.cs index b4f200805..dbbe1d27a 100644 --- a/PKHeX.Core/PKM/Util/PokeCrypto.cs +++ b/PKHeX.Core/PKM/Util/PokeCrypto.cs @@ -60,8 +60,8 @@ public static class PokeCrypto /// /// Positions for shuffling. /// - private static ReadOnlySpan BlockPosition => new byte[] - { + private static ReadOnlySpan BlockPosition => + [ 0, 1, 2, 3, 0, 1, 3, 2, 0, 2, 1, 3, @@ -96,16 +96,16 @@ public static class PokeCrypto 0, 3, 2, 1, 1, 0, 2, 3, 1, 0, 3, 2, - }; + ]; /// - /// Positions for unshuffling. + /// Positions for un-shuffling. /// - private static ReadOnlySpan BlockPositionInvert => new byte[] - { + private static ReadOnlySpan BlockPositionInvert => + [ 0, 1, 2, 4, 3, 5, 6, 7, 12, 18, 13, 19, 8, 10, 14, 20, 16, 22, 9, 11, 15, 21, 17, 23, 0, 1, 2, 4, 3, 5, 6, 7, // duplicates of 0-7 to eliminate modulus - }; + ]; /// /// Shuffles a 232 byte array containing Pokémon data. diff --git a/PKHeX.Core/PKM/Util/RecentTrainerCache.cs b/PKHeX.Core/PKM/Util/RecentTrainerCache.cs index 40e14d425..c79f8808e 100644 --- a/PKHeX.Core/PKM/Util/RecentTrainerCache.cs +++ b/PKHeX.Core/PKM/Util/RecentTrainerCache.cs @@ -44,7 +44,7 @@ public static void SetRecentTrainer(ITrainerInfo trainer) public static void SetConsoleRegionData3DS(IRegionOrigin pk) => SetConsoleRegionData3DS(pk, Trainer); /// - /// Fetches an trainer to apply details to the input . + /// Fetches a trainer to apply details to the input . /// /// Entity to apply details to. /// Trainer that is receiving the entity. @@ -57,7 +57,7 @@ public static void SetConsoleRegionData3DS(IRegionOrigin pk, ITrainerInfo traine } /// - /// Fetches an trainer to apply details to the input . + /// Fetches a trainer to apply details to the input . /// /// Entity to apply details to. public static void SetFirstCountryRegion(IGeoTrack pk) diff --git a/PKHeX.Core/PKM/Util/SpeciesName.cs b/PKHeX.Core/PKM/Util/SpeciesName.cs index 50be7c29f..81e0f506c 100644 --- a/PKHeX.Core/PKM/Util/SpeciesName.cs +++ b/PKHeX.Core/PKM/Util/SpeciesName.cs @@ -38,7 +38,7 @@ public static class SpeciesName /// /// Indexing matches . private static readonly string[] EggNames = - { + [ "タマゴ", "タマゴ", "Egg", @@ -50,14 +50,14 @@ public static class SpeciesName "알", "蛋", "蛋", - }; + ]; /// /// to table for all values. /// - private static readonly IReadOnlyList> SpeciesDict = GetDictionary(SpeciesLang); + private static readonly Dictionary[] SpeciesDict = GetDictionary(SpeciesLang); - private static IReadOnlyList> GetDictionary(IReadOnlyList> names) + private static Dictionary[] GetDictionary(IReadOnlyList> names) { var result = new Dictionary[names.Count]; for (int i = 0; i < result.Length; i++) @@ -302,7 +302,7 @@ public static bool TryGetSpecies(ReadOnlySpan speciesName, int language, o var dict = SpeciesDict[language]; if (!dict.TryGetValue(hash, out species)) return false; - // Double check the species name + // Double-check the species name var arr = SpeciesLang[language]; var expect = arr[species]; return speciesName.SequenceEqual(expect); diff --git a/PKHeX.Core/PKM/XK3.cs b/PKHeX.Core/PKM/XK3.cs index cf7636440..2884b6adb 100644 --- a/PKHeX.Core/PKM/XK3.cs +++ b/PKHeX.Core/PKM/XK3.cs @@ -7,13 +7,13 @@ namespace PKHeX.Core; /// Generation 3 format, exclusively for Pokémon XD. public sealed class XK3 : G3PKM, IShadowCapture { - public override ReadOnlySpan ExtraBytes => new ushort[] - { + public override ReadOnlySpan ExtraBytes => + [ 0x0A, 0x0B, 0x0C, 0x0D, 0x1E, 0x1F, 0x2A, 0x2B, 0x7A, 0x7B, 0x7E, 0x7F, - }; + ]; public override int SIZE_PARTY => PokeCrypto.SIZE_3XSTORED; public override int SIZE_STORED => PokeCrypto.SIZE_3XSTORED; diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo1.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo1.cs index 59f228fef..7951071bd 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo1.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo1.cs @@ -5,12 +5,10 @@ namespace PKHeX.Core; /// /// class with values from Generation 1 games. /// -public sealed class PersonalInfo1 : PersonalInfo, IPersonalInfoTM +public sealed class PersonalInfo1(byte[] Data) : PersonalInfo, IPersonalInfoTM { public const int SIZE = 0x1C; - private readonly byte[] Data; - public PersonalInfo1(byte[] data) => Data = data; public override byte[] Write() => Data; public override byte Gender { get => Data[0x00]; set => Data[0x00] = value; } @@ -91,8 +89,8 @@ public void SetAllLearnTM(Span result, ReadOnlySpan moves) } // 0-2 to indicate how many steps down to get the base species ID. - private static ReadOnlySpan EvoStages => new byte[] - { + private static ReadOnlySpan EvoStages => + [ 0, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, @@ -108,7 +106,7 @@ public void SetAllLearnTM(Span result, ReadOnlySpan moves) 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, - }; + ]; /// /// Gets the amount of times a species has evolved from the base species. diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo2.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo2.cs index 9bf6bcc1f..f390ffed4 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo2.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo2.cs @@ -5,12 +5,10 @@ namespace PKHeX.Core; /// /// class with values from Generation 2 games. /// -public sealed class PersonalInfo2 : PersonalInfo, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo2(byte[] Data) : PersonalInfo, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x20; - private readonly byte[] Data; - public PersonalInfo2(byte[] data) => Data = data; public override byte[] Write() => Data; public int DEX_ID { get => Data[0x00]; set => Data[0x00] = (byte)value; } diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo3.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo3.cs index cef163ee9..436ec4a4e 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo3.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo3.cs @@ -6,12 +6,9 @@ namespace PKHeX.Core; /// /// class with values from Generation 3 games. /// -public sealed class PersonalInfo3 : PersonalInfo, IPersonalAbility12 +public sealed class PersonalInfo3(byte[] Data) : PersonalInfo, IPersonalAbility12 { public const int SIZE = 0x1C; - private readonly byte[] Data; - - public PersonalInfo3(byte[] data) => Data = data; public override byte[] Write() => Data; @@ -65,12 +62,12 @@ public sealed class PersonalInfo3 : PersonalInfo, IPersonalAbility12 /// /// TM/HM learn compatibility flags for individual moves. /// - public bool[] TMHM { get; private set; } = Array.Empty(); + public bool[] TMHM { get; private set; } = []; /// /// Grass-Fire-Water-Etc typed learn compatibility flags for individual moves. /// - public bool[] TypeTutors { get; private set; } = Array.Empty(); + public bool[] TypeTutors { get; private set; } = []; public void CopyFrom(PersonalInfo3 other) { diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo4.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo4.cs index 819bdb9ea..a240a113b 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo4.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo4.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from Generation 4 games. /// -public sealed class PersonalInfo4 : PersonalInfo, IPersonalAbility12, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo4(byte[] Data) : PersonalInfo, IPersonalAbility12, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x2C; - private readonly byte[] Data; - public PersonalInfo4(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -67,7 +65,7 @@ public sealed class PersonalInfo4 : PersonalInfo, IPersonalAbility12, IPersonalI /// /// Grass-Fire-Water-Etc typed learn compatibility flags for individual moves. /// - public bool[] TypeTutors { get; private set; } = Array.Empty(); + public bool[] TypeTutors { get; private set; } = []; private const int TMHM = 0x1C; private const int CountTM = 92; diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo5B2W2.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo5B2W2.cs index edf125351..fb3fff65e 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo5B2W2.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo5B2W2.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the Black 2 & White 2 games. /// -public sealed class PersonalInfo5B2W2 : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo5B2W2(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x4C; - private readonly byte[] Data; - public PersonalInfo5B2W2(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -275,10 +273,10 @@ public void SetAllLearnTutor4(Span result) } } - private static ReadOnlySpan TutorMoves1 => new ushort[] { 450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008 }; // Driftveil - private static ReadOnlySpan TutorMoves2 => new ushort[] { 277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 399, 428, 406, 304, 231 }; // Lentimas - private static ReadOnlySpan TutorMoves3 => new ushort[] { 020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 355 }; // Humilau - private static ReadOnlySpan TutorMoves4 => new ushort[] { 380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 214, 285 }; // Nacrene + private static ReadOnlySpan TutorMoves1 =>[ 450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008 ]; // Driftveil + private static ReadOnlySpan TutorMoves2 =>[ 277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 399, 428, 406, 304, 231 ]; // Lentimas + private static ReadOnlySpan TutorMoves3 =>[ 020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 355 ]; // Humilau + private static ReadOnlySpan TutorMoves4 =>[ 380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 214, 285 ]; // Nacrene public bool GetIsTutorSpecial(ushort move) { diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo5BW.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo5BW.cs index b3b916ffc..d1c0b3e9a 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo5BW.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo5BW.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the Black & White games. /// -public sealed class PersonalInfo5BW : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo5BW(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x3C; - private readonly byte[] Data; - public PersonalInfo5BW(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo6AO.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo6AO.cs index f5ef9b3bd..5d090d138 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo6AO.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo6AO.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the OR & AS games. /// -public sealed class PersonalInfo6AO : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo6AO(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x50; - private readonly byte[] Data; - public PersonalInfo6AO(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -275,10 +273,10 @@ public void SetAllLearnTutor4(Span result) } } - private static ReadOnlySpan TutorMoves1 => new ushort[] { 450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008 }; - private static ReadOnlySpan TutorMoves2 => new ushort[] { 277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 399, 428, 406, 304, 231 }; - private static ReadOnlySpan TutorMoves3 => new ushort[] { 020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 355, 264, 351, 352 }; // Last 3 added, Different from G5 Humilau - private static ReadOnlySpan TutorMoves4 => new ushort[] { 380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 214, 285 }; + private static ReadOnlySpan TutorMoves1 => [ 450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008 ]; + private static ReadOnlySpan TutorMoves2 => [ 277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 399, 428, 406, 304, 231 ]; + private static ReadOnlySpan TutorMoves3 => [ 020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 355, 264, 351, 352 ]; // Last 3 added, Different from Gen5 Humilau + private static ReadOnlySpan TutorMoves4 => [ 380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 214, 285 ]; public bool GetIsTutorSpecial(ushort move) { diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo6XY.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo6XY.cs index d77f10f8e..fc95b82d0 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo6XY.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo6XY.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the X & Y games. /// -public sealed class PersonalInfo6XY : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo6XY(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x40; - private readonly byte[] Data; - public PersonalInfo6XY(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo7.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo7.cs index 03ec37c88..ad2f60da4 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo7.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo7.cs @@ -6,12 +6,11 @@ namespace PKHeX.Core; /// /// class with values from the Sun & Moon games. /// -public sealed class PersonalInfo7 : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType +public sealed class PersonalInfo7(byte[] Data) + : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType { public const int SIZE = 0x54; - private readonly byte[] Data; - public PersonalInfo7(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -164,13 +163,13 @@ public void SetAllLearnTutorSpecial(Span result) } } - private static ReadOnlySpan Tutors_USUM => new ushort[] - { + private static ReadOnlySpan Tutors_USUM => + [ 450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008, 277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 428, 406, 304, 231, 020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 264, 351, 352, 380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 285, 477, 502, 432, 710, 707, 675, 673, - }; + ]; } diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo7GG.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo7GG.cs index 908ca06ce..fdbdd10d8 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo7GG.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo7GG.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the games. /// -public sealed class PersonalInfo7GG : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM +public sealed class PersonalInfo7GG(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM { public const int SIZE = 0x54; - private readonly byte[] Data; - public PersonalInfo7GG(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo8BDSP.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo8BDSP.cs index 0f23dc98d..2aa9084e3 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo8BDSP.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo8BDSP.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the games. /// -public sealed class PersonalInfo8BDSP : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType, IPermitRecord +public sealed class PersonalInfo8BDSP(byte[] Data) + : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTutorType, IPermitRecord { public const int SIZE = 0x44; - private readonly byte[] Data; - - public PersonalInfo8BDSP(byte[] data) => Data = data; public override byte[] Write() => Data; diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo8LA.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo8LA.cs index 8501223a7..dae5ec58e 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo8LA.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo8LA.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the games. /// -public sealed class PersonalInfo8LA : PersonalInfo, IPersonalAbility12H, IPermitRecord +public sealed class PersonalInfo8LA(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPermitRecord { public const int SIZE = 0xB0; - private readonly byte[] Data; - public PersonalInfo8LA(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -117,8 +115,8 @@ public bool GetIsLearnMoveShop(ushort move) public int RecordCountUsed => MoveShopCount; public bool HasMoveShop => MoveShopBits != 0; - private static ReadOnlySpan MoveShopMoves => new ushort[] - { + private static ReadOnlySpan MoveShopMoves => + [ (int)Move.FalseSwipe, (int)Move.FireFang, (int)Move.ThunderFang, @@ -180,7 +178,7 @@ public bool GetIsLearnMoveShop(ushort move) (int)Move.DracoMeteor, (int)Move.SteelBeam, (int)Move.VoltTackle, - }; + ]; public static ushort GetMoveShopMove(int index) { diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo8SWSH.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo8SWSH.cs index ba0cefc65..09b38ac52 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo8SWSH.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo8SWSH.cs @@ -6,12 +6,11 @@ namespace PKHeX.Core; /// /// class with values from the games. /// -public sealed class PersonalInfo8SWSH : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPersonalInfoTR, IPersonalInfoTutorType, IPermitRecord +public sealed class PersonalInfo8SWSH(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, + IPersonalInfoTR, IPersonalInfoTutorType, IPermitRecord { public const int SIZE = 0xB0; - private readonly byte[] Data; - public PersonalInfo8SWSH(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -207,8 +206,8 @@ public void SetAllLearnTR(Span result) } } - private static ReadOnlySpan TM_SWSH => new ushort[] - { + private static ReadOnlySpan TM_SWSH => + [ 005, 025, 006, 007, 008, 009, 019, 042, 063, 416, 345, 076, 669, 083, 086, 091, 103, 113, 115, 219, 120, 156, 157, 168, 173, 182, 184, 196, 202, 204, @@ -219,10 +218,10 @@ public void SetAllLearnTR(Span result) 433, 472, 478, 440, 474, 490, 496, 506, 512, 514, 521, 523, 527, 534, 541, 555, 566, 577, 580, 581, 604, 678, 595, 598, 206, 403, 684, 693, 707, 784, - }; + ]; - private static ReadOnlySpan TR_SWSH => new ushort[] - { + private static ReadOnlySpan TR_SWSH => + [ 014, 034, 053, 056, 057, 058, 059, 067, 085, 087, 089, 094, 097, 116, 118, 126, 127, 133, 141, 161, 164, 179, 188, 191, 200, 473, 203, 214, 224, 226, @@ -233,10 +232,10 @@ public void SetAllLearnTR(Span result) 430, 437, 438, 441, 442, 444, 446, 447, 482, 484, 486, 492, 500, 502, 503, 526, 528, 529, 535, 542, 583, 599, 605, 663, 667, 675, 676, 706, 710, 776, - }; + ]; - private static ReadOnlySpan TypeTutor8 => new ushort[] - { + private static ReadOnlySpan TypeTutor8 => + [ (int)Move.GrassPledge, (int)Move.FirePledge, (int)Move.WaterPledge, @@ -245,14 +244,14 @@ public void SetAllLearnTR(Span result) (int)Move.HydroCannon, (int)Move.DracoMeteor, (int)Move.SteelBeam, - }; + ]; - private static ReadOnlySpan Tutors_SWSH => new ushort[] - { + private static ReadOnlySpan Tutors_SWSH => + [ 805, 807, 812, 804, 803, 813, 811, 810, 815, 814, 797, 806, 800, 809, 799, 808, 798, 802, - }; + ]; public bool IsRecordPermitted(int index) => GetIsLearnTR(index); diff --git a/PKHeX.Core/PersonalInfo/Info/PersonalInfo9SV.cs b/PKHeX.Core/PersonalInfo/Info/PersonalInfo9SV.cs index 9d8cad68d..14d0c27db 100644 --- a/PKHeX.Core/PersonalInfo/Info/PersonalInfo9SV.cs +++ b/PKHeX.Core/PersonalInfo/Info/PersonalInfo9SV.cs @@ -6,12 +6,10 @@ namespace PKHeX.Core; /// /// class with values from the games. /// -public sealed class PersonalInfo9SV : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPermitRecord +public sealed class PersonalInfo9SV(byte[] Data) : PersonalInfo, IPersonalAbility12H, IPersonalInfoTM, IPermitRecord { public const int SIZE = 0x4C; - private readonly byte[] Data; - public PersonalInfo9SV(byte[] data) => Data = data; public override byte[] Write() => Data; public override int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } @@ -115,8 +113,8 @@ public void SetAllLearnTM(Span result) public int RecordCountTotal => 202; public int RecordCountUsed => CountTM; - private static ReadOnlySpan TM_SV => new ushort[] - { + private static ReadOnlySpan TM_SV => + [ 005, 036, 204, 313, 097, 189, 184, 182, 424, 422, 423, 352, 067, 491, 512, 522, 060, 109, 168, 574, 885, 884, 886, 451, 083, 263, 342, 332, 523, 506, @@ -138,7 +136,7 @@ public void SetAllLearnTM(Span result) 360, 282, 450, 162, 410, 679, 667, 333, 503, 535, 669, 253, 264, 311, 803, 807, 812, 814, 809, 808, 799, 802, - }; + ]; public byte DexKitakami { get => Data[0x4A]; set => Data[0x4A] = value; } public byte DexBlueberry { get => Data[0x4B]; set => Data[0x4B] = value; } diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_de.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_de.txt index a265d1d9a..00fd65f93 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_de.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_de.txt @@ -1,4 +1,5 @@ -Es erinnert sich daran, + +Es erinnert sich daran, Es erinnert sich daran, Es erinnert sich daran, Es erinnert sich daran, diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_en.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_en.txt index acea9bc33..51f53ce8f 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_en.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_en.txt @@ -1,4 +1,5 @@ -The Pokémon remembers + +The Pokémon remembers The Pokémon remembers The Pokémon remembers The Pokémon remembers diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_es.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_es.txt index fa8314a5c..c8d331791 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_es.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_es.txt @@ -1,4 +1,5 @@ -El Pokémon recuerda muy vagamente + +El Pokémon recuerda muy vagamente El Pokémon recuerda vagamente El Pokémon recuerda más o menos El Pokémon recuerda bastante bien diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_fr.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_fr.txt index d30f14265..fb65e4224 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_fr.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_fr.txt @@ -1,4 +1,5 @@ -se souvient vaguement que + +se souvient vaguement que se souvient vaguement que se souvient vaguement que se souvient vaguement que diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_it.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_it.txt index fcfa0ac35..7e9f4d8f1 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_it.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_it.txt @@ -1,4 +1,5 @@ -Il Pokémon ricorda ancora + +Il Pokémon ricorda ancora Il Pokémon ricorda ancora Il Pokémon ricorda ancora Il Pokémon ricorda ancora diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_ja.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_ja.txt index 4d72a41a7..42129f120 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_ja.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_ja.txt @@ -1,4 +1,5 @@ -おもいで らしいわ + +おもいで らしいわ おもいで らしいわ おもいで らしいわ おもいで らしいわ diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_ko.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_ko.txt index 8265a3cc5..3a496d8aa 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_ko.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_ko.txt @@ -1,4 +1,5 @@ -추억인 것 같아 + +추억인 것 같아 추억인 것 같아 추억인 것 같아 추억인 것 같아 diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_zh.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_zh.txt index 3a59b4a0c..c7f4ed6b3 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_zh.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_zh.txt @@ -1,4 +1,5 @@ -宝可梦记得 + +宝可梦记得 宝可梦记得 宝可梦记得 宝可梦记得 diff --git a/PKHeX.Core/Resources/text/memories/text_Intensity_zh2.txt b/PKHeX.Core/Resources/text/memories/text_Intensity_zh2.txt index ad7abbe1f..721d64a80 100644 --- a/PKHeX.Core/Resources/text/memories/text_Intensity_zh2.txt +++ b/PKHeX.Core/Resources/text/memories/text_Intensity_zh2.txt @@ -1,4 +1,5 @@ -寶可夢記得 + +寶可夢記得 寶可夢記得 寶可夢記得 寶可夢記得 diff --git a/PKHeX.Core/Ribbons/IRibbonSetMark8.cs b/PKHeX.Core/Ribbons/IRibbonSetMark8.cs index 42fb57368..e023c3b76 100644 --- a/PKHeX.Core/Ribbons/IRibbonSetMark8.cs +++ b/PKHeX.Core/Ribbons/IRibbonSetMark8.cs @@ -163,6 +163,6 @@ public static void CopyRibbonSetMark8(this IRibbonSetMark8 set, IRibbonSetMark8 RibbonIndex.MarkFlustered => set.RibbonMarkFlustered, RibbonIndex.MarkPumpedUp => set.RibbonMarkPumpedUp, RibbonIndex.MarkZeroEnergy => set.RibbonMarkZeroEnergy, - _ => throw new ArgumentOutOfRangeException(nameof(index), index, null) + _ => throw new ArgumentOutOfRangeException(nameof(index), index, null), }; } diff --git a/PKHeX.Core/Saves/Access/ISaveBlock7SM.cs b/PKHeX.Core/Saves/Access/ISaveBlock7SM.cs index 5fc476f93..a2cc00711 100644 --- a/PKHeX.Core/Saves/Access/ISaveBlock7SM.cs +++ b/PKHeX.Core/Saves/Access/ISaveBlock7SM.cs @@ -1,9 +1,7 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Interface for Accessing named blocks within a Generation 7 save file. /// /// Blocks specific for in addition to the blocks. -public interface ISaveBlock7SM : ISaveBlock7Main -{ -} +public interface ISaveBlock7SM : ISaveBlock7Main; diff --git a/PKHeX.Core/Saves/Access/ISaveBlock8SWSH.cs b/PKHeX.Core/Saves/Access/ISaveBlock8SWSH.cs index 57b8382ca..c5c2f5ecb 100644 --- a/PKHeX.Core/Saves/Access/ISaveBlock8SWSH.cs +++ b/PKHeX.Core/Saves/Access/ISaveBlock8SWSH.cs @@ -1,9 +1,7 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Interface for Accessing named blocks within a Generation 8 save file. /// /// Blocks specific for in addition to the blocks. -public interface ISaveBlock8SWSH : ISaveBlock8Main -{ -} +public interface ISaveBlock8SWSH : ISaveBlock8Main; diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor5B2W2.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor5B2W2.cs index b9a1c6587..91e6086af 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor5B2W2.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor5B2W2.cs @@ -5,10 +5,11 @@ namespace PKHeX.Core; /// /// Information for Accessing individual blocks within a . /// -public sealed class SaveBlockAccessor5B2W2 : ISaveBlockAccessor, ISaveBlock5BW, ISaveBlock5B2W2 +public sealed class SaveBlockAccessor5B2W2(SAV5B2W2 sav) + : ISaveBlockAccessor, ISaveBlock5BW, ISaveBlock5B2W2 { private static readonly BlockInfoNDS[] BlocksB2W2 = - { + [ new(0x00000, 0x03e0, 0x003E2, 0x25F00), // 00 Box Names new(0x00400, 0x0ff0, 0x013F2, 0x25F02), // 01 Box 1 new(0x01400, 0x0ff0, 0x023F2, 0x25F04), // 02 Box 2 @@ -35,7 +36,7 @@ public sealed class SaveBlockAccessor5B2W2 : ISaveBlockAccessor, I new(0x16400, 0x0ff0, 0x173F2, 0x25F2E), // 23 Box 23 new(0x17400, 0x0ff0, 0x183F2, 0x25F30), // 24 Box 24 new(0x18400, 0x09ec, 0x18DEE, 0x25F32), // 25 Inventory - new(0x18E00, 0x0534, 0x19336, 0x25F34), // 26 Party Pokemon + new(0x18E00, 0x0534, 0x19336, 0x25F34), // 26 Party Pokémon new(0x19400, 0x00b0, 0x194B2, 0x25F36), // 27 Trainer Data new(0x19500, 0x00a8, 0x195AA, 0x25F38), // 28 Trainer Position new(0x19600, 0x1338, 0x1A93A, 0x25F3A), // 29 Unity Tower and survey stuff @@ -67,7 +68,7 @@ public sealed class SaveBlockAccessor5B2W2 : ISaveBlockAccessor, I new(0x21900, 0x0034, 0x21936, 0x25F6E), // 55 Encount (Swarm and other overworld info - 2C - swarm, 2D - repel steps, 2E repel type) new(0x21A00, 0x003c, 0x21A3E, 0x25F70), // 56 Battle Subway Play Info new(0x21B00, 0x01ac, 0x21CAE, 0x25F72), // 57 Battle Subway Score Info - new(0x21D00, 0x0b90, 0x22892, 0x25F74), // 58 Battle Subway WiFi Info + new(0x21D00, 0x0b90, 0x22892, 0x25F74), // 58 Battle Subway Wi-Fi Info new(0x22900, 0x00ac, 0x229AE, 0x25F76), // 59 Online Records new(0x22A00, 0x0850, 0x23252, 0x25F78), // 60 Entralink Forest pokémon data new(0x23300, 0x0284, 0x23586, 0x25F7A), // 61 Answered Questions @@ -83,41 +84,22 @@ public sealed class SaveBlockAccessor5B2W2 : ISaveBlockAccessor, I new(0x25A00, 0x03e4, 0x25DE6, 0x25F8E), // 71 Pokestar Studios new(0x25E00, 0x00f0, 0x25EF2, 0x25F90), // 72 ??? new(0x25F00, 0x0094, 0x25FA2, 0x25FA2), // 73 Checksum Block - }; - - public SaveBlockAccessor5B2W2(SAV5B2W2 sav) - { - BoxLayout = new BoxLayout5(sav, 0x00000); - Items = new MyItem5B2W2(sav, 0x18400); - PlayerData = new PlayerData5(sav, 0x19400); - UnityTower = new UnityTower5(sav, 0x19600); - Mystery = new MysteryBlock5(sav, 0x1C800); - Musical = new Musical5(sav, 0x1F700); - Daycare = new Daycare5(sav, 0x20D00); - Misc = new Misc5B2W2(sav, 0x21100); - Entralink = new Entralink5B2W2(sav, 0x21200); - Zukan = new Zukan5(sav, 0x21400, 0x328); // form flags size is + 8 from bw with new forms (therians) - Encount = new Encount5B2W2(sav, 0x21900); - BattleSubway = new BattleSubway5(sav, 0x21B00); - PWT = new PWTBlock5(sav, 0x23700); - Medals = new MedalList5(sav, 0x25300); - Festa = new FestaBlock5(sav, 0x25900); - } + ]; public IReadOnlyList BlockInfo => BlocksB2W2; - public MyItem Items { get; } - public Zukan5 Zukan { get; } - public Misc5 Misc { get; } - public MysteryBlock5 Mystery { get; } - public Daycare5 Daycare { get; } - public BoxLayout5 BoxLayout { get; } - public PlayerData5 PlayerData { get; } - public BattleSubway5 BattleSubway { get; } - public PWTBlock5 PWT { get; } - public Entralink5 Entralink { get; } - public FestaBlock5 Festa { get; } - public Musical5 Musical { get; } - public Encount5 Encount { get; } - public UnityTower5 UnityTower { get; } - public MedalList5 Medals { get; } + public BoxLayout5 BoxLayout { get; } = new(sav, 0x00000); + public PlayerData5 PlayerData { get; } = new(sav, 0x19400); + public MyItem Items { get; } = new MyItem5B2W2(sav, 0x18400); + public UnityTower5 UnityTower { get; } = new(sav, 0x19600); + public MysteryBlock5 Mystery { get; } = new(sav, 0x1C800); + public Musical5 Musical { get; } = new(sav, 0x1F700); + public Daycare5 Daycare { get; } = new(sav, 0x20D00); + public Misc5 Misc { get; } = new Misc5B2W2(sav, 0x21100); + public Zukan5 Zukan { get; } = new(sav, 0x21400, 0x328); // form flags size is + 8 from B/W with new forms (Therians) + public Entralink5 Entralink { get; } = new Entralink5B2W2(sav, 0x21200); + public Encount5 Encount { get; } = new Encount5B2W2(sav, 0x21900); + public BattleSubway5 BattleSubway { get; } = new(sav, 0x21B00); + public PWTBlock5 PWT { get; } = new(sav, 0x23700); + public MedalList5 Medals { get; } = new(sav, 0x25300); + public FestaBlock5 Festa { get; } = new(sav, 0x25900); } diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor5BW.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor5BW.cs index 972af61be..5f8be3768 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor5BW.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor5BW.cs @@ -5,10 +5,10 @@ namespace PKHeX.Core; /// /// Information for Accessing individual blocks within a . /// -public sealed class SaveBlockAccessor5BW : ISaveBlockAccessor, ISaveBlock5BW +public sealed class SaveBlockAccessor5BW(SAV5BW sav) : ISaveBlockAccessor, ISaveBlock5BW { private static readonly BlockInfoNDS[] BlocksBW = - { + [ new(0x00000, 0x03E0, 0x003E2, 0x23F00), // 00 Box Names new(0x00400, 0x0FF0, 0x013F2, 0x23F02), // 01 Box 1 new(0x01400, 0x0FF0, 0x023F2, 0x23F04), // 02 Box 2 @@ -35,7 +35,7 @@ public sealed class SaveBlockAccessor5BW : ISaveBlockAccessor, ISa new(0x16400, 0x0FF0, 0x173F2, 0x23F2E), // 23 Box 23 new(0x17400, 0x0FF0, 0x183F2, 0x23F30), // 24 Box 24 new(0x18400, 0x09C0, 0x18DC2, 0x23F32), // 25 Inventory - new(0x18E00, 0x0534, 0x19336, 0x23F34), // 26 Party Pokemon + new(0x18E00, 0x0534, 0x19336, 0x23F34), // 26 Party Pokémon new(0x19400, 0x0068, 0x1946A, 0x23F36), // 27 Trainer Data new(0x19500, 0x009C, 0x1959E, 0x23F38), // 28 Trainer Position new(0x19600, 0x1338, 0x1A93A, 0x23F3A), // 29 Unity Tower and survey stuff @@ -68,7 +68,7 @@ public sealed class SaveBlockAccessor5BW : ISaveBlockAccessor, ISa new(0x21B00, 0x0034, 0x21B36, 0x23F70), // 56 Encount Swarm and other overworld info - 2C - swarm, 2D - repel steps, 2E repel type new(0x21C00, 0x003C, 0x21C3E, 0x23F72), // 57 Battle Subway Play Info new(0x21D00, 0x01AC, 0x21EAE, 0x23F74), // 58 Battle Subway Score Info - new(0x21F00, 0x0B90, 0x22A92, 0x23F76), // 59 Battle Subway WiFi Info + new(0x21F00, 0x0B90, 0x22A92, 0x23F76), // 59 Battle Subway Wi-Fi Info new(0x22B00, 0x009C, 0x22B9E, 0x23F78), // 60 Online Records new(0x22C00, 0x0850, 0x23452, 0x23F7A), // 61 Entralink Forest pokémon data new(0x23500, 0x0028, 0x2352A, 0x23F7C), // 62 ??? @@ -79,35 +79,19 @@ public sealed class SaveBlockAccessor5BW : ISaveBlockAccessor, ISa new(0x23D00, 0x0040, 0x23D42, 0x23F86), // 67 ??? new(0x23E00, 0x00FC, 0x23EFE, 0x23F88), // 68 ??? new(0x23F00, 0x008C, 0x23F9A, 0x23F9A), // 69 Checksums */ - }; - - public SaveBlockAccessor5BW(SAV5BW sav) - { - BoxLayout = new BoxLayout5(sav, 0x00000); - Items = new MyItem5BW(sav, 0x18400); - PlayerData = new PlayerData5(sav, 0x19400); - UnityTower = new UnityTower5(sav, 0x19600); - Mystery = new MysteryBlock5(sav, 0x1C800); - Musical = new Musical5(sav, 0x1F700); - Daycare = new Daycare5(sav, 0x20E00); - Misc = new Misc5BW(sav, 0x21200); - Entralink = new Entralink5BW(sav, 0x21300); - Zukan = new Zukan5(sav, 0x21600, 0x320); - Encount = new Encount5BW(sav, 0x21B00); - BattleSubway = new BattleSubway5(sav, 0x21D00); - } + ]; public IReadOnlyList BlockInfo => BlocksBW; - public MyItem Items { get; } - public Zukan5 Zukan { get; } - public Misc5 Misc { get; } - public MysteryBlock5 Mystery { get; } - public Daycare5 Daycare { get; } - public BoxLayout5 BoxLayout { get; } - public PlayerData5 PlayerData { get; } - public BattleSubway5 BattleSubway { get; } - public Entralink5 Entralink { get; } - public Musical5 Musical { get; } - public Encount5 Encount { get; } - public UnityTower5 UnityTower { get; } + public BoxLayout5 BoxLayout { get; } = new(sav, 0x00000); + public MyItem Items { get; } = new MyItem5BW(sav, 0x18400); + public PlayerData5 PlayerData { get; } = new(sav, 0x19400); + public UnityTower5 UnityTower { get; } = new(sav, 0x19600); + public MysteryBlock5 Mystery { get; } = new(sav, 0x1C800); + public Musical5 Musical { get; } = new(sav, 0x1F700); + public Daycare5 Daycare { get; } = new(sav, 0x20E00); + public Misc5 Misc { get; } = new Misc5BW(sav, 0x21200); + public Entralink5 Entralink { get; } = new Entralink5BW(sav, 0x21300); + public Zukan5 Zukan { get; } = new(sav, 0x21600, 0x320); + public Encount5 Encount { get; } = new Encount5BW(sav, 0x21B00); + public BattleSubway5 BattleSubway { get; } = new(sav, 0x21D00); } diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor6AO.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor6AO.cs index b3295ebb7..12c6191b9 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor6AO.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor6AO.cs @@ -11,7 +11,7 @@ public sealed class SaveBlockAccessor6AO : ISaveBlockAccessor, ISave private const int boAO = BlockMetadataOffset; private static readonly BlockInfo6[] BlocksAO = - { + [ new(boAO, 00, 0x00000, 0x002C8), // 00 Puff new(boAO, 01, 0x00400, 0x00B90), // 01 MyItem new(boAO, 02, 0x01000, 0x0002C), // 02 ItemInfo (Select Bound Items) @@ -70,7 +70,7 @@ public sealed class SaveBlockAccessor6AO : ISaveBlockAccessor, ISave new(boAO, 55, 0x2B600, 0x078B0), // 55 EonTicket new(boAO, 56, 0x33000, 0x34AD0), // 56 Box new(boAO, 57, 0x67C00, 0x0E058), // 57 JPEG - }; + ]; public IReadOnlyList BlockInfo => BlocksAO; public MyItem Items { get; } diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor6AODemo.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor6AODemo.cs index 8facd22f1..b17fa2b01 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor6AODemo.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor6AODemo.cs @@ -5,13 +5,13 @@ namespace PKHeX.Core; /// /// Information for Accessing individual blocks within a . /// -public sealed class SaveBlockAccessor6AODemo : ISaveBlockAccessor, ISaveBlock6Core +public sealed class SaveBlockAccessor6AODemo(SAV6AODemo sav) : ISaveBlockAccessor, ISaveBlock6Core { public const int BlockMetadataOffset = SaveUtil.SIZE_G6ORASDEMO - 0x200; private const int boAOdemo = BlockMetadataOffset; private static readonly BlockInfo6[] BlocksAODemo = - { + [ new(boAOdemo, 00, 0x00000, 0x00B90), // MyItem new(boAOdemo, 01, 0x00C00, 0x0002C), // ItemInfo6 new(boAOdemo, 02, 0x00E00, 0x00038), // GameTime @@ -28,27 +28,15 @@ public sealed class SaveBlockAccessor6AODemo : ISaveBlockAccessor, I new(boAOdemo, 13, 0x04E00, 0x00048), // Repel Info, (Swarm?) and other overworld info (roamer) new(boAOdemo, 14, 0x05000, 0x00400), // PokeDiarySave new(boAOdemo, 15, 0x05400, 0x0025C), // Record - }; + ]; public IReadOnlyList BlockInfo => BlocksAODemo; - public MyItem Items { get; } - public ItemInfo6 ItemInfo { get; } - public GameTime6 GameTime { get; } - public Situation6 Situation { get; } - public PlayTime6 Played { get; } - public MyStatus6 Status { get; } - public RecordBlock6 Records { get; } - public Misc6AO Misc { get; } - - public SaveBlockAccessor6AODemo(SAV6AODemo sav) - { - Items = new MyItem6AO(sav, 0x00000); - ItemInfo = new ItemInfo6(sav, 0x00C00); - GameTime = new GameTime6(sav, 0x00E00); - Situation = new Situation6(sav, 0x01000); - Played = new PlayTime6(sav, 0x01400); - Status = new MyStatus6(sav, 0x03C00); - Records = new RecordBlock6AO(sav, 0x05400); - Misc = new Misc6AO(sav, 0x03A00); - } + public MyItem Items { get; } = new MyItem6AO(sav, 0x00000); + public ItemInfo6 ItemInfo { get; } = new(sav, 0x00C00); + public GameTime6 GameTime { get; } = new(sav, 0x00E00); + public Situation6 Situation { get; } = new(sav, 0x01000); + public PlayTime6 Played { get; } = new(sav, 0x01400); + public MyStatus6 Status { get; } = new(sav, 0x03C00); + public RecordBlock6 Records { get; } = new RecordBlock6AO(sav, 0x05400); + public Misc6AO Misc { get; } = new(sav, 0x03A00); } diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor6XY.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor6XY.cs index 8df090532..3e7e73ef6 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor6XY.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor6XY.cs @@ -5,13 +5,13 @@ namespace PKHeX.Core; /// /// Information for Accessing individual blocks within a . /// -public sealed class SaveBlockAccessor6XY : ISaveBlockAccessor, ISaveBlock6XY +public sealed class SaveBlockAccessor6XY(SAV6XY sav) : ISaveBlockAccessor, ISaveBlock6XY { public const int BlockMetadataOffset = SaveUtil.SIZE_G6XY - 0x200; private const int boXY = BlockMetadataOffset; private static readonly BlockInfo6[] BlocksXY = - { + [ new(boXY, 00, 0x00000, 0x002C8), // 00 Puff new(boXY, 01, 0x00400, 0x00B88), // 01 MyItem new(boXY, 02, 0x01000, 0x0002C), // 02 ItemInfo (Select Bound Items) @@ -67,55 +67,29 @@ public sealed class SaveBlockAccessor6XY : ISaveBlockAccessor, ISave new(boXY, 52, 0x21E00, 0x00628), // 52 ValidationSave (updateable Public Key for legal check api calls) new(boXY, 53, 0x22600, 0x34AD0), // 53 Box new(boXY, 54, 0x57200, 0x0E058), // 54 JPEG - }; + ]; public IReadOnlyList BlockInfo => BlocksXY; - public MyItem Items { get; } - public ItemInfo6 ItemInfo { get; } - public GameTime6 GameTime { get; } - public Situation6 Situation { get; } - public PlayTime6 Played { get; } - public MyStatus6 Status { get; } - public RecordBlock6 Records { get; } - public SubEventLog6 SUBE { get; } - public ConfigSave6 Config { get; } - public Encount6 Encount { get; } - public SaveBlockAccessor6XY(SAV6XY sav) - { - Puff = new Puff6(sav, 0x00000); - Items = new MyItem6XY(sav, 0x00400); - ItemInfo = new ItemInfo6(sav, 0x01000); - GameTime = new GameTime6(sav, 0x01200); - Situation = new Situation6(sav, 0x01400); - Played = new PlayTime6(sav, 0x01800); - Fashion = new Fashion6XY(sav, 0x1A00); - Misc = new Misc6XY(sav, 0x4200); - BoxLayout = new BoxLayout6(sav, 0x4400); - BattleBox = new BattleBox6(sav, 0x04A00); - Status = new MyStatus6XY(sav, 0x14000); - Zukan = new Zukan6XY(sav, 0x15000, 0x3C8); - Config = new ConfigSave6(sav, 0x16200); - OPower = new OPower6(sav, 0x16A00); - Encount = new Encount6(sav, 0x17E00); - MysteryGift = new MysteryBlock6(sav, 0x1BC00); - SUBE = new SubEventLog6XY(sav, 0x1D800); - Records = new RecordBlock6XY(sav, 0x1E400); - SuperTrain = new SuperTrainBlock(sav, 0x1F200); - Link = new LinkBlock6(sav, 0x1FE00); - Maison = new MaisonBlock(sav, 0x1B000); - } - - public Puff6 Puff { get; } - public BoxLayout6 BoxLayout { get; } - public BattleBox6 BattleBox { get; } - public OPower6 OPower { get; } - public MysteryBlock6 MysteryGift { get; } - public LinkBlock6 Link { get; } - public SuperTrainBlock SuperTrain { get; } - public MaisonBlock Maison { get; } - - public Misc6XY Misc { get; } - public Zukan6XY Zukan { get; } - public Fashion6XY Fashion { get; } + public Puff6 Puff { get; } = new(sav, 0x00000); + public MyItem Items { get; } = new MyItem6XY(sav, 0x00400); + public ItemInfo6 ItemInfo { get; } = new(sav, 0x01000); + public GameTime6 GameTime { get; } = new(sav, 0x01200); + public Situation6 Situation { get; } = new(sav, 0x01400); + public PlayTime6 Played { get; } = new(sav, 0x01800); + public Fashion6XY Fashion { get; } = new(sav, 0x1A00); + public Misc6XY Misc { get; } = new(sav, 0x4200); + public BoxLayout6 BoxLayout { get; } = new(sav, 0x4400); + public BattleBox6 BattleBox { get; } = new(sav, 0x04A00); + public MyStatus6 Status { get; } = new MyStatus6XY(sav, 0x14000); + public Zukan6XY Zukan { get; } = new(sav, 0x15000, 0x3C8); + public ConfigSave6 Config { get; } = new(sav, 0x16200); + public OPower6 OPower { get; } = new(sav, 0x16A00); + public Encount6 Encount { get; } = new(sav, 0x17E00); + public MysteryBlock6 MysteryGift { get; } = new(sav, 0x1BC00); + public SubEventLog6 SUBE { get; } = new SubEventLog6XY(sav, 0x1D800); + public RecordBlock6 Records { get; } = new RecordBlock6XY(sav, 0x1E400); + public SuperTrainBlock SuperTrain { get; } = new(sav, 0x1F200); + public LinkBlock6 Link { get; } = new(sav, 0x1FE00); + public MaisonBlock Maison { get; } = new(sav, 0x1B000); } diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor7SM.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor7SM.cs index 3edf76a42..0ac0b0b9a 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor7SM.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor7SM.cs @@ -11,7 +11,7 @@ public sealed class SaveBlockAccessor7SM : ISaveBlockAccessor, ISave private const int boSM = BlockMetadataOffset; private static readonly BlockInfo7[] BlockInfoSM = - { + [ new(boSM, 00, 0x00000, 0x00DE0), // 00 MyItem new(boSM, 01, 0x00E00, 0x0007C), // 01 Situation new(boSM, 02, 0x01000, 0x00014), // 02 RandomGroup @@ -49,7 +49,7 @@ public sealed class SaveBlockAccessor7SM : ISaveBlockAccessor, ISave new(boSM, 34, 0x6B600, 0x00120), // 34 WeatherSave new(boSM, 35, 0x6B800, 0x001C8), // 35 QRReaderSaveData new(boSM, 36, 0x6BA00, 0x00200), // 36 TurtleSalmonSave - }; + ]; public SaveBlockAccessor7SM(SAV7SM sav) { diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor7USUM.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor7USUM.cs index 9ad3e92fb..17d5969fe 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor7USUM.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor7USUM.cs @@ -11,7 +11,7 @@ public sealed class SaveBlockAccessor7USUM : ISaveBlockAccessor, ISa private const int boUU = BlockMetadataOffset; private static readonly BlockInfo7[] BlockInfoUSUM = - { + [ new(boUU, 00, 0x00000, 0x00E28), // 00 MyItem new(boUU, 01, 0x01000, 0x0007C), // 01 Situation new(boUU, 02, 0x01200, 0x00014), // 02 RandomGroup @@ -51,7 +51,7 @@ public sealed class SaveBlockAccessor7USUM : ISaveBlockAccessor, ISa new(boUU, 36, 0x6C000, 0x00200), // 36 TurtleSalmonSave new(boUU, 37, 0x6C200, 0x0039C), // 37 BattleFesSave new(boUU, 38, 0x6C600, 0x00400), // 38 FinderStudioSave - }; + ]; public SaveBlockAccessor7USUM(SAV7USUM sav) { diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor7b.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor7b.cs index ec5d2b446..f0af8a325 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor7b.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor7b.cs @@ -10,7 +10,7 @@ public sealed class SaveBlockAccessor7b : ISaveBlockAccessor, ISave private const int boGG = 0xB8800 - 0x200; // nowhere near 1MB (savedata.bin size) private static readonly BlockInfo7b[] BlockInfoGG = - { + [ new(boGG, 00, 0x00000, 0x00D90), new(boGG, 01, 0x00E00, 0x00200), new(boGG, 02, 0x01000, 0x00168), @@ -32,7 +32,7 @@ public sealed class SaveBlockAccessor7b : ISaveBlockAccessor, ISave new(boGG, 18, 0x4E200, 0x69780), new(boGG, 19, 0xB7A00, 0x000B0), new(boGG, 20, 0xB7C00, 0x00940), - }; + ]; public IReadOnlyList BlockInfo => BlockInfoGG; diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor8SWSH.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor8SWSH.cs index b74e3730f..8189b9bed 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor8SWSH.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor8SWSH.cs @@ -234,9 +234,9 @@ public SaveBlockAccessor8SWSH(SAV8SWSH sav) public const uint KDiggingDuoStreakStamina = 0x066F38F5; // U32 public const uint KBirthMonth = 0x0D987D50; // U32 public const uint KBirthDay = 0x355C8314; // U32 - public const uint KCurrentDexEntry = 0x62743428; // U16 Species ID of last Pokedex entry viewed in Galar Dex - public const uint KCurrentDexEntryR1 = 0x789FF72D; // U16 Species ID of last Pokedex entry viewed in Armor Dex - public const uint KCurrentDexEntryR2 = 0x759FF274; // U16 Species ID of last Pokedex entry viewed in Crown Dex + public const uint KCurrentDexEntry = 0x62743428; // U16 Species ID of last Pokédex entry viewed in Galar Dex + public const uint KCurrentDexEntryR1 = 0x789FF72D; // U16 Species ID of last Pokédex entry viewed in Armor Dex + public const uint KCurrentDexEntryR2 = 0x759FF274; // U16 Species ID of last Pokédex entry viewed in Crown Dex public const uint KCurrentDex = 0x9CF58395; // U32 Galar=0, Armor=1, Crown=2 public const uint KVolumeBackgroundMusic = 0xF8154AC9; // U32 0-10 diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs index 929d42e35..90381470f 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs @@ -77,7 +77,7 @@ public SaveBlockAccessor9SV(SAV9SV sav) private const uint KItem = 0x21C9BD44; // Items private const uint KPlayTime = 0xEDAFF794; // Time Played private const uint KSessionLength = 0x1522C79C; // Milliseconds(?) elapsed - private const uint KOverworld = 0x173304D8; // [0x158+7C][20] overworld pokemon + private const uint KOverworld = 0x173304D8; // [0x158+7C][20] overworld Pokémon private const uint KGimmighoul = 0x53DC955C; // ulong seed x2 (today and tomorrow); Gimmighoul struct (0x20): bool is_active, u64 hash, u64 seed, bool ??, bool first_time private const uint KTeraRaidPaldea = 0xCAAC8800; private const uint KTeraRaidKitakami = 0x100B93DA; diff --git a/PKHeX.Core/Saves/Blocks/BlockInfo.cs b/PKHeX.Core/Saves/Blocks/BlockInfo.cs index 41c2e2dd8..cf400b544 100644 --- a/PKHeX.Core/Saves/Blocks/BlockInfo.cs +++ b/PKHeX.Core/Saves/Blocks/BlockInfo.cs @@ -61,7 +61,7 @@ public static string GetChecksumInfo(IReadOnlyList blocks, Span private static int GetInvalidBlockCount(IReadOnlyList blocks, Span data, out List list) { int invalid = 0; - list = new List(); + list = []; for (int i = 0; i < blocks.Count; i++) { var block = blocks[i]; diff --git a/PKHeX.Core/Saves/Blocks/BlockInfo3DS.cs b/PKHeX.Core/Saves/Blocks/BlockInfo3DS.cs index 9dc0c03df..0d5028949 100644 --- a/PKHeX.Core/Saves/Blocks/BlockInfo3DS.cs +++ b/PKHeX.Core/Saves/Blocks/BlockInfo3DS.cs @@ -48,20 +48,17 @@ protected override void SetChecksum(Span data) } } -public sealed class BlockInfo6 : BlockInfo3DS +public sealed class BlockInfo6(int bo, uint id, int ofs, int len) : BlockInfo3DS(bo, id, ofs, len) { - public BlockInfo6(int bo, uint id, int ofs, int len) : base(bo, id, ofs, len) { } protected override ushort GetChecksum(ReadOnlySpan data) => Checksums.CRC16_CCITT(data.Slice(Offset, Length)); } -public sealed class BlockInfo7 : BlockInfo3DS +public sealed class BlockInfo7(int bo, uint id, int ofs, int len) : BlockInfo3DS(bo, id, ofs, len) { - public BlockInfo7(int bo, uint id, int ofs, int len) : base(bo, id, ofs, len) { } protected override ushort GetChecksum(ReadOnlySpan data) => Checksums.CRC16Invert(data.Slice(Offset, Length)); } -public sealed class BlockInfo7b : BlockInfo3DS +public sealed class BlockInfo7b(int bo, uint id, int ofs, int len) : BlockInfo3DS(bo, id, ofs, len) { - public BlockInfo7b(int bo, uint id, int ofs, int len) : base(bo, id, ofs, len) { } protected override ushort GetChecksum(ReadOnlySpan data) => Checksums.CRC16NoInvert(data.Slice(Offset, Length)); } diff --git a/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeCrypto.cs b/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeCrypto.cs index 60d728b8b..40475450f 100644 --- a/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeCrypto.cs +++ b/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeCrypto.cs @@ -47,7 +47,7 @@ public static bool VerifyMemePOKE(ReadOnlySpan input, out byte[] output) return true; } - output = Array.Empty(); + output = []; return false; } @@ -58,7 +58,7 @@ public static bool VerifyMemeData(ReadOnlySpan input, out byte[] output) if (VerifyMemeData(input, out output, keyIndex)) return true; } - output = Array.Empty(); + output = []; return false; } @@ -66,7 +66,7 @@ public static bool VerifyMemeData(ReadOnlySpan input, out byte[] output, M { if (input.Length < MemeKey.SignatureLength) { - output = Array.Empty(); + output = []; return false; } var key = new MemeKey(keyIndex); @@ -84,7 +84,7 @@ public static bool VerifyMemeData(ReadOnlySpan input, out byte[] output, M if (DecryptCompare(output, sigBuffer, key)) return true; - output = Array.Empty(); + output = []; return false; } @@ -108,7 +108,7 @@ public static bool VerifyMemeData(ReadOnlySpan input, out byte[] output, i output = newOutput; return true; } - output = Array.Empty(); + output = []; return false; } diff --git a/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeKey.cs b/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeKey.cs index 8289d85c9..18952b949 100644 --- a/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeKey.cs +++ b/PKHeX.Core/Saves/Encryption/MemeCrypto/MemeKey.cs @@ -235,23 +235,23 @@ public static bool IsValidPokeKeyIndex(int index) #endregion #region Official Keydata - private static ReadOnlySpan DER_LW=> new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB7, 0x56, 0xE1, 0xDC, 0xD8, 0xCE, 0xCE, 0x78, 0xE1, 0x48, 0x10, 0x7B, 0x1B, 0xAC, 0x11, 0x5F, 0xDB, 0x17, 0xDE, 0x84, 0x34, 0x53, 0xCA, 0xB7, 0xD4, 0xE6, 0xDF, 0x8D, 0xD2, 0x1F, 0x5A, 0x3D, 0x17, 0xB4, 0x47, 0x7A, 0x8A, 0x53, 0x1D, 0x97, 0xD5, 0x7E, 0xB5, 0x58, 0xF0, 0xD5, 0x8A, 0x4A, 0xF5, 0xBF, 0xAD, 0xDD, 0xA4, 0xA0, 0xBC, 0x1D, 0xC2, 0x2F, 0xF8, 0x75, 0x76, 0xC7, 0x26, 0x8B, 0x94, 0x28, 0x19, 0xD4, 0xC8, 0x3F, 0x78, 0xE1, 0xEE, 0x92, 0xD4, 0x06, 0x66, 0x2F, 0x4E, 0x68, 0x47, 0x1E, 0x4D, 0xE8, 0x33, 0xE5, 0x12, 0x6C, 0x32, 0xEB, 0x63, 0xA8, 0x68, 0x34, 0x5D, 0x1D, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_0 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB3, 0xD6, 0x8C, 0x9B, 0x10, 0x90, 0xF6, 0xB1, 0xB8, 0x8E, 0xCF, 0xA9, 0xE2, 0xF6, 0x0E, 0x9C, 0x62, 0xC3, 0x03, 0x3B, 0x5B, 0x64, 0x28, 0x2F, 0x26, 0x2C, 0xD3, 0x93, 0xB4, 0x33, 0xD9, 0x7B, 0xD3, 0xDB, 0x7E, 0xBA, 0x47, 0x0B, 0x1A, 0x77, 0xA3, 0xDB, 0x3C, 0x18, 0xA1, 0xE7, 0x61, 0x69, 0x72, 0x22, 0x9B, 0xDA, 0xD5, 0x4F, 0xB0, 0x2A, 0x19, 0x54, 0x6C, 0x65, 0xFA, 0x47, 0x73, 0xAA, 0xBE, 0x9B, 0x8C, 0x92, 0x67, 0x07, 0xE7, 0xB7, 0xDD, 0xE4, 0xC8, 0x67, 0xC0, 0x1C, 0x08, 0x02, 0x98, 0x5E, 0x43, 0x86, 0x56, 0x16, 0x8A, 0x44, 0x30, 0xF3, 0xF3, 0xB9, 0x66, 0x2D, 0x7D, 0x01, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_1 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC1, 0x0F, 0x40, 0x97, 0xFD, 0x3C, 0x78, 0x1A, 0x8F, 0xDE, 0x10, 0x1E, 0xF3, 0xB2, 0xF0, 0x91, 0xF8, 0x2B, 0xEE, 0x47, 0x42, 0x32, 0x4B, 0x92, 0x06, 0xC5, 0x81, 0x76, 0x6E, 0xAF, 0x2F, 0xBB, 0x42, 0xC7, 0xD6, 0x0D, 0x74, 0x9B, 0x99, 0x9C, 0x52, 0x9B, 0x0E, 0x22, 0xAD, 0x05, 0xE0, 0xC8, 0x80, 0x23, 0x12, 0x19, 0xAD, 0x47, 0x31, 0x14, 0xEC, 0x45, 0x43, 0x80, 0xA9, 0x28, 0x98, 0xD7, 0xA8, 0xB5, 0x4D, 0x94, 0x32, 0x58, 0x48, 0x97, 0xD6, 0xAF, 0xE4, 0x86, 0x02, 0x35, 0x12, 0x61, 0x90, 0xA3, 0x28, 0xDD, 0x65, 0x25, 0xD9, 0x7B, 0x90, 0x58, 0xD9, 0x86, 0x40, 0xB0, 0xFA, 0x05, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_2 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC3, 0xC8, 0xD8, 0x9F, 0x55, 0xD6, 0xA2, 0x36, 0xA1, 0x15, 0xC7, 0x75, 0x94, 0xD4, 0xB3, 0x18, 0xF0, 0xA0, 0xA0, 0xE3, 0x25, 0x2C, 0xC0, 0xD6, 0x34, 0x5E, 0xB9, 0xE3, 0x3A, 0x43, 0xA5, 0xA5, 0x6D, 0xC9, 0xD1, 0x0B, 0x7B, 0x59, 0xC1, 0x35, 0x39, 0x61, 0x59, 0xEC, 0x4D, 0x01, 0xDE, 0xBC, 0x5F, 0xB3, 0xA4, 0xCA, 0xE4, 0x78, 0x53, 0xE2, 0x05, 0xFE, 0x08, 0x98, 0x2D, 0xFC, 0xC0, 0xC3, 0x9F, 0x05, 0x57, 0x44, 0x9F, 0x97, 0xD4, 0x1F, 0xED, 0x13, 0xB8, 0x86, 0xAE, 0xBE, 0xEA, 0x91, 0x8F, 0x47, 0x67, 0xE8, 0xFB, 0xE0, 0x49, 0x4F, 0xFF, 0x6F, 0x6E, 0xE3, 0x50, 0x8E, 0x3A, 0x3F, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_3 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB6, 0x1E, 0x19, 0x20, 0x91, 0xF9, 0x0A, 0x8F, 0x76, 0xA6, 0xEA, 0xAA, 0x9A, 0x3C, 0xE5, 0x8C, 0x86, 0x3F, 0x39, 0xAE, 0x25, 0x3F, 0x03, 0x78, 0x16, 0xF5, 0x97, 0x58, 0x54, 0xE0, 0x7A, 0x9A, 0x45, 0x66, 0x01, 0xE7, 0xC9, 0x4C, 0x29, 0x75, 0x9F, 0xE1, 0x55, 0xC0, 0x64, 0xED, 0xDF, 0xA1, 0x11, 0x44, 0x3F, 0x81, 0xEF, 0x1A, 0x42, 0x8C, 0xF6, 0xCD, 0x32, 0xF9, 0xDA, 0xC9, 0xD4, 0x8E, 0x94, 0xCF, 0xB3, 0xF6, 0x90, 0x12, 0x0E, 0x8E, 0x6B, 0x91, 0x11, 0xAD, 0xDA, 0xF1, 0x1E, 0x7C, 0x96, 0x20, 0x8C, 0x37, 0xC0, 0x14, 0x3F, 0xF2, 0xBF, 0x3D, 0x7E, 0x83, 0x11, 0x41, 0xA9, 0x73, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_4 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xA0, 0xF2, 0xAC, 0x80, 0xB4, 0x08, 0xE2, 0xE4, 0xD5, 0x89, 0x16, 0xA1, 0xC7, 0x06, 0xBE, 0xE7, 0xA2, 0x47, 0x58, 0xA6, 0x2C, 0xE9, 0xB5, 0x0A, 0xF1, 0xB3, 0x14, 0x09, 0xDF, 0xCB, 0x38, 0x2E, 0x88, 0x5A, 0xA8, 0xBB, 0x8C, 0x0E, 0x4A, 0xD1, 0xBC, 0xF6, 0xFF, 0x64, 0xFB, 0x30, 0x37, 0x75, 0x7D, 0x2B, 0xEA, 0x10, 0xE4, 0xFE, 0x90, 0x07, 0xC8, 0x50, 0xFF, 0xDC, 0xF7, 0x0D, 0x2A, 0xFA, 0xA4, 0xC5, 0x3F, 0xAF, 0xE3, 0x8A, 0x99, 0x17, 0xD4, 0x67, 0x86, 0x2F, 0x50, 0xFE, 0x37, 0x59, 0x27, 0xEC, 0xFE, 0xF4, 0x33, 0xE6, 0x1B, 0xF8, 0x17, 0xA6, 0x45, 0xFA, 0x56, 0x65, 0xD9, 0xCF, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_5 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xD0, 0x46, 0xF2, 0x87, 0x28, 0x68, 0xA5, 0x08, 0x92, 0x05, 0xB2, 0x26, 0xDE, 0x13, 0xD8, 0x6D, 0xA5, 0x52, 0x64, 0x6A, 0xC1, 0x52, 0xC8, 0x46, 0x15, 0xBE, 0x8E, 0x0A, 0x58, 0x97, 0xC3, 0xEA, 0x45, 0x87, 0x10, 0x28, 0xF4, 0x51, 0x86, 0x0E, 0xA2, 0x26, 0xD5, 0x3B, 0x68, 0xDD, 0xD5, 0xA7, 0x7D, 0x1A, 0xD8, 0x2F, 0xAF, 0x85, 0x7E, 0xA5, 0x2C, 0xF7, 0x93, 0x31, 0x12, 0xEE, 0xC3, 0x67, 0xA0, 0x6C, 0x07, 0x61, 0xE5, 0x80, 0xD3, 0xD7, 0x0B, 0x6B, 0x9C, 0x83, 0x7B, 0xAA, 0x3F, 0x16, 0xD1, 0xFF, 0x7A, 0xA2, 0x0D, 0x87, 0xA2, 0xA5, 0xE2, 0xBC, 0xC6, 0xE3, 0x83, 0xBF, 0x12, 0xD5, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_6 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xD3, 0x79, 0x91, 0x90, 0x01, 0xD7, 0xFF, 0x40, 0xAC, 0x59, 0xDF, 0x47, 0x5C, 0xF6, 0xC6, 0x36, 0x8B, 0x19, 0x58, 0xDD, 0x4E, 0x87, 0x0D, 0xFD, 0x1C, 0xE1, 0x12, 0x18, 0xD5, 0xEA, 0x9D, 0x88, 0xDD, 0x7A, 0xD5, 0x30, 0xE2, 0x80, 0x6B, 0x0B, 0x09, 0x2C, 0x02, 0xE2, 0x5D, 0xB0, 0x92, 0x51, 0x89, 0x08, 0xED, 0xA5, 0x74, 0xA0, 0x96, 0x8D, 0x49, 0xB0, 0x50, 0x39, 0x54, 0xB2, 0x42, 0x84, 0xFA, 0x75, 0x44, 0x5A, 0x07, 0x4C, 0xE6, 0xE1, 0xAB, 0xCE, 0xC8, 0xFD, 0x01, 0xDA, 0xA0, 0xD2, 0x1A, 0x0D, 0xD9, 0x7B, 0x41, 0x7B, 0xC3, 0xE5, 0x4B, 0xEB, 0x72, 0x53, 0xFC, 0x06, 0xD3, 0xF3, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_7 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB7, 0x51, 0xCB, 0x7D, 0x28, 0x26, 0x25, 0xF2, 0x96, 0x1A, 0x71, 0x38, 0x65, 0x0A, 0xBE, 0x1A, 0x6A, 0xA8, 0x0D, 0x69, 0x54, 0x8B, 0xA3, 0xAE, 0x9D, 0xFF, 0x06, 0x5B, 0x28, 0x05, 0xEB, 0x36, 0x75, 0xD9, 0x60, 0xC6, 0x20, 0x96, 0xC2, 0x83, 0x5B, 0x1D, 0xF1, 0xC2, 0x90, 0xFC, 0x19, 0x41, 0x19, 0x44, 0xAF, 0xDF, 0x34, 0x58, 0xE3, 0xB1, 0xBC, 0x81, 0xA9, 0x8C, 0x3F, 0x3E, 0x95, 0xD0, 0xEE, 0x0C, 0x20, 0xA0, 0x25, 0x9E, 0x61, 0x43, 0x99, 0x40, 0x43, 0x54, 0xD9, 0x0F, 0x0C, 0x69, 0x11, 0x1A, 0x4E, 0x52, 0x5F, 0x42, 0x5F, 0xBB, 0x31, 0xA3, 0x8B, 0x8C, 0x55, 0x8F, 0x23, 0x73, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_8 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB3, 0x28, 0xFE, 0x4C, 0xC4, 0x16, 0x27, 0x88, 0x2B, 0x04, 0xFB, 0xA0, 0xA3, 0x96, 0xA1, 0x52, 0x85, 0xA8, 0x56, 0x4B, 0x61, 0x12, 0xC1, 0x20, 0x30, 0x48, 0x76, 0x6D, 0x82, 0x7E, 0x8E, 0x4E, 0x56, 0x55, 0xD4, 0x4B, 0x26, 0x6B, 0x28, 0x36, 0x57, 0x5A, 0xE6, 0x8C, 0x83, 0x01, 0x63, 0x2A, 0x3E, 0x58, 0xB1, 0xF4, 0x36, 0x21, 0x31, 0xE9, 0x7B, 0x0A, 0xA0, 0xAF, 0xC3, 0x8F, 0x2F, 0x76, 0x90, 0xCB, 0xD4, 0xF3, 0xF4, 0x65, 0x20, 0x72, 0xBF, 0xD8, 0xE9, 0x42, 0x1D, 0x2B, 0xEE, 0xF1, 0x77, 0x87, 0x3C, 0xD7, 0xD0, 0x8B, 0x6C, 0x0D, 0x10, 0x22, 0x10, 0x9C, 0xA3, 0xED, 0x5B, 0x63, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_9 => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC4, 0xB3, 0x2F, 0xD1, 0x16, 0x1C, 0xC3, 0x0D, 0x04, 0xBD, 0x56, 0x9F, 0x40, 0x9E, 0x87, 0x8A, 0xA2, 0x81, 0x5C, 0x91, 0xDD, 0x00, 0x9A, 0x5A, 0xE8, 0xBF, 0xDA, 0xEA, 0x7D, 0x11, 0x6B, 0xF2, 0x49, 0x66, 0xBF, 0x10, 0xFC, 0xC0, 0x01, 0x4B, 0x25, 0x8D, 0xFE, 0xF6, 0x61, 0x4E, 0x55, 0xFB, 0x6D, 0xAB, 0x23, 0x57, 0xCD, 0x6D, 0xF5, 0xB6, 0x3A, 0x5F, 0x05, 0x9F, 0x72, 0x44, 0x69, 0xC0, 0x17, 0x8D, 0x83, 0xF8, 0x8F, 0x45, 0x04, 0x89, 0x82, 0xEA, 0xE7, 0xA7, 0xCC, 0x24, 0x9F, 0x84, 0x66, 0x7F, 0xC3, 0x93, 0x68, 0x4D, 0xA5, 0xEF, 0xE1, 0x85, 0x6E, 0xB1, 0x00, 0x27, 0xD1, 0xD7, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_A => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC5, 0xB7, 0x54, 0x01, 0xE8, 0x33, 0x52, 0xA6, 0x4E, 0xEC, 0x89, 0x16, 0xC4, 0x20, 0x6F, 0x17, 0xEC, 0x33, 0x8A, 0x24, 0xA6, 0xF7, 0xFD, 0x51, 0x52, 0x60, 0x69, 0x6D, 0x72, 0x28, 0x49, 0x6A, 0xBC, 0x14, 0x23, 0xE1, 0xFF, 0x30, 0x51, 0x41, 0x49, 0xFC, 0x19, 0x97, 0x20, 0xE9, 0x5E, 0x68, 0x25, 0x39, 0x89, 0x2E, 0x51, 0x0B, 0x23, 0x9A, 0x8C, 0x7A, 0x41, 0x3D, 0xE4, 0xEE, 0xE7, 0x45, 0x94, 0xF0, 0x73, 0x81, 0x5E, 0x9B, 0x43, 0x47, 0x11, 0xF6, 0x80, 0x7E, 0x8B, 0x9E, 0x7C, 0x10, 0xC2, 0x81, 0xF8, 0x9C, 0xF3, 0xB1, 0xC1, 0x4E, 0x3F, 0x0A, 0xDF, 0x83, 0xA2, 0x80, 0x5F, 0x09, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_B => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xAC, 0x36, 0xB8, 0x8D, 0x00, 0xC3, 0x99, 0xC6, 0x60, 0xB4, 0x84, 0x62, 0x87, 0xFF, 0xC7, 0xF9, 0xDF, 0x5C, 0x07, 0x48, 0x7E, 0xAA, 0xE3, 0xCD, 0x4E, 0xFD, 0x00, 0x29, 0xD3, 0xB8, 0x6E, 0xD3, 0x65, 0x8A, 0xD7, 0xDE, 0xE4, 0xC7, 0xF5, 0xDA, 0x25, 0xF9, 0xF6, 0x00, 0x88, 0x85, 0xF3, 0x43, 0x12, 0x22, 0x74, 0x99, 0x4C, 0xAB, 0x64, 0x77, 0x76, 0xF0, 0xAD, 0xCF, 0xBA, 0x1E, 0x0E, 0xCE, 0xC8, 0xBF, 0x57, 0xCA, 0xAB, 0x84, 0x88, 0xBD, 0xD5, 0x9A, 0x55, 0x19, 0x5A, 0x01, 0x67, 0xC7, 0xD2, 0xC4, 0xA9, 0xCF, 0x67, 0x9D, 0x0E, 0xFF, 0x4A, 0x62, 0xB5, 0xC8, 0x56, 0x8E, 0x09, 0x77, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_C => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xCA, 0xC0, 0x51, 0x4D, 0x4B, 0x6A, 0x3F, 0x70, 0x77, 0x1C, 0x46, 0x1B, 0x01, 0xBD, 0xE3, 0xB6, 0xD4, 0x7A, 0x0A, 0xDA, 0x07, 0x80, 0x74, 0xDD, 0xA5, 0x07, 0x03, 0xD8, 0xCC, 0x28, 0x08, 0x93, 0x79, 0xDA, 0x64, 0xFB, 0x3A, 0x34, 0xAD, 0x34, 0x35, 0xD2, 0x4F, 0x73, 0x31, 0x38, 0x3B, 0xDA, 0xDC, 0x48, 0x77, 0x66, 0x2E, 0xFB, 0x55, 0x5D, 0xA2, 0x07, 0x76, 0x19, 0xB7, 0x0A, 0xB0, 0x34, 0x2E, 0xBE, 0x6E, 0xE8, 0x88, 0xEB, 0xF3, 0xCF, 0x4B, 0x7E, 0x8B, 0xCC, 0xA9, 0x5C, 0x61, 0xE9, 0x93, 0xBD, 0xD6, 0x10, 0x4C, 0x10, 0xD1, 0x11, 0x15, 0xDC, 0x84, 0x17, 0x8A, 0x58, 0x94, 0x35, 0x02, 0x03, 0x01, 0x00, 0x01 }; - private static ReadOnlySpan DER_D => new byte[] { 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB9, 0x06, 0x46, 0x67, 0x40, 0xF5, 0xA9, 0x42, 0x8D, 0xA8, 0x4B, 0x41, 0x8C, 0x7F, 0xA6, 0x14, 0x6F, 0x7E, 0x24, 0xC7, 0x83, 0x37, 0x3D, 0x67, 0x1F, 0x92, 0x14, 0xB4, 0x09, 0x48, 0xA4, 0xA3, 0x17, 0xC1, 0xA4, 0x46, 0x01, 0x11, 0xB4, 0x5D, 0x2D, 0xAD, 0xD0, 0x93, 0x81, 0x54, 0x01, 0x57, 0x3E, 0x52, 0xF0, 0x17, 0x88, 0x90, 0xD3, 0x5C, 0xBD, 0x95, 0x71, 0x2E, 0xFA, 0xAE, 0x0D, 0x20, 0xAD, 0x47, 0x18, 0x76, 0x48, 0x77, 0x5C, 0xD9, 0x56, 0x94, 0x31, 0xB1, 0xFC, 0x3C, 0x78, 0x41, 0x13, 0xE3, 0xA4, 0x84, 0x36, 0xD3, 0x0B, 0x2C, 0xD1, 0x62, 0x21, 0x8D, 0x67, 0x81, 0xF5, 0xED, 0x02, 0x03, 0x01, 0x00, 0x01 }; + private static ReadOnlySpan DER_LW=> [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB7, 0x56, 0xE1, 0xDC, 0xD8, 0xCE, 0xCE, 0x78, 0xE1, 0x48, 0x10, 0x7B, 0x1B, 0xAC, 0x11, 0x5F, 0xDB, 0x17, 0xDE, 0x84, 0x34, 0x53, 0xCA, 0xB7, 0xD4, 0xE6, 0xDF, 0x8D, 0xD2, 0x1F, 0x5A, 0x3D, 0x17, 0xB4, 0x47, 0x7A, 0x8A, 0x53, 0x1D, 0x97, 0xD5, 0x7E, 0xB5, 0x58, 0xF0, 0xD5, 0x8A, 0x4A, 0xF5, 0xBF, 0xAD, 0xDD, 0xA4, 0xA0, 0xBC, 0x1D, 0xC2, 0x2F, 0xF8, 0x75, 0x76, 0xC7, 0x26, 0x8B, 0x94, 0x28, 0x19, 0xD4, 0xC8, 0x3F, 0x78, 0xE1, 0xEE, 0x92, 0xD4, 0x06, 0x66, 0x2F, 0x4E, 0x68, 0x47, 0x1E, 0x4D, 0xE8, 0x33, 0xE5, 0x12, 0x6C, 0x32, 0xEB, 0x63, 0xA8, 0x68, 0x34, 0x5D, 0x1D, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_0 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB3, 0xD6, 0x8C, 0x9B, 0x10, 0x90, 0xF6, 0xB1, 0xB8, 0x8E, 0xCF, 0xA9, 0xE2, 0xF6, 0x0E, 0x9C, 0x62, 0xC3, 0x03, 0x3B, 0x5B, 0x64, 0x28, 0x2F, 0x26, 0x2C, 0xD3, 0x93, 0xB4, 0x33, 0xD9, 0x7B, 0xD3, 0xDB, 0x7E, 0xBA, 0x47, 0x0B, 0x1A, 0x77, 0xA3, 0xDB, 0x3C, 0x18, 0xA1, 0xE7, 0x61, 0x69, 0x72, 0x22, 0x9B, 0xDA, 0xD5, 0x4F, 0xB0, 0x2A, 0x19, 0x54, 0x6C, 0x65, 0xFA, 0x47, 0x73, 0xAA, 0xBE, 0x9B, 0x8C, 0x92, 0x67, 0x07, 0xE7, 0xB7, 0xDD, 0xE4, 0xC8, 0x67, 0xC0, 0x1C, 0x08, 0x02, 0x98, 0x5E, 0x43, 0x86, 0x56, 0x16, 0x8A, 0x44, 0x30, 0xF3, 0xF3, 0xB9, 0x66, 0x2D, 0x7D, 0x01, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_1 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC1, 0x0F, 0x40, 0x97, 0xFD, 0x3C, 0x78, 0x1A, 0x8F, 0xDE, 0x10, 0x1E, 0xF3, 0xB2, 0xF0, 0x91, 0xF8, 0x2B, 0xEE, 0x47, 0x42, 0x32, 0x4B, 0x92, 0x06, 0xC5, 0x81, 0x76, 0x6E, 0xAF, 0x2F, 0xBB, 0x42, 0xC7, 0xD6, 0x0D, 0x74, 0x9B, 0x99, 0x9C, 0x52, 0x9B, 0x0E, 0x22, 0xAD, 0x05, 0xE0, 0xC8, 0x80, 0x23, 0x12, 0x19, 0xAD, 0x47, 0x31, 0x14, 0xEC, 0x45, 0x43, 0x80, 0xA9, 0x28, 0x98, 0xD7, 0xA8, 0xB5, 0x4D, 0x94, 0x32, 0x58, 0x48, 0x97, 0xD6, 0xAF, 0xE4, 0x86, 0x02, 0x35, 0x12, 0x61, 0x90, 0xA3, 0x28, 0xDD, 0x65, 0x25, 0xD9, 0x7B, 0x90, 0x58, 0xD9, 0x86, 0x40, 0xB0, 0xFA, 0x05, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_2 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC3, 0xC8, 0xD8, 0x9F, 0x55, 0xD6, 0xA2, 0x36, 0xA1, 0x15, 0xC7, 0x75, 0x94, 0xD4, 0xB3, 0x18, 0xF0, 0xA0, 0xA0, 0xE3, 0x25, 0x2C, 0xC0, 0xD6, 0x34, 0x5E, 0xB9, 0xE3, 0x3A, 0x43, 0xA5, 0xA5, 0x6D, 0xC9, 0xD1, 0x0B, 0x7B, 0x59, 0xC1, 0x35, 0x39, 0x61, 0x59, 0xEC, 0x4D, 0x01, 0xDE, 0xBC, 0x5F, 0xB3, 0xA4, 0xCA, 0xE4, 0x78, 0x53, 0xE2, 0x05, 0xFE, 0x08, 0x98, 0x2D, 0xFC, 0xC0, 0xC3, 0x9F, 0x05, 0x57, 0x44, 0x9F, 0x97, 0xD4, 0x1F, 0xED, 0x13, 0xB8, 0x86, 0xAE, 0xBE, 0xEA, 0x91, 0x8F, 0x47, 0x67, 0xE8, 0xFB, 0xE0, 0x49, 0x4F, 0xFF, 0x6F, 0x6E, 0xE3, 0x50, 0x8E, 0x3A, 0x3F, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_3 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB6, 0x1E, 0x19, 0x20, 0x91, 0xF9, 0x0A, 0x8F, 0x76, 0xA6, 0xEA, 0xAA, 0x9A, 0x3C, 0xE5, 0x8C, 0x86, 0x3F, 0x39, 0xAE, 0x25, 0x3F, 0x03, 0x78, 0x16, 0xF5, 0x97, 0x58, 0x54, 0xE0, 0x7A, 0x9A, 0x45, 0x66, 0x01, 0xE7, 0xC9, 0x4C, 0x29, 0x75, 0x9F, 0xE1, 0x55, 0xC0, 0x64, 0xED, 0xDF, 0xA1, 0x11, 0x44, 0x3F, 0x81, 0xEF, 0x1A, 0x42, 0x8C, 0xF6, 0xCD, 0x32, 0xF9, 0xDA, 0xC9, 0xD4, 0x8E, 0x94, 0xCF, 0xB3, 0xF6, 0x90, 0x12, 0x0E, 0x8E, 0x6B, 0x91, 0x11, 0xAD, 0xDA, 0xF1, 0x1E, 0x7C, 0x96, 0x20, 0x8C, 0x37, 0xC0, 0x14, 0x3F, 0xF2, 0xBF, 0x3D, 0x7E, 0x83, 0x11, 0x41, 0xA9, 0x73, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_4 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xA0, 0xF2, 0xAC, 0x80, 0xB4, 0x08, 0xE2, 0xE4, 0xD5, 0x89, 0x16, 0xA1, 0xC7, 0x06, 0xBE, 0xE7, 0xA2, 0x47, 0x58, 0xA6, 0x2C, 0xE9, 0xB5, 0x0A, 0xF1, 0xB3, 0x14, 0x09, 0xDF, 0xCB, 0x38, 0x2E, 0x88, 0x5A, 0xA8, 0xBB, 0x8C, 0x0E, 0x4A, 0xD1, 0xBC, 0xF6, 0xFF, 0x64, 0xFB, 0x30, 0x37, 0x75, 0x7D, 0x2B, 0xEA, 0x10, 0xE4, 0xFE, 0x90, 0x07, 0xC8, 0x50, 0xFF, 0xDC, 0xF7, 0x0D, 0x2A, 0xFA, 0xA4, 0xC5, 0x3F, 0xAF, 0xE3, 0x8A, 0x99, 0x17, 0xD4, 0x67, 0x86, 0x2F, 0x50, 0xFE, 0x37, 0x59, 0x27, 0xEC, 0xFE, 0xF4, 0x33, 0xE6, 0x1B, 0xF8, 0x17, 0xA6, 0x45, 0xFA, 0x56, 0x65, 0xD9, 0xCF, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_5 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xD0, 0x46, 0xF2, 0x87, 0x28, 0x68, 0xA5, 0x08, 0x92, 0x05, 0xB2, 0x26, 0xDE, 0x13, 0xD8, 0x6D, 0xA5, 0x52, 0x64, 0x6A, 0xC1, 0x52, 0xC8, 0x46, 0x15, 0xBE, 0x8E, 0x0A, 0x58, 0x97, 0xC3, 0xEA, 0x45, 0x87, 0x10, 0x28, 0xF4, 0x51, 0x86, 0x0E, 0xA2, 0x26, 0xD5, 0x3B, 0x68, 0xDD, 0xD5, 0xA7, 0x7D, 0x1A, 0xD8, 0x2F, 0xAF, 0x85, 0x7E, 0xA5, 0x2C, 0xF7, 0x93, 0x31, 0x12, 0xEE, 0xC3, 0x67, 0xA0, 0x6C, 0x07, 0x61, 0xE5, 0x80, 0xD3, 0xD7, 0x0B, 0x6B, 0x9C, 0x83, 0x7B, 0xAA, 0x3F, 0x16, 0xD1, 0xFF, 0x7A, 0xA2, 0x0D, 0x87, 0xA2, 0xA5, 0xE2, 0xBC, 0xC6, 0xE3, 0x83, 0xBF, 0x12, 0xD5, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_6 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xD3, 0x79, 0x91, 0x90, 0x01, 0xD7, 0xFF, 0x40, 0xAC, 0x59, 0xDF, 0x47, 0x5C, 0xF6, 0xC6, 0x36, 0x8B, 0x19, 0x58, 0xDD, 0x4E, 0x87, 0x0D, 0xFD, 0x1C, 0xE1, 0x12, 0x18, 0xD5, 0xEA, 0x9D, 0x88, 0xDD, 0x7A, 0xD5, 0x30, 0xE2, 0x80, 0x6B, 0x0B, 0x09, 0x2C, 0x02, 0xE2, 0x5D, 0xB0, 0x92, 0x51, 0x89, 0x08, 0xED, 0xA5, 0x74, 0xA0, 0x96, 0x8D, 0x49, 0xB0, 0x50, 0x39, 0x54, 0xB2, 0x42, 0x84, 0xFA, 0x75, 0x44, 0x5A, 0x07, 0x4C, 0xE6, 0xE1, 0xAB, 0xCE, 0xC8, 0xFD, 0x01, 0xDA, 0xA0, 0xD2, 0x1A, 0x0D, 0xD9, 0x7B, 0x41, 0x7B, 0xC3, 0xE5, 0x4B, 0xEB, 0x72, 0x53, 0xFC, 0x06, 0xD3, 0xF3, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_7 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB7, 0x51, 0xCB, 0x7D, 0x28, 0x26, 0x25, 0xF2, 0x96, 0x1A, 0x71, 0x38, 0x65, 0x0A, 0xBE, 0x1A, 0x6A, 0xA8, 0x0D, 0x69, 0x54, 0x8B, 0xA3, 0xAE, 0x9D, 0xFF, 0x06, 0x5B, 0x28, 0x05, 0xEB, 0x36, 0x75, 0xD9, 0x60, 0xC6, 0x20, 0x96, 0xC2, 0x83, 0x5B, 0x1D, 0xF1, 0xC2, 0x90, 0xFC, 0x19, 0x41, 0x19, 0x44, 0xAF, 0xDF, 0x34, 0x58, 0xE3, 0xB1, 0xBC, 0x81, 0xA9, 0x8C, 0x3F, 0x3E, 0x95, 0xD0, 0xEE, 0x0C, 0x20, 0xA0, 0x25, 0x9E, 0x61, 0x43, 0x99, 0x40, 0x43, 0x54, 0xD9, 0x0F, 0x0C, 0x69, 0x11, 0x1A, 0x4E, 0x52, 0x5F, 0x42, 0x5F, 0xBB, 0x31, 0xA3, 0x8B, 0x8C, 0x55, 0x8F, 0x23, 0x73, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_8 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB3, 0x28, 0xFE, 0x4C, 0xC4, 0x16, 0x27, 0x88, 0x2B, 0x04, 0xFB, 0xA0, 0xA3, 0x96, 0xA1, 0x52, 0x85, 0xA8, 0x56, 0x4B, 0x61, 0x12, 0xC1, 0x20, 0x30, 0x48, 0x76, 0x6D, 0x82, 0x7E, 0x8E, 0x4E, 0x56, 0x55, 0xD4, 0x4B, 0x26, 0x6B, 0x28, 0x36, 0x57, 0x5A, 0xE6, 0x8C, 0x83, 0x01, 0x63, 0x2A, 0x3E, 0x58, 0xB1, 0xF4, 0x36, 0x21, 0x31, 0xE9, 0x7B, 0x0A, 0xA0, 0xAF, 0xC3, 0x8F, 0x2F, 0x76, 0x90, 0xCB, 0xD4, 0xF3, 0xF4, 0x65, 0x20, 0x72, 0xBF, 0xD8, 0xE9, 0x42, 0x1D, 0x2B, 0xEE, 0xF1, 0x77, 0x87, 0x3C, 0xD7, 0xD0, 0x8B, 0x6C, 0x0D, 0x10, 0x22, 0x10, 0x9C, 0xA3, 0xED, 0x5B, 0x63, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_9 => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC4, 0xB3, 0x2F, 0xD1, 0x16, 0x1C, 0xC3, 0x0D, 0x04, 0xBD, 0x56, 0x9F, 0x40, 0x9E, 0x87, 0x8A, 0xA2, 0x81, 0x5C, 0x91, 0xDD, 0x00, 0x9A, 0x5A, 0xE8, 0xBF, 0xDA, 0xEA, 0x7D, 0x11, 0x6B, 0xF2, 0x49, 0x66, 0xBF, 0x10, 0xFC, 0xC0, 0x01, 0x4B, 0x25, 0x8D, 0xFE, 0xF6, 0x61, 0x4E, 0x55, 0xFB, 0x6D, 0xAB, 0x23, 0x57, 0xCD, 0x6D, 0xF5, 0xB6, 0x3A, 0x5F, 0x05, 0x9F, 0x72, 0x44, 0x69, 0xC0, 0x17, 0x8D, 0x83, 0xF8, 0x8F, 0x45, 0x04, 0x89, 0x82, 0xEA, 0xE7, 0xA7, 0xCC, 0x24, 0x9F, 0x84, 0x66, 0x7F, 0xC3, 0x93, 0x68, 0x4D, 0xA5, 0xEF, 0xE1, 0x85, 0x6E, 0xB1, 0x00, 0x27, 0xD1, 0xD7, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_A => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xC5, 0xB7, 0x54, 0x01, 0xE8, 0x33, 0x52, 0xA6, 0x4E, 0xEC, 0x89, 0x16, 0xC4, 0x20, 0x6F, 0x17, 0xEC, 0x33, 0x8A, 0x24, 0xA6, 0xF7, 0xFD, 0x51, 0x52, 0x60, 0x69, 0x6D, 0x72, 0x28, 0x49, 0x6A, 0xBC, 0x14, 0x23, 0xE1, 0xFF, 0x30, 0x51, 0x41, 0x49, 0xFC, 0x19, 0x97, 0x20, 0xE9, 0x5E, 0x68, 0x25, 0x39, 0x89, 0x2E, 0x51, 0x0B, 0x23, 0x9A, 0x8C, 0x7A, 0x41, 0x3D, 0xE4, 0xEE, 0xE7, 0x45, 0x94, 0xF0, 0x73, 0x81, 0x5E, 0x9B, 0x43, 0x47, 0x11, 0xF6, 0x80, 0x7E, 0x8B, 0x9E, 0x7C, 0x10, 0xC2, 0x81, 0xF8, 0x9C, 0xF3, 0xB1, 0xC1, 0x4E, 0x3F, 0x0A, 0xDF, 0x83, 0xA2, 0x80, 0x5F, 0x09, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_B => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xAC, 0x36, 0xB8, 0x8D, 0x00, 0xC3, 0x99, 0xC6, 0x60, 0xB4, 0x84, 0x62, 0x87, 0xFF, 0xC7, 0xF9, 0xDF, 0x5C, 0x07, 0x48, 0x7E, 0xAA, 0xE3, 0xCD, 0x4E, 0xFD, 0x00, 0x29, 0xD3, 0xB8, 0x6E, 0xD3, 0x65, 0x8A, 0xD7, 0xDE, 0xE4, 0xC7, 0xF5, 0xDA, 0x25, 0xF9, 0xF6, 0x00, 0x88, 0x85, 0xF3, 0x43, 0x12, 0x22, 0x74, 0x99, 0x4C, 0xAB, 0x64, 0x77, 0x76, 0xF0, 0xAD, 0xCF, 0xBA, 0x1E, 0x0E, 0xCE, 0xC8, 0xBF, 0x57, 0xCA, 0xAB, 0x84, 0x88, 0xBD, 0xD5, 0x9A, 0x55, 0x19, 0x5A, 0x01, 0x67, 0xC7, 0xD2, 0xC4, 0xA9, 0xCF, 0x67, 0x9D, 0x0E, 0xFF, 0x4A, 0x62, 0xB5, 0xC8, 0x56, 0x8E, 0x09, 0x77, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_C => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xCA, 0xC0, 0x51, 0x4D, 0x4B, 0x6A, 0x3F, 0x70, 0x77, 0x1C, 0x46, 0x1B, 0x01, 0xBD, 0xE3, 0xB6, 0xD4, 0x7A, 0x0A, 0xDA, 0x07, 0x80, 0x74, 0xDD, 0xA5, 0x07, 0x03, 0xD8, 0xCC, 0x28, 0x08, 0x93, 0x79, 0xDA, 0x64, 0xFB, 0x3A, 0x34, 0xAD, 0x34, 0x35, 0xD2, 0x4F, 0x73, 0x31, 0x38, 0x3B, 0xDA, 0xDC, 0x48, 0x77, 0x66, 0x2E, 0xFB, 0x55, 0x5D, 0xA2, 0x07, 0x76, 0x19, 0xB7, 0x0A, 0xB0, 0x34, 0x2E, 0xBE, 0x6E, 0xE8, 0x88, 0xEB, 0xF3, 0xCF, 0x4B, 0x7E, 0x8B, 0xCC, 0xA9, 0x5C, 0x61, 0xE9, 0x93, 0xBD, 0xD6, 0x10, 0x4C, 0x10, 0xD1, 0x11, 0x15, 0xDC, 0x84, 0x17, 0x8A, 0x58, 0x94, 0x35, 0x02, 0x03, 0x01, 0x00, 0x01 ]; + private static ReadOnlySpan DER_D => [ 0x30, 0x7C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x6B, 0x00, 0x30, 0x68, 0x02, 0x61, 0x00, 0xB9, 0x06, 0x46, 0x67, 0x40, 0xF5, 0xA9, 0x42, 0x8D, 0xA8, 0x4B, 0x41, 0x8C, 0x7F, 0xA6, 0x14, 0x6F, 0x7E, 0x24, 0xC7, 0x83, 0x37, 0x3D, 0x67, 0x1F, 0x92, 0x14, 0xB4, 0x09, 0x48, 0xA4, 0xA3, 0x17, 0xC1, 0xA4, 0x46, 0x01, 0x11, 0xB4, 0x5D, 0x2D, 0xAD, 0xD0, 0x93, 0x81, 0x54, 0x01, 0x57, 0x3E, 0x52, 0xF0, 0x17, 0x88, 0x90, 0xD3, 0x5C, 0xBD, 0x95, 0x71, 0x2E, 0xFA, 0xAE, 0x0D, 0x20, 0xAD, 0x47, 0x18, 0x76, 0x48, 0x77, 0x5C, 0xD9, 0x56, 0x94, 0x31, 0xB1, 0xFC, 0x3C, 0x78, 0x41, 0x13, 0xE3, 0xA4, 0x84, 0x36, 0xD3, 0x0B, 0x2C, 0xD1, 0x62, 0x21, 0x8D, 0x67, 0x81, 0xF5, 0xED, 0x02, 0x03, 0x01, 0x00, 0x01 ]; // Signing Keys - private static ReadOnlySpan D_3 => new byte[] { 0x00, 0x77, 0x54, 0x55, 0x66, 0x8F, 0xFF, 0x3C, 0xBA, 0x30, 0x26, 0xC2, 0xD0, 0xB2, 0x6B, 0x80, 0x85, 0x89, 0x59, 0x58, 0x34, 0x11, 0x57, 0xAE, 0xB0, 0x3B, 0x6B, 0x04, 0x95, 0xEE, 0x57, 0x80, 0x3E, 0x21, 0x86, 0xEB, 0x6C, 0xB2, 0xEB, 0x62, 0xA7, 0x1D, 0xF1, 0x8A, 0x3C, 0x9C, 0x65, 0x79, 0x07, 0x76, 0x70, 0x96, 0x1B, 0x3A, 0x61, 0x02, 0xDA, 0xBE, 0x5A, 0x19, 0x4A, 0xB5, 0x8C, 0x32, 0x50, 0xAE, 0xD5, 0x97, 0xFC, 0x78, 0x97, 0x8A, 0x32, 0x6D, 0xB1, 0xD7, 0xB2, 0x8D, 0xCC, 0xCB, 0x2A, 0x3E, 0x01, 0x4E, 0xDB, 0xD3, 0x97, 0xAD, 0x33, 0xB8, 0xF2, 0x8C, 0xD5, 0x25, 0x05, 0x42, 0x51 }; + private static ReadOnlySpan D_3 => [ 0x00, 0x77, 0x54, 0x55, 0x66, 0x8F, 0xFF, 0x3C, 0xBA, 0x30, 0x26, 0xC2, 0xD0, 0xB2, 0x6B, 0x80, 0x85, 0x89, 0x59, 0x58, 0x34, 0x11, 0x57, 0xAE, 0xB0, 0x3B, 0x6B, 0x04, 0x95, 0xEE, 0x57, 0x80, 0x3E, 0x21, 0x86, 0xEB, 0x6C, 0xB2, 0xEB, 0x62, 0xA7, 0x1D, 0xF1, 0x8A, 0x3C, 0x9C, 0x65, 0x79, 0x07, 0x76, 0x70, 0x96, 0x1B, 0x3A, 0x61, 0x02, 0xDA, 0xBE, 0x5A, 0x19, 0x4A, 0xB5, 0x8C, 0x32, 0x50, 0xAE, 0xD5, 0x97, 0xFC, 0x78, 0x97, 0x8A, 0x32, 0x6D, 0xB1, 0xD7, 0xB2, 0x8D, 0xCC, 0xCB, 0x2A, 0x3E, 0x01, 0x4E, 0xDB, 0xD3, 0x97, 0xAD, 0x33, 0xB8, 0xF2, 0x8C, 0xD5, 0x25, 0x05, 0x42, 0x51 ]; #endregion } diff --git a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlock.cs b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlock.cs index 8b59f0eb4..9a8f6dfa9 100644 --- a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlock.cs +++ b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlock.cs @@ -59,7 +59,7 @@ public void ChangeData(ReadOnlySpan value) /// /// Hash key /// Value the block has - internal SCBlock(uint key, SCTypeCode type) : this(key, type, Array.Empty()) + internal SCBlock(uint key, SCTypeCode type) : this(key, type, []) { } @@ -261,7 +261,7 @@ public static SCBlock ReadFromOffset(ReadOnlySpan data, uint key, ref int private static void EnsureArrayIsSane(SCTypeCode sub, ReadOnlySpan arr) { if (sub == SCTypeCode.Bool3) - Debug.Assert(arr.IndexOfAnyExcept(0, 1, 2) == -1); + Debug.Assert(!arr.ContainsAnyExcept(0, 1, 2)); else Debug.Assert(sub > SCTypeCode.Array); } diff --git a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockCompare.cs b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockCompare.cs index 8b777c71d..3c1ac7811 100644 --- a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockCompare.cs +++ b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockCompare.cs @@ -8,10 +8,10 @@ namespace PKHeX.Core; public sealed class SCBlockCompare { - private readonly List AddedKeys = new(); - private readonly List RemovedKeys = new(); - private readonly List TypesChanged = new(); - private readonly List ValueChanged = new(); + private readonly List AddedKeys = []; + private readonly List RemovedKeys = []; + private readonly List TypesChanged = []; + private readonly List ValueChanged = []; private readonly Dictionary KeyNames; private string GetKeyName(uint key) => KeyNames.TryGetValue(key, out var value) ? value : $"{key:X8}"; diff --git a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs index 0fbedde68..063b53b9a 100644 --- a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs +++ b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs @@ -26,7 +26,7 @@ public SCBlockMetadata(SCBlockAccessor accessor, IEnumerable extraKeyNam ValueList = aType.GetAllConstantsOfType(); AddExtraKeyNames(ValueList, extraKeyNames); if (exclusions.Length > 0) - ValueList = ValueList.Where(z => !exclusions.Any(z.Value.Contains)).ToDictionary(z => z.Key, z => z.Value); + ValueList = ValueList.Where(z => !exclusions.Any(z.Value.Contains)).ToDictionary(); Accessor = accessor; } @@ -114,7 +114,7 @@ private string GetBlockHint(SCBlock z, int index) } /// - /// Returns an object that wraps the block with a Value property to get/set via a PropertyGrid/etc control. + /// Returns an object that wraps the block with a Value property to get/set via a PropertyGrid/etc. control. /// /// Returns null if no wrapping is supported. public static object? GetEditableBlockObject(SCBlock block) => block.Type switch @@ -135,10 +135,9 @@ private string GetBlockHint(SCBlock z, int index) _ => null, }; - private sealed class WrappedValueView where T : struct + private sealed class WrappedValueView(SCBlock Parent, object currentValue) where T : struct { - private readonly SCBlock Parent; - private T _value; + private T _value = (T)Convert.ChangeType(currentValue, typeof(T)); [Description("Stored Value for this Block")] public T Value @@ -149,12 +148,8 @@ public T Value // ReSharper disable once UnusedMember.Local [Description("Type of Value this Block stores")] +#pragma warning disable CA1822 public string ValueType => typeof(T).Name; - - public WrappedValueView(SCBlock block, object currentValue) - { - Parent = block; - _value = (T)Convert.ChangeType(currentValue, typeof(T)); - } +#pragma warning restore CA1822 } } diff --git a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCXorShift32.cs b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCXorShift32.cs index 1ac94be9e..b4a0c056a 100644 --- a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCXorShift32.cs +++ b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCXorShift32.cs @@ -8,12 +8,10 @@ namespace PKHeX.Core; /// This implementation allows for yielding crypto bytes on demand. /// /// -public ref struct SCXorShift32 +public ref struct SCXorShift32(uint seed) { private int Counter; - private uint State; - - public SCXorShift32(uint seed) => State = GetInitialState(seed); + private uint State = GetInitialState(seed); private static uint GetInitialState(uint state) { diff --git a/PKHeX.Core/Saves/Encryption/SwishCrypto/SwishCrypto.cs b/PKHeX.Core/Saves/Encryption/SwishCrypto/SwishCrypto.cs index 3937aa4f0..3d04aeb44 100644 --- a/PKHeX.Core/Saves/Encryption/SwishCrypto/SwishCrypto.cs +++ b/PKHeX.Core/Saves/Encryption/SwishCrypto/SwishCrypto.cs @@ -20,24 +20,24 @@ public static class SwishCrypto { private const int SIZE_HASH = SHA256.HashSizeInBytes; // 0x20 - private static ReadOnlySpan IntroHashBytes => new byte[] - { + private static ReadOnlySpan IntroHashBytes => + [ 0x9E, 0xC9, 0x9C, 0xD7, 0x0E, 0xD3, 0x3C, 0x44, 0xFB, 0x93, 0x03, 0xDC, 0xEB, 0x39, 0xB4, 0x2A, 0x19, 0x47, 0xE9, 0x63, 0x4B, 0xA2, 0x33, 0x44, 0x16, 0xBF, 0x82, 0xA2, 0xBA, 0x63, 0x55, 0xB6, 0x3D, 0x9D, 0xF2, 0x4B, 0x5F, 0x7B, 0x6A, 0xB2, 0x62, 0x1D, 0xC2, 0x1B, 0x68, 0xE5, 0xC8, 0xB5, 0x3A, 0x05, 0x90, 0x00, 0xE8, 0xA8, 0x10, 0x3D, 0xE2, 0xEC, 0xF0, 0x0C, 0xB2, 0xED, 0x4F, 0x6D, - }; + ]; - private static ReadOnlySpan OutroHashBytes => new byte[] - { + private static ReadOnlySpan OutroHashBytes => + [ 0xD6, 0xC0, 0x1C, 0x59, 0x8B, 0xC8, 0xB8, 0xCB, 0x46, 0xE1, 0x53, 0xFC, 0x82, 0x8C, 0x75, 0x75, 0x13, 0xE0, 0x45, 0xDF, 0x32, 0x69, 0x3C, 0x75, 0xF0, 0x59, 0xF8, 0xD9, 0xA2, 0x5F, 0xB2, 0x17, 0xE0, 0x80, 0x52, 0xDB, 0xEA, 0x89, 0x73, 0x99, 0x75, 0x79, 0xAF, 0xCB, 0x2E, 0x80, 0x07, 0xE6, 0xF1, 0x26, 0xE0, 0x03, 0x0A, 0xE6, 0x6F, 0xF6, 0x41, 0xBF, 0x7E, 0x59, 0xC2, 0xAE, 0x55, 0xFD, - }; + ]; - private static ReadOnlySpan StaticXorpad => new byte[] - { + private static ReadOnlySpan StaticXorpad => + [ 0xA0, 0x92, 0xD1, 0x06, 0x07, 0xDB, 0x32, 0xA1, 0xAE, 0x01, 0xF5, 0xC5, 0x1E, 0x84, 0x4F, 0xE3, 0x53, 0xCA, 0x37, 0xF4, 0xA7, 0xB0, 0x4D, 0xA0, 0x18, 0xB7, 0xC2, 0x97, 0xDA, 0x5F, 0x53, 0x2B, 0x75, 0xFA, 0x48, 0x16, 0xF8, 0xD4, 0x8A, 0x6F, 0x61, 0x05, 0xF4, 0xE2, 0xFD, 0x04, 0xB5, 0xA3, @@ -46,7 +46,7 @@ public static class SwishCrypto 0xA4, 0x67, 0x5D, 0x23, 0x17, 0xC0, 0x52, 0xE1, 0xA6, 0x30, 0x7C, 0x2B, 0xB6, 0x70, 0x36, 0x5B, 0x2A, 0x27, 0x69, 0x33, 0xF5, 0x63, 0x7B, 0x36, 0x3F, 0x26, 0x9B, 0xA3, 0xED, 0x7A, 0x53, 0x00, 0xA4, 0x48, 0xB3, 0x50, 0x9E, 0x14, 0xA0, 0x52, 0xDE, 0x7E, 0x10, 0x2B, 0x1B, 0x77, 0x6E, 0, // aligned to 0x80 - }; + ]; public static void CryptStaticXorpadBytes(Span data) { @@ -112,7 +112,7 @@ public static IReadOnlyList Decrypt(Span data) private const int BlockDataRatioEstimate1 = 777; // bytes per block, on average (generous) private const int BlockDataRatioEstimate2 = 555; // bytes per block, on average (stingy) - private static IReadOnlyList ReadBlocks(ReadOnlySpan data) + private static List ReadBlocks(ReadOnlySpan data) { var result = new List(data.Length / BlockDataRatioEstimate2); int offset = 0; diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs index c5a0820fc..aaea10a5d 100644 --- a/PKHeX.Core/Saves/SAV1.cs +++ b/PKHeX.Core/Saves/SAV1.cs @@ -21,7 +21,7 @@ public sealed class SAV1 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo public override PersonalTable1 Personal { get; } - public override ReadOnlySpan HeldItems => Array.Empty(); + public override ReadOnlySpan HeldItems => []; public override IReadOnlyList PKMExtensions => Array.FindAll(PKM.Extensions, f => { @@ -424,10 +424,10 @@ public override IReadOnlyList Inventory get { InventoryPouch[] pouch = - { + [ new InventoryPouchGB(InventoryType.Items, ItemStorage1.Instance, 99, Offsets.Items, 20), new InventoryPouchGB(InventoryType.PCItems, ItemStorage1.Instance, 99, Offsets.PCItems, 50), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/SAV1Stadium.cs b/PKHeX.Core/Saves/SAV1Stadium.cs index b855180dd..641b15bec 100644 --- a/PKHeX.Core/Saves/SAV1Stadium.cs +++ b/PKHeX.Core/Saves/SAV1Stadium.cs @@ -13,7 +13,7 @@ public sealed class SAV1Stadium : SAV_STADIUM public override PersonalTable1 Personal => PersonalTable.Y; public override int MaxEV => EffortValues.Max12; - public override ReadOnlySpan HeldItems => Array.Empty(); + public override ReadOnlySpan HeldItems => []; public override GameVersion Version { get; protected set; } = GameVersion.Stadium; protected override SAV1Stadium CloneInternal() => new((byte[])Data.Clone(), Japanese); @@ -112,8 +112,7 @@ protected override PK1 GetPKM(byte[] data) int len = StringLength; var nick = data.AsSpan(PokeCrypto.SIZE_1STORED, len); var ot = data.AsSpan(PokeCrypto.SIZE_1STORED + len, len); - data = data.Slice(0, PokeCrypto.SIZE_1STORED); - var pk1 = new PK1(data, Japanese); + var pk1 = new PK1(data[..PokeCrypto.SIZE_1STORED], Japanese); nick.CopyTo(pk1.Nickname_Trash); ot.CopyTo(pk1.OT_Trash); return pk1; diff --git a/PKHeX.Core/Saves/SAV1StadiumJ.cs b/PKHeX.Core/Saves/SAV1StadiumJ.cs index 2a8de2297..039f18c36 100644 --- a/PKHeX.Core/Saves/SAV1StadiumJ.cs +++ b/PKHeX.Core/Saves/SAV1StadiumJ.cs @@ -14,7 +14,7 @@ public sealed class SAV1StadiumJ : SAV_STADIUM public override PersonalTable1 Personal => PersonalTable.Y; public override int MaxEV => EffortValues.Max12; - public override ReadOnlySpan HeldItems => Array.Empty(); + public override ReadOnlySpan HeldItems => []; public override GameVersion Version { get; protected set; } = GameVersion.StadiumJ; protected override SAV1StadiumJ CloneInternal() => new((byte[])Data.Clone()); @@ -85,7 +85,7 @@ protected override PK1 GetPKM(byte[] data) const int len = StringLength; var nick = data.AsSpan(0x21, len); var ot = data.AsSpan(0x21 + len, len); - data = data.Slice(0, 0x21); + data = data[..0x21]; var pk1 = new PK1(data, true); nick.CopyTo(pk1.Nickname_Trash); ot.CopyTo(pk1.OT_Trash); diff --git a/PKHeX.Core/Saves/SAV2.cs b/PKHeX.Core/Saves/SAV2.cs index 9e91fc7e3..a18766f87 100644 --- a/PKHeX.Core/Saves/SAV2.cs +++ b/PKHeX.Core/Saves/SAV2.cs @@ -219,14 +219,14 @@ protected override byte[] GetFinalData() { // Calculate oddball checksum ushort sum = 0; - Span<(ushort, ushort)> offsetpairs = stackalloc (ushort,ushort)[] - { + Span<(ushort, ushort)> offsetpairs = + [ (0x106B, 0x1533), (0x1534, 0x1A12), (0x1A13, 0x1C38), (0x3DD8, 0x3F79), (0x7E39, 0x7E6A), - }; + ]; foreach (var p in offsetpairs) { for (int i = p.Item1; i < p.Item2; i++) @@ -555,13 +555,13 @@ public override IReadOnlyList Inventory { var info = Version == GameVersion.C ? ItemStorage2.InstanceC : ItemStorage2.InstanceGS; InventoryPouch[] pouch = - { + [ new InventoryPouchGB(InventoryType.TMHMs, info, 99, Offsets.PouchTMHM, 57), new InventoryPouchGB(InventoryType.Items, info, 99, Offsets.PouchItem, 20), new InventoryPouchGB(InventoryType.KeyItems, info, 99, Offsets.PouchKey, 26), new InventoryPouchGB(InventoryType.Balls, info, 99, Offsets.PouchBall, 12), new InventoryPouchGB(InventoryType.PCItems, info, 99, Offsets.PouchPC, 50), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); @@ -643,7 +643,7 @@ protected override void SetDex(PKM pk) private void SetUnownFormFlags() { - // Give all Unown caught to prevent a crash on pokedex view + // Give all Unown caught to prevent a crash on Pokédex view for (int i = 1; i <= 26; i++) Data[Offsets.PokedexSeen + 0x1F + i] = (byte)i; if (UnownFirstSeen == 0) // Invalid diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index 2fff1bba6..f8f3363b4 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -594,20 +594,18 @@ public sealed override int SetString(Span destBuffer, ReadOnlySpan v public MailDetail GetMail(int mailIndex) { var ofs = GetMailOffset(mailIndex); - var data = Large.Slice(ofs, Mail3.SIZE); + var data = Large.AsSpan(ofs, Mail3.SIZE).ToArray(); return new Mail3(data, ofs, Japanese); } #region eBerry - public abstract byte[] GetEReaderBerry(); - public abstract void SetEReaderBerry(ReadOnlySpan data); - public abstract string EBerryName { get; } - public abstract bool IsEBerryEngima { get; } + public abstract Span EReaderBerry(); + public string EBerryName => GetString(EReaderBerry()[..7]); + public bool IsEBerryEngima => EReaderBerry()[0] is 0 or 0xFF; #endregion #region eTrainer - public abstract byte[] GetEReaderTrainer(); - public abstract void SetEReaderTrainer(ReadOnlySpan data); + public abstract Span EReaderTrainer(); #endregion public abstract Gen3MysteryData MysteryData { get; set; } diff --git a/PKHeX.Core/Saves/SAV3Colosseum.cs b/PKHeX.Core/Saves/SAV3Colosseum.cs index 000ccb26e..297bcf145 100644 --- a/PKHeX.Core/Saves/SAV3Colosseum.cs +++ b/PKHeX.Core/Saves/SAV3Colosseum.cs @@ -40,7 +40,7 @@ public sealed class SAV3Colosseum : SaveFile, IGCSaveFile public SAV3Colosseum() : base(SaveUtil.SIZE_G3COLO) { - BAK = Array.Empty(); + BAK = []; StrategyMemo = Initialize(); ClearBoxes(); } @@ -385,14 +385,14 @@ public override IReadOnlyList Inventory { var info = ItemStorage3Colo.Instance; InventoryPouch[] pouch = - { + [ new InventoryPouch3GC(InventoryType.Items, info, 99, 0x007F8, 20), // 20 COLO, 30 XD new InventoryPouch3GC(InventoryType.KeyItems, info, 1, 0x00848, 43), new InventoryPouch3GC(InventoryType.Balls, info, 99, 0x008F4, 16), new InventoryPouch3GC(InventoryType.TMHMs, info, 99, 0x00934, 64), // no HMs new InventoryPouch3GC(InventoryType.Berries, info, 999, 0x00A34, 46), new InventoryPouch3GC(InventoryType.Medicine, info, 99, 0x00AEC, 3), // Cologne - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/SAV3E.cs b/PKHeX.Core/Saves/SAV3E.cs index a658fdb27..e467adb67 100644 --- a/PKHeX.Core/Saves/SAV3E.cs +++ b/PKHeX.Core/Saves/SAV3E.cs @@ -133,15 +133,15 @@ protected override InventoryPouch3[] GetItems() { const int max = 99; var info = ItemStorage3E.Instance; - return new InventoryPouch3[] - { + return + [ new(InventoryType.Items, info, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), new(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), new(InventoryType.Balls, info, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), new(InventoryType.TMHMs, info, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), new(InventoryType.Berries, info, 999, OFS_PouchBerry, 46), new(InventoryType.PCItems, info, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), - }; + ]; } public PokeBlock3Case PokeBlocks @@ -189,16 +189,11 @@ public int SwarmIndex private const int OFFSET_EBERRY = 0x31F8; private const int SIZE_EBERRY = 0x34; - public override byte[] GetEReaderBerry() => Large.Slice(OFFSET_EBERRY, SIZE_EBERRY); - public override void SetEReaderBerry(ReadOnlySpan data) => data.CopyTo(Large.AsSpan(OFFSET_EBERRY)); - - public override string EBerryName => GetString(Large.AsSpan(OFFSET_EBERRY, 7)); - public override bool IsEBerryEngima => Large[OFFSET_EBERRY] is 0 or 0xFF; + public override Span EReaderBerry() => Large.AsSpan(OFFSET_EBERRY, SIZE_EBERRY); #endregion #region eTrainer - public override byte[] GetEReaderTrainer() => Small.Slice(0xBEC, 0xBC); - public override void SetEReaderTrainer(ReadOnlySpan data) => data.CopyTo(Small.AsSpan(0xBEC)); + public override Span EReaderTrainer() => Small.AsSpan(0xBEC, 0xBC); #endregion public int WonderOffset => WonderNewsOffset; @@ -206,20 +201,26 @@ public int SwarmIndex private int WonderCardOffset => WonderNewsOffset + (Japanese ? WonderNews3.SIZE_JAP : WonderNews3.SIZE); private int WonderCardExtraOffset => WonderCardOffset + (Japanese ? WonderCard3.SIZE_JAP : WonderCard3.SIZE); - public WonderNews3 WonderNews { get => new(Large.Slice(WonderNewsOffset, Japanese ? WonderNews3.SIZE_JAP : WonderNews3.SIZE)); set => SetData(Large.AsSpan(WonderOffset), value.Data); } - public WonderCard3 WonderCard { get => new(Large.Slice(WonderCardOffset, Japanese ? WonderCard3.SIZE_JAP : WonderCard3.SIZE)); set => SetData(Large.AsSpan(WonderCardOffset), value.Data); } - public WonderCard3Extra WonderCardExtra { get => new(Large.Slice(WonderCardExtraOffset, WonderCard3Extra.SIZE)); set => SetData(Large.AsSpan(WonderCardExtraOffset), value.Data); } + private Span WonderNewsData => Large.AsSpan(WonderNewsOffset, Japanese ? WonderNews3.SIZE_JAP : WonderNews3.SIZE); + private Span WonderCardData => Large.AsSpan(WonderCardOffset, Japanese ? WonderCard3.SIZE_JAP : WonderCard3.SIZE); + private Span WonderCardExtraData => Large.AsSpan(WonderCardExtraOffset, WonderCard3Extra.SIZE); + + public WonderNews3 WonderNews { get => new(WonderNewsData.ToArray()); set => SetData(WonderNewsData, value.Data); } + public WonderCard3 WonderCard { get => new(WonderCardData.ToArray()); set => SetData(WonderCardData, value.Data); } + public WonderCard3Extra WonderCardExtra { get => new(WonderCardExtraData.ToArray()); set => SetData(WonderCardExtraData, value.Data); } // 0x338: 4 easy chat words // 0x340: news MENewsJisanStruct // 0x344: uint[5], uint[5] tracking? + private Span MysterySpan => Large.AsSpan(0x3728, MysteryEvent3.SIZE); public override Gen3MysteryData MysteryData { - get => new MysteryEvent3(Large.Slice(0x3728, MysteryEvent3.SIZE)); - set => SetData(Large.AsSpan(0x3728), value.Data); + get => new MysteryEvent3(MysterySpan.ToArray()); + set => SetData(MysterySpan, value.Data); } - public RecordMixing3Gift RecordMixingGift { get => new(Large.Slice(0x3B14, RecordMixing3Gift.SIZE)); set => SetData(Large.AsSpan(0x3B14), value.Data); } + private Span RecordMixingData => Large.AsSpan(0x3B14, RecordMixing3Gift.SIZE); + public RecordMixing3Gift RecordMixingGift { get => new(RecordMixingData.ToArray()); set => SetData(RecordMixingData, value.Data); } protected override int SeenOffset3 => 0x3B24; @@ -235,9 +236,10 @@ public override Gen3MysteryData MysteryData private const int OFS_BV = 31 * 0x1000; // last sector of the save public bool HasBattleVideo => Data.Length > SaveUtil.SIZE_G3RAWHALF && ReadUInt32LittleEndian(Data.AsSpan(OFS_BV)) == EXTRADATA_SENTINEL; + private Span BattleVideoData => Data.AsSpan(OFS_BV + 4, BV3.SIZE); public BV3 BattleVideo { - get => !HasBattleVideo ? new BV3() : new BV3(Data.Slice(OFS_BV + 4, BV3.SIZE)); - set => SetData(Data.AsSpan(OFS_BV + 4, BV3.SIZE), value.Data); + get => !HasBattleVideo ? new BV3(BattleVideoData.ToArray()) : new BV3(); + set => SetData(BattleVideoData, value.Data); } } diff --git a/PKHeX.Core/Saves/SAV3FRLG.cs b/PKHeX.Core/Saves/SAV3FRLG.cs index 24f877d2f..cf1112b6a 100644 --- a/PKHeX.Core/Saves/SAV3FRLG.cs +++ b/PKHeX.Core/Saves/SAV3FRLG.cs @@ -121,15 +121,15 @@ protected override InventoryPouch3[] GetItems() { const int max = 999; var info = ItemStorage3FRLG.Instance; - return new InventoryPouch3[] - { + return + [ new(InventoryType.Items, info, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), new(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), new(InventoryType.Balls, info, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), new(InventoryType.TMHMs, info, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), new(InventoryType.Berries, info, 999, OFS_PouchBerry, 43), new(InventoryType.PCItems, info, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), - }; + ]; } protected override int SeenOffset2 => 0x5F8; @@ -145,16 +145,11 @@ protected override InventoryPouch3[] GetItems() private const int OFFSET_EBERRY = 0x30EC; private const int SIZE_EBERRY = 0x34; - public override byte[] GetEReaderBerry() => Large.Slice(OFFSET_EBERRY, SIZE_EBERRY); - public override void SetEReaderBerry(ReadOnlySpan data) => data.CopyTo(Large.AsSpan(OFFSET_EBERRY)); - - public override string EBerryName => GetString(Large.AsSpan(OFFSET_EBERRY, 7)); - public override bool IsEBerryEngima => Large[OFFSET_EBERRY] is 0 or 0xFF; + public override Span EReaderBerry() => Large.AsSpan(OFFSET_EBERRY, SIZE_EBERRY); #endregion #region eTrainer - public override byte[] GetEReaderTrainer() => Small.Slice(0x4A0, 0xBC); - public override void SetEReaderTrainer(ReadOnlySpan data) => data.CopyTo(Small.AsSpan(0x4A0)); + public override Span EReaderTrainer() => Small.AsSpan(0x4A0, 0xBC); #endregion public int WonderOffset => WonderNewsOffset; @@ -162,18 +157,20 @@ protected override InventoryPouch3[] GetItems() private int WonderCardOffset => WonderNewsOffset + (Japanese ? WonderNews3.SIZE_JAP : WonderNews3.SIZE); private int WonderCardExtraOffset => WonderCardOffset + (Japanese ? WonderCard3.SIZE_JAP : WonderCard3.SIZE); - public WonderNews3 WonderNews { get => new(Large.Slice(WonderNewsOffset, Japanese ? WonderNews3.SIZE_JAP : WonderNews3.SIZE)); set => SetData(Large.AsSpan(WonderOffset), value.Data); } - public WonderCard3 WonderCard { get => new(Large.Slice(WonderCardOffset, Japanese ? WonderCard3.SIZE_JAP : WonderCard3.SIZE)); set => SetData(Large.AsSpan(WonderCardOffset), value.Data); } - public WonderCard3Extra WonderCardExtra { get => new(Large.Slice(WonderCardExtraOffset, WonderCard3Extra.SIZE)); set => SetData(Large.AsSpan(WonderCardExtraOffset), value.Data); } + private Span WonderNewsData => Large.AsSpan(WonderNewsOffset, Japanese ? WonderNews3.SIZE_JAP : WonderNews3.SIZE); + private Span WonderCardData => Large.AsSpan(WonderCardOffset, Japanese ? WonderCard3.SIZE_JAP : WonderCard3.SIZE); + private Span WonderCardExtraData => Large.AsSpan(WonderCardExtraOffset, WonderCard3Extra.SIZE); + + public WonderNews3 WonderNews { get => new(WonderNewsData.ToArray()); set => SetData(WonderNewsData, value.Data); } + public WonderCard3 WonderCard { get => new(WonderCardData.ToArray()); set => SetData(WonderCardData, value.Data); } + public WonderCard3Extra WonderCardExtra { get => new(WonderCardExtraData.ToArray()); set => SetData(WonderCardExtraData, value.Data); } + // 0x338: 4 easy chat words // 0x340: news MENewsJisanStruct // 0x344: uint[5], uint[5] tracking? - public override Gen3MysteryData MysteryData - { - get => new MysteryEvent3(Large.Slice(0x361C, MysteryEvent3.SIZE)); - set => SetData(Large.AsSpan(0x361C), value.Data); - } + private Span MysterySpan => Large.AsSpan(0x361C, MysteryEvent3.SIZE); + public override Gen3MysteryData MysteryData { get => new MysteryEvent3(MysterySpan.ToArray()); set => SetData(MysterySpan, value.Data); } protected override int SeenOffset3 => 0x3A18; diff --git a/PKHeX.Core/Saves/SAV3GCMemoryCard.cs b/PKHeX.Core/Saves/SAV3GCMemoryCard.cs index 6aa14e1de..09cbca8fa 100644 --- a/PKHeX.Core/Saves/SAV3GCMemoryCard.cs +++ b/PKHeX.Core/Saves/SAV3GCMemoryCard.cs @@ -27,7 +27,7 @@ public enum GCMemoryCardState /// /// GameCube save container which may or may not contain Generation 3 objects. /// -public sealed class SAV3GCMemoryCard +public sealed class SAV3GCMemoryCard(byte[] Data) { private const int BLOCK_SIZE = 0x2000; private const int MBIT_TO_BLOCKS = 0x10; @@ -64,8 +64,6 @@ public static bool IsMemoryCardSize(ReadOnlySpan Data) private const int BlockAlloc = BLOCK_SIZE * BlockAlloc_Block; private const int BlockAllocBAK = BLOCK_SIZE * BlockAllocBackup_Block; - public SAV3GCMemoryCard(byte[] data) => Data = data; - // Checksums private (ushort Checksum, ushort Inverse) GetChecksum(int block, int offset, [ConstantExpected(Min = 0)] int length) { @@ -219,7 +217,7 @@ public GCMemoryCardState GetMemoryCardState() ? DirectoryBackup_Block : Directory_Block; - // Search for pokemon savegames in the directory + // Search for Pokémon saves in the directory SaveGameCount = 0; for (int i = 0; i < NumEntries_Directory; i++) { @@ -310,7 +308,7 @@ public void SelectSaveGame(GameVersion Game) } public string GCISaveName => GCISaveGameName(); - public readonly byte[] Data; + public readonly byte[] Data = Data; private string GCISaveGameName() { @@ -337,7 +335,7 @@ public ReadOnlyMemory ReadSaveGameData() { var entry = EntrySelected; if (entry < 0) - return Array.Empty(); // No entry selected + return ReadOnlyMemory.Empty; // No entry selected return ReadSaveGameData(entry); } diff --git a/PKHeX.Core/Saves/SAV3RS.cs b/PKHeX.Core/Saves/SAV3RS.cs index 182fe8bcc..e3cb0e5de 100644 --- a/PKHeX.Core/Saves/SAV3RS.cs +++ b/PKHeX.Core/Saves/SAV3RS.cs @@ -95,15 +95,15 @@ protected override InventoryPouch3[] GetItems() { const int max = 99; var info = ItemStorage3RS.Instance; - return new InventoryPouch3[] - { + return + [ new(InventoryType.Items, info, max, OFS_PouchHeldItem, (OFS_PouchKeyItem - OFS_PouchHeldItem) / 4), new(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, (OFS_PouchBalls - OFS_PouchKeyItem) / 4), new(InventoryType.Balls, info, max, OFS_PouchBalls, (OFS_PouchTMHM - OFS_PouchBalls) / 4), new(InventoryType.TMHMs, info, max, OFS_PouchTMHM, (OFS_PouchBerry - OFS_PouchTMHM) / 4), new(InventoryType.Berries, info, 999, OFS_PouchBerry, 46), new(InventoryType.PCItems, info, 999, OFS_PCItem, (OFS_PouchHeldItem - OFS_PCItem) / 4), - }; + ]; } public PokeBlock3Case PokeBlocks @@ -116,10 +116,11 @@ public PokeBlock3Case PokeBlocks public DecorationInventory3 Decorations => new(Large.AsSpan(0x26A0, DecorationInventory3.SIZE)); + private Span SwarmData => Large.AsSpan(0x2AFC, Swarm3.SIZE); public Swarm3 Swarm { - get => new(Large.Slice(0x2AFC, Swarm3.SIZE)); - set => SetData(Large.AsSpan(0x2AFC), value.Data); + get => new(SwarmData.ToArray()); + set => SetData(SwarmData, value.Data); } private void ClearSwarm() => Large.AsSpan(0x2AFC, Swarm3.SIZE).Clear(); @@ -151,25 +152,18 @@ public int SwarmIndex private const int OFFSET_EBERRY = 0x3160; private const int SIZE_EBERRY = 0x530; - public override byte[] GetEReaderBerry() => Large.Slice(OFFSET_EBERRY, SIZE_EBERRY); - public override void SetEReaderBerry(ReadOnlySpan data) => data.CopyTo(Large.AsSpan(OFFSET_EBERRY)); - - public override string EBerryName => GetString(Large.AsSpan(OFFSET_EBERRY, 7)); - public override bool IsEBerryEngima => Large[OFFSET_EBERRY] is 0 or 0xFF; + public override Span EReaderBerry() => Large.AsSpan(OFFSET_EBERRY, SIZE_EBERRY); #endregion #region eTrainer - public override byte[] GetEReaderTrainer() => Small.Slice(0x498, 0xBC); - public override void SetEReaderTrainer(ReadOnlySpan data) => data.CopyTo(Small.AsSpan(0x498)); + public override Span EReaderTrainer() => Small.AsSpan(0x498, 0xBC); #endregion - public override Gen3MysteryData MysteryData - { - get => new MysteryEvent3RS(Large.Slice(0x3690, MysteryEvent3.SIZE)); - set => SetData(Large.AsSpan(0x3690), value.Data); - } + private Span MysterySpan => Large.AsSpan(0x3690, MysteryEvent3.SIZE); + public override Gen3MysteryData MysteryData { get => new MysteryEvent3(MysterySpan.ToArray()); set => SetData(MysterySpan, value.Data); } - public RecordMixing3Gift RecordMixingGift { get => new(Large.Slice(0x3A7C, RecordMixing3Gift.SIZE)); set => SetData(Large.AsSpan(0x3A7C), value.Data); } + private Span RecordSpan => Large.AsSpan(0x3A7C, RecordMixing3Gift.SIZE); + public RecordMixing3Gift RecordMixingGift { get => new(RecordSpan.ToArray()); set => SetData(RecordSpan, value.Data); } protected override int SeenOffset3 => 0x3A8C; #endregion diff --git a/PKHeX.Core/Saves/SAV3RSBox.cs b/PKHeX.Core/Saves/SAV3RSBox.cs index a9698858e..213da60d2 100644 --- a/PKHeX.Core/Saves/SAV3RSBox.cs +++ b/PKHeX.Core/Saves/SAV3RSBox.cs @@ -22,7 +22,7 @@ public SAV3RSBox(bool japanese = false) : base(SaveUtil.SIZE_G3BOX) { Japanese = japanese; Box = 0; - Blocks = Array.Empty(); + Blocks = []; ClearBoxes(); } @@ -39,7 +39,11 @@ private void InitializeData() int[] SaveCounts = Array.ConvertAll(Blocks, block => (int)block.SaveCount); SaveCount = SaveCounts.Max(); int ActiveSAV = Array.IndexOf(SaveCounts, SaveCount) / BLOCK_COUNT; - Blocks = Blocks.Skip(ActiveSAV * BLOCK_COUNT).Take(BLOCK_COUNT).OrderBy(b => b.ID).ToArray(); + var ordered = Blocks + .Skip(ActiveSAV * BLOCK_COUNT) + .Take(BLOCK_COUNT) + .OrderBy(b => b.ID); + Blocks = [..ordered]; // Set up PC data buffer beyond end of save file. Box = Data.Length; @@ -193,7 +197,7 @@ protected override byte[] DecryptPKM(byte[] data) return PokeCrypto.DecryptArray3(data); } - protected override void SetDex(PKM pk) { /* No Pokedex for this game, do nothing */ } + protected override void SetDex(PKM pk) { /* No Pokédex for this game, do nothing */ } public override void WriteBoxSlot(PKM pk, Span data) { diff --git a/PKHeX.Core/Saves/SAV3XD.cs b/PKHeX.Core/Saves/SAV3XD.cs index bbd67d003..fd088cff4 100644 --- a/PKHeX.Core/Saves/SAV3XD.cs +++ b/PKHeX.Core/Saves/SAV3XD.cs @@ -32,7 +32,7 @@ public sealed class SAV3XD : SaveFile, IGCSaveFile public SAV3XD() : base(SaveUtil.SIZE_G3XD) { - BAK = Array.Empty(); + BAK = []; // create fake objects StrategyMemo = new StrategyMemo(); ShadowInfo = new ShadowInfoTableXD(false); @@ -426,7 +426,7 @@ public override IReadOnlyList Inventory { var info = ItemStorage3XD.Instance; InventoryPouch[] pouch = - { + [ new InventoryPouch3GC(InventoryType.Items, info, 999, OFS_PouchHeldItem, 30), // 20 COLO, 30 XD new InventoryPouch3GC(InventoryType.KeyItems, info, 1, OFS_PouchKeyItem, 43), new InventoryPouch3GC(InventoryType.Balls, info, 999, OFS_PouchBalls, 16), @@ -434,7 +434,7 @@ public override IReadOnlyList Inventory new InventoryPouch3GC(InventoryType.Berries, info, 999, OFS_PouchBerry, 46), new InventoryPouch3GC(InventoryType.Medicine, info, 999, OFS_PouchCologne, 3), // Cologne new InventoryPouch3GC(InventoryType.BattleItems, info, 1, OFS_PouchDisc, 60), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index b5276a89d..d7eb565f2 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -40,7 +40,7 @@ public abstract class SAV4 : SaveFile, IEventFlag37 public sealed override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex); public sealed override void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(General, offset, bitIndex, value); - protected SAV4(int gSize, int sSize) + protected SAV4([ConstantExpected] int gSize, [ConstantExpected] int sSize) { GeneralBuffer = new byte[gSize]; StorageBuffer = new byte[sSize]; @@ -49,7 +49,7 @@ protected SAV4(int gSize, int sSize) ClearBoxes(); } - protected SAV4(byte[] data, int gSize, int sSize, int sStart) : base(data) + protected SAV4(byte[] data, [ConstantExpected] int gSize, [ConstantExpected] int sSize, [ConstantExpected] int sStart) : base(data) { var GeneralBlockPosition = GetActiveBlock(data, 0, gSize); var StorageBlockPosition = GetActiveBlock(data, sStart, sSize); @@ -173,7 +173,7 @@ public sealed override string ChecksumInfo } } - private static int GetActiveBlock(ReadOnlySpan data, [ConstantExpected(Min = 0)] int begin, [ConstantExpected(Min = 0)] int length) + private static int GetActiveBlock(ReadOnlySpan data, [ConstantExpected] int begin, [ConstantExpected] int length) { int offset = begin + length - 0x14; return SAV4BlockDetection.CompareFooters(data, offset, offset + PartitionSize); @@ -189,11 +189,11 @@ private int GetActiveExtraBlock(BlockInfo4 block) // Battle Hall/Battle Videos var KeyOffset = Extra; - var KeyBackupOffset = Extra + 0x4 * (ExtraBlocks.Count - 1); - var PreferOffset = Extra + 2 * 0x4 * (ExtraBlocks.Count - 1); - var key = ReadUInt32LittleEndian(General[(KeyOffset + 0x4 * (index - 1))..]); - var keyBackup = ReadUInt32LittleEndian(General[(KeyBackupOffset + 0x4 * (index - 1))..]); - var prefer = General[(PreferOffset + (index - 1))]; + var KeyBackupOffset = Extra + (0x4 * (ExtraBlocks.Count - 1)); + var PreferOffset = Extra + (2 * 0x4 * (ExtraBlocks.Count - 1)); + var key = ReadUInt32LittleEndian(General[(KeyOffset + (0x4 * (index - 1)))..]); + var keyBackup = ReadUInt32LittleEndian(General[(KeyBackupOffset + (0x4 * (index - 1)))..]); + var prefer = General[PreferOffset + (index - 1)]; return SAV4BlockDetection.CompareExtra(Data, Data.AsSpan(PartitionSize), block, key, keyBackup, prefer); } @@ -412,8 +412,8 @@ private bool MatchMysteryGifts(DataMysteryGift[] value, Span indexes) if (!pcd.GiftEquals(pgt)) continue; - if (this is SAV4HGSS) - j++; // hgss 0,1,2; dppt 1,2,3 + if (this is not SAV4HGSS) + j++; // HG/SS 0,1,2; D/P/Pt 1,2,3 indexes[i] = pgt.Slot = j; break; } diff --git a/PKHeX.Core/Saves/SAV4DP.cs b/PKHeX.Core/Saves/SAV4DP.cs index 839e1a7d5..709da844a 100644 --- a/PKHeX.Core/Saves/SAV4DP.cs +++ b/PKHeX.Core/Saves/SAV4DP.cs @@ -30,9 +30,11 @@ public SAV4DP(byte[] data) : base(data, GeneralSize, StorageSize, GeneralSize) public const int GeneralSize = 0xC100; private const int StorageSize = 0x121E0; // Start 0xC100, +4 starts box data - protected override BlockInfo4[] ExtraBlocks => new[] { + + protected override BlockInfo4[] ExtraBlocks => + [ new BlockInfo4(0, 0x20000, 0x2AC0), // Hall of Fame - }; + ]; private void Initialize() { @@ -89,7 +91,7 @@ public override IReadOnlyList Inventory { var info = ItemStorage4DP.Instance; InventoryPouch[] pouch = - { + [ new InventoryPouch4(InventoryType.Items, info, 999, 0x624), new InventoryPouch4(InventoryType.KeyItems, info, 1, 0x8B8), new InventoryPouch4(InventoryType.TMHMs, info, 99, 0x980), @@ -98,7 +100,7 @@ public override IReadOnlyList Inventory new InventoryPouch4(InventoryType.Berries, info, 999, 0xBE0), new InventoryPouch4(InventoryType.Balls, info, 999, 0xCE0), new InventoryPouch4(InventoryType.BattleItems, info, 999, 0xD1C), - }; + ]; return pouch.LoadAll(General); } set => value.SaveAll(General); @@ -163,13 +165,13 @@ public override Span Rival_Trash public override uint SwarmSeed { get => ReadUInt32LittleEndian(General[0x53C8..]); set => WriteUInt32LittleEndian(General[0x53C8..], value); } public override uint SwarmMaxCountModulo => 28; - protected override ReadOnlySpan TreeSpecies =>new ushort[] - { + protected override ReadOnlySpan TreeSpecies => + [ 000, 000, 000, 000, 000, 000, 265, 266, 415, 412, 420, 190, 415, 412, 420, 190, 214, 265, 446, 446, 446, 446, 446, 446, - }; + ]; public Roamer4 RoamerMesprit => GetRoamer(0); public Roamer4 RoamerCresselia => GetRoamer(1); diff --git a/PKHeX.Core/Saves/SAV4HGSS.cs b/PKHeX.Core/Saves/SAV4HGSS.cs index ac0709770..6726a71e2 100644 --- a/PKHeX.Core/Saves/SAV4HGSS.cs +++ b/PKHeX.Core/Saves/SAV4HGSS.cs @@ -32,14 +32,16 @@ public SAV4HGSS(byte[] data) : base(data, GeneralSize, StorageSize, GeneralSize private const int StorageSize = 0x12310; // Start 0xF700, +0 starts box data private const int GeneralGap = 0xD8; protected override int FooterSize => 0x10; - protected override BlockInfo4[] ExtraBlocks => new[] { + + protected override BlockInfo4[] ExtraBlocks => + [ new BlockInfo4(0, 0x23000, 0x2AC0), // Hall of Fame new BlockInfo4(1, 0x26000, 0x0BB0), // Battle Hall new BlockInfo4(2, 0x27000, 0x1D60), // Battle Video (My Video) new BlockInfo4(3, 0x29000, 0x1D60), // Battle Video (Other Videos 1) new BlockInfo4(4, 0x2B000, 0x1D60), // Battle Video (Other Videos 2) new BlockInfo4(5, 0x2D000, 0x1D60), // Battle Video (Other Videos 3) - }; + ]; private void Initialize() { @@ -106,7 +108,7 @@ public override int CurrentBox public override byte[] BoxFlags { - get => new[] { Storage[BOX_FLAGS] }; + get => [ Storage[BOX_FLAGS] ]; set => Storage[BOX_FLAGS] = value[0]; } @@ -155,7 +157,7 @@ public override IReadOnlyList Inventory { var info = ItemStorage4HGSS.Instance; InventoryPouch[] pouch = - { + [ new InventoryPouch4(InventoryType.Items, info, 999, 0x644), // 0x644-0x8D7 (0x8CB) new InventoryPouch4(InventoryType.KeyItems, info, 1, 0x8D8), // 0x8D8-0x99F (0x979) new InventoryPouch4(InventoryType.TMHMs, info, 99, 0x9A0), // 0x9A0-0xB33 (0xB2F) @@ -164,7 +166,7 @@ public override IReadOnlyList Inventory new InventoryPouch4(InventoryType.Berries, info, 999, 0xC04), // 0xC04-0xD03 new InventoryPouch4(InventoryType.Balls, info, 999, 0xD04), // 0xD04-0xD63 new InventoryPouch4(InventoryType.BattleItems, info, 999, 0xD64), // 0xD64-0xD97 - }; + ]; return pouch.LoadAll(General); } set => value.SaveAll(General); @@ -223,8 +225,8 @@ public void PokeGearClearAllCallers(int start = 0) dex[start..].Fill(PokegearNumber.None); } - private static ReadOnlySpan NotTrainers => new[] - { + private static ReadOnlySpan NotTrainers => + [ PokegearNumber.Mother, PokegearNumber.Professor_Elm, PokegearNumber.Professor_Oak, @@ -236,7 +238,7 @@ public void PokeGearClearAllCallers(int start = 0) PokegearNumber.Bill, PokegearNumber.Bike_Shop, PokegearNumber.Baoba, - }; + ]; public void PokeGearUnlockAllCallersNoTrainers() { diff --git a/PKHeX.Core/Saves/SAV4Pt.cs b/PKHeX.Core/Saves/SAV4Pt.cs index c41e0c7aa..7ee659285 100644 --- a/PKHeX.Core/Saves/SAV4Pt.cs +++ b/PKHeX.Core/Saves/SAV4Pt.cs @@ -29,14 +29,16 @@ public SAV4Pt(byte[] data) : base(data, GeneralSize, StorageSize, GeneralSize) public const int GeneralSize = 0xCF2C; private const int StorageSize = 0x121E4; // Start 0xCF2C, +4 starts box data - protected override BlockInfo4[] ExtraBlocks => new[] { + + protected override BlockInfo4[] ExtraBlocks => + [ new BlockInfo4(0, 0x20000, 0x2AC0), // Hall of Fame new BlockInfo4(1, 0x23000, 0x0BB0), // Battle Hall new BlockInfo4(2, 0x24000, 0x1D60), // Battle Video (My Video) new BlockInfo4(3, 0x26000, 0x1D60), // Battle Video (Other Videos 1) new BlockInfo4(4, 0x28000, 0x1D60), // Battle Video (Other Videos 2) new BlockInfo4(5, 0x2A000, 0x1D60), // Battle Video (Other Videos 3) - }; + ]; private void Initialize() { @@ -105,7 +107,7 @@ public override IReadOnlyList Inventory { var info = ItemStorage4Pt.Instance; InventoryPouch[] pouch = - { + [ new InventoryPouch4(InventoryType.Items, info, 999, 0x630), new InventoryPouch4(InventoryType.KeyItems, info, 1, 0x8C4), new InventoryPouch4(InventoryType.TMHMs, info, 99, 0x98C), @@ -114,7 +116,7 @@ public override IReadOnlyList Inventory new InventoryPouch4(InventoryType.Berries, info, 999, 0xBEC), new InventoryPouch4(InventoryType.Balls, info, 999, 0xCEC), new InventoryPouch4(InventoryType.BattleItems, info, 999, 0xD28), - }; + ]; return pouch.LoadAll(General); } set => value.SaveAll(General); @@ -140,13 +142,13 @@ public override Span Rival_Trash public override uint SwarmSeed { get => ReadUInt32LittleEndian(General[0x5664..]); set => WriteUInt32LittleEndian(General[0x5664..], value); } public override uint SwarmMaxCountModulo => 22; - protected override ReadOnlySpan TreeSpecies => new ushort[] - { + protected override ReadOnlySpan TreeSpecies => + [ 000, 000, 000, 000, 000, 000, 415, 265, 412, 420, 190, 190, 412, 420, 415, 190, 190, 214, 446, 446, 446, 446, 446, 446, - }; + ]; public Roamer4 RoamerMesprit => GetRoamer(0); public Roamer4 RoamerCresselia => GetRoamer(1); diff --git a/PKHeX.Core/Saves/SAV4Sinnoh.cs b/PKHeX.Core/Saves/SAV4Sinnoh.cs index 4f3b0eb1e..599163ee1 100644 --- a/PKHeX.Core/Saves/SAV4Sinnoh.cs +++ b/PKHeX.Core/Saves/SAV4Sinnoh.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -9,12 +10,12 @@ namespace PKHeX.Core; public abstract class SAV4Sinnoh : SAV4 { protected override int FooterSize => 0x14; - protected SAV4Sinnoh(int gSize, int sSize) : base(gSize, sSize) { } - protected SAV4Sinnoh(byte[] data, int gSize, int sSize, int sStart) : base(data, gSize, sSize, sStart) { } + protected SAV4Sinnoh([ConstantExpected] int gSize, [ConstantExpected] int sSize) : base(gSize, sSize) { } + protected SAV4Sinnoh(byte[] data, [ConstantExpected] int gSize, [ConstantExpected] int sSize, [ConstantExpected] int sStart) : base(data, gSize, sSize, sStart) { } #region Storage // u32 currentBox - // box{pk4[30}[18] + // box{pk4[30][18]} // g4str[18] boxNames // byte[18] boxWallpapers private const int BOX_COUNT = 18; @@ -39,7 +40,7 @@ public abstract class SAV4Sinnoh : SAV4 public override byte[] BoxFlags { - get => new[] { Storage[BOX_FLAGS] }; + get => [ Storage [BOX_FLAGS] ]; set => Storage[BOX_FLAGS] = value[0]; } @@ -152,7 +153,6 @@ private Span GetHoneyTreeSpan(int index) /// /// First 40 are the sphere type, last 40 are the sphere sizes /// - /// public Span GetUGI_Spheres() => General.Slice(OFS_UG_Items + 0x78, UG_POUCH_SIZE * 2); #endregion diff --git a/PKHeX.Core/Saves/SAV5.cs b/PKHeX.Core/Saves/SAV5.cs index d732e5bcc..983799c01 100644 --- a/PKHeX.Core/Saves/SAV5.cs +++ b/PKHeX.Core/Saves/SAV5.cs @@ -107,7 +107,7 @@ public override int PartyCount public bool BattleBoxLocked { - get => Data[BattleBoxOffset + 0x358] != 0; // wifi/live + get => Data[BattleBoxOffset + 0x358] != 0; // Wi-Fi/Live Tournament Active set => Data[BattleBoxOffset + 0x358] = value ? (byte)1 : (byte)0; } @@ -176,7 +176,7 @@ private bool CGearSkinPresent set => Data[CGearSkinInfoOffset + 2] = Data[PlayerData.Offset + (this is SAV5B2W2 ? 0x6C : 0x54)] = value ? (byte)1 : (byte)0; } - private static ReadOnlySpan DLCFooter => new byte[] { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x27, 0x00, 0x00, 0x27, 0x35, 0x05, 0x31, 0x00, 0x00 }; + private static ReadOnlySpan DLCFooter => [ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x27, 0x00, 0x00, 0x27, 0x35, 0x05, 0x31, 0x00, 0x00 ]; public byte[] CGearSkinData { diff --git a/PKHeX.Core/Saves/SAV6.cs b/PKHeX.Core/Saves/SAV6.cs index 8227b0393..2a5cb1858 100644 --- a/PKHeX.Core/Saves/SAV6.cs +++ b/PKHeX.Core/Saves/SAV6.cs @@ -52,7 +52,7 @@ public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord, ISaveBlock6Core, IReg public int GetBattleBoxSlot(int slot) => BattleBoxOffset + (slot * SIZE_STORED); public virtual string JPEGTitle => string.Empty; - public virtual byte[] GetJPEGData() => Array.Empty(); + public virtual byte[] GetJPEGData() => []; protected internal const int LongStringLength = 0x22; // bytes, not characters protected internal const int ShortStringLength = 0x1A; // bytes, not characters diff --git a/PKHeX.Core/Saves/SAV6AO.cs b/PKHeX.Core/Saves/SAV6AO.cs index 5ff3ba7bc..ae207991d 100644 --- a/PKHeX.Core/Saves/SAV6AO.cs +++ b/PKHeX.Core/Saves/SAV6AO.cs @@ -175,7 +175,7 @@ public override void SetDaycareHasEgg(int loc, bool hasEgg) } public override string JPEGTitle => !HasJPPEGData ? string.Empty : StringConverter6.GetString(Data.AsSpan(JPEG, 0x1A)); - public override byte[] GetJPEGData() => !HasJPPEGData ? Array.Empty() : Data.AsSpan(JPEG + 0x54, 0xE004).ToArray(); + public override byte[] GetJPEGData() => !HasJPPEGData ? [] : Data.AsSpan(JPEG + 0x54, 0xE004).ToArray(); private bool HasJPPEGData => Data[JPEG + 0x54] == 0xFF; protected override bool[] MysteryGiftReceivedFlags { get => Blocks.MysteryGift.GetReceivedFlags(); set => Blocks.MysteryGift.SetReceivedFlags(value); } diff --git a/PKHeX.Core/Saves/SAV6XY.cs b/PKHeX.Core/Saves/SAV6XY.cs index f0f7e5fb4..c874eb1b7 100644 --- a/PKHeX.Core/Saves/SAV6XY.cs +++ b/PKHeX.Core/Saves/SAV6XY.cs @@ -112,7 +112,7 @@ public override void SetDaycareRNGSeed(int loc, string seed) } public override string JPEGTitle => !HasJPPEGData ? string.Empty : StringConverter6.GetString(Data.AsSpan(JPEG, 0x1A)); - public override byte[] GetJPEGData() => !HasJPPEGData ? Array.Empty() : Data.AsSpan(JPEG + 0x54, 0xE004).ToArray(); + public override byte[] GetJPEGData() => !HasJPPEGData ? [] : Data.AsSpan(JPEG + 0x54, 0xE004).ToArray(); private bool HasJPPEGData => Data[JPEG + 0x54] == 0xFF; public void UnlockAllFriendSafariSlots() diff --git a/PKHeX.Core/Saves/SAV7.cs b/PKHeX.Core/Saves/SAV7.cs index f15f3c72f..32032fe4e 100644 --- a/PKHeX.Core/Saves/SAV7.cs +++ b/PKHeX.Core/Saves/SAV7.cs @@ -29,7 +29,7 @@ protected SAV7(int size, int biOffset) : base(size, biOffset) protected void ReloadBattleTeams() { - var demo = this is SAV7SM && Data.AsSpan(BoxLayout.Offset, 0x4C4).IndexOfAnyExcept(0) == -1; // up to Battle Box values + var demo = this is SAV7SM && !Data.AsSpan(BoxLayout.Offset, 0x4C4).ContainsAnyExcept(0); // up to Battle Box values if (demo || !State.Exportable) { BoxLayout.ClearBattleTeams(); @@ -210,7 +210,7 @@ private static uint GetFormArgument(PKM pk) if (pk.Form == 0) return 0; // Gen7 allows forms to be stored in the box with the current duration & form - // Just cap out the form duration anyways + // Just cap out the form duration anyway return pk.Species switch { (int)Species.Furfrou => 5u, // Furfrou diff --git a/PKHeX.Core/Saves/SAV7b.cs b/PKHeX.Core/Saves/SAV7b.cs index 63bab140b..aebe7e232 100644 --- a/PKHeX.Core/Saves/SAV7b.cs +++ b/PKHeX.Core/Saves/SAV7b.cs @@ -106,7 +106,7 @@ protected override void SetPKM(PKM pk, bool isParty = false) protected override PB7 GetPKM(byte[] data) => new(data); protected override byte[] DecryptPKM(byte[] data) => PokeCrypto.DecryptArray6(data); public override int GetBoxOffset(int box) => Box + (box * BoxSlotCount * SIZE_BOXSLOT); - protected override IList[] SlotPointers => new[] { Blocks.Storage.PokeListInfo }; + protected override IList[] SlotPointers => [ Blocks.Storage.PokeListInfo ]; public override int GetPartyOffset(int slot) => Blocks.Storage.GetPartyOffset(slot); public override int PartyCount { get => Blocks.Storage.PartyCount; protected set => Blocks.Storage.PartyCount = value; } diff --git a/PKHeX.Core/Saves/SAV8LA.cs b/PKHeX.Core/Saves/SAV8LA.cs index e5bf372d1..841b7b94a 100644 --- a/PKHeX.Core/Saves/SAV8LA.cs +++ b/PKHeX.Core/Saves/SAV8LA.cs @@ -13,7 +13,7 @@ public sealed class SAV8LA : SaveFile, ISaveBlock8LA, ISCBlockArray, ISaveFileRe public SAV8LA(byte[] data) : this(SwishCrypto.Decrypt(data)) { } - private SAV8LA(IReadOnlyList blocks) : base(Array.Empty()) + private SAV8LA(IReadOnlyList blocks) : base([]) { AllBlocks = blocks; Blocks = new SaveBlockAccessor8LA(this); @@ -195,12 +195,12 @@ public override bool GetCaught(ushort species) public override byte[] BoxFlags { - get => new[] - { + get => + [ Convert.ToByte(Blocks.GetBlock(SaveBlockAccessor8LA.KUnlockedSecretBox01).Type - 1), Convert.ToByte(Blocks.GetBlock(SaveBlockAccessor8LA.KUnlockedSecretBox02).Type - 1), Convert.ToByte(Blocks.GetBlock(SaveBlockAccessor8LA.KUnlockedSecretBox03).Type - 1), - }; + ]; set { if (value.Length != 3) diff --git a/PKHeX.Core/Saves/SAV8SWSH.cs b/PKHeX.Core/Saves/SAV8SWSH.cs index 946b49859..c9f3f792b 100644 --- a/PKHeX.Core/Saves/SAV8SWSH.cs +++ b/PKHeX.Core/Saves/SAV8SWSH.cs @@ -10,7 +10,7 @@ public sealed class SAV8SWSH : SaveFile, ISaveBlock8SWSH, ITrainerStatRecord, IS { public SAV8SWSH(byte[] data) : this(SwishCrypto.Decrypt(data)) { } - private SAV8SWSH(IReadOnlyList blocks) : base(Array.Empty()) + private SAV8SWSH(IReadOnlyList blocks) : base([]) { AllBlocks = blocks; Blocks = new SaveBlockAccessor8SWSH(this); @@ -277,7 +277,10 @@ public override StorageSlotSource GetSlotFlags(int index) public override byte[] BoxFlags { - get => new [] {(byte)(Blocks.GetBlock(SaveBlockAccessor8SWSH.KSecretBoxUnlocked).Type - 1)}; + get => + [ + (byte)(Blocks.GetBlock(SaveBlockAccessor8SWSH.KSecretBoxUnlocked).Type - 1), + ]; set { if (value.Length != 1) @@ -313,7 +316,7 @@ public void UnlockAllDiglett() // Zone specific values (int Zone, int Max)[] zones = - { + [ (0201, 16), // Fields of Honor (0202, 18), // Soothing Wetlands (0203, 6), // Forest of Focus @@ -330,7 +333,7 @@ public void UnlockAllDiglett() (0223, 3), // Insular Sea (0224, 1), // Honeycalm Sea (0231, 9), // Honeycalm Island - }; + ]; var s = Blocks; foreach (var (zone, max) in zones) { diff --git a/PKHeX.Core/Saves/SAV9SV.cs b/PKHeX.Core/Saves/SAV9SV.cs index 461c5ae36..c161d4606 100644 --- a/PKHeX.Core/Saves/SAV9SV.cs +++ b/PKHeX.Core/Saves/SAV9SV.cs @@ -14,7 +14,7 @@ public sealed class SAV9SV : SaveFile, ISaveBlock9Main, ISCBlockArray, ISaveFile public SAV9SV(byte[] data) : this(SwishCrypto.Decrypt(data)) { } - private SAV9SV(IReadOnlyList blocks) : base(Array.Empty()) + private SAV9SV(IReadOnlyList blocks) : base([]) { AllBlocks = blocks; Blocks = new SaveBlockAccessor9SV(this); @@ -340,13 +340,13 @@ public void CollectAllStakes() } } - var blocks = new[] - { + string[] blocks = + [ "WEVT_SUB_014_EVENT_STATE_UTHUWA", "WEVT_SUB_015_EVENT_STATE_TSURUGI", "WEVT_SUB_016_EVENT_STATE_MOKKAN", "WEVT_SUB_017_EVENT_STATE_MAGATAMA", - }; + ]; foreach (var block in blocks) Accessor.GetBlock(block).SetValue(1); // lift seals from each shrine diff --git a/PKHeX.Core/Saves/SaveFile.cs b/PKHeX.Core/Saves/SaveFile.cs index 0f8a8cbf7..89d5b953b 100644 --- a/PKHeX.Core/Saves/SaveFile.cs +++ b/PKHeX.Core/Saves/SaveFile.cs @@ -22,7 +22,7 @@ protected SaveFile(byte[] data, bool exportable = true) Metadata = new SaveFileMetadata(this); } - protected SaveFile(int size = 0) : this(size == 0 ? Array.Empty() : new byte[size], false) { } + protected SaveFile(int size = 0) : this(size == 0 ? [] : new byte[size], false) { } protected internal abstract string ShortSummary { get; } public abstract string Extension { get; } @@ -113,15 +113,15 @@ public void SetData(Span dest, ReadOnlySpan input) /// Flag is Set (true) or not Set (false) public virtual void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(Data, offset, bitIndex, value); - public virtual IReadOnlyList Inventory { get => Array.Empty(); set { } } + public virtual IReadOnlyList Inventory { get => []; set { } } #region Mystery Gift protected virtual int GiftCountMax => int.MinValue; protected virtual int GiftFlagMax => 0x800; protected int WondercardData { get; set; } = int.MinValue; public bool HasWondercards => WondercardData > -1; - protected virtual bool[] MysteryGiftReceivedFlags { get => Array.Empty(); set { } } - protected virtual DataMysteryGift[] MysteryGiftCards { get => Array.Empty(); set { } } + protected virtual bool[] MysteryGiftReceivedFlags { get => []; set { } } + protected virtual DataMysteryGift[] MysteryGiftCards { get => []; set { } } public virtual MysteryGiftAlbum GiftAlbum { @@ -360,7 +360,7 @@ protected virtual void SetPartyValues(PKM pk, bool isParty) ///
/// Entity to adapt /// Entity exists in party format - /// Setting on whether or not to adapt + /// Setting on whether to adapt public void AdaptPKM(PKM pk, bool party = true, PKMImportSetting trade = PKMImportSetting.UseDefault) { if (GetTradeUpdateSetting(trade)) @@ -434,7 +434,7 @@ public int CaughtCount public bool HasBox => Box > -1; public virtual int BoxSlotCount => 30; public virtual int BoxesUnlocked { get => -1; set { } } - public virtual byte[] BoxFlags { get => Array.Empty(); set { } } + public virtual byte[] BoxFlags { get => []; set { } } public virtual int CurrentBox { get; set; } #region BoxData @@ -492,12 +492,12 @@ public void AddBoxData(IList data, int box, int index) #endregion #region Storage Health & Metadata - protected int[] TeamSlots = Array.Empty(); + protected int[] TeamSlots = []; /// /// Slot indexes that are protected from overwriting. /// - protected virtual IList[] SlotPointers => new[] { TeamSlots }; + protected virtual IList[] SlotPointers => [ TeamSlots ]; public virtual StorageSlotSource GetSlotFlags(int index) => StorageSlotSource.None; public StorageSlotSource GetSlotFlags(int box, int slot) => GetSlotFlags((box * BoxSlotCount) + slot); public bool IsSlotLocked(int box, int slot) => GetSlotFlags(box, slot).HasFlag(StorageSlotSource.Locked); @@ -896,7 +896,7 @@ public static bool CompressStorage(this SaveFile sav, Span storage, out in { if (ctr != i) // copy required { - shiftedSlots = true; // appending empty slots afterwards is now required since a rewrite was done + shiftedSlots = true; // appending empty slots afterward is now required since a rewrite was done int destOfs = sav.GetBoxSlotOffset(ctr); storage[offset..(offset + size)].CopyTo(storage[destOfs..(destOfs + size)]); SlotPointerUtil.UpdateRepointFrom(ctr, i, slotPointers); diff --git a/PKHeX.Core/Saves/SaveFileMetadata.cs b/PKHeX.Core/Saves/SaveFileMetadata.cs index c2f92661e..5a5bc525e 100644 --- a/PKHeX.Core/Saves/SaveFileMetadata.cs +++ b/PKHeX.Core/Saves/SaveFileMetadata.cs @@ -26,8 +26,8 @@ public sealed record SaveFileMetadata(SaveFile SAV) ///
public string? FileFolder { get; private set; } - private byte[] Footer = Array.Empty(); // .dsv - private byte[] Header = Array.Empty(); // .gci + private byte[] Footer = []; // .dsv + private byte[] Header = []; // .gci private string BAKSuffix => $" [{SAV.ShortSummary}].bak"; @@ -53,9 +53,9 @@ public sealed record SaveFileMetadata(SaveFile SAV) public byte[] Finalize(byte[] data, BinaryExportSetting setting) { if (Footer.Length > 0 && setting.HasFlag(BinaryExportSetting.IncludeFooter)) - return ArrayUtil.ConcatAll(data, Footer); + return [..data, ..Footer]; if (Header.Length > 0 && setting.HasFlag(BinaryExportSetting.IncludeHeader)) - return ArrayUtil.ConcatAll(Header, data); + return [..Header, ..data]; return data; } diff --git a/PKHeX.Core/Saves/Storage/SAV4Ranch.cs b/PKHeX.Core/Saves/Storage/SAV4Ranch.cs index 291dd5bcd..8b03c528b 100644 --- a/PKHeX.Core/Saves/Storage/SAV4Ranch.cs +++ b/PKHeX.Core/Saves/Storage/SAV4Ranch.cs @@ -56,7 +56,7 @@ public SAV4Ranch(byte[] data) : base(data, typeof(RK4), 0) // Block 00, Offset = Metadata object // Block 01, Offset = Mii Data Array object // Block 02, Offset = Mii Link Data Array object - // Block 03, Offset = Pokemon Data Array object + // Block 03, Offset = Pokémon Data Array object // Block 04, Offset = reserved object // Unpack the binary a little: @@ -96,7 +96,7 @@ public RanchToy GetRanchToy(int index) throw new ArgumentOutOfRangeException(nameof(index)); int toyOffset = ToyBaseOffset + (RanchToy.SIZE * index); - var data = Data.Slice(toyOffset, RanchToy.SIZE); + var data = Data.AsSpan(toyOffset, RanchToy.SIZE).ToArray(); return new RanchToy(data); } @@ -117,7 +117,7 @@ public RanchMii GetRanchMii(int index) throw new ArgumentOutOfRangeException(nameof(index)); int offset = MiiDataOffset + (RanchMii.SIZE * index); - var data = Data.Slice(offset, RanchMii.SIZE); + var data = Data.AsSpan(offset, RanchMii.SIZE).ToArray(); return new RanchMii(data); } @@ -136,7 +136,7 @@ public RanchTrainerMii GetRanchTrainerMii(int index) throw new ArgumentOutOfRangeException(nameof(index)); int offset = TrainerMiiDataOffset + (RanchTrainerMii.SIZE * index); - var data = Data.Slice(offset, RanchTrainerMii.SIZE); + var data = Data.AsSpan(offset, RanchTrainerMii.SIZE).ToArray(); return new RanchTrainerMii(data); } @@ -180,7 +180,7 @@ private int GetOccupiedSlotCount() protected override byte[] DecryptPKM(byte[] data) { - var pokeData = PokeCrypto.DecryptArray45(data.Slice(0, PokeCrypto.SIZE_4STORED)); + var pokeData = PokeCrypto.DecryptArray45(data.AsSpan(0, PokeCrypto.SIZE_4STORED)); var ranchData = data.AsSpan(PokeCrypto.SIZE_4STORED, 0x1C); var finalData = new byte[SIZE_STORED]; @@ -210,7 +210,7 @@ public override void WriteBoxSlot(PKM pk, Span data) bool isBlank = pk.Data.SequenceEqual(BlankPKM.Data); if (!isBlank && rk4.OwnershipType == RanchOwnershipType.None) - rk4.OwnershipType = RanchOwnershipType.Hayley; // Pokemon without an Ownership type get erased when the save is loaded. Hayley is considered 'default'. + rk4.OwnershipType = RanchOwnershipType.Hayley; // Pokémon without an Ownership type get erased when the save is loaded. Hayley is considered 'default'. base.WriteBoxSlot(rk4, data); } diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV3.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV3.cs index fad8ea1dc..d07f22ab0 100644 --- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV3.cs +++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV3.cs @@ -5,15 +5,17 @@ namespace PKHeX.Core; -public sealed class BV3 : BattleVideo +public sealed class BV3(byte[] Data) : BattleVideo { + public BV3() : this(new byte[SIZE]) { } + + public readonly byte[] Data = (byte[])Data.Clone(); + internal const int SIZE = 0xF80; public override int Generation => 3; public override IReadOnlyList BattlePKMs => PlayerTeams.SelectMany(z => z).ToArray(); - public readonly byte[] Data; - internal new static bool IsValid(ReadOnlySpan data) { if (data.Length != SIZE) @@ -28,16 +30,9 @@ internal new static bool IsValid(ReadOnlySpan data) return chk == expect; } - public BV3(byte[] data) => Data = (byte[])data.Clone(); - public BV3() : this(new byte[SIZE]) { } - public IReadOnlyList PlayerTeams { - get => new[] - { - GetTeam(0), - GetTeam(1), - }; + get => [GetTeam(0), GetTeam(1)]; set { SetTeam(value[0], 0); @@ -55,7 +50,8 @@ public PK3[] GetTeam(int teamIndex) for (int p = 0; p < 6; p++) { int offset = ofs + (PokeCrypto.SIZE_3PARTY * p); - team[p] = new PK3(Data.Slice(offset, PokeCrypto.SIZE_3PARTY)); + var span = Data.AsSpan(offset, PokeCrypto.SIZE_3PARTY); + team[p] = new PK3(span.ToArray()); } return team; diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs index 196e0df38..e76111e27 100644 --- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs +++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV6.cs @@ -6,11 +6,12 @@ namespace PKHeX.Core; -public sealed class BV6 : BattleVideo +public sealed class BV6(byte[] Data) : BattleVideo { + private readonly byte[] Data = (byte[])Data.Clone(); + public const int SIZE = 0x2E60; private const string NPC = "NPC"; - private readonly byte[] Data; private const int PlayerCount = 4; public override IReadOnlyList BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray(); @@ -23,7 +24,6 @@ internal new static bool IsValid(ReadOnlySpan data) return ReadUInt64LittleEndian(data[0xE18..]) != 0 && ReadUInt16LittleEndian(data[0xE12..]) == 0; } - public BV6(byte[] data) => Data = (byte[])data.Clone(); public int Mode { get => Data[0x00]; set => Data[0x00] = (byte)value; } public int Style { get => Data[0x01]; set => Data[0x01] = (byte)value; } @@ -99,7 +99,8 @@ public PK6[] GetTeam(int t) { int offset = start + (PokeCrypto.SIZE_6PARTY * ((t * 6) + p)); offset += 8 * (((t * 6) + p) / 6); // 8 bytes padding between teams - team[p] = new PK6(Data.Slice(offset, PokeCrypto.SIZE_6PARTY)); + var span = Data.AsSpan(offset, PokeCrypto.SIZE_6PARTY); + team[p] = new PK6(span.ToArray()); } return team; diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs index 5402551d0..263c35f51 100644 --- a/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs +++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BV7.cs @@ -5,21 +5,19 @@ namespace PKHeX.Core; -public sealed class BV7 : BattleVideo +public sealed class BV7(byte[] data) : BattleVideo { public const int SIZE = 0x2BC0; private const string NPC = "NPC"; private const int PlayerCount = 4; public override int Generation => 7; - private readonly byte[] Data; + private readonly byte[] Data = (byte[])data.Clone(); public override IReadOnlyList BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray(); internal new static bool IsValid(ReadOnlySpan data) => data.Length == SIZE; - public BV7(byte[] data) => Data = (byte[])data.Clone(); - - private static ReadOnlySpan offsets => new ushort[] { 0xE41, 0x145E, 0x1A7B, 0x2098 }; + private static ReadOnlySpan TeamOffsets => [0xE41, 0x145E, 0x1A7B, 0x2098]; public IReadOnlyList PlayerTeams { @@ -40,11 +38,12 @@ public IReadOnlyList PlayerTeams public PK7[] GetTeam(int teamIndex) { var team = new PK7[6]; - var ofs = offsets[teamIndex]; + var ofs = TeamOffsets[teamIndex]; for (int p = 0; p < 6; p++) { int offset = ofs + (PokeCrypto.SIZE_6PARTY * p); - team[p] = new PK7(Data.Slice(offset, PokeCrypto.SIZE_6STORED)); + var span = Data.AsSpan(offset, PokeCrypto.SIZE_6STORED); + team[p] = new PK7(span.ToArray()); } return team; @@ -52,7 +51,7 @@ public PK7[] GetTeam(int teamIndex) public void SetTeam(IReadOnlyList team, int teamIndex) { - var ofs = offsets[teamIndex]; + var ofs = TeamOffsets[teamIndex]; for (int p = 0; p < 6; p++) { int offset = ofs + (PokeCrypto.SIZE_6PARTY * p); diff --git a/PKHeX.Core/Saves/Substructures/Gen12/G1OverworldSpawner.cs b/PKHeX.Core/Saves/Substructures/Gen12/G1OverworldSpawner.cs index b052c1715..cd487fe8c 100644 --- a/PKHeX.Core/Saves/Substructures/Gen12/G1OverworldSpawner.cs +++ b/PKHeX.Core/Saves/Substructures/Gen12/G1OverworldSpawner.cs @@ -104,21 +104,9 @@ public sealed class FlagPairG1 internal FlagPairG1(int hide) => SpawnFlag = hide; } -public sealed class FlagPairG1Detail +public sealed class FlagPairG1Detail(FlagPairG1 Backing, string Name, bool[] Event, bool[] Spawn) { - private readonly FlagPairG1 Backing; - public readonly string Name; - - private readonly bool[] Event; - private readonly bool[] Spawn; - - public FlagPairG1Detail(FlagPairG1 back, string name, bool[] ev, bool[] spawn) - { - Backing = back; - Name = name; - Event = ev; - Spawn = spawn; - } + public readonly string Name = Name; public void Invert() => SetState(!IsHidden); public void Reset() => SetState(false); diff --git a/PKHeX.Core/Saves/Substructures/Gen3/DecorationInventory3.cs b/PKHeX.Core/Saves/Substructures/Gen3/DecorationInventory3.cs index 62de6cbaf..2290b7b56 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/DecorationInventory3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/DecorationInventory3.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace PKHeX.Core; @@ -9,6 +9,7 @@ namespace PKHeX.Core; public const int SIZE = 150; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public DecorationInventory3(Span data) => Data = data; public Span Desk => MemoryMarshal.Cast(Data[..10]); diff --git a/PKHeX.Core/Saves/Substructures/Gen3/EReaderBerrySettings.cs b/PKHeX.Core/Saves/Substructures/Gen3/EReaderBerrySettings.cs index fdbb64eff..7f878af33 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/EReaderBerrySettings.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/EReaderBerrySettings.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System; using static PKHeX.Core.EReaderBerryMatch; namespace PKHeX.Core; @@ -27,8 +27,8 @@ public static EReaderBerryMatch GetStatus() if (IsEnigma) // no e-Reader Berry data provided, can't hold berry. return NoData; - var name = Name; - if (EReaderBerriesNames_USA.Contains(name)) + ReadOnlySpan name = Name; + if (IsEReaderBerriesNameUSA(name)) { return Language switch { @@ -37,7 +37,7 @@ public static EReaderBerryMatch GetStatus() _ => InvalidUSA, }; } - if (EReaderBerriesNames_JP.Contains(name)) + if (IsEReaderBerriesNameJPN(name)) { return Language switch { @@ -49,35 +49,31 @@ public static EReaderBerryMatch GetStatus() return NoMatch; } - private static readonly HashSet EReaderBerriesNames_USA = new() - { - // USA Series 1 - "PUMKIN", - "DRASH", - "EGGANT", - "STRIB", - "CHILAN", - "NUTPEA", - }; + public static bool IsEReaderBerriesNameUSA(ReadOnlySpan name) => name is + "PUMKIN" or + "DRASH" or + "EGGANT" or + "STRIB" or + "CHILAN" or + "NUTPEA" + ; - private static readonly HashSet EReaderBerriesNames_JP = new() - { - // JP Series 1 - "カチャ", // PUMKIN - "ブ-カ", // DRASH - "ビスナ", // EGGANT - "エドマ", // STRIB - "ホズ", // CHILAN - "ラッカ", // NUTPEA - "クオ", // KU + public static bool IsEReaderBerriesNameJPN(ReadOnlySpan name) => name is + "カチャ" or // PUMKIN + "ブ-カ" or // DRASH + "ビスナ" or // EGGANT + "エドマ" or // STRIB + "ホズ" or // CHILAN + "ラッカ" or // NUTPEA + "クオ" or // KU // JP Series 2 - "ギネマ", // GINEMA - "クオ", // KUO - "ヤゴ", // YAGO - "トウガ", // TOUGA - "ニニク", // NINIKU - "トポ", // TOPO - }; + "ギネマ" or // GINEMA + "クオ" or // KUO + "ヤゴ" or // YAGO + "トウガ" or // TOUGA + "ニニク" or // NINIKU + "トポ" // TOPO + ; public static void LoadFrom(SAV3 sav3) { diff --git a/PKHeX.Core/Saves/Substructures/Gen3/Gen3MysteryData.cs b/PKHeX.Core/Saves/Substructures/Gen3/Gen3MysteryData.cs index b0d786660..e7f1f3a00 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/Gen3MysteryData.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/Gen3MysteryData.cs @@ -30,8 +30,8 @@ private static ushort GetChecksum(ReadOnlySpan data) return (ushort)~chk; } - private static ReadOnlySpan CRCTable => new ushort[] - { + private static ReadOnlySpan CRCTable => + [ 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, @@ -64,5 +64,5 @@ private static ushort GetChecksum(ReadOnlySpan data) 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs b/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs index 9d8e600bd..a7e5db3bb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs @@ -4,24 +4,13 @@ namespace PKHeX.Core; -public sealed class HallFame3Entry +public sealed class HallFame3Entry(byte[] Data, int Offset, bool Japanese) { - private readonly byte[] Parent; - private readonly bool Japanese; - private readonly int Offset; - private const int Count = 6; public const int SIZE = Count * HallFame3PKM.SIZE; - public HallFame3Entry(byte[] data, int offset, bool japanese) - { - Parent = data; - Japanese = japanese; - Offset = offset; - } - private int GetMemberOffset(int index) => Offset + (index * HallFame3PKM.SIZE); - private HallFame3PKM GetMember(int index) => new(Parent, GetMemberOffset(index), Japanese); + private HallFame3PKM GetMember(int index) => new(Data, GetMemberOffset(index), Japanese); public HallFame3PKM[] Team { @@ -56,20 +45,11 @@ public static void SetEntries(SAV3 sav, HallFame3Entry[] entries) } } -public sealed class HallFame3PKM : ISpeciesForm +public sealed class HallFame3PKM(byte[] Data, int Offset, bool Japanese) : ISpeciesForm { public const int SIZE = 20; - public HallFame3PKM(byte[] data, int offset, bool jp) - { - Data = data; - Offset = offset; - Japanese = jp; - } - - public readonly byte[] Data; - private readonly int Offset; - private readonly bool Japanese; + public readonly byte[] Data = Data; public int TID16 { get => ReadUInt16LittleEndian(Data.AsSpan(0 + Offset)); set => WriteUInt16LittleEndian(Data.AsSpan(0 + Offset), (ushort)value); } public int SID16 { get => ReadUInt16LittleEndian(Data.AsSpan(2 + Offset)); set => WriteUInt16LittleEndian(Data.AsSpan(2 + Offset), (ushort)value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen3/PokeBlock3.cs b/PKHeX.Core/Saves/Substructures/Gen3/PokeBlock3.cs index 9f735b518..10a8aa6a7 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/PokeBlock3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/PokeBlock3.cs @@ -2,11 +2,9 @@ namespace PKHeX.Core; -public sealed class PokeBlock3 +public sealed class PokeBlock3(byte[] Data) { public const int SIZE = 8; - private readonly byte[] Data; - public PokeBlock3(byte[] data) => Data = data; public PokeBlock3Color Color { get => (PokeBlock3Color)Data[0]; set => Data[0] = (byte)value; } public byte Spicy { get => Data[1]; set => Data[1] = value; } @@ -27,7 +25,7 @@ public void Maximize(bool create = false) Color = PokeBlock3Color.Gold; } - public void SetBlock(Span data) => Data.CopyTo(data); + public void SetBlock(Span data1) => Data.CopyTo(data1); public static PokeBlock3 GetBlock(ReadOnlySpan data, int offset) { diff --git a/PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs b/PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs index 353450683..ff0308ba0 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/RTC3.cs @@ -1,15 +1,13 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; -public sealed class RTC3 +public sealed class RTC3(byte[] Data) { - public readonly byte[] Data; + public readonly byte[] Data = Data; public const int Size = 8; - public RTC3(byte[] data) => Data = data; - public int Day { get => ReadUInt16LittleEndian(Data.AsSpan(0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(0x00), (ushort)value); } public int Hour { get => Data[2]; set => Data[2] = (byte)value; } public int Minute { get => Data[3]; set => Data[3] = (byte)value; } diff --git a/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs b/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs index 9b4033f6e..85636dcde 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/Record3.cs @@ -4,10 +4,8 @@ namespace PKHeX.Core; -public sealed class Record3 +public sealed class Record3(SAV3 SAV) { - private readonly SAV3 SAV; - public uint GetRecord(int record) => ReadUInt32LittleEndian(SAV.Large.AsSpan(GetRecordOffset(record))) ^ SAV.SecurityKey; public void SetRecord(int record, uint value) => WriteUInt32LittleEndian(SAV.Large.AsSpan(GetRecordOffset(record)), value ^ SAV.SecurityKey); @@ -18,8 +16,6 @@ private int GetRecordOffset(int record) return offset; } - public Record3(SAV3 sav) => SAV = sav; - public static int GetOffset(GameVersion ver) => ver switch { GameVersion.RS or GameVersion.R or GameVersion.S => 0x1540, diff --git a/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs b/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs index 9c838d528..c50f7984d 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs @@ -75,7 +75,7 @@ public int CurrentLevel ///
public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set => SetIVs(value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs index 3e8271f02..962f091f4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3.cs @@ -3,18 +3,10 @@ namespace PKHeX.Core; -public sealed class SecretBase3 +public sealed class SecretBase3(byte[] Data, int Offset) { - private readonly byte[] Data; - private readonly int Offset; private bool Japanese => Language == (int) LanguageID.Japanese; - public SecretBase3(byte[] data, int offset) - { - Data = data; - Offset = offset; - } - public int SecretBaseLocation { get => Data[Offset + 0]; set => Data[Offset + 0] = (byte) value; } public int OT_Gender @@ -60,15 +52,16 @@ public ushort SecretBasesReceived public int Unused11 { get => Data[Offset + 0x11]; set => Data[Offset + 0x11] = (byte)value; } // alignment padding public Span GetDecorations() => Data.AsSpan(Offset + 0x12, 0x10); - public void SetDecorations(Span value) => value.CopyTo(Data.AsSpan(Offset + 0x12, 0x10)); + public void SetDecorations(Span value) => value.CopyTo(GetDecorations()); - public Span GetDecorationCoordinates() => Data.Slice(Offset + 0x22, 0x10); - public void SetDecorationCoordinates(Span value) => value.CopyTo(Data.AsSpan(Offset + 0x22, 0x10)); + public Span GetDecorationCoordinates() => Data.AsSpan(Offset + 0x22, 0x10); + public void SetDecorationCoordinates(Span value) => value.CopyTo(GetDecorationCoordinates()); + private Span TeamData => Data.AsSpan(Offset + 50, 72); public SecretBase3Team Team { - get => new(Data.Slice(Offset + 50, 72)); - set => value.Write().CopyTo(Data, Offset + 50); + get => new(TeamData.ToArray()); + set => value.Write().CopyTo(TeamData); } public int TID16 diff --git a/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs b/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs index e5c9481d8..715d8a992 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/StrategyMemo.cs @@ -66,18 +66,11 @@ public void SetEntry(StrategyMemoEntry entry) } } -public sealed class StrategyMemoEntry +public sealed class StrategyMemoEntry(bool XD, byte[] Data) { - public readonly byte[] Data; - private readonly bool XD; + public readonly byte[] Data = Data; - public StrategyMemoEntry(bool xd) : this(xd, new byte[StrategyMemo.SIZE_ENTRY]) { } - - public StrategyMemoEntry(bool xd, byte[] data) - { - Data = data; - XD = xd; - } + public StrategyMemoEntry(bool XD) : this(XD, new byte[StrategyMemo.SIZE_ENTRY]) { } public ushort Species { diff --git a/PKHeX.Core/Saves/Substructures/Gen3/Swarm3.cs b/PKHeX.Core/Saves/Substructures/Gen3/Swarm3.cs index c7e12f0af..e53a30529 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/Swarm3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/Swarm3.cs @@ -7,10 +7,10 @@ namespace PKHeX.Core; [StructLayout(LayoutKind.Sequential, Pack = 4, Size = SIZE)] -public sealed class Swarm3 +public sealed class Swarm3(byte[] Data) { public const int SIZE = 0x14; - public readonly byte[] Data; + public readonly byte[] Data = Data; private Span Raw => Data.AsSpan(); @@ -28,8 +28,6 @@ public sealed class Swarm3 public byte EncounterProbability { get => Raw[0x11]; set => Raw[0x11] = value; } public ushort DaysLeft { get => ReadUInt16LittleEndian(Raw[0x12..]); set => WriteUInt16LittleEndian(Raw[0x12..], value); } - public Swarm3(byte[] data) => Data = data; - public Swarm3(Species species, byte level, byte map, Move m1, Move m2 = 0, Move m3 = 0, Move m4 = 0) : this(new byte[SIZE]) { Gen3Species = SpeciesConverter.GetInternal3((ushort)species); @@ -47,20 +45,20 @@ public Swarm3(Species species, byte level, byte map, Move m1, Move m2 = 0, Move public static class Swarm3Details { public static readonly Swarm3[] Swarms_RS = - { + [ new(Surskit, 03, 0x11, Bubble, QuickAttack), // Route 102 new(Surskit, 15, 0x1D, Bubble, QuickAttack), // Route 114 new(Surskit, 15, 0x20, Bubble, QuickAttack), // Route 117 new(Surskit, 28, 0x23, Bubble, QuickAttack), // Route 120 new(Skitty, 15, 0x1F, Growl, Tackle), // Route 116 - }; + ]; public static readonly Swarm3[] Swarms_E = - { + [ new(Seedot, 03, 0x11, Bide, Harden, LeechSeed), // Route 102 new(Nuzleaf, 15, 0x1D, Harden, Growth, NaturePower, LeechSeed), // Route 114 new(Seedot, 13, 0x20, Harden, Growth, NaturePower, LeechSeed), // Route 117 new(Seedot, 25, 0x23, GigaDrain, Frustration, SolarBeam, LeechSeed), // Route 120 new(Skitty, 08, 0x1F, Growl, Tackle, TailWhip, Attract), // Route 116 - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Dendou4.cs b/PKHeX.Core/Saves/Substructures/Gen4/Dendou4.cs index 33a0d2149..281542718 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Dendou4.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Dendou4.cs @@ -68,6 +68,7 @@ private Dendou4Record GetRecord(int index) private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public Dendou4Record(Span data) => Data = data; public Dendou4Entity this[int index] => GetEntity(index); @@ -91,6 +92,7 @@ private Dendou4Entity GetEntity(int index) public const int SIZE = 0x3C; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public Dendou4Entity(Span data) => Data = data; public ushort Species { get => ReadUInt16LittleEndian(Data); set => WriteUInt16LittleEndian(Data, value); } public byte Level { get => Data[2]; set => Data[2] = value; } diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Geonet4.cs b/PKHeX.Core/Saves/Substructures/Gen4/Geonet4.cs index 31e0e2527..70ba9d655 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Geonet4.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Geonet4.cs @@ -14,8 +14,8 @@ public sealed class Geonet4 private readonly int Offset; private const int CountryCount = 233; - private static ReadOnlySpan LegalCountries => new byte[] - { + private static ReadOnlySpan LegalCountries => + [ 001, 002, 003, 006, 008, 009, 012, 013, 015, 016, 017, 018, 020, 021, 022, 023, 025, 027, 028, 029, 031, 033, 034, 035, 036, 040, 042, 043, 045, 048, 049, 050, 052, 054, 055, 056, 058, 059, 060, 061, 062, 069, 070, 071, 072, 074, 077, 078, @@ -25,7 +25,7 @@ public sealed class Geonet4 164, 166, 167, 110, 171, 172, 179, 183, 186, 187, 188, 189, 192, 193, 194, 196, 198, 199, 200, 202, 205, 207, 211, 212, 216, 218, 219, 204, 221, 220, 222, 224, 226, 227, - }; + ]; public static byte GetSubregionCount(byte country) => country switch { diff --git a/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeUtil.cs b/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeUtil.cs index 7d6a64eee..225ceb9ca 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeUtil.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeUtil.cs @@ -51,7 +51,7 @@ private static void AdjustOverlap(Span result) } } - // There aren't any RNG considerations for Munchlax/etc encounter slot legality. + // There aren't any RNG considerations for Munchlax/etc. encounter slot legality. // The RNG calls for populating the tree are disjointed from the RNG calls for generating the Entity upon encounter. // Group -> Slot -> Shakes diff --git a/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeValue.cs b/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeValue.cs index e8892e136..544a61163 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeValue.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/HoneyTreeValue.cs @@ -6,17 +6,15 @@ namespace PKHeX.Core; /// /// Honey Tree in Sinnoh (Gen4) /// -public sealed class HoneyTreeValue +public sealed class HoneyTreeValue(byte[] Data) { public const int Size = 8; - public readonly byte[] Data; + public readonly byte[] Data = Data; public uint Time { get => ReadUInt32LittleEndian(Data.AsSpan(0)); set => WriteUInt32LittleEndian(Data.AsSpan(0), value); } public int Slot { get => Data[4]; set => Data[4] = (byte)value; } public int SubTable { get => Data[5]; set => Data[5] = (byte)value; } // offset by 1 with respect to Group public int Group { get => Data[6]; set { Data[6] = (byte)value; SubTable = Math.Max(0, Group - 1); } } public int Shake { get => Data[7]; set => Data[7] = (byte)value; } - - public HoneyTreeValue(byte[] data) => Data = data; } diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Poffin4.cs b/PKHeX.Core/Saves/Substructures/Gen4/Poffin4.cs index 279261d67..c9dc5b327 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Poffin4.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Poffin4.cs @@ -3,12 +3,10 @@ namespace PKHeX.Core; -public sealed class Poffin4 +public sealed class Poffin4(byte[] Data) { public const int SIZE = 8; - public readonly byte[] Data; - - public Poffin4(byte[] data) => Data = data; + public readonly byte[] Data = Data; private const string Stats = nameof(Stats); diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchLevel.cs b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchLevel.cs index 23088de52..f510185c8 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchLevel.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchLevel.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Logic to calculate max counts denoted by the ranch level in My Pokemon Ranch +/// Logic to calculate max counts denoted by the ranch level in My Pokémon Ranch /// public static class RanchLevel { diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchMii.cs b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchMii.cs index 276e89254..baa84c2eb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchMii.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchMii.cs @@ -3,12 +3,10 @@ namespace PKHeX.Core; -public sealed class RanchMii +public sealed class RanchMii(byte[] Data) { public const int SIZE = 0x28; - public readonly byte[] Data; - - public RanchMii(byte[] data) => Data = data; + public readonly byte[] Data = Data; public uint MiiId { get => ReadUInt32BigEndian(Data); set => WriteUInt32BigEndian(Data, value); } public uint SystemId { get => ReadUInt32BigEndian(Data.AsSpan(0x04)); set => WriteUInt32BigEndian(Data.AsSpan(0x04), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchOwnershipType.cs b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchOwnershipType.cs index 28d555832..c08eb18e2 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchOwnershipType.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchOwnershipType.cs @@ -8,7 +8,7 @@ public enum RanchOwnershipType : byte Hayley_Traded = 5, } -// this might actually be an index to which Mii trainer owns the pokemon +// this might actually be an index to which Mii trainer owns the Pokémon public enum RanchOwnershipStatus : ushort { None = 0, diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToy.cs b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToy.cs index 31b87d2f2..427799489 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToy.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToy.cs @@ -3,12 +3,10 @@ namespace PKHeX.Core; -public sealed class RanchToy +public sealed class RanchToy(byte[] Data) { public const int SIZE = 0x08; - public readonly byte[] Data; - - public RanchToy(byte[] ranchToyData) => Data = ranchToyData; + public readonly byte[] Data = Data; public RanchToyType ToyType { get => (RanchToyType)Data[0]; set => Data[0] = (byte)value; } // 1,2,3 alignment diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToyType.cs b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToyType.cs index a2b004b1e..efb980068 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToyType.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchToyType.cs @@ -1,7 +1,7 @@ namespace PKHeX.Core; /// -/// Toys used in My Pokemon Ranch save files. +/// Toys used in My Pokémon Ranch save files. /// public enum RanchToyType : byte { diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchTrainerMii.cs b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchTrainerMii.cs index 8b5685f3e..30888a355 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchTrainerMii.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Ranch/RanchTrainerMii.cs @@ -3,12 +3,10 @@ namespace PKHeX.Core; -public sealed class RanchTrainerMii +public sealed class RanchTrainerMii(byte[] Data) { public const int SIZE = 0x2C; - public readonly byte[] Data; - - public RanchTrainerMii(byte[] data) => Data = data; + public readonly byte[] Data = Data; public uint MiiId { get => ReadUInt32BigEndian(Data.AsSpan(0x00)); set => WriteUInt32BigEndian(Data.AsSpan(0x00), value); } public uint SystemId { get => ReadUInt32BigEndian(Data.AsSpan(0x04)); set => WriteUInt32BigEndian(Data.AsSpan(0x04), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen4/Roamer4.cs b/PKHeX.Core/Saves/Substructures/Gen4/Roamer4.cs index 9cbf34b5c..fb224b8ba 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/Roamer4.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/Roamer4.cs @@ -9,12 +9,11 @@ namespace PKHeX.Core; /// /// size 0x14 [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class Roamer4 +public sealed class Roamer4(Memory Raw) { public const int SIZE = 0x14; - public readonly Memory Raw; + public readonly Memory Raw = Raw; - public Roamer4(Memory raw) => Raw = raw; private Span Data => Raw.Span; public int Location { get => ReadInt32LittleEndian(Data); set => WriteInt32LittleEndian(Data, value); } @@ -40,7 +39,7 @@ public sealed class Roamer4 /// public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set => SetIVs(value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs b/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs index 622b5f6f8..a6287d907 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/CGearBackground.cs @@ -43,13 +43,13 @@ public sealed class CGearBackground * The tiles are chosen based on the 16bit index of the tile. * 0x300 * 2 = 0x600! * - * CGearBackgrounds tilemap (when stored on BW) employs some obfuscation. - * BW obfuscates by adding 0xA0A0. + * CGearBackgrounds tilemap (when stored on B/W) employs some obfuscation. + * B/W obfuscates by adding 0xA0A0. * The obfuscated number is then tweaked by adding 15*(i/17) * To reverse, use a similar reverse calculation * PSK files are basically raw game rips (obfuscated) - * CGB files are un-obfuscated / B2W2. - * Due to BW and B2W2 using different obfuscation adds, PSK files are incompatible between the versions. + * CGB files are un-obfuscated / B2/W2. + * Due to B/W and B2/W2 using different obfuscation adds, PSK files are incompatible between the versions. */ public readonly int[] ColorPalette; @@ -171,7 +171,7 @@ public static CGearBackground GetBackground(ReadOnlySpan data) throw new ArgumentException($"Too many unique tiles. Expected < 256, received {tilelist.Count}."); // Finished! - return new CGearBackground(palette, tilelist.ToArray(), tm); + return new CGearBackground(palette, [.. tilelist], tm); } private static int[] GetColorData(ReadOnlySpan data) @@ -220,7 +220,7 @@ private static Tile GetTile(ReadOnlySpan colors, ReadOnlySpan palette, private static void GetTileList(ReadOnlySpan tiles, out List tilelist, out TileMap tm) { - tilelist = new List { tiles[0] }; + tilelist = [tiles[0]]; tm = new TileMap(LengthTileMap); // start at 1 as the 0th tile is always non-duplicate @@ -228,7 +228,7 @@ private static void GetTileList(ReadOnlySpan tiles, out List tilelis FindPossibleRotatedTile(tiles[i], tilelist, tm, i); } - private static void FindPossibleRotatedTile(Tile t, IList tilelist, TileMap tm, int tileIndex) + private static void FindPossibleRotatedTile(Tile t, List tilelist, TileMap tm, int tileIndex) { // Test all tiles currently in the list for (int i = 0; i < tilelist.Count; i++) @@ -293,7 +293,7 @@ public sealed class Tile // Keep track of known rotations for this tile. // If the tile's rotated value has not yet been calculated, the field is null. - private byte[] PixelData = Array.Empty(); + private byte[] PixelData = []; private byte[]? PixelDataX; private byte[]? PixelDataY; @@ -471,16 +471,10 @@ private bool IsMirrorXY(ReadOnlySpan tileColors) } } -public sealed class TileMap +public sealed class TileMap(int length) { - public readonly byte[] TileChoices; - public readonly byte[] Rotations; - - public TileMap(int length) - { - TileChoices = new byte[length / 2]; - Rotations = new byte[length / 2]; - } + public readonly byte[] TileChoices = new byte[length / 2]; + public readonly byte[] Rotations = new byte[length / 2]; internal TileMap(ReadOnlySpan data) : this(data.Length) => LoadData(data, TileChoices, Rotations); diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Color15Bit.cs b/PKHeX.Core/Saves/Substructures/Gen5/Color15Bit.cs index c26e9142f..ad93a802a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Color15Bit.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Color15Bit.cs @@ -60,11 +60,11 @@ private static byte Convert8to5(int colorval) /// /// Interpolated color gradient lookup table for 5-bit to 8-bit expansion. /// - private static ReadOnlySpan Convert5To8 => new byte[] // 0x20 entries - { + private static ReadOnlySpan Convert5To8 => // 0x20 entries + [ 0x00,0x08,0x10,0x18,0x20,0x29,0x31,0x39, 0x41,0x4A,0x52,0x5A,0x62,0x6A,0x73,0x7B, 0x83,0x8B,0x94,0x9C,0xA4,0xAC,0xB4,0xBD, 0xC5,0xCD,0xD5,0xDE,0xE6,0xEE,0xF6,0xFF, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Daycare5.cs b/PKHeX.Core/Saves/Substructures/Gen5/Daycare5.cs index c6bbe7405..f5f9ca865 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Daycare5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Daycare5.cs @@ -7,7 +7,7 @@ public sealed class Daycare5 : SaveBlock { // struct daycareSlot // bool32 occupied - // pk5party pk + // pk5 (party sized) pk // u32 expGained private const int SlotSize = 4 + PokeCrypto.SIZE_5PARTY + 4; // occupied u32 flag, pk5, exp @@ -15,7 +15,7 @@ public sealed class Daycare5 : SaveBlock // daycareSlot[2] // ???->end ??? - public const int DaycareSeedSize = 16; // 8 bytes, b2w2 only + public const int DaycareSeedSize = 16; // 8 bytes, B2/W2 only public Daycare5(SAV5 sav, int offset) : base(sav) => Offset = offset; diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Encount5.cs b/PKHeX.Core/Saves/Substructures/Gen5/Encount5.cs index 1cfe842b2..b4aa08dd1 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Encount5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Encount5.cs @@ -22,18 +22,14 @@ public uint SwarmIndex } } -public sealed class Encount5BW : Encount5 +public sealed class Encount5BW(SAV5BW SAV, int offset) : Encount5(SAV, offset) { - public Encount5BW(SAV5BW SAV, int offset) : base(SAV, offset) { } - public override byte SwarmSeed { get => Data[Offset + 0x30]; set => Data[Offset + 0x30] = value; } public override uint SwarmMaxCountModulo => 17; } -public sealed class Encount5B2W2 : Encount5 +public sealed class Encount5B2W2(SAV5B2W2 SAV, int offset) : Encount5(SAV, offset) { - public Encount5B2W2(SAV5B2W2 SAV, int offset) : base(SAV, offset) { } - public override byte SwarmSeed { get => Data[Offset + 0x2C]; set => Data[Offset + 0x2C] = value; } public override uint SwarmMaxCountModulo => 19; } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Entralink5.cs b/PKHeX.Core/Saves/Substructures/Gen5/Entralink5.cs index 2edf01f91..22a114f2d 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Entralink5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Entralink5.cs @@ -20,10 +20,8 @@ public ushort BlackCityLevel } } -public sealed class Entralink5BW : Entralink5 +public sealed class Entralink5BW(SAV5BW SAV, int offset) : Entralink5(SAV, offset) { - public Entralink5BW(SAV5BW SAV, int offset) : base(SAV, offset) { } - public byte MissionsComplete { get => Data[Offset + 0x1A4]; @@ -31,10 +29,8 @@ public byte MissionsComplete } } -public sealed class Entralink5B2W2 : Entralink5 +public sealed class Entralink5B2W2(SAV5B2W2 SAV, int offset) : Entralink5(SAV, offset) { - public Entralink5B2W2(SAV5B2W2 SAV, int offset) : base(SAV, offset) { } - public byte PassPower1 { get => Data[Offset + 0x1A0]; diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeForest.cs b/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeForest.cs index ed972dc10..6da725037 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeForest.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeForest.cs @@ -4,12 +4,12 @@ namespace PKHeX.Core; /// -/// Generation 5 Entree Forest +/// Generation 5 Entrée Forest /// public sealed class EntreeForest { /// - /// Areas 1 thru 8 have 20 slots. + /// Areas 1 through 8 have 20 slots. /// private const byte Count18 = 20; @@ -21,7 +21,7 @@ public sealed class EntreeForest private const int TotalSlots = Count18 + (3 * 8 * Count18) + (3 * Count9); // 530 /// - /// Areas 3 thru 8 can be unlocked (set a value 0 to 6). + /// Areas 3 through 8 can be unlocked (set a value 0 to 6). /// private const byte MaxUnlock38Areas = 6; diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeSlot.cs b/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeSlot.cs index ea1c5baa9..a9e6bf8b7 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeSlot.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Entree/EntreeSlot.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core; /// /// Generation 5 slot /// -public sealed class EntreeSlot : ISpeciesForm +public sealed class EntreeSlot(Memory Data) : ISpeciesForm { /// /// index @@ -62,7 +62,7 @@ public sealed class EntreeSlot : ISpeciesForm set => RawValue = ((RawValue << 3) >> 3) | (uint)((value & 0x7) << 29); } - private Memory Data { get; } + private Memory Data { get; } = Data; /// /// Raw Data Value @@ -85,6 +85,4 @@ public uint RawValue /// Extra metadata for the slot which is not stored in the raw data. /// public EntreeForestArea Area { get; init; } - - public EntreeSlot(Memory data) => Data = data; } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/FestaBlock5.cs b/PKHeX.Core/Saves/Substructures/Gen5/FestaBlock5.cs index 0c3f31cf5..bb0d95066 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/FestaBlock5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/FestaBlock5.cs @@ -114,47 +114,47 @@ public void UnlockAllFunfestMissions() } private readonly int[][] FunfestMissionUnlockFlagRequired = - { - Array.Empty(), // 00 - Array.Empty(), // 01 - new[] { 2444 }, // 02 - Array.Empty(), // 03 - new[] { 2445 }, // 04 - Array.Empty(), // 05 - new[] { 2462 }, // 06 - new[] { 2452, 2476 }, // 07 - new[] { 2476, 2548 }, // 08 - new[] { 2447 }, new[] { 2447 }, // 09 - new[] { 2453 }, new[] { 2453 }, // 10 - new[] { 2504 }, // 11 - new[] { 2457, 2507 }, // 12 - new[] { 2458, 2478 }, // 13 - new[] { 2456, 2508 }, // 14 - new[] { 2448 }, new[] { 2448 }, // 15 - new[] { 2549 }, // 16 - new[] { 2449 }, // 17 - new[] { 2479, 2513 }, // 18 - new[] { 2479, 2550 }, // 19 - new[] { 2481 }, // 20 - new[] { 2459 }, // 21 - new[] { 2454 }, // 22 - new[] { 2551 }, // 23 - new[] { 2400 }, // 24 - new[] { 2400 }, // 25 - new[] { 2400 }, new[] { 2400 }, // 26 - new[] { 2400 }, new[] { 2400 }, // 27 - new[] { 2400 }, // 28 - new[] { 2400, 2460 }, // 29 - new[] { 2400 }, // 30 - new[] { 2400, 2461 }, new[] { 2400, 2461 }, // 31 - new[] { 2437 }, // 32 - new[] { 2450 }, // 33 - new[] { 2451 }, // 34 - new[] { 2455 }, // 35 - new[] { 0105 }, // 36 - new[] { 2400 }, // 37 - new[] { 2557 }, // 38 - }; + [ + [], // 00 + [], // 01 + [2444], // 02 + [], // 03 + [2445], // 04 + [], // 05 + [2462], // 06 + [2452, 2476], // 07 + [2476, 2548], // 08 + [2447], [2447], // 09 + [2453], [2453], // 10 + [2504], // 11 + [2457, 2507], // 12 + [2458, 2478], // 13 + [2456, 2508], // 14 + [2448], [2448], // 15 + [2549], // 16 + [2449], // 17 + [2479, 2513], // 18 + [2479, 2550], // 19 + [2481], // 20 + [2459], // 21 + [2454], // 22 + [2551], // 23 + [2400], // 24 + [2400], // 25 + [2400], [2400], // 26 + [2400], [2400], // 27 + [2400], // 28 + [2400, 2460], // 29 + [2400], // 30 + [2400, 2461], [2400, 2461], // 31 + [2437], // 32 + [2450], // 33 + [2451], // 34 + [2455], // 35 + [0105], // 36 + [2400], // 37 + [2557], // 38 + ]; public static int GetExpNeededForLevelUp(int lv) { diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Medal5.cs b/PKHeX.Core/Saves/Substructures/Gen5/Medal5.cs index f86bb60a8..1e05d51cb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Medal5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Medal5.cs @@ -3,12 +3,10 @@ namespace PKHeX.Core; -public sealed class Medal5 +public sealed class Medal5(Memory Data) { public const int SIZE = 4; - private readonly Memory Data; private Span Span => Data.Span; - public Medal5(Memory data) => Data = data; // Structure: // ushort Date:7 diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Misc5.cs b/PKHeX.Core/Saves/Substructures/Gen5/Misc5.cs index 60b68ccd7..ed8f51c0f 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Misc5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Misc5.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -30,10 +30,8 @@ public ushort PokeTransferMinigameScore private int GetBadgeVictorySpeciesOffset(uint badge, uint slot) { - if (badge >= 8) - throw new ArgumentOutOfRangeException(nameof(badge)); - if (slot >= 6) - throw new ArgumentOutOfRangeException(nameof(slot)); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(badge, 8); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(slot, 6); return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort)); } @@ -51,16 +49,14 @@ public void SetBadgeVictorySpecies(uint badge, uint slot, ushort species) } } -public sealed class Misc5BW : Misc5 +public sealed class Misc5BW(SAV5BW sav, int offset) : Misc5(sav, offset) { - public Misc5BW(SAV5BW sav, int offset) : base(sav, offset) { } protected override int TransferMinigameScoreOffset => 0x14; protected override int BadgeVictoryOffset => 0x58; // thru 0xB7 } -public sealed class Misc5B2W2 : Misc5 +public sealed class Misc5B2W2(SAV5B2W2 sav, int offset) : Misc5(sav, offset) { - public Misc5B2W2(SAV5B2W2 sav, int offset) : base(sav, offset) { } protected override int TransferMinigameScoreOffset => 0x18; protected override int BadgeVictoryOffset => 0x5C; // thru 0xBB } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs index 05447539a..c76ceadd2 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5B2W2.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core; public sealed class MyItem5B2W2 : MyItem { - // offsets/pouch sizes are the same for both BW and B2W2, but Key Item permissions are different + // offsets/pouch sizes are the same for both B/W and B2/W2, but Key Item permissions are different private const int HeldItem = 0x000; // 0 private const int KeyItem = 0x4D8; // 1 private const int TMHM = 0x624; // 2 @@ -18,13 +18,13 @@ public override IReadOnlyList Inventory { var info = ItemStorage5B2W2.Instance; InventoryPouch4[] pouch = - { + [ new(InventoryType.Items, info, 999, Offset + HeldItem), new(InventoryType.KeyItems, info, 1, Offset + KeyItem), new(InventoryType.TMHMs, info, 1, Offset + TMHM), new(InventoryType.Medicine, info, 999, Offset + Medicine), new(InventoryType.Berries, info, 999, Offset + Berry), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs index 56e385692..1529d9180 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/MyItem5BW.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core; public sealed class MyItem5BW : MyItem { - // offsets/pouch sizes are the same for both BW and B2W2, but Key Item permissions are different + // offsets/pouch sizes are the same for both B/W and B2/W2, but Key Item permissions are different private const int HeldItem = 0x000; // 0 private const int KeyItem = 0x4D8; // 1 private const int TMHM = 0x624; // 2 @@ -19,13 +19,13 @@ public override IReadOnlyList Inventory { var info = ItemStorage5BW.Instance; InventoryPouch4[] pouch = - { + [ new(InventoryType.Items, info, 999, Offset + HeldItem), new(InventoryType.KeyItems, info, 1, Offset + KeyItem), new(InventoryType.TMHMs, info, 1, Offset + TMHM), new(InventoryType.Medicine, info, 999, Offset + Medicine), new(InventoryType.Berries, info, 999, Offset + Berry), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen5/PassPower5.cs b/PKHeX.Core/Saves/Substructures/Gen5/PassPower5.cs index 9d1083d01..5f46f2bf1 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/PassPower5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/PassPower5.cs @@ -1,4 +1,4 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Text File 263 in Black2/White2 @@ -56,7 +56,7 @@ public enum PassPower5 // 47 None = 48, - // B2W2 + // B2/W2 Search_Plus1 = 49, Search_Plus2 = 50, Search_Plus3 = 51, diff --git a/PKHeX.Core/Saves/Substructures/Gen5/Roamer5.cs b/PKHeX.Core/Saves/Substructures/Gen5/Roamer5.cs index b4e1cb942..f2e9ae0b2 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/Roamer5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/Roamer5.cs @@ -9,12 +9,11 @@ namespace PKHeX.Core; /// /// size 0x18 [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class Roamer5 +public sealed class Roamer5(byte[] Data, int offset) { public const int SIZE = 0x14; - private readonly Memory Raw; + private readonly Memory Raw = Data.AsMemory(offset, SIZE); - public Roamer5(byte[] raw, int offset) => Raw = raw.AsMemory(offset, SIZE); private Span Data => Raw.Span; public ushort Location { get => ReadUInt16LittleEndian(Data); set => WriteUInt16LittleEndian(Data , value); } @@ -41,7 +40,7 @@ public sealed class Roamer5 /// public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set => SetIVs(value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen5/UnityTower5.cs b/PKHeX.Core/Saves/Substructures/Gen5/UnityTower5.cs index 95f2fdd50..31591d29e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/UnityTower5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/UnityTower5.cs @@ -6,8 +6,8 @@ public sealed class UnityTower5 : SaveBlock { private const int CountryCount = 232; - private static ReadOnlySpan LegalCountries => new byte[] - { + private static ReadOnlySpan LegalCountries => + [ 001, 002, 003, 006, 008, 009, 012, 013, 015, 016, 017, 018, 020, 021, 022, 023, 025, 027, 028, 029, 031, 033, 034, 035, 036, 040, 042, 043, 045, 047, 048, 049, 051, 053, 054, 058, 060, 061, 062, 063, 064, 071, 072, 073, 074, 076, 079, 080, @@ -17,7 +17,7 @@ public sealed class UnityTower5 : SaveBlock 166, 167, 170, 173, 174, 181, 185, 186, 188, 189, 190, 191, 194, 195, 196, 198, 199, 200, 201, 203, 205, 206, 210, 211, 215, 217, 218, 219, 220, 221, 222, 224, 226, 227, - }; + ]; public static byte GetSubregionCount(byte country) => country switch { diff --git a/PKHeX.Core/Saves/Substructures/Gen6/BoxLayout6.cs b/PKHeX.Core/Saves/Substructures/Gen6/BoxLayout6.cs index 2b338cab8..47c8b2e99 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/BoxLayout6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/BoxLayout6.cs @@ -50,7 +50,7 @@ public void SetBoxName(int box, ReadOnlySpan value) public byte[] BoxFlags { - get => new[] { Data[Offset + PCFlags] }; // 7 bits for wallpaper unlocks, top bit to unlock final box (delta episode) + get => [ Data[Offset + PCFlags] ]; // 7 bits for wallpaper unlocks, top bit to unlock final box (delta episode) set { if (value.Length != 1) diff --git a/PKHeX.Core/Saves/Substructures/Gen6/Encount6.cs b/PKHeX.Core/Saves/Substructures/Gen6/Encount6.cs index 178c21ab9..255f5bf22 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/Encount6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/Encount6.cs @@ -37,17 +37,16 @@ public Roamer6 Roamer } [TypeConverter(typeof(ValueTypeTypeConverter))] -public sealed class PokeRadar6 +public sealed class PokeRadar6(Memory Data) { public const int SIZE = 2 + (RecordCount * PokeRadarRecord.SIZE); // 0x18 private const int MaxCharge = 50; private const int RecordCount = 5; - public readonly Memory Data; + public readonly Memory Data = Data; private Span Span => Data.Span; - public PokeRadar6(Memory data) => Data = data; public override string ToString() => ((Species)PokeRadarSpecies).ToString(); public ushort PokeRadarSpecies { get => ReadUInt16LittleEndian(Span[..2]); set => WriteUInt16LittleEndian(Span[..2], value); } @@ -105,14 +104,13 @@ public void WriteRecord(Span data) } [TypeConverter(typeof(ValueTypeTypeConverter))] -public sealed class Roamer6 +public sealed class Roamer6(Memory Data) { public const int SIZE = 0x28; - public readonly Memory Data; + public readonly Memory Data = Data; private Span Span => Data.Span; - public Roamer6(Memory data) => Data = data; public override string ToString() => ((Species)Species).ToString(); private ushort SpecForm { get => ReadUInt16LittleEndian(Span[..2]); set => WriteUInt16LittleEndian(Span[..2], value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/Fashion6XY.cs b/PKHeX.Core/Saves/Substructures/Gen6/Fashion6XY.cs index 3f8a79bcd..5cd2af712 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/Fashion6XY.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/Fashion6XY.cs @@ -11,8 +11,8 @@ public void UnlockAllAccessories() SAV.SetData(AllAccessories, Offset); } - private static ReadOnlySpan AllAccessories => new byte[] - { + private static ReadOnlySpan AllAccessories => + [ 0xFE,0xFF,0xFF,0x7E,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xEF,0xFF,0xFF,0xFF,0xF9,0xFF,0xFB,0xFF,0xF7,0xFF,0xFF,0x0F,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF, @@ -20,5 +20,5 @@ public void UnlockAllAccessories() 0xFF,0xFF,0xFF,0xF9,0xFF,0xFB,0xFF,0xF7,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/HallFame6Entity.cs b/PKHeX.Core/Saves/Substructures/Gen6/HallFame6Entity.cs index d631ae992..59e98c171 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/HallFame6Entity.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/HallFame6Entity.cs @@ -7,6 +7,7 @@ namespace PKHeX.Core; { public const int SIZE = 0x48; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public HallFame6Entity(Span data) => Data = data; public ushort Species { get => ReadUInt16LittleEndian(Data); set => WriteUInt16LittleEndian(Data, value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/LinkBlock6.cs b/PKHeX.Core/Saves/Substructures/Gen6/LinkBlock6.cs index f10f56912..fdda2c6a4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/LinkBlock6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/LinkBlock6.cs @@ -8,7 +8,7 @@ public sealed class LinkBlock6 : SaveBlock public LinkBlock6(SAV6XY sav, int offset) : base(sav) => Offset = offset; public LinkBlock6(SAV6AO sav, int offset) : base(sav) => Offset = offset; - public byte[] GetLinkInfoData() => Data.Slice(Offset + 0x1FF, PL6.Size); + public byte[] GetLinkInfoData() => Data.AsSpan(Offset + 0x1FF, PL6.Size).ToArray(); public PL6 GetLinkInfo() => new(GetLinkInfoData()); public void SetLinkInfoData(ReadOnlySpan data) diff --git a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs index d033cd47e..5bddfe2dc 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6AO.cs @@ -19,13 +19,13 @@ public override IReadOnlyList Inventory { var info = ItemStorage6AO.Instance; InventoryPouch4[] pouch = - { + [ new(InventoryType.Items, info, 999, Offset + HeldItem), new(InventoryType.KeyItems, info, 1, Offset + KeyItem), new(InventoryType.TMHMs, info, 1, Offset + TMHM), new(InventoryType.Medicine, info, 999, Offset + Medicine), new(InventoryType.Berries, info, 999, Offset + Berry), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs index ac5d0b2a4..dc4131cd0 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/MyItem6XY.cs @@ -18,13 +18,13 @@ public override IReadOnlyList Inventory { var info = ItemStorage6XY.Instance; InventoryPouch4[] pouch = - { + [ new(InventoryType.Items, info, 999, Offset + HeldItem), new(InventoryType.KeyItems, info, 1, Offset + KeyItem), new(InventoryType.TMHMs, info, 1, Offset + TMHM), new(InventoryType.Medicine, info, 999, Offset + Medicine), new(InventoryType.Berries, info, 999, Offset + Berry), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6XY.cs b/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6XY.cs index 5f3f2a2f6..c5c15d5d3 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6XY.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/MyStatus6XY.cs @@ -6,11 +6,9 @@ namespace PKHeX.Core; /// /// XY specific features for /// -/// These properties are technically included in OR/AS but they are unused; assumed backwards compatibility for communications with XY -public sealed class MyStatus6XY : MyStatus6 +/// These properties are technically included in OR/AS, but they are unused; assumed backwards compatibility for communications with XY +public sealed class MyStatus6XY(SAV6XY sav, int offset) : MyStatus6(sav, offset) { - public MyStatus6XY(SAV6XY sav, int offset) : base(sav, offset) { } - public TrainerFashion6 Fashion { get => TrainerFashion6.GetFashion(SAV.Data, Offset + 0x30, SAV.Gender); diff --git a/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPower6.cs b/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPower6.cs index 1a937ceb4..a1c5dcb3b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPower6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPower6.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core; public sealed class OPower6 : SaveBlock { private static readonly OPowerFlagSet[] Mapping = - { + [ // Skip unused byte new(5, Hatching) {Offset = 1}, new(5, Bargain) {Offset = 6}, @@ -30,7 +30,7 @@ public sealed class OPower6 : SaveBlock new(3, Speed) {Offset = 56}, new(3, Critical) {Offset = 59}, new(3, Accuracy) {Offset = 62}, - }; + ]; public OPower6(SAV6XY sav, int offset) : base(sav) => Offset = offset; public OPower6(SAV6AO sav, int offset) : base(sav) => Offset = offset; @@ -71,7 +71,7 @@ private void ToggleFlags(bool allEvents = false, bool clearOnly = false) if (clearOnly) continue; - int lvl = allEvents ? m.BaseCount : (m.BaseCount != 1 ? 3 : 0); // Full_Recovery is ORAS/event only @ 1 level + int lvl = allEvents ? m.BaseCount : (m.BaseCount != 1 ? 3 : 0); // Full_Recovery is OR/AS event only @ 1 level m.SetOPowerLevel(span, lvl); if (!allEvents) continue; diff --git a/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPowerFlagSet.cs b/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPowerFlagSet.cs index 0deab4174..f7c4793f8 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPowerFlagSet.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/OPower/OPowerFlagSet.cs @@ -3,20 +3,15 @@ namespace PKHeX.Core; -internal sealed class OPowerFlagSet +internal sealed class OPowerFlagSet(int Count, OPower6Type Identifier) { - public readonly OPower6Type Identifier; - public readonly int Count; - public int Offset { get; set; } + public readonly OPower6Type Identifier = Identifier; + public readonly int Count = Count; + public int BaseCount => Math.Min(3, Count); public bool HasOPowerS => Count > 3; public bool HasOPowerMAX => Count == 5; - - public OPowerFlagSet(int count, OPower6Type ident) - { - Identifier = ident; - Count = count; - } + public int Offset { get; init; } public int GetOPowerLevel(ReadOnlySpan data) { diff --git a/PKHeX.Core/Saves/Substructures/Gen6/PSS6.cs b/PKHeX.Core/Saves/Substructures/Gen6/PSS6.cs index 1f4135541..a3d080adf 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/PSS6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/PSS6.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; public static class PSS6 { private const string Header = "PSS List"; - private static readonly string[] headers = { "PSS Data - Friends", "PSS Data - Acquaintances", "PSS Data - Passerby" }; + private static readonly string[] headers = ["PSS Data - Friends", "PSS Data - Acquaintances", "PSS Data - Passerby"]; public static List GetPSSParse(SAV6 SAV) { @@ -27,7 +27,7 @@ public static List GetPSSParse(SAV6 SAV) return result; } - private static void ReadTrainers(ICollection result, Span data, int offset, int count) + private static void ReadTrainers(List result, Span data, int offset, int count) { int r_offset = offset; const int size = 0xC8; @@ -43,7 +43,7 @@ private static void ReadTrainers(ICollection result, Span data, in } } - private static bool ReadTrainer(ICollection result, ReadOnlySpan data) + private static bool ReadTrainer(List result, ReadOnlySpan data) { ulong pssID = ReadUInt64LittleEndian(data); if (pssID == 0) diff --git a/PKHeX.Core/Saves/Substructures/Gen6/RecordBlock6.cs b/PKHeX.Core/Saves/Substructures/Gen6/RecordBlock6.cs index 86c1c31e7..cdb8d6291 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/RecordBlock6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/RecordBlock6.cs @@ -52,13 +52,12 @@ public override void SetRecord(int recordID, int value) } } -public sealed class RecordBlock6XY : RecordBlock6 +public sealed class RecordBlock6XY(SAV6XY sav, int offset) : RecordBlock6(sav, offset) { - public RecordBlock6XY(SAV6XY sav, int offset) : base(sav, offset) { } protected override ReadOnlySpan RecordMax => MaxType_XY; - private static ReadOnlySpan MaxType_XY => new byte[] - { + private static ReadOnlySpan MaxType_XY => + [ 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -80,7 +79,7 @@ public sealed class RecordBlock6XY : RecordBlock6 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - }; + ]; } public sealed class RecordBlock6AO : RecordBlock6 @@ -89,8 +88,8 @@ public sealed class RecordBlock6AO : RecordBlock6 public RecordBlock6AO(SAV6AODemo sav, int offset) : base(sav, offset) { } protected override ReadOnlySpan RecordMax => MaxType_AO; - private static ReadOnlySpan MaxType_AO => new byte[] - { + private static ReadOnlySpan MaxType_AO => + [ 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -112,16 +111,15 @@ public sealed class RecordBlock6AO : RecordBlock6 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - }; + ]; } -public sealed class RecordBlock7SM : RecordBlock6 +public sealed class RecordBlock7SM(SAV7SM sav, int offset) : RecordBlock6(sav, offset) { - public RecordBlock7SM(SAV7SM sav, int offset) : base(sav, offset) { } protected override ReadOnlySpan RecordMax => MaxType_SM; - private static ReadOnlySpan MaxType_SM => new byte[] - { + private static ReadOnlySpan MaxType_SM => + [ 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, @@ -143,16 +141,15 @@ public sealed class RecordBlock7SM : RecordBlock6 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - }; + ]; } -public sealed class RecordBlock7USUM : RecordBlock6 +public sealed class RecordBlock7USUM(SAV7USUM sav, int offset) : RecordBlock6(sav, offset) { - public RecordBlock7USUM(SAV7USUM sav, int offset) : base(sav, offset) { } protected override ReadOnlySpan RecordMax => MaxType_USUM; - private static ReadOnlySpan MaxType_USUM => new byte[] - { + private static ReadOnlySpan MaxType_USUM => + [ 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, @@ -174,5 +171,5 @@ public sealed class RecordBlock7USUM : RecordBlock6 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 5, 5, 4, 5, 5, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6.cs b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6.cs index 8c4b95f47..7a8b338ee 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6.cs @@ -6,15 +6,15 @@ namespace PKHeX.Core; /// /// Secret base format for /// -public class SecretBase6 +public class SecretBase6(byte[] Data, int Offset = 0) { public const int SIZE = 0x310; public const int COUNT_GOODS = 28; public const int MinLocationID = -1; public const int MaxLocationID = 85; - protected readonly byte[] Data; - protected readonly int Offset; + protected readonly byte[] Data = Data; + protected readonly int Offset = Offset; // structure: (first at 23D24 in sav) // [000-001] u8 IsNew @@ -37,12 +37,6 @@ public class SecretBase6 // [30D] byte CollectedFlagsYesterday // 2 bytes alignment for u32 - public SecretBase6(byte[] data, int offset = 0) - { - Data = data; - Offset = offset; - } - public bool IsNew { get => Data[Offset] == 1; @@ -67,9 +61,7 @@ public int BaseLocation }; } - public SecretBase6GoodPlacement GetPlacement(int index) => new(Data.AsSpan(Offset + GetPlacementOffset(index))); - - public void SetPlacement(int index, SecretBase6GoodPlacement value) => value.Write(Data.AsSpan(Offset + GetPlacementOffset(index))); + public SecretBase6GoodPlacement GetPlacement(int index) => new(Data, Offset + GetPlacementOffset(index)); private static int GetPlacementOffset(int index) { @@ -143,7 +135,7 @@ public void Load(SecretBase6 other) LoadSelf(other); } - public virtual byte[] Write() => Data.Slice(Offset, SIZE); + public virtual byte[] Write() => Data.AsSpan(Offset, SIZE).ToArray(); public static SecretBase6? Read(byte[] data) { @@ -159,14 +151,10 @@ public void Load(SecretBase6 other) /// /// An expanded structure of containing extra fields to describe another trainer's base. /// -public sealed class SecretBase6Other : SecretBase6 +public sealed class SecretBase6Other(byte[] Data, int Offset = 0) : SecretBase6(Data, Offset) { public new const int SIZE = 0x3E0; - public SecretBase6Other(byte[] data, int offset = 0) : base(data, offset) - { - } - // [310-31F] u128 key struct // [320] byte language // [321] byte trainer gender @@ -201,17 +189,9 @@ public byte Gender public const int COUNT_TEAM = 3; - public SecretBase6PKM GetParticipant(int index) - { - var data = Data.Slice(GetParticipantOffset(index), SecretBase6PKM.SIZE); - return new SecretBase6PKM(data); - } - - public void SetParticipant(int index, SecretBase6PKM pk) - { - var ofs = GetParticipantOffset(index); - pk.Data.CopyTo(Data, ofs); - } + private Span GetParticipantData(int index) => Data.AsSpan(GetParticipantOffset(index), SecretBase6PKM.SIZE); + public SecretBase6PKM GetParticipant(int index) => new(GetParticipantData(index).ToArray()); + public void SetParticipant(int index, SecretBase6PKM pk) => pk.Data.CopyTo(GetParticipantData(index)); public int GetParticipantOffset(int index) { @@ -244,5 +224,5 @@ public void SetTeam(SecretBase6PKM[] arr) protected override void LoadOther(SecretBase6Other other) => other.Data.AsSpan(other.Offset, SIZE).CopyTo(Data.AsSpan(Offset)); - public override byte[] Write() => Data.Slice(Offset, SIZE); + public override byte[] Write() => Data.AsSpan(Offset, SIZE).ToArray(); } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodPlacement.cs b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodPlacement.cs index 6a6c0be62..40298141b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodPlacement.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodPlacement.cs @@ -1,40 +1,24 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; -public sealed class SecretBase6GoodPlacement +public sealed class SecretBase6GoodPlacement(byte[] Data, int Offset) { public const int SIZE = 12; - public ushort Good { get; set; } - public ushort X { get; set; } - public ushort Y { get; set; } - public byte Rotation { get; set; } + private byte[] Raw { get; } = Data; + private int Offset { get; } = Offset; + + private Span Data => Raw.AsSpan(Offset); + + public ushort Good { get => ReadUInt16LittleEndian(Data); set => WriteUInt16LittleEndian(Data, value); } + public ushort X { get => ReadUInt16LittleEndian(Data[2..]); set => WriteUInt16LittleEndian(Data[2..], value); } + public ushort Y { get => ReadUInt16LittleEndian(Data[4..]); set => WriteUInt16LittleEndian(Data[4..], value); } + + public byte Rotation { get => Data[6]; set => Data[6] = value; } // byte unused - public ushort Param1 { get; set; } - public ushort Param2 { get; set; } - - public SecretBase6GoodPlacement(ReadOnlySpan data) - { - Good = ReadUInt16LittleEndian(data); - X = ReadUInt16LittleEndian(data[2..]); - Y = ReadUInt16LittleEndian(data[4..]); - Rotation = data[6]; - - Param1 = ReadUInt16LittleEndian(data[8..]); - Param2 = ReadUInt16LittleEndian(data[10..]); - } - - public void Write(Span data) - { - WriteUInt16LittleEndian(data, Good); - WriteUInt16LittleEndian(data[2..], X); - WriteUInt16LittleEndian(data[4..], Y); - data[6] = Rotation; - - WriteUInt16LittleEndian(data[8..], Param1); - WriteUInt16LittleEndian(data[10..], Param2); - } + public ushort Param1 { get => ReadUInt16LittleEndian(Data[8..]); set => WriteUInt16LittleEndian(Data[8..], value); } + public ushort Param2 { get => ReadUInt16LittleEndian(Data[10..]); set => WriteUInt16LittleEndian(Data[10..], value); } } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodStock.cs b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodStock.cs index 802906b16..cc9059c27 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodStock.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase/SecretBase6GoodStock.cs @@ -1,4 +1,5 @@ -using System; +using System; +using System.Runtime.InteropServices; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -6,23 +7,14 @@ namespace PKHeX.Core; /// /// Generation 6 Secret Base Decoration Good Inventory stock for a given good-index. /// -public sealed class SecretBase6GoodStock +public sealed class SecretBase6GoodStock(byte[] Data, int Offset) { public const int SIZE = 4; - public ushort Count { get; set; } - public bool IsNew { get; set; } + private Span Span => Data.AsSpan(Offset); - public SecretBase6GoodStock(ReadOnlySpan data) - { - Count = ReadUInt16LittleEndian(data); - IsNew = data[2] != 0; - } + public ushort Count { get => ReadUInt16LittleEndian(Span); set => WriteUInt16LittleEndian(Span, value); } + public bool IsNew { get => Span[2] != 0; set => Span[2] = (byte)(value ? 1 : 0); } - public void Write(Span data) - { - WriteUInt16LittleEndian(data, Count); - data[2] = (byte)(IsNew ? 1 : 0); - data[3] = 0; - } + public void Clear() => MemoryMarshal.Write(Span, 0); } diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase6Block.cs b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase6Block.cs index f343cda64..6f8b8301f 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SecretBase6Block.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SecretBase6Block.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -21,8 +21,7 @@ public sealed class SecretBase6Block : SaveBlock public const int Count_Goods = 200; public const int Count_Goods_Used = 173; - public SecretBase6GoodStock GetGood(int index) => new(Data.AsSpan(Offset + GetGoodOffset(index))); - public void SetGood(SecretBase6GoodStock good, int index) => good.Write(Data.AsSpan(Offset + GetGoodOffset(index))); + public SecretBase6GoodStock GetGood(int index) => new(Data, Offset + GetGoodOffset(index)); private static int GetGoodOffset(int index) { diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs b/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs index 19fe2a142..822e7ce59 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -24,11 +24,8 @@ public abstract class SubEventLog6 : SaveBlock, IGymTeamInfo private int GetBadgeVictorySpeciesOffset(uint badge, uint slot) { - if (badge >= 8) - throw new ArgumentOutOfRangeException(nameof(badge)); - if (slot >= 6) - throw new ArgumentOutOfRangeException(nameof(slot)); - + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(badge, 8); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(slot, 6); return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort)); } @@ -45,10 +42,8 @@ public void SetBadgeVictorySpecies(uint badge, uint slot, ushort species) } } -public sealed class SubEventLog6XY : SubEventLog6 +public sealed class SubEventLog6XY(SAV6XY sav, int offset) : SubEventLog6(sav, offset) { - public SubEventLog6XY(SAV6XY sav, int offset) : base(sav, offset) { } - // Structure: // 0x00 @@ -70,7 +65,7 @@ public ushort ChateauPoints get => (ushort)(ChateauValue >> 4); set => ChateauValue = (ushort)((ushort)(value << 4) | (ChateauValue & 0xFu)); } - // other chateau data? + // other château data? // u32 SUBE @ 0x28 // 0x2C @@ -92,10 +87,8 @@ public ushort ChateauPoints // u8[0xA0] unused? } -public sealed class SubEventLog6AO : SubEventLog6 +public sealed class SubEventLog6AO(SAV6AO sav, int offset) : SubEventLog6(sav, offset) { - public SubEventLog6AO(SAV6AO sav, int offset) : base(sav, offset) { } - // Structure: // 0x00 @@ -104,7 +97,7 @@ public sealed class SubEventLog6AO : SubEventLog6 // u32 SUBE @ 0x5C // 0x60 - protected override int BadgeVictoryOffset => 0x60; // thru 0xBF + protected override int BadgeVictoryOffset => 0x60; // through 0xBF // u16[6 * 8] trainer teams for gyms // u32 SUBE @ 0xC0 diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SuperTrainBlock.cs b/PKHeX.Core/Saves/Substructures/Gen6/SuperTrainBlock.cs index 6c00694ef..018d658f6 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/SuperTrainBlock.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/SuperTrainBlock.cs @@ -283,17 +283,8 @@ public void UnlockAllStages(bool dist) public void ClearBlock() => Array.Clear(Data, Offset, 0x318); } -public sealed class SuperTrainingSpeciesRecord : ISpeciesForm +public sealed class SuperTrainingSpeciesRecord(byte[] Data, int Offset) : ISpeciesForm { - private readonly byte[] Data; - private readonly int Offset; - - public SuperTrainingSpeciesRecord(byte[] data, int offset) - { - Data = data; - Offset = offset; - } - /// /// of the Record Holder. /// diff --git a/PKHeX.Core/Saves/Substructures/Gen6/TrainerFashion6.cs b/PKHeX.Core/Saves/Substructures/Gen6/TrainerFashion6.cs index 614d07b42..1673956bb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen6/TrainerFashion6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen6/TrainerFashion6.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -76,11 +76,8 @@ public enum F6Skin } } -public sealed class Fashion6Male : TrainerFashion6 +public sealed class Fashion6Male(byte[] data, int offset) : TrainerFashion6(data, offset) { - public Fashion6Male(byte[] data, int offset) - : base(data, offset) { } - public uint Version { get => GetBits(data0, 0, 3); set => data0 = SetBits(data0, 0, 3, value); } public uint Model { get => GetBits(data0, 3, 3); set => data0 = SetBits(data0, 3, 3, value); } public F6Skin Skin { get => (F6Skin)GetBits(data0, 6, 2); set => data0 = SetBits(data0, 6, 2, (uint)value); } @@ -276,11 +273,8 @@ public enum F6HairStyleFront } } -public sealed class Fashion6Female : TrainerFashion6 +public sealed class Fashion6Female(byte[] data, int offset) : TrainerFashion6(data, offset) { - public Fashion6Female(byte[] data, int offset) - : base(data, offset) { } - public uint Version { get => GetBits(data0, 0, 3); set => data0 = SetBits(data0, 0, 3, value); } public uint Model { get => GetBits(data0, 3, 3); set => data0 = SetBits(data0, 3, 3, value); } public F6Skin Skin { get => (F6Skin)GetBits(data0, 6, 2); set => data0 = SetBits(data0, 6, 2, (uint)value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/BattleTree7.cs b/PKHeX.Core/Saves/Substructures/Gen7/BattleTree7.cs index 7a6d252ec..a2debebff 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/BattleTree7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/BattleTree7.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using static System.Buffers.Binary.BinaryPrimitives; @@ -11,8 +11,7 @@ public sealed class BattleTree7 : SaveBlock public int GetTreeStreak(int battletype, bool super, bool max) { - if (battletype > 3) - throw new ArgumentOutOfRangeException(nameof(battletype)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(battletype, 3); var offset = GetStreakOffset(battletype, super, max); return ReadUInt16LittleEndian(Data.AsSpan(Offset + offset)); @@ -20,8 +19,7 @@ public int GetTreeStreak(int battletype, bool super, bool max) public void SetTreeStreak(int value, int battletype, bool super, bool max) { - if (battletype > 3) - throw new ArgumentOutOfRangeException(nameof(battletype)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(battletype, 3); if (value > ushort.MaxValue) value = ushort.MaxValue; @@ -96,33 +94,20 @@ public BattleTreeTrainer[] ScoutedTrainers } [TypeConverter(typeof(ValueTypeTypeConverter))] -public sealed class BattleTreeTrainer +public sealed class BattleTreeTrainer(short id, BattleTreePokemon poke1, BattleTreePokemon poke2) { - public short ID { get; set; } - public BattleTreePokemon Poke1 { get; set; } - public BattleTreePokemon Poke2 { get; set; } - - public BattleTreeTrainer(short id, BattleTreePokemon poke1, BattleTreePokemon poke2) - { - ID = id; - Poke1 = poke1; - Poke2 = poke2; - } + public short ID { get; set; } = id; + public BattleTreePokemon Poke1 { get; set; } = poke1; + public BattleTreePokemon Poke2 { get; set; } = poke2; public override string ToString() => $"{ID}: [{Poke1}] & [{Poke2}]"; } [TypeConverter(typeof(ValueTypeTypeConverter))] -public sealed class BattleTreePokemon +public sealed class BattleTreePokemon(short p1, sbyte a1) { - public short ID { get; set; } - public sbyte AbilityIndex { get; set; } - - public BattleTreePokemon(short p1, sbyte a1) - { - ID = p1; - AbilityIndex = a1; - } + public short ID { get; set; } = p1; + public sbyte AbilityIndex { get; set; } = a1; public override string ToString() => $"{ID},{AbilityIndex}"; } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/BoxLayout7.cs b/PKHeX.Core/Saves/Substructures/Gen7/BoxLayout7.cs index 6e15517ec..44b6d9ef3 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/BoxLayout7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/BoxLayout7.cs @@ -45,7 +45,7 @@ public void SetBoxWallpaper(int box, int value) public byte[] BoxFlags { - get => new[] { Data[Offset + PCFlags] }; // bits for wallpaper unlocks + get => [ Data[Offset + PCFlags] ]; // bits for wallpaper unlocks set { if (value.Length != 1) diff --git a/PKHeX.Core/Saves/Substructures/Gen7/FashionBlock7.cs b/PKHeX.Core/Saves/Substructures/Gen7/FashionBlock7.cs index c41148f09..7301628c6 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/FashionBlock7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/FashionBlock7.cs @@ -47,23 +47,17 @@ public void Reset() }; // Offsets that are set to '3' when the game starts for a specific gender. - private static ReadOnlySpan DefaultFashionOffsetSM_M => new ushort[] { 0x000, 0x0FB, 0x124, 0x28F, 0x3B4, 0x452, 0x517 }; - private static ReadOnlySpan DefaultFashionOffsetSM_F => new ushort[] { 0x000, 0x100, 0x223, 0x288, 0x3B4, 0x452, 0x517 }; - private static ReadOnlySpan DefaultFashionOffsetUU_M => new ushort[] { 0x03A, 0x109, 0x1DA, 0x305, 0x3D9, 0x4B1, 0x584 }; - private static ReadOnlySpan DefaultFashionOffsetUU_F => new ushort[] { 0x05E, 0x208, 0x264, 0x395, 0x3B4, 0x4F9, 0x5A8 }; + private static ReadOnlySpan DefaultFashionOffsetSM_M => [ 0x000, 0x0FB, 0x124, 0x28F, 0x3B4, 0x452, 0x517 ]; + private static ReadOnlySpan DefaultFashionOffsetSM_F => [ 0x000, 0x100, 0x223, 0x288, 0x3B4, 0x452, 0x517 ]; + private static ReadOnlySpan DefaultFashionOffsetUU_M => [ 0x03A, 0x109, 0x1DA, 0x305, 0x3D9, 0x4B1, 0x584 ]; + private static ReadOnlySpan DefaultFashionOffsetUU_F => [ 0x05E, 0x208, 0x264, 0x395, 0x3B4, 0x4F9, 0x5A8 ]; } // Every fashion item is 2 bits, New Flag (high) & Owned Flag (low) -public sealed class FashionItem7 +public sealed class FashionItem7(byte b) { - public bool IsOwned { get; set; } - public bool IsNew { get; set; } - - public FashionItem7(byte b) - { - IsOwned = (b & 1) != 0; - IsNew = (b & 2) != 0; - } + public bool IsOwned { get; set; } = (b & 1) != 0; + public bool IsNew { get; set; } = (b & 2) != 0; public byte Value => (byte)((IsOwned ? 1 : 0) | (IsNew ? 2 : 0)); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs b/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs index 082529254..1ab5e3d3e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/FestaFacility.cs @@ -35,8 +35,8 @@ public FestaFacility(SAV7 sav, int index) public uint UsedRandStat { get => ReadUInt32LittleEndian(Data.AsSpan(0x2C)); set => WriteUInt32LittleEndian(Data.AsSpan(0x2C), value); } public int NPC { get => Math.Max(0, ReadInt32LittleEndian(Data.AsSpan(0x30))); set => WriteInt32LittleEndian(Data.AsSpan(0x30), Math.Max(0, value)); } - public byte[] TrainerFesID { get => Data.Slice(0x34, 0xC); set => value.CopyTo(Data, 0x34); } - public void ClearTrainerFesID() => Data.AsSpan(0x34, 0xC).Clear(); + public Span TrainerFesID => Data.AsSpan(0x34, 0xC); + public void ClearTrainerFesID() => TrainerFesID.Clear(); public int ExchangeLeftCount { get => Data[0x40]; set => Data[0x40] = (byte)value; } // used when Type=Exchange public int GetMessage(int index) => index switch diff --git a/PKHeX.Core/Saves/Substructures/Gen7/FieldMenu7.cs b/PKHeX.Core/Saves/Substructures/Gen7/FieldMenu7.cs index 58a124cd3..f1d1d90bf 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/FieldMenu7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/FieldMenu7.cs @@ -8,7 +8,7 @@ public sealed class FieldMenu7 : SaveBlock public FieldMenu7(SAV7SM sav, int offset) : base(sav) => Offset = offset; public FieldMenu7(SAV7USUM sav, int offset) : base(sav) => Offset = offset; - // USUM ONLY + // US/UM ONLY public ushort RotomAffection { get => ReadUInt16LittleEndian(SAV.Data.AsSpan(Offset + 0x1A)); diff --git a/PKHeX.Core/Saves/Substructures/Gen7/FieldMoveModelSave7.cs b/PKHeX.Core/Saves/Substructures/Gen7/FieldMoveModelSave7.cs index 8edb7edac..e5a195d95 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/FieldMoveModelSave7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/FieldMoveModelSave7.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -8,7 +8,7 @@ public sealed class FieldMoveModelSave7 : SaveBlock public FieldMoveModelSave7(SAV7SM sav, int offset) : base(sav) => Offset = offset; public FieldMoveModelSave7(SAV7USUM sav, int offset) : base(sav) => Offset = offset; - //public int Unknown { get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0x00), (ushort)value); } // related to Ride Pokemon + //public int Unknown { get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0x00), (ushort)value); } // related to Ride Pokémon public float X { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x08)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x08), value); } public float Z { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x0C)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x0C), value); } public float Y { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x10), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/CaptureRecords.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/CaptureRecords.cs index b6b59cc67..7d4622dcb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/CaptureRecords.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/CaptureRecords.cs @@ -19,10 +19,10 @@ public sealed class CaptureRecords : SaveBlock // 0x770 ?? - // 0x46D94 is a u32 stores how many total Pokémon you've caught (caps out at 999,999,999). + // 0x46D94: u32 stores how many total Pokémon you've caught (caps out at 999,999,999). private const int TotalCapturedOffset = 0x794; - // 0x46DA8 is a u32 that stores how many Pokémon you've transferred to Professor Oak. + // 0x46DA8: u32 that stores how many Pokémon you've transferred to Professor Oak. // This value is equal to the sum of all individual transferred Species, but caps out at 999,999,999 even if the sum of all individual Species exceeds this. private const int TotalTransferredOffset = 0x7A8; diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/EventWork7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/EventWork7b.cs index 487849080..197ebf2c1 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/EventWork7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/EventWork7b.cs @@ -11,7 +11,7 @@ public EventWork7b(SAV7b sav, int offset) : base(sav) // Zone @ 0x21A0 - 0x21AF (128 flags) // System @ 0x21B0 - 0x21EF (512 flags) -- is this really 256 instead, with another 256 region after for the small vanish? // Vanish @ 0x21F0 - 0x22AF (1536 flags) - // Event @ 0x22B0 - 0x23A7 (rest of the flags) (512) -- I think trainer flags are afterwards.... For now, this is a catch-all + // Event @ 0x22B0 - 0x23A7 (rest of the flags) (512) -- I think trainer flags are afterward.... For now, this is a catch-all // time flags (39 used flags of 42) = 6 bytes 0x22F0-0x22F5 // trainer flags (???) = 0x22F6 - end? diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Fashion7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Fashion7b.cs index d24209e13..2a6dd0548 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Fashion7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/Fashion7b.cs @@ -16,8 +16,8 @@ public void UnlockAllAccessoriesStarter() SAV.SetData(AllAccessoriesStarter, Offset); } - private static ReadOnlySpan AllAccessoriesPlayer => new byte[] - { + private static ReadOnlySpan AllAccessoriesPlayer => + [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -28,10 +28,10 @@ public void UnlockAllAccessoriesStarter() 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; + ]; - private static ReadOnlySpan AllAccessoriesStarter => new byte[] - { + private static ReadOnlySpan AllAccessoriesStarter => + [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFD, 0xFB, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -39,5 +39,5 @@ public void UnlockAllAccessoriesStarter() 0x7F, 0xFD, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/GP1.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/GP1.cs index 7d1a033a9..58babb732 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/GP1.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/GP1.cs @@ -8,10 +8,11 @@ namespace PKHeX.Core; /// /// Go Park Entity transferred from to . /// -public sealed class GP1 : IEncounterInfo, IFixedAbilityNumber, IScaledSizeReadOnly, IEncounterConvertible +public sealed class GP1(byte[] Data) + : IEncounterInfo, IFixedAbilityNumber, IScaledSizeReadOnly, IEncounterConvertible { public const int SIZE = 0x1B0; - public readonly byte[] Data; + public readonly byte[] Data = Data; public GameVersion Version => GameVersion.GO; public bool EggEncounter => false; @@ -21,7 +22,6 @@ public sealed class GP1 : IEncounterInfo, IFixedAbilityNumber, IScaledSizeReadOn public EntityContext Context => EntityContext.Gen7b; public AbilityPermission Ability => AbilityPermission.Any12; - public GP1(byte[] data) => Data = data; public GP1() : this(new byte[SIZE]) => InitializeBlank(Data); public void WriteTo(byte[] data, int offset) => Data.CopyTo(data, offset); @@ -41,13 +41,13 @@ private static GP1 FromData(ReadOnlySpan span) /// /// First 0x20 bytes of an empty , all other bytes are 0. /// - private static ReadOnlySpan Blank20 => new byte[] - { + private static ReadOnlySpan Blank20 => + [ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x85, 0xEC, 0x33, 0x01, - }; + ]; public static void InitializeBlank(Span data) => Blank20.CopyTo(data); @@ -204,8 +204,7 @@ public PB7 ConvertToPKM(ITrainerInfo sav, EncounterCriteria criteria) } Span moves = stackalloc ushort[4]; - ILearnSource source = LearnSource7GG.Instance; - source.SetEncounterMoves(Species, Form, Level, moves); + ((ILearnSource)LearnSource7GG.Instance).SetEncounterMoves(Species, Form, Level, moves); pk.SetMoves(moves); pk.OT_Friendship = pk.PersonalInfo.BaseFriendship; diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs index 7bb48e913..0782fa228 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/MyItem7b.cs @@ -20,7 +20,7 @@ public override IReadOnlyList Inventory { var info = ItemStorage7GG.Instance; InventoryPouch7b[] pouch = - { + [ new(InventoryType.Medicine, info, 999, Medicine, PouchSize7b.Medicine), new(InventoryType.TMHMs, info, 1, TM, PouchSize7b.TM), new(InventoryType.Balls, info, 999, Catching, PouchSize7b.Catching), @@ -28,7 +28,7 @@ public override IReadOnlyList Inventory new(InventoryType.BattleItems, info, 999, Battle, PouchSize7b.Battle), new(InventoryType.ZCrystals, info, 999, PowerUp, PouchSize7b.PowerUp), new(InventoryType.Candy, info, 999, Candy, PouchSize7b.Candy), - }; + ]; return pouch.LoadAll(Data); } set diff --git a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/WB7Records.cs b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/WB7Records.cs index 67da7813c..aae4bdca9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/LGPE/WB7Records.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/LGPE/WB7Records.cs @@ -13,16 +13,14 @@ public sealed class WB7Records : SaveBlock private int GetRecordOffset(int index) { - if (index >= RecordMax) - throw new ArgumentOutOfRangeException(nameof(index)); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, RecordMax); return Offset + (index * WR7.Size); } private int GetFlagOffset(int flag) { - if (flag >= FlagCountMax) - throw new ArgumentOutOfRangeException(nameof(flag)); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(flag, FlagCountMax); return FlagStart + (flag / 8); } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs index 97add76d4..eafc3ea30 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7SM.cs @@ -19,14 +19,14 @@ public override IReadOnlyList Inventory { var info = ItemStorage7SM.Instance; InventoryPouch7[] pouch = - { + [ new(InventoryType.Medicine, info, 999, Offset + Medicine), new(InventoryType.Items, info, 999, Offset + HeldItem), new(InventoryType.TMHMs, info, 1, Offset + TMHM), new(InventoryType.Berries, info, 999, Offset + Berry), new(InventoryType.KeyItems, info, 1, Offset + KeyItem), new(InventoryType.ZCrystals, info, 1, Offset + ZCrystals), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs index 73459dd03..d264f273a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/MyItem7USUM.cs @@ -20,7 +20,7 @@ public override IReadOnlyList Inventory { var info = ItemStorage7USUM.Instance; InventoryPouch7[] pouch = - { + [ new(InventoryType.Medicine, info, 999, Medicine), new(InventoryType.Items, info, 999, HeldItem), new(InventoryType.TMHMs, info, 1, TMHM), @@ -28,7 +28,7 @@ public override IReadOnlyList Inventory new(InventoryType.KeyItems, info, 1, KeyItem), new(InventoryType.ZCrystals, info, 1, ZCrystals), new(InventoryType.BattleItems, info, 999, BattleItems), - }; + ]; return pouch.LoadAll(Data); } set => value.SaveAll(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen7/PlayerBattleStyle7.cs b/PKHeX.Core/Saves/Substructures/Gen7/PlayerBattleStyle7.cs index 59cfbdb50..9af2cfc69 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/PlayerBattleStyle7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/PlayerBattleStyle7.cs @@ -1,4 +1,4 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; public enum PlayerBattleStyle7 { @@ -12,7 +12,7 @@ public enum PlayerBattleStyle7 Idol, /// - /// USUM Only + /// US/UM Only /// Nihilist, } diff --git a/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs b/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs index 2b226012e..f45fffa4d 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs @@ -21,8 +21,8 @@ public static class QR7 { public const int SIZE = 0x1A2; - private static ReadOnlySpan GenderDifferences => new byte[] - { + private static ReadOnlySpan GenderDifferences => + [ 0x08, 0x10, 0x18, 0x06, 0x00, 0x36, 0x00, 0x00, 0x03, 0x00, 0x30, 0x00, 0x02, 0x80, 0xC1, 0x08, 0x06, 0x00, 0x00, 0x04, 0x60, 0x00, 0x04, 0x46, 0x4C, 0x8C, 0xD1, 0x22, 0x21, 0x01, @@ -32,7 +32,7 @@ public static class QR7 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, - }; + ]; private static bool IsGenderDifferent(ushort species) { diff --git a/PKHeX.Core/Saves/Substructures/Gen7/WormholeInfoReader.cs b/PKHeX.Core/Saves/Substructures/Gen7/WormholeInfoReader.cs index 135ec7f1d..7e0e9ba46 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/WormholeInfoReader.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/WormholeInfoReader.cs @@ -2,14 +2,13 @@ namespace PKHeX.Core; -public sealed class WormholeInfoReader +public sealed class WormholeInfoReader(SAV7 SAV) { - public readonly SAV7 SAV; - public WormholeInfoReader(SAV7 sav) => SAV = sav; + public readonly SAV7 SAV = SAV; // Wormhole shininess & flags found by @PP-theSLAYER // https://projectpokemon.org/home/forums/topic/39433-gen-7-save-research-thread/?page=3&tab=comments#comment-239090 - public bool WormholeShininess // 0x4535 = Misc (0x4400 in USUM) + 0x0135 + public bool WormholeShininess // 0x4535 = Misc (0x4400 in US/UM) + 0x0135 { get => SAV.Data[SAV.Misc.Offset + 0x0135] == 1; set => SAV.Data[SAV.Misc.Offset + 0x0135] = value ? (byte)1 : (byte)0; @@ -39,16 +38,16 @@ public int WormholeSlot } } - public static ReadOnlySpan StandardWormholes => new ushort[] - { + public static ReadOnlySpan StandardWormholes => + [ 256, // Red 257, // Green 258, // Yellow 259, // Blue - }; + ]; - public static ReadOnlySpan WormholeSlotsRed => new ushort[] - { + public static ReadOnlySpan WormholeSlotsRed => + [ 0, // filler used for indexing with slot number 144, // Articuno 145, // Zapdos @@ -65,10 +64,10 @@ public int WormholeSlot 561, // Sigilyph 581, // Swanna 277, // Swellow - }; + ]; - public static ReadOnlySpan WormholeSlotsGreen => new ushort[] - { + public static ReadOnlySpan WormholeSlotsGreen => + [ 0, // filler used for indexing with slot number 150, // Mewtwo 243, // Raikou @@ -85,10 +84,10 @@ public int WormholeSlot 695, // Heliolisk 274, // Nuzleaf 326, // Grumpig - }; + ]; - public static ReadOnlySpan WormholeSlotsYellow => new ushort[] - { + public static ReadOnlySpan WormholeSlotsYellow => + [ 0, // filler used for indexing with slot number 377, // Regirock 378, // Regice @@ -105,10 +104,10 @@ public int WormholeSlot 450, // Hippowdon 558, // Crustle 219, // Magcargo - }; + ]; - public static ReadOnlySpan WormholeSlotsBlue => new ushort[] - { + public static ReadOnlySpan WormholeSlotsBlue => + [ 0, // filler used for indexing with slot number 245, // Suicune 249, // Lugia @@ -125,7 +124,7 @@ public int WormholeSlot 618, // Stunfisk 419, // Floatzel 195, // Quagsire - }; + ]; public static ushort WormholeSlotToPokemon(int mapid, int slot) { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTowerWork8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTowerWork8b.cs index e047ed70a..7050b982e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTowerWork8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTowerWork8b.cs @@ -55,19 +55,10 @@ private static void SetRecords(IReadOnlyList value) } [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class BattleTowerClassData8b +public sealed class BattleTowerClassData8b(byte[] Data, int Offset) { public const int SIZE = 0x68; - private readonly int Offset; - private readonly byte[] Data; - - public BattleTowerClassData8b(byte[] data, int offset) - { - Data = data; - Offset = offset; - } - public override string ToString() => $"Rank: {Rank}, Streak: {RenshouCount} (Max {RenshouCountOld}), Wins: {TotalWins}|{TotalWinsLoop}|{TotalWinsLose}"; public byte Cleared diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/EncounterSave8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/EncounterSave8b.cs index 25018eaba..60eff98af 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/EncounterSave8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/EncounterSave8b.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using static System.Buffers.Binary.BinaryPrimitives; @@ -144,43 +144,39 @@ public short SprayCount } [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class HoneyTree8b +public sealed class HoneyTree8b(byte[] Data, int Offset) { public const int SIZE = 0xC; - private readonly int Offset; - private readonly byte[] Data; - - public HoneyTree8b(byte[] data, int offset) - { - Data = data; - Offset = offset; - } - public bool Spreaded { get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x00)) == 1; set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 0x00), value ? 1u : 0u); } + public int Minutes { get => ReadInt32LittleEndian(Data.AsSpan(Offset + 0x04)); set => WriteInt32LittleEndian(Data.AsSpan(Offset + 0x04), value); } + public byte TblMonsNo { get => Data[Offset + 0x08]; set => Data[Offset + 0x08] = value; } + public byte RareLv { get => Data[Offset + 0x09]; set => Data[Offset + 0x09] = value; } + public byte SwayLv { get => Data[Offset + 0x0A]; set => Data[Offset + 0x0A] = value; } + // 0xB alignment } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs index 8cdd2a778..cd373b6c9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/MyItem8b.cs @@ -56,8 +56,8 @@ public ushort GetNextSortIndex(InventoryType type) private IReadOnlyList ConvertToPouches() { - var pouches = new[] - { + InventoryPouch8b[] pouches = + [ MakePouch(InventoryType.Items), MakePouch(InventoryType.KeyItems), MakePouch(InventoryType.TMHMs), @@ -66,7 +66,7 @@ private IReadOnlyList ConvertToPouches() MakePouch(InventoryType.Balls), MakePouch(InventoryType.BattleItems), MakePouch(InventoryType.Treasure), - }; + ]; return pouches.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/MysteryBlock8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/MysteryBlock8b.cs index 7ff0b70f3..b82ed80e6 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/MysteryBlock8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/MysteryBlock8b.cs @@ -150,23 +150,14 @@ private void SetOneDay(IReadOnlyList value) } [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class RecvData8b +public sealed class RecvData8b(byte[] Data, int Offset = 0) { public const int SIZE = 0xE0; // private const int ItemCount = 7; // private const int DressIDCount = 7; - private readonly int Offset; - private readonly byte[] Data; - - public RecvData8b(byte[] data, int offset = 0) - { - Data = data; - Offset = offset; - } - public override string ToString() => $"{DeliveryID:0000} @ {LocalTimestamp:F}"; - public void CopyTo(Span destination, int offset) => Data.AsSpan(Offset, SIZE).CopyTo(destination[offset..]); + public void CopyTo(Span destination, int offset1) => Data.AsSpan(Offset, SIZE).CopyTo(destination[offset1..]); public void Clear() => Data.AsSpan(Offset, SIZE).Clear(); public long Ticks { get => ReadInt64LittleEndian(Data.AsSpan(Offset)); set => WriteInt64LittleEndian(Data.AsSpan(Offset), value); } @@ -234,22 +225,13 @@ public string OT } [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class OneDay8b +public sealed class OneDay8b(byte[] Data, int Offset = 0) { public const int SIZE = 0x10; - private readonly int Offset; - private readonly byte[] Data; - - public OneDay8b(byte[] data, int offset = 0) - { - Data = data; - Offset = offset; - } - public override string ToString() => $"{DeliveryID:0000} @ {LocalTimestamp:F}"; - public void CopyTo(Span destination, int offset) => Data.AsSpan(Offset, SIZE).CopyTo(destination[offset..]); + public void CopyTo(Span destination, int offset1) => Data.AsSpan(Offset, SIZE).CopyTo(destination[offset1..]); public void Clear() => Data.AsSpan(Offset, SIZE).Clear(); public long Ticks { get => ReadInt64LittleEndian(Data.AsSpan(Offset)); set => WriteInt64LittleEndian(Data.AsSpan(Offset), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/RandomGroup8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/RandomGroup8b.cs index a3242f328..a5099f6eb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/RandomGroup8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/RandomGroup8b.cs @@ -42,7 +42,7 @@ private static void SetSeeds(IReadOnlyList value) /// Random Seed data. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class RandomSeed8b +public sealed class RandomSeed8b(byte[] Data, int Offset) { public const int GROUP_NAME_SIZE = 16; // chars public const int PERSON_NAME_SIZE = 32; // chars @@ -57,15 +57,6 @@ public sealed class RandomSeed8b private const int OFS_UID = OFS_TICK + 8; // 0x80 public const int SIZE = OFS_UID + 4; // 0x84 - private readonly int Offset; - private readonly byte[] Data; - - public RandomSeed8b(byte[] data, int offset) - { - Data = data; - Offset = offset; - } - public string GroupName { get => StringConverter8.GetString(Data.AsSpan(Offset + OFS_GROUPNAME, GROUP_NAME_SIZE * 2)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/Record8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/Record8b.cs index 950967892..8e48cf321 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/Record8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/Record8b.cs @@ -48,8 +48,8 @@ public void SetRecord(int recordID, int value) public void AddRecord(int recordID, int count = 1) => SetRecord(recordID, GetRecord(recordID) + count); - public static ReadOnlySpan MaxValue_BDSP => new[] - { + public static ReadOnlySpan MaxValue_BDSP => + [ int.MaxValue, // CLEAR_TIME 9_999, // DENDOU_CNT 999_999, // CAPTURE_POKE @@ -80,7 +80,7 @@ public void SetRecord(int recordID, int value) 100, // CONTEST_RATE_LOCAL 100, // CONTEST_RATE_NETWORK 65_536,// CONTEST_GET_RIBBON - }; + ]; public static readonly Dictionary RecordList_8b = new() { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/RecordAddData8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/RecordAddData8b.cs index 66494b251..b067c9976 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/RecordAddData8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/RecordAddData8b.cs @@ -47,23 +47,16 @@ public void ReplaceOT(ITrainerInfo oldTrainer, ITrainerInfo newTrainer) } } -public sealed class RecordAdd8b +public sealed class RecordAdd8b(byte[] Data, int Offset) { public const int SIZE = 0x30; - public readonly byte[] Data; - private readonly int Offset; - - public RecordAdd8b(byte[] data, int offset) - { - Data = data; - Offset = offset; - } public string OT { get => StringConverter8.GetString(Data.AsSpan(Offset + 0, 0x1A)); set => StringConverter8.SetString(Data.AsSpan(Offset + 0, 0x1A), value, 12, StringConverterOption.ClearZero); } + // 1A reserved byte // 1B reserved byte diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/SealDeco8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/SealDeco8b.cs index 5265642c5..a0815fed4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/SealDeco8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/SealDeco8b.cs @@ -45,21 +45,13 @@ private static void SetCapsules(IReadOnlyList value) } [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class SealCapsule8b +public sealed class SealCapsule8b(byte[] Data, int Offset) { public const int COUNT_SEAL = 20; // AffixSealData[20] public const int SIZE = 12 + (COUNT_SEAL * AffixSealData8b.SIZE); // 0xAC - private readonly int Offset; - private readonly byte[] Data; - public override string ToString() => $"{(Species)Species}-{EncryptionConstant:X8}-{Unknown}"; - public SealCapsule8b(byte[] data, int offset) - { - Data = data; - Offset = offset; - } public uint Species { get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0)); set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 0), value); } public uint EncryptionConstant { get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 4)); set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 4), value); } public uint Unknown { get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 8)); set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 8), value); } @@ -87,21 +79,12 @@ private static void SetSeals(IReadOnlyList value) } [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class AffixSealData8b +public sealed class AffixSealData8b(byte[] Data, int Offset) { public const int SIZE = 8; // u16 id, s16 x,y,z - private readonly int Offset; - private readonly byte[] Data; - public override string ToString() => $"{(Seal8b)SealID}-({X},{Y},{Z})"; - public AffixSealData8b(byte[] data, int offset) - { - Data = data; - Offset = offset; - } - public ushort SealID { get => ReadUInt16LittleEndian(Data.AsSpan(Offset + 0)); set => WriteUInt16LittleEndian(Data.AsSpan(Offset + 0), value); } public short X { get => ReadInt16LittleEndian(Data.AsSpan(Offset + 2)); set => WriteInt16LittleEndian(Data.AsSpan(Offset + 2), value); } public short Y { get => ReadInt16LittleEndian(Data.AsSpan(Offset + 4)); set => WriteInt16LittleEndian(Data.AsSpan(Offset + 4), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/Zukan8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/Zukan8b.cs index 125a17311..1a0e52426 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/Zukan8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/Zukan8b.cs @@ -7,7 +7,7 @@ namespace PKHeX.Core; /// Pokédex structure used for Brilliant Diamond & Shining Pearl. /// /// size 0x30B8, struct_name ZUKAN_WORK -public sealed class Zukan8b : ZukanBase +public sealed class Zukan8b(SAV8BS sav, int dex) : ZukanBase(sav, dex) { /* Structure Notes: u32 [493] state: None/HeardOf/Seen/Captured @@ -133,8 +133,6 @@ bool[18] Arceus private static PersonalTable8BDSP Personal => PersonalTable.BDSP; - public Zukan8b(SAV8BS sav, int dex) : base(sav, dex) { } - public ZukanState8b GetState(ushort species) { if (species > Legal.MaxSpeciesID_4) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/BoxLayout8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/BoxLayout8a.cs index 6c60671c9..b6a31be7e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/BoxLayout8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/BoxLayout8a.cs @@ -7,14 +7,12 @@ namespace PKHeX.Core; /// Exposes information about Box Names and which box is the first box to show when the UI is opened. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class BoxLayout8a : SaveBlock, IBoxDetailName +public sealed class BoxLayout8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data), IBoxDetailName { public const int BoxCount = 32; private const int StringMaxLength = SAV6.LongStringLength / 2; // 0x22 bytes - public BoxLayout8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } - private static int GetBoxNameOffset(int box) => SAV6.LongStringLength * box; private Span GetBoxNameSpan(int box) => Data.AsSpan(GetBoxNameOffset(box), SAV6.LongStringLength); public string GetBoxName(int box) => SAV.GetString(GetBoxNameSpan(box)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Coordinates8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Coordinates8a.cs index 743706073..5ca6853e1 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Coordinates8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Coordinates8a.cs @@ -9,18 +9,26 @@ namespace PKHeX.Core; /// Stores the position of the player. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class Coordinates8a : SaveBlock +public sealed class Coordinates8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Coordinates8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } - // Map + private Span MapName() => Data.AsSpan(0x08, 0x48); + public string M { - get => Util.TrimFromZero(Encoding.ASCII.GetString(Data, 0x08, 0x48)); + get + { + var span = MapName(); + var trim = span.IndexOf(0); + if (trim >= 0) + span = span[..trim]; + return Encoding.ASCII.GetString(span); + } set { - for (int i = 0; i < 0x48; i++) - Data[0x08 + i] = (byte)(value.Length > i ? value[i] : '\0'); + var span = MapName(); + span.Clear(); + Encoding.ASCII.GetBytes(value, span); } } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Epoch1970Value.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Epoch1970Value.cs index 43cebd960..bf2830e67 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Epoch1970Value.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Epoch1970Value.cs @@ -8,13 +8,11 @@ namespace PKHeX.Core; /// Stores the to indicate the seconds since 1970 that an event occurred. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class Epoch1970Value +public sealed class Epoch1970Value(Memory Data) { - private readonly Memory Data; private Span Span => Data.Span; public Epoch1970Value(SCBlock block) : this(block.Data) { } - public Epoch1970Value(Memory data) => Data = data; /// /// time_t (seconds since 1970 Epoch) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/LastSaved8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/LastSaved8a.cs index 27a815e51..ad8691183 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/LastSaved8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/LastSaved8a.cs @@ -12,9 +12,8 @@ namespace PKHeX.Core; /// Month value is offset by -1. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class LastSaved8a : SaveBlock +public sealed class LastSaved8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data) { - public LastSaved8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } private uint LastSaved { get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x0)); set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 0x0), value); } private int LastSavedYear { get => (int)(LastSaved & 0xFFF); set => LastSaved = (LastSaved & 0xFFFFF000) | (uint)value; } private int LastSavedMonth { get => (int)((LastSaved >> 12) & 0xF); set => LastSaved = (LastSaved & 0xFFFF0FFF) | (((uint)value & 0xF) << 12); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs index 2b224e7ad..20a0213bc 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs @@ -9,15 +9,13 @@ namespace PKHeX.Core; /// /// Reads four separate pouch blobs: Items, Key Items, Storage, and Recipes. /// -public sealed class MyItem8a : MyItem +public sealed class MyItem8a(SAV8LA sav, SCBlock block) : MyItem(sav, block.Data) { - public MyItem8a(SAV8LA SAV, SCBlock block) : base(SAV, block.Data) { } - public override IReadOnlyList Inventory { get { - var access = ((SAV8LA)SAV).Accessor; + var access = sav.Accessor; var satchel = (uint)access.GetBlock(SaveBlockAccessor8LA.KSatchelUpgrades).GetValue(); var regularSize = (int)Math.Min(675, satchel + 20); @@ -31,13 +29,13 @@ public override IReadOnlyList Inventory stored.GetPouch(access.GetBlock(SaveBlockAccessor8LA.KItemStored).Data); recipe.GetPouch(access.GetBlock(SaveBlockAccessor8LA.KItemRecipe).Data); - var result = new[] { regular, key, stored, recipe }; + InventoryPouch8a[] result = [ regular, key, stored, recipe ]; LoadFavorites(result, access); return result; } set { - var access = ((SAV8LA)SAV).Accessor; + var access = sav.Accessor; foreach (var p in value) ((InventoryPouch8a)p).SanitizeCounts(); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs index 9377e69f5..a3a7f065b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyStatus8a.cs @@ -8,10 +8,8 @@ namespace PKHeX.Core; /// Stores data about the player. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class MyStatus8a : SaveBlock +public sealed class MyStatus8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data) { - public MyStatus8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } - public uint ID32 { get => ReadUInt32LittleEndian(Data.AsSpan(0x10)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Party8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Party8a.cs index b2066b9dd..76ad00a20 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Party8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Party8a.cs @@ -1,9 +1,7 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public sealed class Party8a : SaveBlock +public sealed class Party8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Party8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } - public int PartyCount { get => Data[6 * PokeCrypto.SIZE_8APARTY]; diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayTime8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayTime8a.cs index 4aefc6a1b..b29cd8e47 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayTime8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayTime8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using static System.Buffers.Binary.BinaryPrimitives; @@ -8,10 +8,8 @@ namespace PKHeX.Core; /// Stores the amount of time the save file has been played. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class PlayTime8a : SaveBlock +public sealed class PlayTime8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data) { - public PlayTime8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } - public ushort PlayedHours { get => ReadUInt16LittleEndian(Data.AsSpan(Offset)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayerFashion8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayerFashion8a.cs index ae2f73dc7..517b872fa 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayerFashion8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/PlayerFashion8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using static System.Buffers.Binary.BinaryPrimitives; @@ -8,9 +8,8 @@ namespace PKHeX.Core; /// Stores the selected appearance choices of the player. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class PlayerFashion8a : SaveBlock +public sealed class PlayerFashion8a(SAV8LA sav, SCBlock block) : SaveBlock(sav, block.Data) { - public PlayerFashion8a(SAV8LA sav, SCBlock block) : base(sav, block.Data) { } public ulong Hair { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x00), value); } public ulong Contacts { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x08)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x08), value); } public ulong Eyebrows { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x10), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexConstants8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexConstants8a.cs index d66ec286c..bae000129 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexConstants8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexConstants8a.cs @@ -9,13 +9,13 @@ public static class PokedexConstants8a { public const int MaxPokedexResearchPoints = 60000; - public static ReadOnlySpan ResearchPointsForRank => new ushort[] - { + public static ReadOnlySpan ResearchPointsForRank => + [ 0, 500, 1800, 3500, 6000, 8500, 11000, 15000, 20000, 30000, 60000, - }; + ]; - public static ReadOnlySpan PokemonInfoIds => new ushort[] - { + public static ReadOnlySpan PokemonInfoIds => + [ 0, 25, 26, 35, 36, 37, 38, 41, 42, 46, 47, 54, 55, 63, 64, 65, 66, 67, 68, 72, 73, 74, 75, 76, 77, 78, 81, 82, 92, 93, @@ -48,10 +48,10 @@ public static class PokedexConstants8a 16877, 18633, 18925, 20681, 20973, 22729, 23021, 24777, 25069, 26825, 27117, 28873, 29165, 30921, 31213, 32969, 33261, 35017, 35309, 37065, 39113, 41161, 43209, 45257, 47305, 49353, 51401, 53449, 55497, - }; + ]; - public static ReadOnlySpan PokemonInfoGenders => new byte[] - { + public static ReadOnlySpan PokemonInfoGenders => + [ 0x04, 0x03, 0x03, 0x08, 0x08, 0x08, 0x08, 0x03, 0x03, 0x08, 0x08, 0x08, 0x08, 0x08, 0x03, 0x03, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, 0x08, 0x08, @@ -84,10 +84,10 @@ public static class PokedexConstants8a 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - }; + ]; - public static ReadOnlySpan FormStorageIndexIds => new ushort[] - { + public static ReadOnlySpan FormStorageIndexIds => + [ 0, 25, 26, 35, 36, 37, 38, 41, 42, 46, 47, 54, 55, 63, 64, 65, 66, 67, 68, 72, 73, 74, 75, 76, 77, 78, 81, 82, 92, 93, 94, 95, 108, 111, 112, 113, 114, 122, 123, 125, 126, 129, 130, 133, 134, 135, 136, 137, @@ -108,10 +108,10 @@ public static class PokedexConstants8a 4645, 4646, 4809, 6345, 6623, 6637, 8393, 8671, 8685, 10441, 10719, 10733, 12489, 12781, 14537, 14829, 16585, 16877, 18633, 18925, 20681, 20973, 22729, 23021, 24777, 25069, 26825, 27117, 28873, 29165, 30921, 31213, 32969, 33261, 35017, 35309, 37065, 39113, 41161, 43209, 45257, 47305, 49353, 51401, 53449, 55497, - }; + ]; - public static ReadOnlySpan FormStorageIndexValues => new ushort[] - { + public static ReadOnlySpan FormStorageIndexValues => + [ 0, 1, 2, 3, 4, 5, 7, 9, 10, 11, 12, 13, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, @@ -132,7 +132,7 @@ public static class PokedexConstants8a 286, 287, 304, 75, 243, 266, 76, 244, 267, 77, 245, 268, 78, 269, 79, 270, 80, 271, 81, 272, 82, 273, 83, 274, 84, 275, 85, 276, 86, 277, 87, 278, 88, 279, 89, 280, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - }; + ]; public static readonly PokedexResearchTask8a[][] ResearchTasks = DeserializeResearchTasks(BinLinkerAccessor.Get(Util.GetBinaryResource("researchtask_la.pkl"), "la"u8)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSave8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSave8a.cs index 43e6c5bda..4d0045d09 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSave8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSave8a.cs @@ -9,11 +9,9 @@ namespace PKHeX.Core; /// /// Pokédex structure used for . /// > -public sealed class PokedexSave8a +public sealed class PokedexSave8a(SAV8LA SaveFile, SCBlock block) { - private readonly SAV8LA SaveFile; - - private readonly PokedexSaveData SaveData; + private readonly PokedexSaveData SaveData = new(block.Data); public const int MAX_SPECIES = 981; public const int MAX_FORM = 120; @@ -21,12 +19,6 @@ public sealed class PokedexSave8a private static PersonalTable8LA Personal => PersonalTable.LA; private const int MaxSpeciesID = Legal.MaxSpeciesID_8a; - public PokedexSave8a(SAV8LA sav, SCBlock block) - { - SaveFile = sav; - SaveData = new PokedexSaveData(block.Data); - } - private const int DexInvalid = 0; public static ushort GetDexIndex(PokedexType8a which, ushort species) @@ -166,15 +158,15 @@ public int GetReportPokeNum() for (ushort species = 1; species <= MaxSpeciesID; species++) { - // Only allow reports of pokemon in hisui dex + // Only allow reports of Pokémon in Hisui dex if (GetDexIndex(Hisui, species) == 0) continue; - // Only allow reports of pokemon which have been caught + // Only allow reports of Pokémon which have been caught if (SaveData.GetPokeGetCount(species) == 0) continue; - // Check if the pokemon is unreported or has unreported tasks. + // Check if the Pokémon is unreported or has unreported tasks. if (!SaveData.HasAnyReport(species) || GetUnreportedTaskCount(species) > 0) count++; } @@ -188,7 +180,7 @@ public int GetTotalReportNum() for (ushort species = 1; species <= MaxSpeciesID; species++) { - // Only allow reports of pokemon which have been caught + // Only allow reports of Pokémon which have been caught if (SaveData.GetPokeGetCount(species) == 0) continue; @@ -436,7 +428,7 @@ public int GetAllPokeResearchPoint() for (ushort species = 1; species <= MaxSpeciesID; species++) { - // Only return pokemon with all required tasks complete + // Only return Pokémon with all required tasks complete if (!IsAllRequiredTasksComplete(species)) continue; @@ -559,8 +551,8 @@ private void UpdateAllCompleteFlags() { var hisuiComplete = true; var hisuiPerfect = true; - Span localComplete = stackalloc bool[] { true, true, true, true, true }; - Span localPerfect = stackalloc bool[] { true, true, true, true, true }; + Span localComplete = [true, true, true, true, true]; + Span localPerfect = [true, true, true, true, true]; for (ushort species = 1; species <= MaxSpeciesID; species++) { @@ -664,7 +656,7 @@ private void IncreaseResearchTaskProgress(ushort species, PokedexResearchTaskTyp if (species >= MAX_SPECIES) return; - // All research increases set the update flag whether or not they increment the value + // All research increases set the update flag whether they increment the value SetPokeHasBeenUpdated(species); // If we shouldn't, don't do the update @@ -696,7 +688,7 @@ public void SetResearchTaskProgressByForce(ushort species, PokedexResearchTaskTy if (species >= MAX_SPECIES) return; - // All research increases set the update flag whether or not they increment the value + // All research increases set the update flag whether they increment the value SetPokeHasBeenUpdated(species); // Get the research entry @@ -886,15 +878,15 @@ public void OnPokeGet(PKM pk, bool sleeping, bool inAir, bool notSpotted, bool s // Light poke potentially obtained OnPokeLightCaught(pk.Species, pa8.WeightAbsolute); - // Handle if pokemon was caught while sleeping + // Handle if Pokémon was caught while sleeping if (sleeping) OnPokeCaughtSleeping(pk.Species); - // Handle if pokemon was caught while in the air + // Handle if Pokémon was caught while in the air if (inAir) OnPokeCaughtInAir(pk.Species); - // Handle if pokemon was caught while not spotted + // Handle if Pokémon was caught while not spotted if (notSpotted) OnPokeCaughtNotSpotted(pk.Species); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSaveResearchEntry.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSaveResearchEntry.cs index 402bf031c..e6d3df248 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSaveResearchEntry.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Pokedex/PokedexSaveResearchEntry.cs @@ -138,8 +138,7 @@ public void IncreaseCurrentResearchLevel(PokedexResearchTaskType8a task, int idx public void SetCurrentResearchLevel(PokedexResearchTaskType8a task, int idx, int value) { // Bound values in [0, 60000] - if (value < 0) - throw new ArgumentOutOfRangeException(nameof(value)); + ArgumentOutOfRangeException.ThrowIfNegative(value); var cappedValue = (ushort)Math.Min(value, PokedexConstants8a.MaxPokedexResearchPoints); switch (task) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/AreaSpawnerSet8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/AreaSpawnerSet8a.cs index cf5f60eb3..351185340 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/AreaSpawnerSet8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/AreaSpawnerSet8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -20,6 +20,7 @@ namespace PKHeX.Core; // metadata (count) public AreaSpawnerSet8a(SCBlock block) : this(block.Data) { } + // ReSharper disable once ConvertToPrimaryConstructor public AreaSpawnerSet8a(Span data) => Data = data; private Span Meta => Data[MetaOffset..]; diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSet8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSet8a.cs index ca05629b6..2c1821a25 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSet8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSet8a.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace PKHeX.Core; @@ -13,6 +13,7 @@ namespace PKHeX.Core; private readonly Span Data; public MassOutbreakSet8a(SCBlock block) : this(block.Data) { } + // ReSharper disable once ConvertToPrimaryConstructor public MassOutbreakSet8a(Span data) => Data = data; public MassOutbreakSpawner8a this[int index] => new(Data.Slice(MassOutbreakSpawner8a.SIZE * index, MassOutbreakSpawner8a.SIZE)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSpawner8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSpawner8a.cs index affed202f..54fe788eb 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSpawner8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassOutbreakSpawner8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -12,6 +12,7 @@ namespace PKHeX.Core; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public MassOutbreakSpawner8a(Span data) => Data = data; public ushort DisplaySpecies { get => ReadUInt16LittleEndian(Data); set => WriteUInt16LittleEndian(Data, value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakArea8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakArea8a.cs index 215a6f552..5bef61f16 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakArea8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakArea8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -13,6 +13,7 @@ namespace PKHeX.Core; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public MassiveOutbreakArea8a(Span data) => Data = data; public ulong AreaHash => ReadUInt64LittleEndian(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSet8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSet8a.cs index 722b821ad..e6319870b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSet8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSet8a.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace PKHeX.Core; @@ -13,6 +13,7 @@ namespace PKHeX.Core; private readonly Span Data; public MassiveOutbreakSet8a(SCBlock block) : this(block.Data) { } + // ReSharper disable once ConvertToPrimaryConstructor public MassiveOutbreakSet8a(Span data) => Data = data; public MassiveOutbreakArea8a this[int index] => new(Data.Slice(MassiveOutbreakArea8a.SIZE * index, MassiveOutbreakArea8a.SIZE)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSpawner8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSpawner8a.cs index d1dfe264d..aef81545c 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSpawner8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/MassiveOutbreakSpawner8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -12,6 +12,7 @@ namespace PKHeX.Core; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public MassiveOutbreakSpawner8a(Span data) => Data = data; public float X { get => ReadSingleLittleEndian(Data); set => WriteSingleLittleEndian(Data, value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/Spawner8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/Spawner8a.cs index f30638c36..c11147338 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/Spawner8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/Spawner8a.cs @@ -15,6 +15,7 @@ namespace PKHeX.Core; // entry[8] // metadata + // ReSharper disable once ConvertToPrimaryConstructor public Spawner8a(Span data) => Data = data; public SpawnerEntry8a this[int index] => GetEntry(index); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerEntry8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerEntry8a.cs index 66a171eb7..5a39201b7 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerEntry8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerEntry8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -14,6 +14,7 @@ namespace PKHeX.Core; public const int SIZE = 0x80; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public SpawnerEntry8a(Span data) => Data = data; public float Coordinate_00 { get => ReadSingleLittleEndian(Data); set => WriteSingleLittleEndian(Data, value); } @@ -48,7 +49,7 @@ namespace PKHeX.Core; public ulong AlphaSeed { get => ReadUInt64LittleEndian(Data[0x58..]); set => WriteUInt64LittleEndian(Data[0x58..], value); } /// - /// When spawning an entity, the game assigns a random alpha move index from the allowed move shop list. + /// When spawning an entity, the game assigns a random alpha move index from the allowed move shop list. /// /// Count of move shop moves that the species can learn /// Learn-able move shop index to set as the diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerMeta8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerMeta8a.cs index 7fc94cbf3..b09e9d034 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerMeta8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/Spawners/SpawnerMeta8a.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -11,6 +11,7 @@ namespace PKHeX.Core; public const int SIZE = 0x40; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public SpawnerMeta8a(Span data) => Data = data; public ulong CountSeed { get => ReadUInt64LittleEndian(Data); set => WriteUInt64LittleEndian(Data , value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/Meta8.cs b/PKHeX.Core/Saves/Substructures/Gen8/Meta8.cs index c267f0729..a234edf81 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/Meta8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/Meta8.cs @@ -46,8 +46,8 @@ public static IEnumerable RipSizes(IReadOnlyCollection blocks) } #endif - private static ReadOnlySpan DefaultChunkSizesSWSH => new uint[] - { + private static ReadOnlySpan DefaultChunkSizesSWSH => + [ 0x00A1F55B, 0x00004, 0x0123EA7A, 0x00004, 0x017C3CBB, 0x00001, 0x0192A204, 0x00009, 0x01A1F6EE, 0x00004, 0x01BFCAD0, 0x00002, 0x02B647B4, 0x00004, 0x02BFCC63, 0x00002, 0x02C163FD, 0x00004, 0x02DD636A, 0x00004, 0x034B256C, 0x00004, 0x03C18D2C, 0x00002, @@ -268,10 +268,10 @@ public static IEnumerable RipSizes(IReadOnlyCollection blocks) 0xFE1AF622, 0x00001, 0xFE2E9869, 0x00004, 0xFE44971E, 0x00002, 0xFE4D59C7, 0x00004, 0xFEB13D33, 0x00002, 0xFEB64141, 0x00001, 0xFEE68CE1, 0x00004, 0xFF4498B1, 0x00002, 0xFFA1F3C8, 0x00004, - }; + ]; - private static ReadOnlySpan DefaultChunkSizesLA => new uint[] - { + private static ReadOnlySpan DefaultChunkSizesLA => + [ 0x00EF4BAE, 0x00140, 0x017C3CBB, 0x00001, 0x02168706, 0x1E460, 0x022A2253, 0x00001, 0x024C8CF3, 0x00004, 0x033D60DA, 0x00004, 0x0493AF74, 0x00004, 0x04AE4181, 0x00001, 0x04EABECF, 0x00004, 0x050E9D63, 0x00004, 0x05E7EBEB, 0x02EE0, 0x062AF6C2, 0x00020, @@ -397,5 +397,5 @@ public static IEnumerable RipSizes(IReadOnlyCollection blocks) 0xF45C3F59, 0x00004, 0xF4954B60, 0x00004, 0xF5D9F4A5, 0x00118, 0xF626721E, 0x00004, 0xF62D79D3, 0x00004, 0xF8154AC9, 0x00004, 0xFB58B1A7, 0x00064, 0xFB5AE87D, 0x00004, 0xFC374750, 0x00004, 0xFF400328, 0x00004, 0xFFCC05C2, 0x00001, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Box8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Box8.cs index 16f52f319..c0c513f7b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Box8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Box8.cs @@ -1,6 +1,3 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public sealed class Box8 : SaveBlock -{ - public Box8(SaveFile sav, SCBlock block) : base(sav, block.Data) { } -} +public sealed class Box8(SaveFile sav, SCBlock block) : SaveBlock(sav, block.Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/BoxLayout8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/BoxLayout8.cs index 5b28c5b50..40077a155 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/BoxLayout8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/BoxLayout8.cs @@ -2,14 +2,12 @@ namespace PKHeX.Core; -public sealed class BoxLayout8 : SaveBlock, IBoxDetailName +public sealed class BoxLayout8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data), IBoxDetailName { public const int BoxCount = 32; private const int StringMaxLength = SAV6.LongStringLength / 2; - public BoxLayout8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - private static int GetBoxNameOffset(int box) => SAV6.LongStringLength * box; private Span GetBoxNameSpan(int box) => Data.AsSpan(GetBoxNameOffset(box), SAV6.LongStringLength); public string GetBoxName(int box) => SAV.GetString(GetBoxNameSpan(box)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Coordinates8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Coordinates8.cs index a5c1e10f5..4cdc9d575 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Coordinates8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Coordinates8.cs @@ -6,10 +6,8 @@ namespace PKHeX.Core; /// /// Stores the position of the player. /// -public sealed class Coordinates8 : SaveBlock +public sealed class Coordinates8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Coordinates8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - // Position public float X { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x10), value); } public float Z { get => ReadSingleLittleEndian(Data.AsSpan(Offset + 0x14)); set => WriteSingleLittleEndian(Data.AsSpan(Offset + 0x14), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Daycare8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Daycare8.cs index 901bb48ce..e6434fdf5 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Daycare8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Daycare8.cs @@ -1,4 +1,4 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; @@ -6,10 +6,8 @@ namespace PKHeX.Core; /// /// Storage for the two in-game daycare structures. /// -public sealed class Daycare8 : SaveBlock +public sealed class Daycare8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Daycare8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - // BLOCK STRUCTURE: // bool8 present // pk8 entry1 diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FashionUnlock8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FashionUnlock8.cs index 1127e287c..5e20c0025 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FashionUnlock8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FashionUnlock8.cs @@ -3,7 +3,7 @@ namespace PKHeX.Core; -public sealed class FashionUnlock8 : SaveBlock +public sealed class FashionUnlock8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { private const int SIZE_ENTRY = 0x80; private const int REGIONS = 15; @@ -18,8 +18,6 @@ public sealed class FashionUnlock8 : SaveBlock public const int REGION_LEGWEAR = 13; public const int REGION_FOOTWEAR = 14; - public FashionUnlock8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public bool[] GetArrayOwnedFlag(int region) => FlagUtil.GitBitFlagArray(Data.AsSpan(region * SIZE_ENTRY), SIZE_ENTRY * 8); public bool[] GetArrayNewFlag(int region) => FlagUtil.GitBitFlagArray(Data.AsSpan((region + REGIONS) * SIZE_ENTRY), SIZE_ENTRY * 8); public int[] GetIndexesOwnedFlag(int region) => GetIndexes(GetArrayOwnedFlag(region)); @@ -38,7 +36,7 @@ public static int[] GetIndexes(ReadOnlySpan arr) if (arr[i]) list.Add(i); } - return list.ToArray(); + return [.. list]; } public static bool[] SetIndexes(ReadOnlySpan arr) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FieldMoveModelSave8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FieldMoveModelSave8.cs index ae88b2dd9..131187f7e 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FieldMoveModelSave8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/FieldMoveModelSave8.cs @@ -1,12 +1,10 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; -public sealed class FieldMoveModelSave8 : SaveBlock +public sealed class FieldMoveModelSave8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public FieldMoveModelSave8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public int M { get => ReadUInt16LittleEndian(Data.AsSpan(0x00)); set => WriteUInt16LittleEndian(Data.AsSpan(0x00), (ushort)value); } public float X { get => ReadSingleLittleEndian(Data.AsSpan(0x08)); set => WriteSingleLittleEndian(Data.AsSpan(0x08), value); } public float Z { get => ReadSingleLittleEndian(Data.AsSpan(0x10)); set => WriteSingleLittleEndian(Data.AsSpan(0x10), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Fused8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Fused8.cs index 6402c5db6..121e189d9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Fused8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Fused8.cs @@ -5,10 +5,8 @@ namespace PKHeX.Core; /// /// Storage for the species that was fused into and . /// -public sealed class Fused8 : SaveBlock +public sealed class Fused8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Fused8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public static int GetFusedSlotOffset(int slot) { if ((uint)slot >= 3) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Misc8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Misc8.cs index ad45a5014..1ead1012b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Misc8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Misc8.cs @@ -1,12 +1,10 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; -public sealed class Misc8 : SaveBlock +public sealed class Misc8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Misc8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public int Badges { get => Data[Offset + 0x00]; diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs index 0b051a6ac..d87710cb9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyItem8.cs @@ -2,7 +2,7 @@ namespace PKHeX.Core; -public sealed class MyItem8 : MyItem +public sealed class MyItem8(SaveFile SAV, SCBlock block) : MyItem(SAV, block.Data) { public const int Medicine = 0; public const int Balls = Medicine + (4 * PouchSize8.Medicine); @@ -14,15 +14,13 @@ public sealed class MyItem8 : MyItem public const int Ingredients = Treasures + (4 * PouchSize8.Treasures); public const int Key = Ingredients + (4 * PouchSize8.Ingredients); - public MyItem8(SaveFile SAV, SCBlock block) : base(SAV, block.Data) { } - public override IReadOnlyList Inventory { get { var info = ItemStorage8SWSH.Instance; InventoryPouch8[] pouch = - { + [ new(InventoryType.Medicine, info, 999, Medicine, PouchSize8.Medicine), new(InventoryType.Balls, info, 999, Balls, PouchSize8.Balls), new(InventoryType.BattleItems, info, 999, Battle, PouchSize8.Battle), @@ -32,7 +30,7 @@ public override IReadOnlyList Inventory new(InventoryType.Treasure, info, 999, Treasures, PouchSize8.Treasures), new(InventoryType.Candy, info, 999, Ingredients, PouchSize8.Ingredients), new(InventoryType.KeyItems, info, 1, Key, PouchSize8.Key), - }; + ]; return pouch.LoadAll(Data); } set diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs index a40d8b3cc..0fb3ffe7f 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/MyStatus8.cs @@ -4,12 +4,10 @@ namespace PKHeX.Core; -public sealed class MyStatus8 : SaveBlock +public sealed class MyStatus8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { public const uint MaxWatt = 9999999; - public MyStatus8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public string Number { get => Encoding.ASCII.GetString(Data, 0x01, 3); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Party8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Party8.cs index 882208fe0..e3ff9e044 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Party8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Party8.cs @@ -1,9 +1,7 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public sealed class Party8 : SaveBlock +public sealed class Party8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Party8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public int PartyCount { get => Data[6 * PokeCrypto.SIZE_8PARTY]; diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/PlayTime8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/PlayTime8.cs index bac808170..2e3b0947a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/PlayTime8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/PlayTime8.cs @@ -3,10 +3,8 @@ namespace PKHeX.Core; -public sealed class PlayTime8 : SaveBlock +public sealed class PlayTime8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public PlayTime8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public int PlayedHours { get => ReadUInt16LittleEndian(Data.AsSpan(Offset)); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RaidSpawnList8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RaidSpawnList8.cs index 673ae6d83..b31721ed4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RaidSpawnList8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RaidSpawnList8.cs @@ -4,16 +4,10 @@ namespace PKHeX.Core; -public sealed class RaidSpawnList8 : SaveBlock +public sealed class RaidSpawnList8(SAV8SWSH sav, SCBlock block, int legal) : SaveBlock(sav, block.Data) { - public readonly int CountAll; - public readonly int CountUsed; - - public RaidSpawnList8(SAV8SWSH sav, SCBlock block, int legal) : base(sav, block.Data) - { - CountAll = block.Data.Length / RaidSpawnDetail.SIZE; - CountUsed = legal; - } + public readonly int CountAll = block.Data.Length / RaidSpawnDetail.SIZE; + public readonly int CountUsed = legal; public const int RaidCountLegal_O0 = 100; public const int RaidCountLegal_R1 = 90; @@ -62,19 +56,10 @@ public string[] DumpAll() } } -public sealed class RaidSpawnDetail +public sealed class RaidSpawnDetail(byte[] Data, int Offset) { public const int SIZE = 0x18; - private readonly byte[] Data; - private readonly int Offset; - - public RaidSpawnDetail(byte[] data, int ofs) - { - Data = data; - Offset = ofs; - } - private const string General = nameof(General); private const string Derived = nameof(Derived); diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Record8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Record8.cs index 40047d4a7..9ad2ebfe7 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Record8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/Record8.cs @@ -4,14 +4,12 @@ namespace PKHeX.Core; -public sealed class Record8 : RecordBlock +public sealed class Record8(SAV8SWSH sav, SCBlock block) : RecordBlock(sav, block.Data) { public const int RecordCount = 50; public const int WattTotal = 22; protected override ReadOnlySpan RecordMax => MaxType_SWSH; - public Record8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public override int GetRecord(int recordID) { int ofs = Records.GetOffset(Offset, recordID); @@ -35,12 +33,12 @@ public override void SetRecord(int recordID, int value) Trace.Fail(nameof(recordID)); } - private static ReadOnlySpan MaxType_SWSH => new byte[] - { + private static ReadOnlySpan MaxType_SWSH => + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RentalTeam8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RentalTeam8.cs index 72997fc69..305e32c7a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RentalTeam8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/RentalTeam8.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; /// /// Container block for a single Generation 8 saved Rental Team /// -public sealed class RentalTeam8 : IRentalTeam, IPokeGroup +public sealed class RentalTeam8(byte[] Data) : IRentalTeam, IPokeGroup { public const int SIZE = 0x880; @@ -27,10 +27,6 @@ public sealed class RentalTeam8 : IRentalTeam, IPokeGroup private const int OFS_6 = OFS_5 + LEN_POKE; private const int POST_META = OFS_6 + LEN_POKE; // 0x866 - private readonly byte[] Data; - - public RentalTeam8(byte[] data) => Data = data; - public ulong ID { get => ReadUInt64LittleEndian(GetMetadataStart()); set => WriteUInt64LittleEndian(GetMetadataStart(), value); } public string TeamID { get => StringConverter8.GetString(GetMetadataStart().Slice(8, 0x1C)); set => StringConverter8.SetString(GetMetadataStart().Slice(8, 0x1C), value, 0x1C / 2); } // 2 unused bytes, probably null terminator for TeamID @@ -40,8 +36,8 @@ public sealed class RentalTeam8 : IRentalTeam, IPokeGroup public PK8 GetSlot(int slot) { var ofs = GetSlotOffset(slot); - var data = Data.Slice(ofs, LEN_POKE); - var pk8 = new PK8(data); + var data1 = Data.AsSpan(ofs, LEN_POKE); + var pk8 = new PK8(data1.ToArray()); pk8.ResetPartyStats(); return pk8; } @@ -49,10 +45,10 @@ public PK8 GetSlot(int slot) public void SetSlot(int slot, PK8 pk) { var ofs = GetSlotOffset(slot); - var data = pk.EncryptedPartyData; + var data1 = pk.EncryptedPartyData; // Wipe Party Stats - Array.Clear(data, LEN_STORED, LEN_PARTYSTAT); - data.CopyTo(Data, ofs); + Array.Clear(data1, LEN_STORED, LEN_PARTYSTAT); + data1.CopyTo(Data, ofs); } public PK8[] GetTeam() diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TeamIndexes8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TeamIndexes8.cs index 44dbbba35..712aeb1f5 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TeamIndexes8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TeamIndexes8.cs @@ -1,16 +1,14 @@ -using System; +using System; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.Core; -public sealed class TeamIndexes8 : SaveBlock, ITeamIndexSet +public sealed class TeamIndexes8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data), ITeamIndexSet { private const int TeamCount = 6; private const int NONE_SELECTED = -1; public readonly int[] TeamSlots = new int[TeamCount * 6]; - public TeamIndexes8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - public void LoadBattleTeams() { if (!SAV.State.Exportable) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TitleScreen8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TitleScreen8.cs index 5774785ff..676590320 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TitleScreen8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TitleScreen8.cs @@ -7,10 +7,8 @@ namespace PKHeX.Core; /// /// Pokémon Team that shows up at the title screen. /// -public sealed class TitleScreen8 : SaveBlock +public sealed class TitleScreen8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public TitleScreen8(SAV8SWSH sav, SCBlock block) : base(sav, block.Data) { } - /// /// Gets an object that exposes the data of the corresponding party . /// @@ -35,17 +33,9 @@ public void LoadTeamData(IList party) } } -public sealed class TitleScreen8Poke : ISpeciesForm +public sealed class TitleScreen8Poke(byte[] Data, int Offset) : ISpeciesForm { public const int SIZE = 0x28; - private readonly byte[] Data; - private readonly int Offset; - - public TitleScreen8Poke(byte[] data, int offset) - { - Data = data; - Offset = offset; - } public ushort Species { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs index c5e2841d4..505aa25a7 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/SWSH/TrainerCard8.cs @@ -5,10 +5,8 @@ namespace PKHeX.Core; -public sealed class TrainerCard8 : SaveBlock +public sealed class TrainerCard8(SAV8SWSH sav, SCBlock block) : SaveBlock(sav, block.Data) { - public TrainerCard8(SAV8SWSH sav, SCBlock block) : base (sav, block.Data) { } - private Span OT_Trash => Data.AsSpan(0x00, 0x1A); public string OT @@ -269,23 +267,15 @@ public byte StartedDay public uint TimestampPrinted { - // should this be a ulong? + // should this be an unsigned long? get => ReadUInt32LittleEndian(Data.AsSpan(Offset + 0x1A8)); set => WriteUInt32LittleEndian(Data.AsSpan(Offset + 0x1A8), value); } } -public sealed class TrainerCard8Poke : ISpeciesForm +public sealed class TrainerCard8Poke(byte[] Data, int Offset) : ISpeciesForm { public const int SIZE = 0x1C; - private readonly byte[] Data; - private readonly int Offset; - - public TrainerCard8Poke(byte[] data, int offset) - { - Data = data; - Offset = offset; - } public ushort Species { diff --git a/PKHeX.Core/Saves/Substructures/Gen9/BoxLayout9.cs b/PKHeX.Core/Saves/Substructures/Gen9/BoxLayout9.cs index ffd789ce9..a44bb5997 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/BoxLayout9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/BoxLayout9.cs @@ -2,14 +2,12 @@ namespace PKHeX.Core; -public sealed class BoxLayout9 : SaveBlock, IBoxDetailName +public sealed class BoxLayout9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data), IBoxDetailName { public const int BoxCount = 32; private const int StringMaxLength = SAV6.LongStringLength / 2; - public BoxLayout9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - private static int GetBoxNameOffset(int box) => SAV6.LongStringLength * box; private Span GetBoxNameSpan(int box) => Data.AsSpan(GetBoxNameOffset(box), SAV6.LongStringLength); diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs b/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs index 25745a6f3..02f65b438 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs @@ -3,10 +3,8 @@ namespace PKHeX.Core; -public sealed class ConfigCamera9 : SaveBlock +public sealed class ConfigCamera9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public ConfigCamera9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - // Structure: u32 /* CameraSupport:1 | On = 0, Off = 1 * CameraInterpolation:1 | Slow = 0, Normal = 1 diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs b/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs index 59147a020..2e97d3229 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs @@ -3,10 +3,8 @@ namespace PKHeX.Core; -public sealed class ConfigSave9 : SaveBlock +public sealed class ConfigSave9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public ConfigSave9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - // Structure: u32 /* TalkingSpeed:2 * SkipMoveLearning:1 | On = 0, Off = 1 diff --git a/PKHeX.Core/Saves/Substructures/Gen9/Epoch1900Value.cs b/PKHeX.Core/Saves/Substructures/Gen9/Epoch1900Value.cs index e83b72c65..fbd78ea72 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/Epoch1900Value.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/Epoch1900Value.cs @@ -7,15 +7,13 @@ namespace PKHeX.Core; /// Stores the to indicate the seconds since 1900 (rounded to days) that an event occurred. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class Epoch1900Value +public sealed class Epoch1900Value(Memory Data) { // Data should be 4 bytes where we only care about the first 3 bytes i.e. 24 bits // First 6 bits are day, next 6 bits are 0 indexed month, last 12 bits are year from 1900 - private readonly Memory Data; private Span Span => Data.Span; public Epoch1900Value(SCBlock block) : this(block.Data) { } - public Epoch1900Value(Memory data) => Data = data; private static DateTime Epoch => new(1900, 1, 1); diff --git a/PKHeX.Core/Saves/Substructures/Gen9/FixedSpawnList9.cs b/PKHeX.Core/Saves/Substructures/Gen9/FixedSpawnList9.cs index ac0460927..4653d5bd4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/FixedSpawnList9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/FixedSpawnList9.cs @@ -6,14 +6,9 @@ namespace PKHeX.Core; [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class FixedSpawnList9 : SaveBlock +public sealed class FixedSpawnList9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public readonly int CountAll; - - public FixedSpawnList9(SAV9SV sav, SCBlock block) : base(sav, block.Data) - { - CountAll = block.Data.Length / FixedSpawnDetail.SIZE; - } + public readonly int CountAll = block.Data.Length / FixedSpawnDetail.SIZE; public FixedSpawnDetail GetSpawn(int entry) => new(Data, entry * FixedSpawnDetail.SIZE); @@ -48,19 +43,10 @@ public PK9[] GetAllEntities() } } -public sealed class FixedSpawnDetail +public sealed class FixedSpawnDetail(byte[] Data, int Offset) { public const int SIZE = 0x170; - private readonly byte[] Data; - private readonly int Offset; - - public FixedSpawnDetail(byte[] data, int ofs) - { - Data = data; - Offset = ofs; - } - private const string General = nameof(General); private const string Misc = nameof(Misc); @@ -81,7 +67,7 @@ public bool IsEnabled [Category(General), Description("Encrypted Entity data.")] public PK9 Entity { - get => new(Data.Slice(Offset + 0x09, PokeCrypto.SIZE_9PARTY)); + get => new(Data.AsSpan(Offset + 0x09, PokeCrypto.SIZE_9PARTY).ToArray()); set => value.EncryptedPartyData.CopyTo(Data, Offset + 0x09); } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/Meta9.cs b/PKHeX.Core/Saves/Substructures/Gen9/Meta9.cs index 1103069bf..8644d306c 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/Meta9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/Meta9.cs @@ -45,8 +45,8 @@ public static IEnumerable RipSizes(IReadOnlyCollection blocks) } #endif - private static ReadOnlySpan DefaultChunkSizesSV => new uint[] - { + private static ReadOnlySpan DefaultChunkSizesSV => + [ 0x0018E0B9, 0x00008, 0x001FD42F, 0x00008, 0x0022B5C9, 0x00008, 0x003096FA, 0x00008, 0x0031E2C7, 0x00008, 0x003D333A, 0x00020, 0x0044E726, 0x00008, 0x00475C1C, 0x00008, 0x004E50A7, 0x00008, 0x00521A8B, 0x00020, 0x005A9661, 0x00008, 0x005AD5F7, 0x00008, @@ -1767,5 +1767,5 @@ public static IEnumerable RipSizes(IReadOnlyCollection blocks) 0xFF844AAA, 0x00008, 0xFF91A170, 0x00008, 0xFFAC1654, 0x00008, 0xFFB34E8D, 0x00008, 0xFFB35E50, 0x00008, 0xFFBE24DA, 0x00008, 0xFFC43650, 0x00008, 0xFFC50DCA, 0x00008, 0xFFDD9BB9, 0x00008, 0xFFEB29AE, 0x00008, 0xFFFCAD52, 0x00008, - }; + ]; } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs b/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs index b48585bde..e6561181a 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/MyItem9.cs @@ -7,12 +7,10 @@ namespace PKHeX.Core; /// Player item pouches storage /// /// size=0xBB80 ( items) -public sealed class MyItem9 : MyItem +public sealed class MyItem9(SaveFile SAV, SCBlock block) : MyItem(SAV, block.Data) { public const int ItemSaveSize = 3000; - public MyItem9(SaveFile SAV, SCBlock block) : base(SAV, block.Data) { } - public int GetItemQuantity(ushort itemIndex) { var ofs = InventoryPouch9.GetItemOffset(itemIndex); @@ -37,8 +35,8 @@ public void SetItemQuantity(ushort itemIndex, int quantity) private IReadOnlyList ConvertToPouches() { - var pouches = new[] - { + InventoryPouch9[] pouches = + [ MakePouch(InventoryType.Medicine), MakePouch(InventoryType.Balls), MakePouch(InventoryType.BattleItems), @@ -49,7 +47,7 @@ private IReadOnlyList ConvertToPouches() MakePouch(InventoryType.Ingredients), MakePouch(InventoryType.KeyItems), MakePouch(InventoryType.Candy), - }; + ]; return pouches.LoadAll(Data); } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/MyStatus9.cs b/PKHeX.Core/Saves/Substructures/Gen9/MyStatus9.cs index 56af9f53f..cafc452fc 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/MyStatus9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/MyStatus9.cs @@ -3,10 +3,8 @@ namespace PKHeX.Core; -public sealed class MyStatus9 : SaveBlock +public sealed class MyStatus9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public MyStatus9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - public uint ID32 { get => ReadUInt32LittleEndian(Data); diff --git a/PKHeX.Core/Saves/Substructures/Gen9/Party9.cs b/PKHeX.Core/Saves/Substructures/Gen9/Party9.cs index 3fe8a73a0..a54f58a2b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/Party9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/Party9.cs @@ -1,9 +1,7 @@ namespace PKHeX.Core; -public sealed class Party9 : SaveBlock +public sealed class Party9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public Party9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - public int PartyCount { get => Data[6 * PokeCrypto.SIZE_9PARTY]; diff --git a/PKHeX.Core/Saves/Substructures/Gen9/PlayTime9.cs b/PKHeX.Core/Saves/Substructures/Gen9/PlayTime9.cs index df7670f2a..f384daf67 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/PlayTime9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/PlayTime9.cs @@ -3,10 +3,8 @@ namespace PKHeX.Core; -public sealed class PlayTime9 : SaveBlock +public sealed class PlayTime9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public PlayTime9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - public int PlayedHours { get => ReadInt32LittleEndian(Data.AsSpan(Offset)); diff --git a/PKHeX.Core/Saves/Substructures/Gen9/PlayerAppearance9.cs b/PKHeX.Core/Saves/Substructures/Gen9/PlayerAppearance9.cs index f565d308e..e255865e9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/PlayerAppearance9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/PlayerAppearance9.cs @@ -8,9 +8,8 @@ namespace PKHeX.Core; /// Stores the selected facial appearances of the player. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class PlayerAppearance9 : SaveBlock +public sealed class PlayerAppearance9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public PlayerAppearance9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } public ulong SkinColor { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x00), value); } public ulong LipColor { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x08)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x08), value); } public ulong ColorContacts { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x10), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashion9.cs b/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashion9.cs index b83bd0f59..8c5c8810b 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashion9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashion9.cs @@ -8,9 +8,8 @@ namespace PKHeX.Core; /// Stores the selected clothing choices of the player. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public sealed class PlayerFashion9 : SaveBlock +public sealed class PlayerFashion9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public PlayerFashion9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } public ulong Base { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x00)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x00), value); } public ulong Accessory { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x08)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x08), value); } public ulong Bag { get => ReadUInt64LittleEndian(Data.AsSpan(Offset + 0x10)); set => WriteUInt64LittleEndian(Data.AsSpan(Offset + 0x10), value); } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashionUnlock9.cs b/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashionUnlock9.cs index 7520179ab..06a69f037 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashionUnlock9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/PlayerFashionUnlock9.cs @@ -7,8 +7,8 @@ namespace PKHeX.Core; public static class PlayerFashionUnlock9 { - private static ReadOnlySpan Eyewear => new ushort[] - { + private static ReadOnlySpan Eyewear => + [ 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, @@ -21,10 +21,10 @@ public static class PlayerFashionUnlock9 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1225, 1226, 1227, 1228, - }; + ]; - private static ReadOnlySpan Gloves => new ushort[] - { + private static ReadOnlySpan Gloves => + [ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, @@ -33,10 +33,10 @@ public static class PlayerFashionUnlock9 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, - }; + ]; - private static ReadOnlySpan Bag => new ushort[] - { + private static ReadOnlySpan Bag => + [ 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, @@ -45,10 +45,10 @@ public static class PlayerFashionUnlock9 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3140, 3141, - }; + ]; - private static ReadOnlySpan Footwear => new ushort[] - { + private static ReadOnlySpan Footwear => + [ 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4028, 4029, 4030, 4031, 4032, 4033, 4034, 4035, 4036, 4037, 4038, 4039, 4040, 4041, 4042, 4043, 4044, 4045, 4046, 4047, 4048, 4049, 4050, 4051, 4052, 4053, 4054, 4055, 4056, 4057, @@ -59,10 +59,10 @@ public static class PlayerFashionUnlock9 4134, 4135, 4136, 4137, 4138, 4139, 4140, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4172, 4173, 4174, 4175, 4176, 4177, 4178, 4179, 4180, 4181, 4182, 4183, 4184, 4185, - }; + ]; - private static ReadOnlySpan Headwear => new ushort[] - { + private static ReadOnlySpan Headwear => + [ 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 5032, 5033, 5034, 5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5043, 5044, 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053, 5054, 5055, 5056, 5057, @@ -90,10 +90,10 @@ public static class PlayerFashionUnlock9 5457, 5458, 5459, 5460, 5461, 5462, 5463, 5464, 5465, 5466, 5467, 5468, 5469, 5470, 5471, 5472, 5473, 5474, 5475, 5476, 5477, 5478, 5479, 5480, 5481, 5482, 5483, 5484, 5485, 5486, 5487, 5488, 5489, 5490, 5491, 5492, 5493, 5494, 5495, 5496, 5497, 5498, 5499, 5500, 5501, 5502, 5503, 5504, - }; + ]; - private static ReadOnlySpan Legwear => new ushort[] - { + private static ReadOnlySpan Legwear => + [ 6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010, 6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6019, 6020, 6021, 6022, 6023, 6024, 6025, 6026, 6027, 6028, 6029, 6030, 6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039, 6040, 6041, 6042, 6043, 6044, 6045, 6046, 6047, 6048, 6049, 6050, 6051, 6052, 6053, 6054, 6055, 6056, @@ -101,18 +101,18 @@ public static class PlayerFashionUnlock9 6076, 6077, 6078, 6079, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089, 6090, 6091, 6092, 6093, 6094, 6095, 6096, 6097, 6098, 6099, 6100, 6101, 6102, 6103, 6104, 6105, 6106, 6107, 6108, 6109, 6110, 6111, 6112, 6113, 6114, 6115, 6116, 6117, 6118, 6119, 6120, 6121, 6122, - }; + ]; - private static ReadOnlySpan ClothingF => new ushort[] { 7000, 7001, 7002, 7003, 7008, 7009, 7010, 7011, 7017, 7019, 7021, 7023, 7025 }; - private static ReadOnlySpan ClothingM => new ushort[] { 7004, 7005, 7006, 7007, 7012, 7013, 7014, 7015, 7016, 7018, 7020, 7022, 7024 }; + private static ReadOnlySpan ClothingF => [ 7000, 7001, 7002, 7003, 7008, 7009, 7010, 7011, 7017, 7019, 7021, 7023, 7025 ]; + private static ReadOnlySpan ClothingM => [ 7004, 7005, 7006, 7007, 7012, 7013, 7014, 7015, 7016, 7018, 7020, 7022, 7024 ]; - private static ReadOnlySpan PhoneCase => new ushort[] - { + private static ReadOnlySpan PhoneCase => + [ 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009, 8010, 8011, 8012, 8013, 8014, 8015, 8016, 8017, 8018, 8019, 8020, 8021, 8022, 8023, 8024, 8025, 8026, 8027, 8028, 8029, 8030, 8031, 8032, 8033, 8034, 8035, 8036, 8037, 8038, 8039, 8040, 8041, 8042, 8043, 8044, 8045, 8046, 8047, 8048, 8049, 8050, 8051, 8052, 8053, 8054, 8055, 8056, 8057, 8058, 8059, 8060, 8061, 8062, 8063, 8064, 8065, 8066, 8067, - }; + ]; public static int Add(SCBlockAccessor acc, uint key, ReadOnlySpan add) { diff --git a/PKHeX.Core/Saves/Substructures/Gen9/RaidSevenStar9.cs b/PKHeX.Core/Saves/Substructures/Gen9/RaidSevenStar9.cs index 747e1c0ee..397028381 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/RaidSevenStar9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/RaidSevenStar9.cs @@ -5,14 +5,9 @@ namespace PKHeX.Core; -public sealed class RaidSevenStar9 : SaveBlock +public sealed class RaidSevenStar9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data) { - public readonly int CountAll; - - public RaidSevenStar9(SAV9SV sav, SCBlock block) : base(sav, block.Data) - { - CountAll = block.Data.Length / SevenStarRaidDetail.SIZE; - } + public readonly int CountAll = block.Data.Length / SevenStarRaidDetail.SIZE; public SevenStarRaidDetail GetRaid(int entry) => new(Data, 0x00 + (entry * SevenStarRaidDetail.SIZE)); @@ -25,19 +20,10 @@ public SevenStarRaidDetail[] GetAllRaids() } } -public sealed class SevenStarRaidDetail +public sealed class SevenStarRaidDetail(byte[] Data, int Offset) { public const int SIZE = 0x08; - private readonly byte[] Data; - private readonly int Offset; - - public SevenStarRaidDetail(byte[] data, int ofs) - { - Data = data; - Offset = ofs; - } - private const string General = nameof(General); [Category(General), Description("Identifier used for this 7 Star Raid. Matches the date this raid was first distributed.")] diff --git a/PKHeX.Core/Saves/Substructures/Gen9/RaidSpawnList9.cs b/PKHeX.Core/Saves/Substructures/Gen9/RaidSpawnList9.cs index 099e45470..6044cdd66 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/RaidSpawnList9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/RaidSpawnList9.cs @@ -69,15 +69,12 @@ public void Propagate(int sourceIndex, bool seedToo) } } -public sealed class TeraRaidDetail +public sealed class TeraRaidDetail(Memory Data) { public const int SIZE = 0x20; - private readonly Memory Data; private Span Span => Data.Span; - public TeraRaidDetail(Memory data) => Data = data; - private const string General = nameof(General); private const string Misc = nameof(Misc); diff --git a/PKHeX.Core/Saves/Substructures/Gen9/RentalTeam9.cs b/PKHeX.Core/Saves/Substructures/Gen9/RentalTeam9.cs index 73fa7e78d..abd9e6cb5 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/RentalTeam9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/RentalTeam9.cs @@ -8,7 +8,7 @@ namespace PKHeX.Core; /// /// A single Generation 9 Rental Team /// -public sealed class RentalTeam9 : IRentalTeam, IPokeGroup +public sealed class RentalTeam9(byte[] Data) : IRentalTeam, IPokeGroup { private const int LEN_OT = 11; // char private const int LEN_TEAMNAME = 10; // char @@ -29,9 +29,7 @@ public sealed class RentalTeam9 : IRentalTeam, IPokeGroup private const int OFS_END = OFS_6 + LEN_POKE; public const int SIZE = OFS_END + sizeof(uint); // 0x844 - public readonly byte[] Data; - - public RentalTeam9(byte[] data) => Data = data; + public readonly byte[] Data = Data; // 2 bytes number public ushort ID @@ -71,8 +69,8 @@ public uint EntityCount public PK9 GetSlot(int slot) { var ofs = GetSlotOffset(slot); - var data = Data.Slice(ofs, LEN_POKE); - var pk9 = new PK9(data); + var data = Data.AsSpan(ofs, LEN_POKE); + var pk9 = new PK9(data.ToArray()); pk9.ResetPartyStats(); return pk9; } diff --git a/PKHeX.Core/Saves/Substructures/Gen9/RentalTeamSet9.cs b/PKHeX.Core/Saves/Substructures/Gen9/RentalTeamSet9.cs index d99fd46bf..f40967340 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/RentalTeamSet9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/RentalTeamSet9.cs @@ -6,13 +6,11 @@ namespace PKHeX.Core; /// /// Save Block for Scarlet/Violet that stores a fixed amount of saved rental teams. /// -public sealed class RentalTeamSet9 : IPokeGroup +public sealed class RentalTeamSet9(byte[] Data) : IPokeGroup { public const int SIZE = Count * RentalTeam9.SIZE; public const int Count = 5; - public readonly byte[] Data; - - public RentalTeamSet9(byte[] data) => Data = data; + public readonly byte[] Data = Data; public RentalTeam9 GetRentalTeam(int index) => RentalTeam9.GetFrom(Data, index); public void SetRentalTeam(int index, RentalTeam9 team) => team.WriteTo(Data, index); diff --git a/PKHeX.Core/Saves/Substructures/Gen9/TeamIndexes9.cs b/PKHeX.Core/Saves/Substructures/Gen9/TeamIndexes9.cs index 2f74d3694..b8bf743db 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/TeamIndexes9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/TeamIndexes9.cs @@ -3,14 +3,12 @@ namespace PKHeX.Core; -public sealed class TeamIndexes9 : SaveBlock, ITeamIndexSet +public sealed class TeamIndexes9(SAV9SV sav, SCBlock block) : SaveBlock(sav, block.Data), ITeamIndexSet { private const int TeamCount = 6; private const int NONE_SELECTED = -1; public readonly int[] TeamSlots = new int[TeamCount * 6]; - public TeamIndexes9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } - public void LoadBattleTeams() { if (!SAV.State.Exportable) diff --git a/PKHeX.Core/Saves/Substructures/IEventFlagArray.cs b/PKHeX.Core/Saves/Substructures/IEventFlagArray.cs index bfc97b378..3f9bce179 100644 --- a/PKHeX.Core/Saves/Substructures/IEventFlagArray.cs +++ b/PKHeX.Core/Saves/Substructures/IEventFlagArray.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace PKHeX.Core; @@ -9,7 +9,7 @@ public interface IEventFlagArray void SetEventFlag(int flagNumber, bool value); } -public interface IEventFlag37 : IEventFlagArray, IEventWorkArray { } +public interface IEventFlag37 : IEventFlagArray, IEventWorkArray; public static class EventFlagArrayExtensions { diff --git a/PKHeX.Core/Saves/Substructures/Inventory/IItemNewFlag.cs b/PKHeX.Core/Saves/Substructures/Inventory/IItemNewFlag.cs index 6d8c5341f..740cb0dd4 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/IItemNewFlag.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/IItemNewFlag.cs @@ -1,7 +1,7 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; public interface IItemNewFlag { - /// Indicates if the item is "NEW"ly obtained and not yet viewed. + /// Indicates if the item is NEW-ly obtained and not yet viewed. bool IsNew { get; set; } } diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem8.cs b/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem8.cs index ab2d47cdd..1aa5d17a2 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem8.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Item/InventoryItem8.cs @@ -22,7 +22,7 @@ public static InventoryItem8 GetValue(uint value) => new() Index = (int)(value & 0x7FF), Count = (int)((value >> 15) & 0x3FF), // clamp to sane values IsNew = (value & 0x40000000) != 0, // 30th bit is "NEW" - IsFavorite = (value & 0x80000000) != 0, // 31th bit is "FAVORITE" + IsFavorite = (value & 0x80000000) != 0, // 31st bit is "FAVORITE" }; public uint GetValue(bool setNew, ICollection original) diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs index 54b4239ed..56162a00d 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch.cs @@ -33,7 +33,7 @@ public abstract class InventoryPouch protected InventoryPouch(InventoryType type, IItemStorage storage, int maxCount, int offset, int size = -1) { - Items = Array.Empty(); + Items = []; Type = type; Info = storage; MaxCount = maxCount; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs index d6f9ef3d5..ad37e56d4 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3.cs @@ -4,15 +4,11 @@ namespace PKHeX.Core; -public sealed class InventoryPouch3 : InventoryPouch +public sealed class InventoryPouch3(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) + : InventoryPouch(type, info, maxCount, offset, size) { public uint SecurityKey { private get; set; } // = 0 // Gen3 Only - public InventoryPouch3(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) - : base(type, info, maxCount, offset, size) - { - } - public override void GetPouch(ReadOnlySpan data) { var span = data[Offset..]; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs index 9ab878403..7d7bb4c04 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch3GC.cs @@ -4,13 +4,9 @@ namespace PKHeX.Core; -public sealed class InventoryPouch3GC : InventoryPouch +public sealed class InventoryPouch3GC(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) + : InventoryPouch(type, info, maxCount, offset, size) { - public InventoryPouch3GC(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) - : base(type, info, maxCount, offset, size) - { - } - public override InventoryItem GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; public override void GetPouch(ReadOnlySpan data) diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs index 3a58c0d3e..666592d60 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch4.cs @@ -6,13 +6,9 @@ namespace PKHeX.Core; /// /// Inventory Pouch with 4 bytes per item (u16 ID, u16 count) /// -public sealed class InventoryPouch4 : InventoryPouch +public sealed class InventoryPouch4(InventoryType type, IItemStorage info, int maxCount, int offset) + : InventoryPouch(type, info, maxCount, offset) { - public InventoryPouch4(InventoryType type, IItemStorage info, int maxCount, int offset) - : base(type, info, maxCount, offset) - { - } - // size: 32bit // u16 id // u16 count diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs index 7dd04c6cc..32eef4277 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7.cs @@ -3,12 +3,11 @@ namespace PKHeX.Core; -public sealed class InventoryPouch7 : InventoryPouch +public sealed class InventoryPouch7(InventoryType type, IItemStorage info, int maxCount, int offset) + : InventoryPouch(type, info, maxCount, offset) { public bool SetNew { get; set; } - private int[] OriginalItems = Array.Empty(); - - public InventoryPouch7(InventoryType type, IItemStorage info, int maxCount, int offset) : base(type, info, maxCount, offset) { } + private int[] OriginalItems = []; public override InventoryItem7 GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs index 246a65854..32345ee54 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch7b.cs @@ -7,15 +7,14 @@ namespace PKHeX.Core; /// /// Inventory Pouch used by /// -public sealed class InventoryPouch7b : InventoryPouch +public sealed class InventoryPouch7b(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) + : InventoryPouch(type, info, maxCount, offset, size) { public bool SetNew { get; set; } - private int[] OriginalItems = Array.Empty(); + private int[] OriginalItems = []; public override InventoryItem7b GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; - public InventoryPouch7b(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) : base(type, info, maxCount, offset, size) { } - public override void GetPouch(ReadOnlySpan data) { var span = data[Offset..]; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs index 44b1da399..ca34b787c 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8.cs @@ -7,12 +7,11 @@ namespace PKHeX.Core; /// /// Inventory Pouch used by /// -public sealed class InventoryPouch8 : InventoryPouch +public sealed class InventoryPouch8(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) + : InventoryPouch(type, info, maxCount, offset, size) { public bool SetNew { get; set; } - private int[] OriginalItems = Array.Empty(); - - public InventoryPouch8(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) : base(type, info, maxCount, offset, size) { } + private int[] OriginalItems = []; public override InventoryItem8 GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs index 3dbf045b8..5492f1f4a 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8a.cs @@ -8,18 +8,14 @@ namespace PKHeX.Core; /// /// Used by . /// -public sealed class InventoryPouch8a : InventoryPouch +public sealed class InventoryPouch8a(InventoryType type, IItemStorage info, int maxCount, int size, int offset = 0) + : InventoryPouch(type, info, maxCount, offset) { - private readonly int MaxSize; - - public InventoryPouch8a(InventoryType type, IItemStorage info, int maxCount, int size, int offset = 0) - : base(type, info, maxCount, offset) => MaxSize = size; - public override InventoryItem8a GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; public override void GetPouch(ReadOnlySpan data) { - var items = new InventoryItem8a[MaxSize]; + var items = new InventoryItem8a[size]; for (int i = 0; i < items.Length; i++) items[i] = GetItem(data, i << 2); diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs index 88573930d..e8efbcb12 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch8b.cs @@ -4,13 +4,11 @@ namespace PKHeX.Core; -public sealed class InventoryPouch8b : InventoryPouch +public sealed class InventoryPouch8b(InventoryType type, IItemStorage info, int maxCount, int offset) + : InventoryPouch(type, info, maxCount, offset) { public bool SetNew { get; set; } - public InventoryPouch8b(InventoryType type, IItemStorage info, int maxCount, int offset) - : base(type, info, maxCount, offset) { } - public override InventoryItem8b GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count, IsNew = true }; public override void GetPouch(ReadOnlySpan data) @@ -41,7 +39,7 @@ public InventoryItem8b GetItem(ReadOnlySpan data, ushort itemID) public override void SetPouch(Span data) { - HashSet processed = new(); + HashSet processed = []; // Write all the item slots still present in the pouch. Keep track of the item IDs processed. var items = (InventoryItem8b[])Items; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs index 0ec88c0b2..0fadb2d55 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouch9.cs @@ -4,16 +4,11 @@ namespace PKHeX.Core; -public sealed class InventoryPouch9 : InventoryPouch +public sealed class InventoryPouch9(InventoryType type, IItemStorage info, int maxCount, uint pouch) + : InventoryPouch(type, info, maxCount, 0) { public bool SetNew { get; set; } - public uint PouchIndex { get; set; } - - public InventoryPouch9(InventoryType type, IItemStorage info, int maxCount, uint pouch) - : base(type, info, maxCount, 0) - { - PouchIndex = pouch; - } + public uint PouchIndex { get; set; } = pouch; public override InventoryItem9 GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count, IsNew = true }; @@ -44,7 +39,7 @@ public static InventoryItem9 GetItem(ReadOnlySpan data, ushort itemID) public override void SetPouch(Span data) { - HashSet processed = new(); + HashSet processed = []; // Write all the item slots still present in the pouch. Keep track of the item IDs processed. var items = (InventoryItem9[])Items; diff --git a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs index b756b006e..6e89c1156 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/Pouch/InventoryPouchGB.cs @@ -3,13 +3,9 @@ namespace PKHeX.Core; -public sealed class InventoryPouchGB : InventoryPouch +public sealed class InventoryPouchGB(InventoryType type, IItemStorage info, int maxCount,int offset, [ConstantExpected] int size) + : InventoryPouch(type, info, maxCount, offset, size) { - public InventoryPouchGB(InventoryType type, IItemStorage info, int maxCount, int offset, [ConstantExpected] int size) - : base(type, info, maxCount, offset, size) - { - } - public override InventoryItem GetEmpty(int itemID = 0, int count = 0) => new() { Index = itemID, Count = count }; public override void GetPouch(ReadOnlySpan data) diff --git a/PKHeX.Core/Saves/Substructures/MysteryGiftAlbum.cs b/PKHeX.Core/Saves/Substructures/MysteryGiftAlbum.cs index a5505240f..40d37a972 100644 --- a/PKHeX.Core/Saves/Substructures/MysteryGiftAlbum.cs +++ b/PKHeX.Core/Saves/Substructures/MysteryGiftAlbum.cs @@ -1,14 +1,14 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; /// /// Structure containing the Mystery Gift Data /// -public class MysteryGiftAlbum +public class MysteryGiftAlbum(DataMysteryGift[] Gifts, bool[] Flags) { /// /// Mystery Gift data received /// - public readonly DataMysteryGift[] Gifts; + public readonly DataMysteryGift[] Gifts = Gifts; /// /// Received Flag list @@ -16,21 +16,14 @@ public class MysteryGiftAlbum /// /// this[index] == true iff index= has been received already. /// - public readonly bool[] Flags; - - public MysteryGiftAlbum(DataMysteryGift[] gifts, bool[] flags) - { - Flags = flags; - Gifts = gifts; - } + public readonly bool[] Flags = Flags; } -public sealed class EncryptedMysteryGiftAlbum : MysteryGiftAlbum +public sealed class EncryptedMysteryGiftAlbum(DataMysteryGift[] Gifts, bool[] Flags, uint Seed) + : MysteryGiftAlbum(Gifts, Flags) { /// /// Encryption Seed (only used in Generation 5 to encrypt the stored data) /// - public readonly uint Seed; - - public EncryptedMysteryGiftAlbum(DataMysteryGift[] gifts, bool[] flags, uint seed) : base(gifts, flags) => Seed = seed; + public readonly uint Seed = Seed; } diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Kitakami.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Kitakami.cs index 722445efa..d414b7b85 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Kitakami.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Kitakami.cs @@ -8,6 +8,7 @@ namespace PKHeX.Core; public const int SIZE = 0x20; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public PokeDexEntry9Kitakami(Span data) => Data = data; /* Structure: 0x20 bytes diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Paldea.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Paldea.cs index aa777d374..1bce04894 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Paldea.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/PokeDexEntry9Paldea.cs @@ -8,6 +8,7 @@ namespace PKHeX.Core; public const int SIZE = 0x18; private readonly Span Data; + // ReSharper disable once ConvertToPrimaryConstructor public PokeDexEntry9Paldea(Span data) => Data = data; public void Clear() => Data.Clear(); diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Kitakami.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Kitakami.cs index fe6721da9..87c2a948f 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Kitakami.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Kitakami.cs @@ -5,12 +5,8 @@ namespace PKHeX.Core; /// /// Pokédex structure used for . /// > -public sealed class Zukan9Kitakami : ZukanBase +public sealed class Zukan9Kitakami(SAV9SV sav, SCBlock Block) : ZukanBase(sav, 0) { - private readonly SCBlock Block; - - public Zukan9Kitakami(SAV9SV sav, SCBlock block) : base(sav, 0) => Block = block; - public PokeDexEntry9Kitakami Get(ushort species) { if (species > SAV.MaxSpeciesID) diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Paldea.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Paldea.cs index 4587e5e32..c37a1505d 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Paldea.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Gen9/Zukan9Paldea.cs @@ -5,12 +5,8 @@ namespace PKHeX.Core; /// /// Pokédex structure used for . /// > -public sealed class Zukan9Paldea : ZukanBase +public sealed class Zukan9Paldea(SAV9SV sav, SCBlock block) : ZukanBase(sav, 0) { - private readonly SCBlock Block; - - public Zukan9Paldea(SAV9SV sav, SCBlock block) : base(sav, 0) => Block = block; - public PokeDexEntry9Paldea Get(ushort species) { if (species > SAV.MaxSpeciesID) @@ -18,7 +14,7 @@ public PokeDexEntry9Paldea Get(ushort species) const int size = PokeDexEntry9Paldea.SIZE; var internalSpecies = SpeciesConverter.GetInternal9(species); - var span = Block.Data.AsSpan(internalSpecies * size, size); + var span = block.Data.AsSpan(internalSpecies * size, size); return new PokeDexEntry9Paldea(span); } @@ -125,7 +121,7 @@ private ushort GetSpecies(byte group, int index) public override void SeenNone() { - Array.Clear(Block.Data, 0, Block.Data.Length); + Array.Clear(block.Data, 0, block.Data.Length); } public override void CaughtNone() diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs index c1c5a6ef8..11f1d5df4 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs @@ -83,8 +83,7 @@ public abstract class Zukan : ZukanBase where T : SaveFile protected Zukan(T sav, int dex, int langflag) : base(sav, dex) { PokeDexLanguageFlags = langflag; - if (langflag > dex) - throw new ArgumentOutOfRangeException(nameof(langflag)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(langflag, dex); } protected abstract int OFS_SEEN { get; } diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan4.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan4.cs index 4f51cc543..574a0dffd 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan4.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan4.cs @@ -6,9 +6,9 @@ namespace PKHeX.Core; /// /// Pokédex structure used by games. /// -public sealed class Zukan4 : ZukanBase +public sealed class Zukan4(SAV4 sav, int offset) : ZukanBase(sav, offset) { - private readonly Memory Buffer; + private readonly Memory Buffer = sav.GeneralBuffer[offset..]; private Span Data => Buffer.Span; // General structure: u32 magic, 4*bitflags, u32 spinda, form flags, language flags, more form flags, upgrade flags @@ -39,11 +39,6 @@ public sealed class Zukan4 : ZukanBase private bool HGSS => SAV is SAV4HGSS; private bool DP => SAV is SAV4DP; - public Zukan4(SAV4 sav, int offset) : base(sav, offset) - { - Buffer = sav.GeneralBuffer[offset..]; - } - public uint Magic { get => ReadUInt32LittleEndian(Data); set => WriteUInt32LittleEndian(Data, value); } public override bool GetCaught(ushort species) => GetRegionFlag(0, species - 1); @@ -73,9 +68,9 @@ private void SetRegionFlag(int region, int index, bool value) public static string[] GetFormNames4Dex(ushort species) { - string[] formNames = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Array.Empty(), EntityContext.Gen4); + string[] formNames = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, [], EntityContext.Gen4); if (species == (int)Species.Pichu) - formNames = new[] { MALE, FEMALE, formNames[1] }; // Spiky + formNames = [MALE, FEMALE, formNames[1]]; // Spiky return formNames; } @@ -107,7 +102,7 @@ public byte[] GetForms(ushort species) return Data.Slice(FormOffset1 + 4, 0x1C).ToArray(); } if (DP) - return Array.Empty(); + return []; int PokeDexLanguageFlags = FormOffset1 + (HGSS ? 0x3C : 0x20); int FormOffset2 = PokeDexLanguageFlags + 0x1F4; @@ -117,7 +112,7 @@ public byte[] GetForms(ushort species) (int)Species.Shaymin => GetDexFormValues(Data[FormOffset2 + 4], 1, 2), (int)Species.Giratina => GetDexFormValues(Data[FormOffset2 + 5], 1, 2), (int)Species.Pichu when HGSS => GetDexFormValues(Data[FormOffset2 + 6], 2, 3), - _ => Array.Empty(), + _ => [], }; } @@ -385,7 +380,7 @@ private int GetSpeciesLanguageByteIndex(ushort species) return species; } - private static ReadOnlySpan DPLangSpecies => new ushort[] { 23, 25, 54, 77, 120, 129, 202, 214, 215, 216, 228, 278, 287, 315 }; + private static ReadOnlySpan DPLangSpecies => [023, 025, 054, 077, 120, 129, 202, 214, 215, 216, 228, 278, 287, 315]; public static int GetGen4LanguageBitIndex(int lang) => --lang switch { @@ -486,7 +481,7 @@ public void ClearSeen(ushort species) SetSeen(species, false); SetSeenGenderNeither(species); - SetForms(species, ReadOnlySpan.Empty); + SetForms(species, []); ClearLanguages(species); } diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan6.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan6.cs index 9e5a5af5c..61e0d681d 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan6.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan6.cs @@ -220,7 +220,7 @@ public Zukan6XY(SAV6XY sav, int dex, int langflag) : base(sav, dex, langflag) protected override void SetCaughtFlag(int bit, int origin) { - // Species: 1-649 for X/Y, and not for ORAS; Set the Foreign Owned Flag + // Species: 1-649 for X/Y, and not for OR/AS; Set the Foreign Owned Flag if (origin < (int)GameVersion.X && bit < (int)Species.Genesect) SetForeignFlag(bit); else diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs index 83d7aca75..62303b8ad 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs @@ -164,7 +164,7 @@ public bool NationalDex } /// - /// Gets the last viewed dex entry in the Pokedex (by National Dex ID), internally called DefaultMons + /// Gets the last viewed dex entry in the Pokédex (by National Dex ID), internally called DefaultMons /// public uint CurrentViewedDex => (ReadUInt32LittleEndian(SAV.Data.AsSpan(PokeDex + 4)) >> 9) & 0x3FF; diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7b.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7b.cs index 4982fd3dd..c60cb17f1 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7b.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7b.cs @@ -6,7 +6,7 @@ namespace PKHeX.Core; /// /// Pokédex structure used for games, slightly modified from . /// > -public sealed class Zukan7b : Zukan7 +public sealed class Zukan7b(SAV7b sav, int dex, int langflag) : Zukan7(sav, dex, langflag) { private const int UNSET = 0x007F00FE; private const int BaseOffset = 0x2A00; @@ -17,10 +17,6 @@ public sealed class Zukan7b : Zukan7 public const byte DefaultEntryValueH = 0xFE; public const byte DefaultEntryValueW = 0x7F; - public Zukan7b(SAV7b sav, int dex, int langflag) : base(sav, dex, langflag) - { - } - public override void SetDex(PKM pk) { if (!TryGetSizeEntryIndex(pk.Species, pk.Form, out _)) @@ -176,8 +172,8 @@ public static bool TryGetSizeEntryIndex(ushort species, byte form, out int index return false; } - private static ReadOnlySpan SizeDexInfoTable => new byte[] - { + private static ReadOnlySpan SizeDexInfoTable => + [ // species, form 003, 1, 006, 1, @@ -212,7 +208,7 @@ public static bool TryGetSizeEntryIndex(ushort species, byte form, out int index 142, 1, 150, 1, 150, 2, - }; + ]; protected override bool GetSaneFormsToIterate(ushort species, out int formStart, out int formEnd, int formIn) { diff --git a/PKHeX.Core/Saves/Substructures/Records.cs b/PKHeX.Core/Saves/Substructures/Records.cs index d60845257..3532f7763 100644 --- a/PKHeX.Core/Saves/Substructures/Records.cs +++ b/PKHeX.Core/Saves/Substructures/Records.cs @@ -32,16 +32,16 @@ public static int GetMax(int recordID, ReadOnlySpan maxes) _ => -1, }; - private static ReadOnlySpan MaxByType => new[] {999_999_999, 9_999_999, 999_999, 99_999, 65535, 9_999, 999, 7}; + private static ReadOnlySpan MaxByType => [999_999_999, 9_999_999, 999_999, 99_999, 65535, 9_999, 999, 7]; - public static ReadOnlySpan DailyPairs_6 => new byte[] {29, 30, 110, 111, 112, 113, 114, 115, 116, 117}; - public static ReadOnlySpan DailyPairs_7 => new byte[] {22, 23, 110, 111, 112, 113, 114, 115, 116, 117}; + public static ReadOnlySpan DailyPairs_6 => [29, 30, 110, 111, 112, 113, 114, 115, 116, 117]; + public static ReadOnlySpan DailyPairs_7 => [22, 23, 110, 111, 112, 113, 114, 115, 116, 117]; /// /// Festa pairs; if updating the lower index record, update the Festa Mission record if currently active? /// - public static ReadOnlySpan FestaPairs_7 => new byte[] - { + public static ReadOnlySpan FestaPairs_7 => + [ 175, 6, 176, 33, 177, 8, @@ -51,7 +51,7 @@ public static int GetMax(int recordID, ReadOnlySpan maxes) 183, 7, 184, 159, 185, 9, - }; + ]; } public static class RecordLists @@ -234,7 +234,7 @@ public static class RecordLists {175, "Times used Escape Rope"}, {176, "Times used Dowsing Machine"}, {177, "Trainer's Eye Rematches"}, - {178, "FUREAI Interest ???"}, // similar to USUM idb + {178, "FUREAI Interest ???"}, // similar to US/UM idb {179, "Shiny Pokemon Encountered"}, {180, "Trick House Clears"}, @@ -314,7 +314,7 @@ public static class RecordLists {067, "Berry Piles (not full) Collected"}, {068, "Berry Piles (full) Collected"}, {069, "Items Reeled In"}, - // USUM + // US/UM {070, "Roto Lotos"}, {072, "Stickers Collected"}, @@ -411,7 +411,7 @@ public static class RecordLists {186, "Get BP at the Battle Tree!"}, {187, "Catch a lot of Pokémon!"}, - // USUM + // US/UM {188, "Ultra Wormhole Travels"}, {189, "Mantine Surf Plays"}, {190, "Photo Club Photos saved"}, diff --git a/PKHeX.Core/Saves/Util/Checksums.cs b/PKHeX.Core/Saves/Util/Checksums.cs index e56510c4e..fe991066e 100644 --- a/PKHeX.Core/Saves/Util/Checksums.cs +++ b/PKHeX.Core/Saves/Util/Checksums.cs @@ -27,8 +27,8 @@ public static ushort CRC16_CCITT(ReadOnlySpan data) return (ushort)((top << 8) | bot); } - private static ReadOnlySpan crc16 => new ushort[] - { + private static ReadOnlySpan crc16 => + [ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, @@ -61,10 +61,10 @@ public static ushort CRC16_CCITT(ReadOnlySpan data) 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040, - }; + ]; - private static ReadOnlySpan crc32 => new uint[] - { + private static ReadOnlySpan crc32 => + [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, @@ -97,13 +97,13 @@ public static ushort CRC16_CCITT(ReadOnlySpan data) 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, - }; + ]; /// Calculates the 16bit checksum over an input byte array. /// Input byte array /// Initial value for checksum /// Checksum - private static ushort CRC16(ReadOnlySpan data, [ConstantExpected(Min = 0)] ushort initial) + private static ushort CRC16(ReadOnlySpan data, [ConstantExpected] ushort initial) { ushort chk = initial; foreach (var b in data) @@ -111,9 +111,11 @@ private static ushort CRC16(ReadOnlySpan data, [ConstantExpected(Min = 0)] return chk; } + private const ushort CRC16Initial = unchecked((ushort)~0); + /// Calculates the 16bit checksum over an input byte array. /// Input byte array - public static ushort CRC16Invert(ReadOnlySpan data) => (ushort)~CRC16(data, unchecked((ushort)~0)); + public static ushort CRC16Invert(ReadOnlySpan data) => (ushort)~CRC16(data, CRC16Initial); /// Calculates the 16bit checksum over an input byte array. /// Input byte array @@ -123,7 +125,7 @@ private static ushort CRC16(ReadOnlySpan data, [ConstantExpected(Min = 0)] /// Input byte array /// Initial value for checksum /// Checksum - public static ushort CheckSum32(ReadOnlySpan data, [ConstantExpected(Min = 0)] uint initial = 0) + public static ushort CheckSum32(ReadOnlySpan data, [ConstantExpected] uint initial = 0) { uint chk = initial; foreach (var u32 in MemoryMarshal.Cast(data)) @@ -140,7 +142,7 @@ public static ushort CheckSum32(ReadOnlySpan data, [ConstantExpected(Min = /// Input byte array /// Initial value for checksum /// Checksum - private static uint CRC32(ReadOnlySpan data, [ConstantExpected(Min = 0)] uint initial) + private static uint CRC32(ReadOnlySpan data, [ConstantExpected] uint initial) { uint chk = initial; foreach (var b in data) @@ -148,11 +150,13 @@ private static uint CRC32(ReadOnlySpan data, [ConstantExpected(Min = 0)] u return chk; } - /// Calculates the 16bit checksum over an input byte array. - /// Input byte array - public static uint CRC32Invert(ReadOnlySpan data) => ~CRC32(data, unchecked((uint)~0)); + private const uint CRC32Initial = unchecked((uint)~0); - /// Calculates the 16bit checksum over an input byte array. + /// Calculates the 32bit checksum over an input byte array. + /// Input byte array + public static uint CRC32Invert(ReadOnlySpan data) => ~CRC32(data, CRC32Initial); + + /// Calculates the 32bit checksum over an input byte array. /// Input byte array public static uint CRC32NoInvert(ReadOnlySpan data) => CRC32(data, 0); @@ -160,7 +164,7 @@ private static uint CRC32(ReadOnlySpan data, [ConstantExpected(Min = 0)] u /// Input byte array /// Initial value for checksum /// Checksum - public static ushort CheckSum16(ReadOnlySpan data, [ConstantExpected(Min = 0)] ushort initial = 0) + public static ushort CheckSum16(ReadOnlySpan data, [ConstantExpected] ushort initial = 0) { ushort acc = initial; foreach (byte b in data) diff --git a/PKHeX.Core/Saves/Util/DexFormUtil.cs b/PKHeX.Core/Saves/Util/DexFormUtil.cs index 9b4e38804..d9bb8207c 100644 --- a/PKHeX.Core/Saves/Util/DexFormUtil.cs +++ b/PKHeX.Core/Saves/Util/DexFormUtil.cs @@ -14,8 +14,8 @@ public static class DexFormUtil public static int GetDexFormCountUSUM(ushort species) => GetDexFormCount(species, formtable_USUM); public static int GetDexFormCountGG(ushort species) => GetDexFormCount(species, formtable_GG); - private static ReadOnlySpan formtable_SM => new ushort[] // u16 species, u16 formcount - { + private static ReadOnlySpan formtable_SM => // u16 species, u16 formcount + [ 0x0003, 0x0002, 0x0006, 0x0003, 0x0009, 0x0002, 0x000F, 0x0002, 0x0012, 0x0002, 0x0013, 0x0002, 0x0014, 0x0003, 0x0019, 0x0007, 0x001A, 0x0002, 0x001B, 0x0002, 0x001C, 0x0002, 0x0025, 0x0002, @@ -45,10 +45,10 @@ public static class DexFormUtil 0x02E2, 0x0002, 0x02E5, 0x0004, 0x02E9, 0x0002, 0x02EA, 0x0002, 0x02F2, 0x0002, 0x02F6, 0x0002, 0x0305, 0x0012, 0x0306, 0x000E, 0x030A, 0x0004, 0x0310, 0x0002, 0x0321, 0x0002, - }; + ]; - private static ReadOnlySpan formtable_USUM => new ushort[] // u16 species, u16 formcount - { + private static ReadOnlySpan formtable_USUM => // u16 species, u16 formcount + [ 0x0003, 0x0002, 0x0006, 0x0003, 0x0009, 0x0002, 0x000F, 0x0002, 0x0012, 0x0002, 0x0013, 0x0002, 0x0014, 0x0003, 0x0019, 0x0008, 0x001A, 0x0002, 0x001B, 0x0002, 0x001C, 0x0002, 0x0025, 0x0002, @@ -80,10 +80,10 @@ public static class DexFormUtil 0x02EA, 0x0002, 0x02F0, 0x0002, 0x02F2, 0x0002, 0x02F6, 0x0002, 0x0305, 0x0012, 0x0306, 0x000E, 0x0309, 0x0002, 0x030A, 0x0004, 0x0310, 0x0002, 0x0320, 0x0004, 0x0321, 0x0002, - }; + ]; - private static ReadOnlySpan formtable_GG => new ushort[] // u16 species, u16 formcount - { + private static ReadOnlySpan formtable_GG => // u16 species, u16 formcount + [ 0x0003, 0x0002, 0x0006, 0x0003, 0x0009, 0x0002, 0x000F, 0x0002, 0x0012, 0x0002, 0x0013, 0x0002, 0x0014, 0x0003, 0x0019, 0x0009, 0x001A, 0x0002, 0x001B, 0x0002, 0x001C, 0x0002, 0x0025, 0x0002, @@ -92,7 +92,7 @@ public static class DexFormUtil 0x004C, 0x0002, 0x0050, 0x0002, 0x0058, 0x0002, 0x0059, 0x0002, 0x005E, 0x0002, 0x0067, 0x0002, 0x0069, 0x0003, 0x0073, 0x0002, 0x007F, 0x0002, 0x0082, 0x0002, 0x008E, 0x0002, 0x0096, 0x0003, - }; + ]; private static int GetDexFormBitIndex(ushort species, byte formCount, int start, ReadOnlySpan formTable) { diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs index 696ec0328..e585838a4 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerARDS.cs @@ -17,6 +17,6 @@ public SaveHandlerSplitResult TrySplit(ReadOnlySpan input) // No authentication to see if it actually is a header; no size collisions expected. var header = input[..sizeHeader].ToArray(); var data = input[sizeHeader..].ToArray(); - return new SaveHandlerSplitResult(data, header, Array.Empty()); + return new SaveHandlerSplitResult(data, header, []); } } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerBizHawk.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerBizHawk.cs index dad3a3b0f..65ec99f3d 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerBizHawk.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerBizHawk.cs @@ -30,6 +30,6 @@ private static bool GetHasFooter(ReadOnlySpan input) var footer = input[realSize..].ToArray(); var data = input[..realSize].ToArray(); - return new SaveHandlerSplitResult(data, Array.Empty(), footer); + return new SaveHandlerSplitResult(data, [], footer); } } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs index 3283f412a..07d7607de 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerDeSmuME.cs @@ -23,6 +23,6 @@ public sealed class SaveHandlerDeSmuME : ISaveHandler var footer = input[RealSize..].ToArray(); var data = input[..RealSize].ToArray(); - return new SaveHandlerSplitResult(data, Array.Empty(), footer); + return new SaveHandlerSplitResult(data, [], footer); } } diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs index a1b9cbc7e..c974f3c3f 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerGCI.cs @@ -12,9 +12,9 @@ public sealed class SaveHandlerGCI : ISaveHandler private const int SIZE_G3COLOGCI = headerSize + SaveUtil.SIZE_G3COLO; // GCI data private const int SIZE_G3XDGCI = headerSize + SaveUtil.SIZE_G3XD; // GCI data - private static readonly string[] HEADER_COLO = { "GC6J", "GC6E", "GC6P" }; // NTSC-J, NTSC-U, PAL - private static readonly string[] HEADER_XD = { "GXXJ", "GXXE", "GXXP" }; // NTSC-J, NTSC-U, PAL - private static readonly string[] HEADER_RSBOX = { "GPXJ", "GPXE", "GPXP" }; // NTSC-J, NTSC-U, PAL + private static readonly string[] HEADER_COLO = ["GC6J", "GC6E", "GC6P"]; // NTSC-J, NTSC-U, PAL + private static readonly string[] HEADER_XD = ["GXXJ", "GXXE", "GXXP"]; // NTSC-J, NTSC-U, PAL + private static readonly string[] HEADER_RSBOX = ["GPXJ", "GPXE", "GPXP"]; // NTSC-J, NTSC-U, PAL private static bool IsGameMatchHeader(ReadOnlySpan headers, ReadOnlySpan data) { @@ -55,7 +55,7 @@ private static bool IsGameMatchHeader(ReadOnlySpan data, ReadOnlySpan()); + return new SaveHandlerSplitResult(data, header, []); } /// diff --git a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs index 29f99e4d1..6d3aa5f5c 100644 --- a/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs +++ b/PKHeX.Core/Saves/Util/Recognition/SaveHandlerSplitResult.cs @@ -1,15 +1,8 @@ -namespace PKHeX.Core; +namespace PKHeX.Core; -public sealed class SaveHandlerSplitResult +public sealed class SaveHandlerSplitResult(byte[] Data, byte[] Header, byte[] Footer) { - public readonly byte[] Header; - public readonly byte[] Footer; - public readonly byte[] Data; - - public SaveHandlerSplitResult(byte[] data, byte[] header, byte[] footer) - { - Data = data; - Header = header; - Footer = footer; - } + public readonly byte[] Header = Header; + public readonly byte[] Footer = Footer; + public readonly byte[] Data = Data; } diff --git a/PKHeX.Core/Saves/Util/SaveExtensions.cs b/PKHeX.Core/Saves/Util/SaveExtensions.cs index 083668bac..ef4496c95 100644 --- a/PKHeX.Core/Saves/Util/SaveExtensions.cs +++ b/PKHeX.Core/Saves/Util/SaveExtensions.cs @@ -38,7 +38,7 @@ public static bool IsCompatiblePKM(this SaveFile sav, PKM pk) return true; } - private static IReadOnlyList GetSaveFileErrata(this SaveFile sav, PKM pk, IBasicStrings strings) + private static List GetSaveFileErrata(this SaveFile sav, PKM pk, IBasicStrings strings) { var errata = new List(); ushort held = (ushort)pk.HeldItem; @@ -165,7 +165,7 @@ public static PKM GetCompatiblePKM(this SaveFile sav, PKM pk) { if (pk.Format >= 3 || sav.Generation >= 7) return EntityConverter.ConvertToType(pk, sav.PKMType, out _) ?? sav.BlankPKM; - // gen1-2 compatibility check + // Gen1/2 compatibility check if (pk.Japanese != ((ILangDeviantSave)sav).Japanese) return sav.BlankPKM; if (sav is SAV2 s2 && s2.Korean != pk.Korean) diff --git a/PKHeX.Core/Saves/Util/SaveFinder.cs b/PKHeX.Core/Saves/Util/SaveFinder.cs index ba701bee1..b05671b39 100644 --- a/PKHeX.Core/Saves/Util/SaveFinder.cs +++ b/PKHeX.Core/Saves/Util/SaveFinder.cs @@ -70,7 +70,7 @@ public static IEnumerable GetSwitchBackupPaths(string root) /// /// Extra list of Backup Paths used for detecting a save file. /// - public static readonly List CustomBackupPaths = new(); + public static readonly List CustomBackupPaths = []; /// /// Finds a compatible save file that was most recently saved (by file write time). diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs index ee9c96055..c0e777ad8 100644 --- a/PKHeX.Core/Saves/Util/SaveUtil.cs +++ b/PKHeX.Core/Saves/Util/SaveUtil.cs @@ -127,26 +127,26 @@ public static class SaveUtil /// Specialized readers for loading save files from non-standard games (e.g. hacks). /// // ReSharper disable once CollectionNeverUpdated.Global - public static readonly List CustomSaveReaders = new(); + public static readonly List CustomSaveReaders = []; #endif #if !EXCLUDE_EMULATOR_FORMATS /// /// Pre-formatters for loading save files from non-standard formats (e.g. emulators). /// - public static readonly ICollection Handlers = new List - { + public static readonly List Handlers = + [ DolphinHandler, new SaveHandlerDeSmuME(), new SaveHandlerBizHawk(), new SaveHandlerARDS(), - }; + ]; #endif private const int SIZE_G9_202 = 0xC8E; // Add 2 blocks (1 obj 0xC80, 1 bool) = 4{key}1{obj}4{len} + 4{key}1{boolT/boolF} - private static readonly HashSet SizesSV = new() - { + private static readonly HashSet SizesSV = + [ SIZE_G9_0, SIZE_G9_0a, SIZE_G9_1, SIZE_G9_1a, SIZE_G9_1A, SIZE_G9_1Aa, @@ -184,32 +184,33 @@ public static class SaveUtil SIZE_G9_DLC1_Y, SIZE_G9_DLC1_Y + SIZE_G9_202, SIZE_G9_DLC1_U, SIZE_G9_DLC1_U + SIZE_G9_202, SIZE_G9_DLC1_V, SIZE_G9_DLC1_V + SIZE_G9_202, - }; + ]; - private static readonly HashSet SizesSWSH = new() - { + private static readonly HashSet SizesSWSH = + [ SIZE_G8SWSH, SIZE_G8SWSH_1, SIZE_G8SWSH_2, SIZE_G8SWSH_2B, SIZE_G8SWSH_3, SIZE_G8SWSH_3A, SIZE_G8SWSH_3B, SIZE_G8SWSH_3C, - }; + ]; - private static readonly HashSet SizesGen2 = new() - { + private static readonly HashSet SizesGen2 = + [ SIZE_G2RAW_U, SIZE_G2VC_U, SIZE_G2BAT_U, SIZE_G2EMU_U, SIZE_G2RAW_J, SIZE_G2BAT_J, SIZE_G2EMU_J, SIZE_G2VC_J, - }; + ]; - private static readonly HashSet Sizes = new(SizesGen2.Concat(SizesSWSH).Concat(SizesSV)) - { + private static readonly HashSet Sizes = + [ + ..SizesGen2, ..SizesSWSH, ..SizesSV, SIZE_G8LA, SIZE_G8LA_1, SIZE_G8BDSP, SIZE_G8BDSP_1, SIZE_G8BDSP_2, SIZE_G8BDSP_3, - // SizesSWSH covers gen8 sizes since there's so many + // SizesSWSH covers Gen8 sizes since there's so many SIZE_G7SM, SIZE_G7USUM, SIZE_G7GG, SIZE_G6XY, SIZE_G6ORAS, SIZE_G6ORASDEMO, SIZE_G5RAW, SIZE_G5BW, SIZE_G5B2W2, SIZE_G4BR, SIZE_G4RAW, SIZE_G3BOX, SIZE_G3COLO, SIZE_G3XD, SIZE_G3RAW, SIZE_G3EMU, SIZE_G3RAWHALF, - // SizesGen2 covers gen2 sizes since there's so many + // SizesGen2 covers Gen2 sizes since there's so many SIZE_G1RAW, SIZE_G1BAT, SIZE_G7BANK, SIZE_G4BANK, SIZE_G4RANCH, SIZE_G4RANCH_PLAT, - }; + ]; /// Determines the type of the provided save data. /// Save data of which to determine the origins of @@ -409,9 +410,9 @@ private static GameVersion GetVersionG3SAV(ReadOnlySpan data) case 1: return FRLG; // fixed value case 0: return RS; // save has no battle tower record data default: - // RS data structure only extends 0x890 bytes; check if any data is present afterwards. + // RS data structure only extends 0x890 bytes; check if any data is present afterward. var remainder = data[0x890..0xF2C]; - if (remainder.IndexOfAnyExcept(0) != -1) + if (remainder.ContainsAnyExcept(0)) return E; return RS; } @@ -491,7 +492,7 @@ private static GameVersion GetIsG4SAV(ReadOnlySpan data) return Invalid; - // The block footers contain a u32 'size' followed by a u32 binary-coded-decimal timestamp + // The block footers contain a 32-bit 'size' followed by a 32-bit binary-coded-decimal timestamp // Korean saves have a different timestamp from other localizations. static bool IsValidGeneralFooter(ReadOnlySpan general) { @@ -583,7 +584,7 @@ private static GameVersion GetIsBelugaSAV(ReadOnlySpan data) const int actualLength = 0xB8800; if (ReadUInt32LittleEndian(data[(actualLength - 0x1F0)..]) != BEEF) // beef table start return Invalid; - if (ReadUInt16LittleEndian(data[(actualLength - 0x200 + 0xB0)..]) != 0x13) // check a block number to double check + if (ReadUInt16LittleEndian(data[(actualLength - 0x200 + 0xB0)..]) != 0x13) // check a block number to double-check return Invalid; return GG; @@ -902,12 +903,12 @@ public static SaveFile GetBlankSAV(EntityContext context, string trainerName, La /// Search all subfolders /// If this function returns true, full path of all that match criteria. If this function returns false, the error message, or null if the directory could not be found /// Option to ignore files with backup names and extensions - /// Boolean indicating whether or not operation was successful. + /// Boolean indicating if the operation was successful. public static bool GetSavesFromFolder(string folderPath, bool deep, out IEnumerable result, bool ignoreBackups = true) { if (!Directory.Exists(folderPath)) { - result = Array.Empty(); + result = []; return false; } try @@ -920,12 +921,12 @@ public static bool GetSavesFromFolder(string folderPath, bool deep, out IEnumera } catch (Exception ex) { - result = new[] - { + result = + [ MsgFileLoadFailAuto + Environment.NewLine + folderPath, MsgFileLoadFailAutoAdvise + Environment.NewLine + MsgFileLoadFailAutoCause, ex.Message, - }; + ]; return false; } } @@ -959,7 +960,7 @@ public static bool IsBackup(ReadOnlySpan path) /// Determines whether the save data size is valid for automatically detecting saves. /// /// Size in bytes of the save data - /// A boolean indicating whether or not the save data size is valid. + /// A boolean indicating if the save data size is valid. public static bool IsSizeValid(long size) => IsSizeValidNoHandler(size) || IsSizeValidHandler(size) || SAV3GCMemoryCard.IsMemoryCardSize(size); /// diff --git a/PKHeX.Core/Util/ArrayUtil.cs b/PKHeX.Core/Util/ArrayUtil.cs index 48d5e6999..b6265d7a8 100644 --- a/PKHeX.Core/Util/ArrayUtil.cs +++ b/PKHeX.Core/Util/ArrayUtil.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; namespace PKHeX.Core; @@ -9,11 +8,6 @@ namespace PKHeX.Core; /// public static class ArrayUtil { - public static int Count(this Span data, T value) where T : IEquatable - { - return ((ReadOnlySpan)data).Count(value); - } - public static T Find(this Span data, Func value) where T : unmanaged { foreach (var x in data) @@ -24,20 +18,6 @@ public static class ArrayUtil return default; } - public static int Count(this ReadOnlySpan data, T value) where T : IEquatable - { - int count = 0; - foreach (var t in data) - { - if (t.Equals(value)) - count++; - } - return count; - } - - public static byte[] Slice(this byte[] src, int offset, [ConstantExpected(Min = 0)] int length) => src.AsSpan(offset, length).ToArray(); - public static T[] Slice(this T[] src, int offset, [ConstantExpected(Min = 0)] int length) => src.AsSpan(offset, length).ToArray(); - /// /// Checks the range (exclusive max) if the is inside. /// @@ -46,7 +26,7 @@ public static class ArrayUtil public static IEnumerable EnumerateSplit(T[] bin, int size, int start = 0) { for (int i = start; i < bin.Length; i += size) - yield return bin.Slice(i, size); + yield return bin.AsSpan(i, size).ToArray(); } /// @@ -86,127 +66,4 @@ public static int FindNextValidIndex(IList dest, Func skip, int ctr++; } } - - internal static T[] ConcatAll(params T[][] arr) - { - int len = 0; - foreach (var a in arr) - len += a.Length; - - var result = new T[len]; - - int ctr = 0; - foreach (var a in arr) - { - a.CopyTo(result, ctr); - ctr += a.Length; - } - - return result; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2) - { - int len = arr1.Length + arr2.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); - return arr; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3) - { - int len = arr1.Length + arr2.Length + arr3.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); ctr += arr2.Length; - arr3.CopyTo(result[ctr..]); - return arr; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4) - { - int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); ctr += arr2.Length; - arr3.CopyTo(result[ctr..]); ctr += arr3.Length; - arr4.CopyTo(result[ctr..]); - return arr; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5) - { - int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); ctr += arr2.Length; - arr3.CopyTo(result[ctr..]); ctr += arr3.Length; - arr4.CopyTo(result[ctr..]); ctr += arr4.Length; - arr5.CopyTo(result[ctr..]); - return arr; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5, ReadOnlySpan arr6) - { - int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length + arr6.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); ctr += arr2.Length; - arr3.CopyTo(result[ctr..]); ctr += arr3.Length; - arr4.CopyTo(result[ctr..]); ctr += arr4.Length; - arr5.CopyTo(result[ctr..]); ctr += arr5.Length; - arr6.CopyTo(result[ctr..]); - return arr; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5, ReadOnlySpan arr6, ReadOnlySpan arr7) - { - int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length + arr6.Length + arr7.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); ctr += arr2.Length; - arr3.CopyTo(result[ctr..]); ctr += arr3.Length; - arr4.CopyTo(result[ctr..]); ctr += arr4.Length; - arr5.CopyTo(result[ctr..]); ctr += arr5.Length; - arr6.CopyTo(result[ctr..]); ctr += arr6.Length; - arr7.CopyTo(result[ctr..]); - return arr; - } - - internal static T[] ConcatAll(ReadOnlySpan arr1, ReadOnlySpan arr2, ReadOnlySpan arr3, ReadOnlySpan arr4, ReadOnlySpan arr5, ReadOnlySpan arr6, ReadOnlySpan arr7, ReadOnlySpan arr8) - { - int len = arr1.Length + arr2.Length + arr3.Length + arr4.Length + arr5.Length + arr6.Length + arr7.Length + arr8.Length; - var arr = new T[len]; - - var result = arr.AsSpan(); - int ctr = 0; - arr1.CopyTo(result); ctr += arr1.Length; - arr2.CopyTo(result[ctr..]); ctr += arr2.Length; - arr3.CopyTo(result[ctr..]); ctr += arr3.Length; - arr4.CopyTo(result[ctr..]); ctr += arr4.Length; - arr5.CopyTo(result[ctr..]); ctr += arr5.Length; - arr6.CopyTo(result[ctr..]); ctr += arr6.Length; - arr7.CopyTo(result[ctr..]); ctr += arr7.Length; - arr8.CopyTo(result[ctr..]); - return arr; - } } diff --git a/PKHeX.Core/Util/ComboItemUtil.cs b/PKHeX.Core/Util/ComboItemUtil.cs index 51c80b22e..8535295a8 100644 --- a/PKHeX.Core/Util/ComboItemUtil.cs +++ b/PKHeX.Core/Util/ComboItemUtil.cs @@ -126,10 +126,8 @@ public static ComboItem[] GetVariedCBListBall(ReadOnlySpan itemNames, Re private static readonly FunctorComparer Comparer = new((a, b) => string.CompareOrdinal(a.Text, b.Text)); - private sealed class FunctorComparer : IComparer + private sealed class FunctorComparer(Comparison Comparison) : IComparer { - private readonly Comparison Comparison; - public FunctorComparer(Comparison comparison) => Comparison = comparison; public int Compare(T? x, T? y) { if (x == null) diff --git a/PKHeX.Core/Util/DateUtil.cs b/PKHeX.Core/Util/DateUtil.cs index 5407592ca..653e7d38a 100644 --- a/PKHeX.Core/Util/DateUtil.cs +++ b/PKHeX.Core/Util/DateUtil.cs @@ -5,12 +5,12 @@ namespace PKHeX.Core; public static class DateUtil { /// - /// Determines whether or not the given date components are valid. + /// Determines whether the given date components are valid. /// /// The year of the date of which to check the validity. /// The month of the date of which to check the validity. /// The day of the date of which to check the validity. - /// A boolean indicating whether or not the date is valid. + /// A boolean indicating if the date is valid. public static bool IsDateValid(int year, int month, int day) { if (year is <= 0 or > 9999) @@ -24,12 +24,12 @@ public static bool IsDateValid(int year, int month, int day) } /// - /// Determines whether or not the given date components are valid. + /// Determines whether the given date components are valid. /// /// The year of the date of which to check the validity. /// The month of the date of which to check the validity. /// The day of the date of which to check the validity. - /// A boolean indicating whether or not the date is valid. + /// A boolean indicating if the date is valid. public static bool IsDateValid(uint year, uint month, uint day) { return year < int.MaxValue && month < int.MaxValue && day < int.MaxValue && IsDateValid((int)year, (int)month, (int)day); diff --git a/PKHeX.Core/Util/FileUtil.cs b/PKHeX.Core/Util/FileUtil.cs index daa360293..a9a55d7c4 100644 --- a/PKHeX.Core/Util/FileUtil.cs +++ b/PKHeX.Core/Util/FileUtil.cs @@ -16,7 +16,7 @@ public static class FileUtil /// Attempts to get a binary object from the provided path. /// /// - /// Reference savefile used for PC Binary compatibility checks. + /// Reference SaveFile used for PC Binary compatibility checks. /// Supported file object reference, null if none found. public static object? GetSupportedFile(string path, SaveFile? reference = null) { @@ -44,7 +44,7 @@ public static class FileUtil /// /// Binary data for the file. /// File extension used as a hint. - /// Reference savefile used for PC Binary compatibility checks. + /// Reference SaveFile used for PC Binary compatibility checks. /// Supported file object reference, null if none found. public static object? GetSupportedFile(byte[] data, ReadOnlySpan ext, SaveFile? reference = null) { @@ -164,7 +164,7 @@ public static bool IsFileTooBig(long length) public static bool IsFileTooSmall(long length) => length < 0x20; // bigger than PK1 /// - /// Tries to get an object from the input parameters. + /// Tries to get a object from the input parameters. /// /// Binary data /// Output result @@ -176,7 +176,7 @@ public static bool TryGetSAV(byte[] data, [NotNullWhen(true)] out SaveFile? sav) } /// - /// Tries to get an object from the input parameters. + /// Tries to get a object from the input parameters. /// /// Binary data /// Output result @@ -205,7 +205,7 @@ public static bool TryGetMemoryCard(string file, [NotNullWhen(true)] out SAV3GCM } /// - /// Tries to get an object from the input parameters. + /// Tries to get a object from the input parameters. /// /// Binary data /// Output result @@ -225,17 +225,17 @@ public static bool TryGetPKM(byte[] data, [NotNullWhen(true)] out PKM? pk, ReadO } /// - /// Tries to get an object from the input parameters. + /// Tries to get a object from the input parameters. /// /// Binary data /// Output result - /// Reference savefile used for PC Binary compatibility checks. + /// Reference SaveFile used for PC Binary compatibility checks. /// True if file object reference is valid, false if none found. public static bool TryGetPCBoxBin(byte[] data, out IEnumerable pkms, SaveFile? sav) { if (sav == null) { - pkms = Array.Empty(); + pkms = []; return false; } var length = data.Length; @@ -244,7 +244,7 @@ public static bool TryGetPCBoxBin(byte[] data, out IEnumerable pkms, Sav pkms = ArrayUtil.EnumerateSplit(data, length); return true; } - pkms = Array.Empty(); + pkms = []; return false; } diff --git a/PKHeX.Core/Util/FlagUtil.cs b/PKHeX.Core/Util/FlagUtil.cs index f829dce60..a26940da2 100644 --- a/PKHeX.Core/Util/FlagUtil.cs +++ b/PKHeX.Core/Util/FlagUtil.cs @@ -15,7 +15,7 @@ public static class FlagUtil /// Bit to read public static bool GetFlag(ReadOnlySpan arr, int offset, int bitIndex) { - bitIndex &= 7; // ensure bit access is 0-7 + bitIndex &= 7; // ensure the bit access is 0-7 return ((arr[offset] >> bitIndex) & 1) != 0; } @@ -28,7 +28,7 @@ public static bool GetFlag(ReadOnlySpan arr, int offset, int bitIndex) /// Bit flag value to set public static void SetFlag(Span arr, int offset, int bitIndex, bool value) { - bitIndex &= 7; // ensure bit access is 0-7 + bitIndex &= 7; // ensure the bit access is 0-7 var current = arr[offset] & ~(1 << bitIndex); var newValue = current | ((value ? 1 : 0) << bitIndex); arr[offset] = (byte)newValue; diff --git a/PKHeX.Core/Util/Localization/LocalizedDescriptionAttribute.cs b/PKHeX.Core/Util/Localization/LocalizedDescriptionAttribute.cs index 80abab047..4d4d10d11 100644 --- a/PKHeX.Core/Util/Localization/LocalizedDescriptionAttribute.cs +++ b/PKHeX.Core/Util/Localization/LocalizedDescriptionAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; @@ -6,18 +6,13 @@ namespace PKHeX.Core; [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter)] -public sealed class LocalizedDescriptionAttribute : DescriptionAttribute +public sealed class LocalizedDescriptionAttribute(string fallback, [CallerMemberName] string? key = null) + : DescriptionAttribute { public static IReadOnlyDictionary Localizer { private get; set; } = new Dictionary(); - public readonly string Fallback; - public readonly string Key; + public readonly string Fallback = fallback; + public readonly string Key = $"LocalizedDescription.{key!}"; - public LocalizedDescriptionAttribute(string fallback, [CallerMemberName] string? key = null) - { - Key = $"LocalizedDescription.{key!}"; - Fallback = fallback; - } - - public override string Description => Localizer.TryGetValue(Key, out var result) ? result : Fallback; + public override string Description => Localizer.GetValueOrDefault(Key, Fallback); } diff --git a/PKHeX.Core/Util/RandUtil.cs b/PKHeX.Core/Util/RandUtil.cs index f0197fd2c..147593bb8 100644 --- a/PKHeX.Core/Util/RandUtil.cs +++ b/PKHeX.Core/Util/RandUtil.cs @@ -9,21 +9,4 @@ public static partial class Util public static uint Rand32() => Rand32(Rand); public static uint Rand32(this Random rnd) => ((uint)rnd.Next(1 << 30) << 2) | (uint)rnd.Next(1 << 2); public static ulong Rand64(this Random rnd) => rnd.Rand32() | ((ulong)rnd.Rand32() << 32); - - /// - /// Shuffles the order of items within a collection of items. - /// - /// Item type - /// RNG object to use - /// Item collection - public static void Shuffle(this Random rnd, Span items) - { - int n = items.Length; - for (int i = 0; i < n - 1; i++) - { - int j = rnd.Next(i, n); - if (j != i) - (items[i], items[j]) = (items[j], items[i]); - } - } } diff --git a/PKHeX.Core/Util/ReflectUtil.cs b/PKHeX.Core/Util/ReflectUtil.cs index 77e310922..2731abc58 100644 --- a/PKHeX.Core/Util/ReflectUtil.cs +++ b/PKHeX.Core/Util/ReflectUtil.cs @@ -155,7 +155,7 @@ public static IEnumerable GetAllTypeInfo(this TypeInfo? typeInfo) /// Object to check for property existence. /// Name of the property. /// Reference to the property info for the object, if it exists. - /// True if has property, and false if does not have property. is null when returning false. + /// True if it has property, and false if it does not have property. is null when returning false. public static bool HasProperty(object obj, string name, [NotNullWhen(true)] out PropertyInfo? pi) { var type = obj.GetType(); diff --git a/PKHeX.Core/Util/ResourceUtil.cs b/PKHeX.Core/Util/ResourceUtil.cs index 7c80e6249..c6756ff49 100644 --- a/PKHeX.Core/Util/ResourceUtil.cs +++ b/PKHeX.Core/Util/ResourceUtil.cs @@ -32,7 +32,7 @@ private static string GetFileName(string resName) return resName.EndsWith(".txt", StringComparison.Ordinal) ? resName[start..^4].ToLowerInvariant() : resName[start..]; } - private static readonly Dictionary stringListCache = new(); + private static readonly Dictionary stringListCache = []; private static readonly object getStringListLoadLock = new(); @@ -99,54 +99,54 @@ private static string GetFileName(string resName) /// /// Base file name /// Ignores Korean Language. - public static string[][] GetLanguageStrings7(string fileName) => new[] - { - Array.Empty(), // 0 - None + public static string[][] GetLanguageStrings7(string fileName) => + [ + [], // 0 - None GetStringList(fileName, "ja"), // 1 GetStringList(fileName, "en"), // 2 GetStringList(fileName, "fr"), // 3 GetStringList(fileName, "it"), // 4 GetStringList(fileName, "de"), // 5 - Array.Empty(), // 6 - None + [], // 6 - None GetStringList(fileName, "es"), // 7 - }; + ]; /// /// Retrieves the localization index list for all requested strings for the through Korean. /// /// Base file name - public static string[][] GetLanguageStrings8(string fileName) => new[] - { - Array.Empty(), // 0 - None + public static string[][] GetLanguageStrings8(string fileName) => + [ + [], // 0 - None GetStringList(fileName, "ja"), // 1 GetStringList(fileName, "en"), // 2 GetStringList(fileName, "fr"), // 3 GetStringList(fileName, "it"), // 4 GetStringList(fileName, "de"), // 5 - Array.Empty(), // 6 - None + [], // 6 - None GetStringList(fileName, "es"), // 7 GetStringList(fileName, "ko"), // 8 - }; + ]; /// /// Retrieves the localization index list for all requested strings for the through Chinese. /// /// Base file name /// String to use for the second Chinese localization. - public static string[][] GetLanguageStrings10(string fileName, string zh2 = "zh") => new[] - { - Array.Empty(), // 0 - None + public static string[][] GetLanguageStrings10(string fileName, string zh2 = "zh") => + [ + [], // 0 - None GetStringList(fileName, "ja"), // 1 GetStringList(fileName, "en"), // 2 GetStringList(fileName, "fr"), // 3 GetStringList(fileName, "it"), // 4 GetStringList(fileName, "de"), // 5 - Array.Empty(), // 6 - None + [], // 6 - None GetStringList(fileName, "es"), // 7 GetStringList(fileName, "ko"), // 8 GetStringList(fileName, "zh"), // 9 GetStringList(fileName, zh2), // 10 - }; + ]; #endregion @@ -171,7 +171,7 @@ public static bool IsStringListCached(string fileName, [NotNullWhen(true)] out s public static string[] LoadStringList(string file, string? txt) { if (txt == null) - return Array.Empty(); + return []; string[] raw = FastSplit(txt); // Make sure only one thread can write to the cache @@ -187,11 +187,11 @@ public static string[] LoadStringList(string file, string? txt) public static byte[] GetBinaryResource(string name) { if (!resourceNameMap.TryGetValue(name, out var resName)) - return Array.Empty(); + return []; using var resource = thisAssembly.GetManifestResourceStream(resName); if (resource is null) - return Array.Empty(); + return []; var buffer = new byte[resource.Length]; resource.ReadExactly(buffer); @@ -214,7 +214,7 @@ private static string[] FastSplit(ReadOnlySpan s) { // Get Count if (s.Length == 0) - return Array.Empty(); + return []; var count = GetCount(s); var result = new string[count]; diff --git a/PKHeX.Core/Util/UpdateUtil.cs b/PKHeX.Core/Util/UpdateUtil.cs index 722fdaa82..847975617 100644 --- a/PKHeX.Core/Util/UpdateUtil.cs +++ b/PKHeX.Core/Util/UpdateUtil.cs @@ -5,7 +5,7 @@ namespace PKHeX.Core; public static class UpdateUtil { /// - /// Gets the latest version of PKHeX according to the Github API + /// Gets the latest version of PKHeX according to the GitHub API /// /// A version representing the latest available version of PKHeX, or null if the latest version could not be determined public static Version? GetLatestPKHeXVersion() diff --git a/PKHeX.Core/Util/Util.cs b/PKHeX.Core/Util/Util.cs index edd280870..4d9b3df20 100644 --- a/PKHeX.Core/Util/Util.cs +++ b/PKHeX.Core/Util/Util.cs @@ -1,12 +1,11 @@ using System; -using System.Runtime.CompilerServices; namespace PKHeX.Core; public static partial class Util { /// - /// Parses the string into an , skipping all characters except for valid digits. + /// Parses the string into a 32-bit integer, skipping all characters except for valid digits. /// /// String to parse /// Parsed value @@ -118,6 +117,10 @@ public static ulong GetHexValue64(ReadOnlySpan value) return result; } +#if NET9_0_OR_GREATER + REPLACE WITH TryFromHexString / TryToHexString +#endif + /// /// Parses a variable length hex string (non-spaced, bytes in reverse order). /// @@ -230,21 +233,4 @@ public static void ToTitleCase(ReadOnlySpan span, Span result) result[i] = c; } } - - /// - /// Trims a string at the first instance of a 0x0000 terminator. - /// - /// String to trim. - /// Trimmed string. - public static ReadOnlySpan TrimFromZero(ReadOnlySpan input) => TrimFromFirst(input, '\0'); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ReadOnlySpan TrimFromFirst(ReadOnlySpan input, char c) - { - int index = input.IndexOf(c); - return index < 0 ? input : input[..index]; - } - - /// - public static string TrimFromZero(string input) => TrimFromZero(input.AsSpan()).ToString(); } diff --git a/PKHeX.Drawing.Misc/PKHeX.Drawing.Misc.csproj b/PKHeX.Drawing.Misc/PKHeX.Drawing.Misc.csproj index 0de5c264b..63c9e8cb1 100644 --- a/PKHeX.Drawing.Misc/PKHeX.Drawing.Misc.csproj +++ b/PKHeX.Drawing.Misc/PKHeX.Drawing.Misc.csproj @@ -1,7 +1,7 @@ - net7.0-windows + net8.0-windows PKHeX.Drawing.Misc @@ -13,7 +13,7 @@ - + diff --git a/PKHeX.Drawing.Misc/QR/QRDecode.cs b/PKHeX.Drawing.Misc/QR/QRDecode.cs index cda5acb70..25c1c9435 100644 --- a/PKHeX.Drawing.Misc/QR/QRDecode.cs +++ b/PKHeX.Drawing.Misc/QR/QRDecode.cs @@ -14,7 +14,7 @@ public static class QRDecode public static QRDecodeResult GetQRData(string address, out byte[] result) { - result = Array.Empty(); + result = []; // Fetch data from QR code... if (!address.StartsWith("http")) diff --git a/PKHeX.Drawing.Misc/QR/QREncode.cs b/PKHeX.Drawing.Misc/QR/QREncode.cs index d84e32b32..710790ab7 100644 --- a/PKHeX.Drawing.Misc/QR/QREncode.cs +++ b/PKHeX.Drawing.Misc/QR/QREncode.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using PKHeX.Core; using QRCoder; @@ -6,17 +6,17 @@ namespace PKHeX.Drawing.Misc; public static class QREncode { - public static Image GenerateQRCode(DataMysteryGift mg) => GenerateQRCode(QRMessageUtil.GetMessage(mg)); - public static Image GenerateQRCode(PKM pk) => GenerateQRCode(QRMessageUtil.GetMessage(pk)); + public static Bitmap GenerateQRCode(DataMysteryGift mg) => GenerateQRCode(QRMessageUtil.GetMessage(mg)); + public static Bitmap GenerateQRCode(PKM pk) => GenerateQRCode(QRMessageUtil.GetMessage(pk)); - public static Image GenerateQRCode7(PK7 pk7, int box = 0, int slot = 0, int copies = 1) + public static Bitmap GenerateQRCode7(PK7 pk7, int box = 0, int slot = 0, int copies = 1) { byte[] data = QR7.GenerateQRData(pk7, box, slot, copies); var msg = QRMessageUtil.GetMessage(data); return GenerateQRCode(msg, ppm: 4); } - private static Image GenerateQRCode(string msg, int ppm = 4) + private static Bitmap GenerateQRCode(string msg, int ppm = 4) { using var generator = new QRCodeGenerator(); using var data = generator.CreateQrCode(msg, QRCodeGenerator.ECCLevel.Q); diff --git a/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs b/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs index 7c7fa886f..5bed65cb9 100644 --- a/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs +++ b/PKHeX.Drawing.Misc/Util/MysteryGiftSpriteUtil.cs @@ -7,9 +7,9 @@ namespace PKHeX.Drawing.Misc; public static class MysteryGiftSpriteUtil { - public static Image Sprite(this MysteryGift gift) => GetSprite(gift); + public static Bitmap Sprite(this MysteryGift gift) => GetSprite(gift); - private static Image GetSprite(MysteryGift gift) + private static Bitmap GetSprite(MysteryGift gift) { if (gift.Empty) return SpriteUtil.Spriter.None; @@ -22,7 +22,7 @@ private static Image GetSprite(MysteryGift gift) return img; } - private static Image GetBaseImage(MysteryGift gift) + private static Bitmap GetBaseImage(MysteryGift gift) { if (gift is { IsEgg: true, Species: (int)Species.Manaphy }) // Manaphy Egg return SpriteUtil.GetMysteryGiftPreviewPoke(gift); diff --git a/PKHeX.Drawing.Misc/Util/PlayerSpriteUtil.cs b/PKHeX.Drawing.Misc/Util/PlayerSpriteUtil.cs index 0277cb073..185d8d2eb 100644 --- a/PKHeX.Drawing.Misc/Util/PlayerSpriteUtil.cs +++ b/PKHeX.Drawing.Misc/Util/PlayerSpriteUtil.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using PKHeX.Core; using PKHeX.Drawing.Misc.Properties; @@ -6,15 +6,15 @@ namespace PKHeX.Drawing.Misc; public static class PlayerSpriteUtil { - public static Image? Sprite(this SaveFile sav) => GetSprite(sav); + public static Bitmap? Sprite(this SaveFile sav) => GetSprite(sav); - private static Image? GetSprite(SaveFile sav) + private static Bitmap? GetSprite(SaveFile sav) { if (sav is IMultiplayerSprite ms) { // Gen6 only string file = $"tr_{ms.MultiplayerSpriteID:00}"; - return Resources.ResourceManager.GetObject(file) as Image ?? Resources.tr_00; + return Resources.ResourceManager.GetObject(file) as Bitmap ?? Resources.tr_00; } return null; } diff --git a/PKHeX.Drawing.Misc/Util/RibbonSpriteUtil.cs b/PKHeX.Drawing.Misc/Util/RibbonSpriteUtil.cs index 8be4bdaa5..63a084287 100644 --- a/PKHeX.Drawing.Misc/Util/RibbonSpriteUtil.cs +++ b/PKHeX.Drawing.Misc/Util/RibbonSpriteUtil.cs @@ -6,19 +6,19 @@ namespace PKHeX.Drawing.Misc; public static class RibbonSpriteUtil { - public static Image? GetRibbonSprite(RibbonIndex ribbon) + public static Bitmap? GetRibbonSprite(RibbonIndex ribbon) { var name = $"Ribbon{ribbon}"; return GetRibbonSprite(name); } - public static Image? GetRibbonSprite(string name) + public static Bitmap? GetRibbonSprite(string name) { var resource = name.Replace("CountG3", "G3").ToLowerInvariant(); return (Bitmap?)Resources.ResourceManager.GetObject(resource); } - public static Image? GetRibbonSprite(string name, int max, int value) + public static Bitmap? GetRibbonSprite(string name, int max, int value) { var resource = GetRibbonSpriteName(name, max, value); return (Bitmap?)Resources.ResourceManager.GetObject(resource); diff --git a/PKHeX.Drawing.Misc/Util/TypeSpriteUtil.cs b/PKHeX.Drawing.Misc/Util/TypeSpriteUtil.cs index 8698d91ec..a8c6a625a 100644 --- a/PKHeX.Drawing.Misc/Util/TypeSpriteUtil.cs +++ b/PKHeX.Drawing.Misc/Util/TypeSpriteUtil.cs @@ -8,21 +8,21 @@ public static class TypeSpriteUtil { private static Bitmap? Get(string name) => Resources.ResourceManager.GetObject(name) as Bitmap; - public static Image? GetTypeSpriteWide(byte type, int generation = PKX.Generation) + public static Bitmap? GetTypeSpriteWide(byte type, int generation = PKX.Generation) { if (generation <= 2) type = (byte)((MoveType)type).GetMoveTypeGeneration(generation); return Get($"type_wide_{type:00}"); } - public static Image? GetTypeSpriteIcon(byte type, int generation = PKX.Generation) + public static Bitmap? GetTypeSpriteIcon(byte type, int generation = PKX.Generation) { if (generation <= 2) type = (byte)((MoveType)type).GetMoveTypeGeneration(generation); return Get($"type_icon_{type:00}"); } - public static Image? GetTypeSpriteGem(byte type) + public static Bitmap? GetTypeSpriteGem(byte type) { return Get($"gem_{type:00}"); } diff --git a/PKHeX.Drawing.Misc/Util/WallpaperUtil.cs b/PKHeX.Drawing.Misc/Util/WallpaperUtil.cs index 1d110b479..5c3965f29 100644 --- a/PKHeX.Drawing.Misc/Util/WallpaperUtil.cs +++ b/PKHeX.Drawing.Misc/Util/WallpaperUtil.cs @@ -7,9 +7,9 @@ namespace PKHeX.Drawing.Misc; public static class WallpaperUtil { - public static Image WallpaperImage(this SaveFile sav, int box) => GetWallpaper(sav, box); + public static Bitmap WallpaperImage(this SaveFile sav, int box) => GetWallpaper(sav, box); - private static Image GetWallpaper(SaveFile sav, int box) + private static Bitmap GetWallpaper(SaveFile sav, int box) { string s = GetWallpaperResourceName(sav.Version, sav.GetBoxWallpaper(box)); return (Bitmap?)Resources.ResourceManager.GetObject(s) ?? Resources.box_wp16xy; diff --git a/PKHeX.Drawing.PokeSprite/Builder/SpriteBuilder.cs b/PKHeX.Drawing.PokeSprite/Builder/SpriteBuilder.cs index 95b5db060..fb23cfb42 100644 --- a/PKHeX.Drawing.PokeSprite/Builder/SpriteBuilder.cs +++ b/PKHeX.Drawing.PokeSprite/Builder/SpriteBuilder.cs @@ -4,7 +4,7 @@ namespace PKHeX.Drawing.PokeSprite; -public abstract class SpriteBuilder : ISpriteBuilder +public abstract class SpriteBuilder : ISpriteBuilder { public static bool ShowEggSpriteAsItem { get; set; } = true; public static bool ShowEncounterBall { get; set; } = true; @@ -104,7 +104,7 @@ public void Initialize(SaveFile sav) /// Is currently in an egg /// Is it shiny /// Context the sprite is for - public Image GetSprite(ushort species, byte form, int gender, uint formarg, int heldItem, bool isEgg, Shiny shiny = Shiny.Never, EntityContext context = EntityContext.None) + public Bitmap GetSprite(ushort species, byte form, int gender, uint formarg, int heldItem, bool isEgg, Shiny shiny = Shiny.Never, EntityContext context = EntityContext.None) { if (species == 0) return None; @@ -118,7 +118,7 @@ public Image GetSprite(ushort species, byte form, int gender, uint formarg, int return GetSprite(baseImage, species, heldItem, isEgg, shiny, context); } - public Image GetSprite(Image baseSprite, ushort species, int heldItem, bool isEgg, Shiny shiny, EntityContext context = EntityContext.None) + public Bitmap GetSprite(Bitmap baseSprite, ushort species, int heldItem, bool isEgg, Shiny shiny, EntityContext context = EntityContext.None) { if (isEgg) baseSprite = LayerOverImageEgg(baseSprite, species, heldItem != 0); @@ -133,7 +133,7 @@ public Image GetSprite(Image baseSprite, ushort species, int heldItem, bool isEg return baseSprite; } - private Image GetBaseImage(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) + private Bitmap GetBaseImage(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) { var img = FormInfo.IsTotemForm(species, form, context) ? GetBaseImageTotem(species, form, gender, formarg, shiny, context) @@ -141,31 +141,31 @@ private Image GetBaseImage(ushort species, byte form, int gender, uint formarg, return img ?? GetBaseImageFallback(species, form, gender, formarg, shiny, context); } - private Image? GetBaseImageTotem(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) + private Bitmap? GetBaseImageTotem(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) { var baseform = FormInfo.GetTotemBaseForm(species, form); - var baseImage = GetBaseImageDefault(species, baseform, gender, formarg, shiny, context); - if (baseImage is not Bitmap b) + var b = GetBaseImageDefault(species, baseform, gender, formarg, shiny, context); + if (b is null) return null; - SpriteUtil.GetSpriteGlow(baseImage, 0, 165, 255, out var pixels, true); + SpriteUtil.GetSpriteGlow(b, 0, 165, 255, out var pixels, true); var layer = ImageUtil.GetBitmap(pixels, b.Width, b.Height, b.PixelFormat); - return ImageUtil.LayerImage(baseImage, layer, 0, 0); + return ImageUtil.LayerImage(b, layer, 0, 0); } - private Image? GetBaseImageDefault(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) + private Bitmap? GetBaseImageDefault(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) { var file = GetSpriteAll(species, form, gender, formarg, shiny, context); - var resource = (Image?)Resources.ResourceManager.GetObject(file); + var resource = (Bitmap?)Resources.ResourceManager.GetObject(file); if (resource is null && HasFallbackMethod) { file = GetSpriteAllSecondary(species, form, gender, formarg, shiny, context); - resource = (Image?)Resources.ResourceManager.GetObject(file); + resource = (Bitmap?)Resources.ResourceManager.GetObject(file); } return resource; } - private Image GetBaseImageFallback(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) + private Bitmap GetBaseImageFallback(ushort species, byte form, int gender, uint formarg, bool shiny, EntityContext context) { if (shiny) // try again without shiny { @@ -175,13 +175,13 @@ private Image GetBaseImageFallback(ushort species, byte form, int gender, uint f } // try again without form - var baseImage = (Image?)Resources.ResourceManager.GetObject(GetSpriteStringSpeciesOnly(species)); + var baseImage = (Bitmap?)Resources.ResourceManager.GetObject(GetSpriteStringSpeciesOnly(species)); if (baseImage == null) // failed again return Unknown; return ImageUtil.LayerImage(baseImage, Unknown, 0, 0, UnknownFormTransparency); } - private Image LayerOverImageItem(Image baseImage, int item, EntityContext context) + private Bitmap LayerOverImageItem(Image baseImage, int item, EntityContext context) { var lump = HeldItemLumpUtil.GetIsLump(item, context); var itemimg = lump switch @@ -197,7 +197,7 @@ private Image LayerOverImageItem(Image baseImage, int item, EntityContext contex return ImageUtil.LayerImage(baseImage, itemimg, x, y); } - private static Image LayerOverImageShiny(Image baseImage, Shiny shiny) + private static Bitmap LayerOverImageShiny(Image baseImage, Shiny shiny) { // Add shiny star to top left of image. Bitmap rare; @@ -208,14 +208,14 @@ private static Image LayerOverImageShiny(Image baseImage, Shiny shiny) return ImageUtil.LayerImage(baseImage, rare, 0, 0, ShinyTransparency); } - private Image LayerOverImageEgg(Image baseImage, ushort species, bool hasItem) + private Bitmap LayerOverImageEgg(Image baseImage, ushort species, bool hasItem) { if (ShowEggSpriteAsItem && !hasItem) return LayerOverImageEggAsItem(baseImage, species); return LayerOverImageEggTransparentSpecies(baseImage, species); } - private Image LayerOverImageEggTransparentSpecies(Image baseImage, ushort species) + private Bitmap LayerOverImageEggTransparentSpecies(Image baseImage, ushort species) { // Partially transparent species. baseImage = ImageUtil.ChangeOpacity(baseImage, EggUnderLayerTransparency); @@ -224,7 +224,7 @@ private Image LayerOverImageEggTransparentSpecies(Image baseImage, ushort specie return ImageUtil.LayerImage(baseImage, egg, 0, 0); } - private Image LayerOverImageEggAsItem(Image baseImage, ushort species) + private Bitmap LayerOverImageEggAsItem(Image baseImage, ushort species) { var egg = GetEggSprite(species); return ImageUtil.LayerImage(baseImage, egg, EggItemShiftX, EggItemShiftY); // similar to held item, since they can't have any diff --git a/PKHeX.Drawing.PokeSprite/PKHeX.Drawing.PokeSprite.csproj b/PKHeX.Drawing.PokeSprite/PKHeX.Drawing.PokeSprite.csproj index 74883934d..1240f6327 100644 --- a/PKHeX.Drawing.PokeSprite/PKHeX.Drawing.PokeSprite.csproj +++ b/PKHeX.Drawing.PokeSprite/PKHeX.Drawing.PokeSprite.csproj @@ -1,12 +1,12 @@ - net7.0-windows + net8.0-windows PKHeX.Drawing.PokeSprite - + diff --git a/PKHeX.Drawing.PokeSprite/Util/SpriteName.cs b/PKHeX.Drawing.PokeSprite/Util/SpriteName.cs index 74e433175..d395cb289 100644 --- a/PKHeX.Drawing.PokeSprite/Util/SpriteName.cs +++ b/PKHeX.Drawing.PokeSprite/Util/SpriteName.cs @@ -72,8 +72,8 @@ public static string GetResourceStringSprite(ushort species, byte form, int gend /// /// Species that show their default Species sprite regardless of current /// - private static ReadOnlySpan SpeciesDefaultFormSprite => new[] - { + private static ReadOnlySpan SpeciesDefaultFormSprite => + [ (ushort)Mothim, (ushort)Scatterbug, (ushort)Spewpa, @@ -85,13 +85,13 @@ public static string GetResourceStringSprite(ushort species, byte form, int gend (ushort)Dudunsparce, (ushort)Poltchageist, (ushort)Sinistcha, - }; + ]; /// /// Species that show a specific Sprite /// - private static ReadOnlySpan SpeciesGenderedSprite => new[] - { + private static ReadOnlySpan SpeciesGenderedSprite => + [ (ushort)Pikachu, (ushort)Hippopotas, (ushort)Hippowdon, @@ -99,5 +99,5 @@ public static string GetResourceStringSprite(ushort species, byte form, int gend (ushort)Frillish, (ushort)Jellicent, (ushort)Pyroar, - }; + ]; } diff --git a/PKHeX.Drawing.PokeSprite/Util/SpriteUtil.cs b/PKHeX.Drawing.PokeSprite/Util/SpriteUtil.cs index 5625a21e9..e45176c59 100644 --- a/PKHeX.Drawing.PokeSprite/Util/SpriteUtil.cs +++ b/PKHeX.Drawing.PokeSprite/Util/SpriteUtil.cs @@ -24,7 +24,7 @@ public static class SpriteUtil /// Changes the builder mode to the requested mode. /// /// Requested sprite builder mode - /// If an out of bounds value is provided, will not change. + /// If an out-of-bounds value is provided, will not change. public static void ChangeMode(SpriteBuilderMode mode) => Spriter = mode switch { SpriteBuilderMode.SpritesArtwork5668 => SB8a, @@ -51,20 +51,20 @@ public static void Initialize(SaveFile sav) Spriter.Initialize(sav); } - public static Image GetBallSprite(int ball) + public static Bitmap GetBallSprite(int ball) { string resource = SpriteName.GetResourceStringBall(ball); return (Bitmap?)Resources.ResourceManager.GetObject(resource) ?? Resources._ball4; // Poké Ball (default) } - public static Image? GetItemSprite(int item) => Resources.ResourceManager.GetObject($"item_{item}") as Image; + public static Bitmap? GetItemSprite(int item) => Resources.ResourceManager.GetObject($"item_{item}") as Bitmap; - public static Image GetSprite(ushort species, byte form, int gender, uint formarg, int item, bool isegg, Shiny shiny, EntityContext context = EntityContext.None) + public static Bitmap GetSprite(ushort species, byte form, int gender, uint formarg, int item, bool isegg, Shiny shiny, EntityContext context = EntityContext.None) { return Spriter.GetSprite(species, form, gender, formarg, item, isegg, shiny, context); } - private static Image GetSprite(PKM pk) + private static Bitmap GetSprite(PKM pk) { var formarg = pk is IFormArgument f ? f.FormArgument : 0; var shiny = !pk.IsShiny ? Shiny.Never : (ShinyExtensions.IsSquareShinyExist(pk) ? Shiny.AlwaysSquare : Shiny.AlwaysStar); @@ -93,7 +93,7 @@ private static Image GetSprite(PKM pk) return img; } - private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false) + private static Bitmap GetSprite(PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false) { bool inBox = (uint)slot < MaxSlotCount; bool empty = pk.Species == 0; @@ -132,7 +132,7 @@ private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fla if (flags.HasFlag(StorageSlotSource.Locked)) sprite = ImageUtil.LayerImage(sprite, Resources.locked, SlotLockShiftX, 0); - // Some games store Party directly in the list of pokemon data (LGP/E). Indicate accordingly. + // Some games store Party directly in the list of Pokémon data (LGP/E). Indicate accordingly. int party = flags.IsParty(); if (party >= 0) sprite = ImageUtil.LayerImage(sprite, PartyMarks[party], PartyMarkShiftX, 0); @@ -146,7 +146,7 @@ private static Image GetSprite(PKM pk, SaveFile sav, int box, int slot, bool fla return sprite; } - private static Image ApplyTeraColor(byte elementalType, Image img, SpriteBackgroundType type) + private static Bitmap ApplyTeraColor(byte elementalType, Bitmap img, SpriteBackgroundType type) { var color = TypeColor.GetTypeSpriteColor(elementalType); var thk = SpriteBuilder.ShowTeraThicknessStripe; @@ -155,7 +155,7 @@ private static Image ApplyTeraColor(byte elementalType, Image img, SpriteBackgro return ApplyColor(img, type, color, thk, op, bg); } - public static Image ApplyEncounterColor(IEncounterTemplate enc, Image img, SpriteBackgroundType type) + public static Bitmap ApplyEncounterColor(IEncounterTemplate enc, Bitmap img, SpriteBackgroundType type) { var index = (enc.GetType().Name.GetHashCode() * 0x43FD43FD); var color = Color.FromArgb(index); @@ -165,7 +165,7 @@ public static Image ApplyEncounterColor(IEncounterTemplate enc, Image img, Sprit return ApplyColor(img, type, color, thk, op, bg); } - private static Image ApplyColor(Image img, SpriteBackgroundType type, Color color, int thick, byte opacStripe, byte opacBack) + private static Bitmap ApplyColor(Bitmap img, SpriteBackgroundType type, Color color, int thick, byte opacStripe, byte opacBack) { if (type == SpriteBackgroundType.BottomStripe) { @@ -190,7 +190,7 @@ private static Image ApplyColor(Image img, SpriteBackgroundType type, Color colo return img; } - private static Image ApplyExperience(PKM pk, Image img, IEncounterTemplate? enc = null) + private static Bitmap ApplyExperience(PKM pk, Image img, IEncounterTemplate? enc = null) { const int bpp = 4; int start = bpp * SpriteWidth * (SpriteHeight - 1); @@ -208,9 +208,9 @@ private static Image ApplyExperience(PKM pk, Image img, IEncounterTemplate? enc } private static readonly Bitmap[] PartyMarks = - { + [ Resources.party1, Resources.party2, Resources.party3, Resources.party4, Resources.party5, Resources.party6, - }; + ]; public static void GetSpriteGlow(PKM pk, byte blue, byte green, byte red, out byte[] pixels, out Image baseSprite, bool forceHollow = false) { @@ -239,12 +239,12 @@ public static void GetSpriteGlow(Image baseSprite, byte blue, byte green, byte r ImageUtil.RemovePixels(pixels, original); } - public static Image GetLegalIndicator(bool valid) => valid ? Resources.valid : Resources.warn; + public static Bitmap GetLegalIndicator(bool valid) => valid ? Resources.valid : Resources.warn; // Extension Methods - public static Image Sprite(this PKM pk) => GetSprite(pk); + public static Bitmap Sprite(this PKM pk) => GetSprite(pk); - public static Image Sprite(this IEncounterTemplate enc) + public static Bitmap Sprite(this IEncounterTemplate enc) { if (enc is MysteryGift g) return GetMysteryGiftPreviewPoke(g); @@ -277,10 +277,10 @@ public static Image Sprite(this IEncounterTemplate enc) _ => 0, }; - public static Image Sprite(this PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false) + public static Bitmap Sprite(this PKM pk, SaveFile sav, int box, int slot, bool flagIllegal = false) => GetSprite(pk, sav, box, slot, flagIllegal); - public static Image GetMysteryGiftPreviewPoke(MysteryGift gift) + public static Bitmap GetMysteryGiftPreviewPoke(MysteryGift gift) { if (gift is { IsEgg: true, Species: (int)Species.Manaphy }) // Manaphy Egg return GetSprite((int)Species.Manaphy, 0, 2, 0, 0, true, Shiny.Never, gift.Context); diff --git a/PKHeX.Drawing/ImageUtil.cs b/PKHeX.Drawing/ImageUtil.cs index 924e12491..2ff3b5129 100644 --- a/PKHeX.Drawing/ImageUtil.cs +++ b/PKHeX.Drawing/ImageUtil.cs @@ -231,7 +231,7 @@ private static void SetAllColorToGrayScale(Span data) { if (data[i + 3] == 0) continue; - byte greyS = (byte)(((0.3 * data[i + 2]) + (0.59 * data[i + 1]) + (0.11 * data[i + 0]))); + byte greyS = (byte)((0.3 * data[i + 2]) + (0.59 * data[i + 1]) + (0.11 * data[i + 0])); data[i + 0] = greyS; data[i + 1] = greyS; data[i + 2] = greyS; diff --git a/PKHeX.Drawing/PKHeX.Drawing.csproj b/PKHeX.Drawing/PKHeX.Drawing.csproj index 9610174c9..5703214b5 100644 --- a/PKHeX.Drawing/PKHeX.Drawing.csproj +++ b/PKHeX.Drawing/PKHeX.Drawing.csproj @@ -1,12 +1,12 @@ - net7.0-windows + net8.0-windows PKHeX.Drawing - + diff --git a/PKHeX.WinForms/Controls/PKM Editor/BallBrowser.cs b/PKHeX.WinForms/Controls/PKM Editor/BallBrowser.cs index 29ae59e83..cf41bdaaa 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/BallBrowser.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/BallBrowser.cs @@ -27,7 +27,7 @@ private void LoadBalls(IEnumerable legal, int max) flags[(int)ball] = true; int countLegal = 0; - List controls = new(); + List controls = []; var names = GameInfo.BallDataSource; for (int ballID = 1; ballID < flags.Length; ballID++) { @@ -62,7 +62,7 @@ private static string GetBallName(int ballID, IEnumerable names) throw new ArgumentOutOfRangeException(nameof(ballID)); } - private PictureBox GetBallView(int ballID, string name, bool valid) + private SelectablePictureBox GetBallView(int ballID, string name, bool valid) { var img = SpriteUtil.GetBallSprite(ballID); var pb = new SelectablePictureBox diff --git a/PKHeX.WinForms/Controls/PKM Editor/ContestStat.cs b/PKHeX.WinForms/Controls/PKM Editor/ContestStat.cs index 9104ac94b..ea814f3dd 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/ContestStat.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/ContestStat.cs @@ -65,8 +65,8 @@ public void ToggleInterface(object o, EntityContext context) Visible = TabStop = true; bool smart = context.Generation() < 6; - Label_Smart.Visible = smart; // show smart gen3-5 - Label_Clever.Visible = !smart; // show clever gen6+ + Label_Smart.Visible = smart; // show "Smart" for Gen3-5 + Label_Clever.Visible = !smart; // show "Clever" for Gen6+ } private void ClickTextBox(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs b/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs index 6d5332aa0..308e0a448 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/GenderToggle.cs @@ -53,11 +53,11 @@ protected override void OnPaint(PaintEventArgs pe) } private static readonly Image[] GenderImages = - { + [ gender_0, gender_1, gender_2, - }; + ]; private int SetGender(int value) { @@ -111,7 +111,7 @@ private void TryToggle() public interface IGenderToggle { /// - /// Enables use of the built in click action. + /// Enables use of the built-in click action. /// bool AllowClick { get; set; } @@ -123,6 +123,6 @@ public interface IGenderToggle /// /// Manually flips the gender state if possible. /// - /// True if can toggle, and the resulting value. + /// True if the gender was toggled, and the current Gender value after the operation. (bool CanToggle, int Value) ToggleGender(); } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 7c9e52dca..4862fe28b 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -37,17 +37,17 @@ public PKMEditor() TB_Nickname.Font = TB_OT.Font = TB_HT.Font = font; // Commonly reused Control arrays - Moves = new[] { MC_Move1, MC_Move2, MC_Move3, MC_Move4 }; - Relearn = new[] { CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 }; - Markings = new[] { PB_Mark1, PB_Mark2, PB_Mark3, PB_Mark4, PB_Mark5, PB_Mark6 }; + Moves = [MC_Move1, MC_Move2, MC_Move3, MC_Move4]; + Relearn = [CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4]; + Markings = [PB_Mark1, PB_Mark2, PB_Mark3, PB_Mark4, PB_Mark5, PB_Mark6]; // Legality Indicators - relearnPB = new[] { PB_WarnRelearn1, PB_WarnRelearn2, PB_WarnRelearn3, PB_WarnRelearn4 }; + relearnPB = [PB_WarnRelearn1, PB_WarnRelearn2, PB_WarnRelearn3, PB_WarnRelearn4]; // Validation of incompletely entered data fields bool Criteria(Control c) => c.BackColor == Draw.InvalidSelection && c is ComboBox { Items.Count: not 0 }; - ValidatedControls = new ValidationRequiredSet[] - { + ValidatedControls = + [ new(Moves, _ => true, z => Criteria(((MoveChoice)z).CB_Move)), new(new[] {CB_Species}, _ => true, Criteria), new(new[] {CB_HeldItem}, pk => pk.Format >= 2, Criteria), @@ -57,7 +57,7 @@ public PKMEditor() new(Relearn, pk => pk.Format >= 6, Criteria), new(new[] {CB_StatNature}, pk => pk.Format >= 8, Criteria), new(new[] {CB_AlphaMastered}, pk => pk is PA8, Criteria), - }; + ]; foreach (var c in WinFormsUtil.GetAllControlsOfType(this)) c.KeyDown += WinFormsUtil.RemoveDropCB; @@ -83,36 +83,25 @@ public PKMEditor() FlickerInterface(); } - private sealed class ValidationRequiredSet + private sealed class ValidationRequiredSet(Control[] Controls, Func ShouldCheck, Func State) { - private readonly Control[] Controls; - private readonly Func ShouldCheck; - private readonly Func IsInvalidState; - public Control? IsNotValid(PKM pk) { if (!ShouldCheck(pk)) return null; - return Array.Find(Controls, z => IsInvalidState(z)); - } - - public ValidationRequiredSet(Control[] controls, Func shouldCheck, Func state) - { - Controls = controls; - ShouldCheck = shouldCheck; - IsInvalidState = state; + return Array.Find(Controls, z => State(z)); } } public void InitializeBinding() { ComboBox[] cbs = - { + [ CB_Nature, CB_StatNature, CB_Country, CB_SubRegion, CB_3DSReg, CB_Language, CB_Ball, CB_HeldItem, CB_Species, DEV_Ability, CB_GroundTile, CB_GameOrigin, CB_BattleVersion, CB_Ability, CB_MetLocation, CB_EggLocation, CB_Language, CB_HTLanguage, CB_AlphaMastered, - }; + ]; foreach (var cb in cbs.Concat(Relearn)) cb.InitializeBinding(); @@ -149,7 +138,7 @@ public bool HideSecretValues public bool Unicode { get; set; } = true; private bool _hax; public bool HaX { get => _hax; set => _hax = Stats.HaX = value; } - private byte[] LastData = Array.Empty(); + private byte[] LastData = []; public PKM Data => Entity; public PKM Entity { get; private set; } = null!; @@ -227,7 +216,7 @@ public bool EditsComplete if (ModifierKeys == (Keys.Control | Keys.Shift | Keys.Alt)) return true; // Override - // If any controls are partially filled out, find the first one so we can indicate as such. + // Find the first unfilled control, indicate as invalid. Control? cb = null; foreach (var type in ValidatedControls) { @@ -1213,7 +1202,7 @@ private void UpdateOriginGame(object sender, EventArgs e) Entity.Version = (byte)version; } - // Visibility logic for Gen 4 ground tile; only show for Gen 4 Pokemon. + // Visibility logic for Gen 4 ground tile; only show for Gen 4 Pokémon. if (Entity is IGroundTile) { bool g4 = Entity.Gen4; @@ -1389,7 +1378,7 @@ private void UpdateNicknameClick(object sender, MouseEventArgs e) return; // Open Trash/Special Character form - // Set the string back to the entity in the right spot, so the span fetch has latest date. + // Set the string back to the entity in the right spot, so the span fetch has the latest data. Span trash; TextBox tb = sender as TextBox ?? TB_Nickname; if (tb == TB_Nickname) @@ -2088,9 +2077,11 @@ private void CB_BattleVersion_SelectedValueChanged(object sender, EventArgs e) PB_BattleVersion.Image = GetMarkSprite(PB_BattleVersion, value != 0); } - private static Image GetMarkSprite(PictureBox p, bool opaque, double trans = 0.175) + private static Bitmap GetMarkSprite(PictureBox p, bool opaque, double trans = 0.175) { - var sprite = p.InitialImage; + var img = p.InitialImage; + if (img is not Bitmap sprite) + throw new Exception(); return opaque ? sprite : ImageUtil.ChangeOpacity(sprite, trans); } @@ -2140,7 +2131,7 @@ private void InitializeLanguage(ITrainerInfo sav) CB_Nature.DataSource = new BindingSource(source.Natures, null); CB_StatNature.DataSource = new BindingSource(source.Natures, null); - // Sub editors + // Sub-editors Stats.InitializeDataSources(); PopulateFilteredDataSources(sav, true); @@ -2188,7 +2179,7 @@ private void PopulateFilteredDataSources(ITrainerInfo sav, bool force = false) } SetIfDifferentCount(source.Species, CB_Species, force); - // Set the Move ComboBoxes too.. + // Set the Move ComboBoxes too. LegalMoveSource.ChangeMoveSource(source.Moves); foreach (var cb in Relearn) SetIfDifferentCount(source.Relearn, cb, force); diff --git a/PKHeX.WinForms/Controls/PKM Editor/ShinyLeaf.cs b/PKHeX.WinForms/Controls/PKM Editor/ShinyLeaf.cs index 504801b5f..72a025689 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/ShinyLeaf.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/ShinyLeaf.cs @@ -11,7 +11,7 @@ public partial class ShinyLeaf : UserControl public ShinyLeaf() { InitializeComponent(); - Flags = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_C }; + Flags = [CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_C]; } private readonly CheckBox[] Flags; diff --git a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs index 9cc5dc2dd..ccbb81469 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs @@ -13,13 +13,13 @@ public partial class StatEditor : UserControl public StatEditor() { InitializeComponent(); - MT_IVs = new[] { TB_IVHP, TB_IVATK, TB_IVDEF, TB_IVSPE, TB_IVSPA, TB_IVSPD }; - MT_EVs = new[] { TB_EVHP, TB_EVATK, TB_EVDEF, TB_EVSPE, TB_EVSPA, TB_EVSPD }; - MT_AVs = new[] { TB_AVHP, TB_AVATK, TB_AVDEF, TB_AVSPE, TB_AVSPA, TB_AVSPD }; - MT_GVs = new[] { TB_GVHP, TB_GVATK, TB_GVDEF, TB_GVSPE, TB_GVSPA, TB_GVSPD }; - MT_Stats = new[] { Stat_HP, Stat_ATK, Stat_DEF, Stat_SPE, Stat_SPA, Stat_SPD }; - L_Stats = new[] { Label_HP, Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD }; - MT_Base = new[] { TB_BaseHP, TB_BaseATK, TB_BaseDEF, TB_BaseSPE, TB_BaseSPA, TB_BaseSPD }; + MT_IVs = [TB_IVHP, TB_IVATK, TB_IVDEF, TB_IVSPE, TB_IVSPA, TB_IVSPD]; + MT_EVs = [TB_EVHP, TB_EVATK, TB_EVDEF, TB_EVSPE, TB_EVSPA, TB_EVSPD]; + MT_AVs = [TB_AVHP, TB_AVATK, TB_AVDEF, TB_AVSPE, TB_AVSPA, TB_AVSPD]; + MT_GVs = [TB_GVHP, TB_GVATK, TB_GVDEF, TB_GVSPE, TB_GVSPA, TB_GVSPD]; + MT_Stats = [Stat_HP, Stat_ATK, Stat_DEF, Stat_SPE, Stat_SPA, Stat_SPD]; + L_Stats = [Label_HP, Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD]; + MT_Base = [TB_BaseHP, TB_BaseATK, TB_BaseDEF, TB_BaseSPE, TB_BaseSPA, TB_BaseSPD]; TB_BST.ResetForeColor(); TB_IVTotal.ForeColor = TB_EVTotal.ForeColor = MT_EVs[0].ForeColor; @@ -32,7 +32,7 @@ public StatEditor() public Color StatDecreased { get; set; } = Color.Blue; public Color StatHyperTrained { get; set; } = Color.LightGreen; - public IMainEditor MainEditor { private get; set; } = null!; + public PKMEditor MainEditor { private get; set; } = null!; public bool HaX { get => CHK_HackedStats.Enabled; set => CHK_HackedStats.Enabled = CHK_HackedStats.Visible = value; } private readonly ToolTip EVTip = new(); @@ -719,13 +719,13 @@ public void InitializeDataSources() private void CHK_Gigantamax_CheckedChanged(object sender, EventArgs e) { if (!ChangingFields) - ((PKMEditor)MainEditor).UpdateSprite(); + MainEditor.UpdateSprite(); } private void CHK_IsAlpha_CheckedChanged(object sender, EventArgs e) { if (!ChangingFields) - ((PKMEditor)MainEditor).UpdateSprite(); + MainEditor.UpdateSprite(); } private void L_TeraTypeOverride_Click(object sender, EventArgs e) => CB_TeraTypeOverride.SelectedValue = Entity.SV ? (int)TeraOverrideNoneValue : CB_TeraTypeOriginal.SelectedValue; @@ -750,7 +750,7 @@ private void ChangeTeraType(object sender, EventArgs e) type = original; PB_TeraType.Image = TypeSpriteUtil.GetTypeSpriteGem(type); if (!ChangingFields) - ((PKMEditor)MainEditor).UpdateSprite(); + MainEditor.UpdateSprite(); } public void CenterSubEditors() diff --git a/PKHeX.WinForms/Controls/PKM Editor/TrainerID.cs b/PKHeX.WinForms/Controls/PKM Editor/TrainerID.cs index 500c0f7a3..f7ca502e1 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/TrainerID.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/TrainerID.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Windows.Forms; using PKHeX.Core; @@ -104,11 +103,11 @@ private void SetFormat(TrainerIDFormat display, int format) (DisplayType, XorFormat) = (display, format); } - private IEnumerable GetControlsForFormat(TrainerIDFormat format) => format switch + private Control[] GetControlsForFormat(TrainerIDFormat format) => format switch { - TrainerIDFormat.SixDigit => new Control[] { Label_SID, TB_SID7, Label_TID, TB_TID7 }, - TrainerIDFormat.SixteenBitSingle => new Control[] { Label_TID, TB_TID }, // Gen1/2 - _ => new Control[] { Label_TID, TB_TID, Label_SID, TB_SID }, + TrainerIDFormat.SixDigit => [Label_SID, TB_SID7, Label_TID, TB_TID7], + TrainerIDFormat.SixteenBitSingle => [Label_TID, TB_TID], // Gen1/2 + _ => [Label_TID, TB_TID, Label_SID, TB_SID], }; private void UpdateTSV(object sender, EventArgs e) => UpdateTSV(); @@ -144,7 +143,7 @@ private void Update_ID(object sender, EventArgs e) } else { - if (value > ushort.MaxValue) // prior to gen7 + if (value > ushort.MaxValue) // prior to Gen7 mt.Text = (value = ushort.MaxValue).ToString(); if (mt == TB_TID) diff --git a/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs b/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs index 61d2b48ee..658cb9197 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs @@ -57,14 +57,14 @@ public sealed class VerticalTabControlEntityEditor : VerticalTabControl /// Tab stripe colors based on Contest Stats. /// private static readonly Color[] SelectedTags = - { + [ Color.FromArgb(248, 152, 096), Color.FromArgb(128, 152, 248), Color.FromArgb(248, 168, 208), Color.FromArgb(112, 224, 112), Color.FromArgb(248, 240, 056), Color.RosyBrown, - }; + ]; protected override void OnDrawItem(DrawItemEventArgs e) { diff --git a/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs index 6fc730493..0e01c0c6f 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/BoxEditor.cs @@ -12,7 +12,7 @@ namespace PKHeX.WinForms.Controls; public partial class BoxEditor : UserControl, ISlotViewer { - public IList SlotPictureBoxes { get; private set; } = Array.Empty(); + public IList SlotPictureBoxes { get; private set; } = []; public SaveFile SAV => M?.SE.SAV ?? throw new ArgumentNullException(nameof(SAV)); public int BoxSlotCount { get; private set; } diff --git a/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs b/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs index 87fb89b7a..fc0d82f7e 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/BoxMenuStrip.cs @@ -9,7 +9,7 @@ namespace PKHeX.WinForms.Controls; public sealed class BoxMenuStrip : ContextMenuStrip { private readonly SAVEditor SAV; - private readonly List CustomItems = new(); + private readonly List CustomItems = []; private readonly BoxManipulator Manipulator; public BoxMenuStrip(SAVEditor sav) @@ -89,18 +89,9 @@ private void AddItem(ISaveFileProvider sav, ToolStripDropDownItem parent, IBoxMa [BoxManipType.ModifyHeal] = Resources.heart, }; - private sealed class ItemVisibility + private sealed class ItemVisibility(ToolStripItem toolStripItem, IBoxManip visible) { - private readonly ToolStripItem Item; - private readonly IBoxManip Manip; - - public ItemVisibility(ToolStripItem toolStripItem, IBoxManip visible) - { - Item = toolStripItem; - Manip = visible; - } - - public void SetVisibility(SaveFile s) => Item.Visible = Manip.Usable(s); + public void SetVisibility(SaveFile s) => toolStripItem.Visible = visible.Usable(s); } public void ToggleVisibility() @@ -110,12 +101,12 @@ public void ToggleVisibility() } private static readonly Image[] TopLevelImages = - { + [ Resources.nocheck, Resources.swapBox, Resources.settings, Resources.wand, - }; + ]; public void Clear() => Manipulator.Execute(BoxManipType.DeleteAll, SAV.CurrentBox, All); public void Sort() => Manipulator.Execute(BoxManipType.SortSpecies, SAV.CurrentBox, All); @@ -127,17 +118,11 @@ public void ToggleVisibility() /// /// Implementation of a WinForms box manipulator (using MessageBox prompts) /// -public sealed class BoxManipulatorWF : BoxManipulator +public sealed class BoxManipulatorWF(SAVEditor editor) : BoxManipulator { - private readonly SAVEditor Editor; - protected override SaveFile SAV => Editor.SAV; + protected override SaveFile SAV => editor.SAV; - public BoxManipulatorWF(SAVEditor editor) - { - Editor = editor; - } - - protected override void FinishBoxManipulation(string message, bool all, int count) => Editor.FinishBoxManipulation(message, all, count); + protected override void FinishBoxManipulation(string message, bool all, int count) => editor.FinishBoxManipulation(message, all, count); protected override bool CanManipulateRegion(int start, int end, string prompt, string fail) { diff --git a/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs b/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs index 4b5e83798..1914601ab 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/ContextMenuSAV.cs @@ -140,11 +140,9 @@ private void MenuOpening(object sender, CancelEventArgs e) private static SlotViewInfo GetSenderInfo(object sender) { var pb = WinFormsUtil.GetUnderlyingControl(sender); - if (pb == null) - throw new InvalidCastException("Unable to find PictureBox"); + ArgumentNullException.ThrowIfNull(pb); var view = WinFormsUtil.FindFirstControlOfType>(pb); - if (view == null) - throw new InvalidCastException("Unable to find View Parent"); + ArgumentNullException.ThrowIfNull(view); var loc = view.GetSlotData(pb); return new SlotViewInfo(loc, view); } diff --git a/PKHeX.WinForms/Controls/SAV Editor/PartyEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/PartyEditor.cs index 807a174fd..00c92f9c4 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/PartyEditor.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/PartyEditor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Windows.Forms; using PKHeX.Core; @@ -8,7 +8,7 @@ namespace PKHeX.WinForms.Controls; public partial class PartyEditor : UserControl, ISlotViewer { - public IList SlotPictureBoxes { get; private set; } = Array.Empty(); + public IList SlotPictureBoxes { get; private set; } = []; public SaveFile SAV => M?.SE.SAV ?? throw new ArgumentNullException(nameof(SAV)); public int BoxSlotCount { get; private set; } diff --git a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs index 886e1c8d7..cfdd41464 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SAVEditor.cs @@ -67,10 +67,10 @@ public SAVEditor() { InitializeComponent(); - L_SlotOccupied = new[] { L_DC1, L_DC2 }; - TB_SlotEXP = new[] { TB_Daycare1XP, TB_Daycare2XP }; - L_SlotEXP = new[] { L_XP1, L_XP2 }; - SlotPictureBoxes = new[] { dcpkx1, dcpkx2 }; + L_SlotOccupied = [L_DC1, L_DC2]; + TB_SlotEXP = [TB_Daycare1XP, TB_Daycare2XP]; + L_SlotEXP = [L_XP1, L_XP2]; + SlotPictureBoxes = [dcpkx1, dcpkx2]; Tab_Box.ContextMenuStrip = SortMenu = new BoxMenuStrip(this); M = new SlotChangeManager(this) { Env = EditEnv }; @@ -201,7 +201,7 @@ public ISlotInfo GetSlotData(PictureBox view) return GetSlotData(index); } - private ISlotInfo GetSlotData(int index) + private SlotInfoMisc GetSlotData(int index) { var ofs = SAV.GetDaycareSlotOffset(SAV.DaycareIndex, index); return new SlotInfoMisc(SAV, index, ofs); @@ -1007,7 +1007,7 @@ public bool ToggleInterface() WindowTranslationRequired |= ToggleViewParty(SAV, BoxTab); int PartyTab = tabBoxMulti.TabPages.IndexOf(Tab_PartyBattle); WindowTranslationRequired |= ToggleViewDaycare(SAV, BoxTab, PartyTab); - SetPKMBoxes(); // Reload all of the PKX Windows + SetPKMBoxes(); // Reload all Entity picture boxes ToggleViewMisc(SAV); @@ -1017,7 +1017,7 @@ public bool ToggleInterface() private void ToggleViewReset() { - // Close subforms that are save dependent + // Close sub-forms that are SaveFile dependent foreach (var z in M.Boxes.Skip(1).ToArray()) z.FindForm()?.Close(); @@ -1142,7 +1142,7 @@ private void ToggleViewSubEditors(SaveFile sav) B_OpenHallofFame.Visible = sav is ISaveBlock6Main or SAV7; B_OpenOPowers.Visible = sav is ISaveBlock6Main; B_OpenPokedex.Visible = sav.HasPokeDex; - B_OpenBerryField.Visible = sav is SAV6XY; // oras undocumented + B_OpenBerryField.Visible = sav is SAV6XY; // OR/AS undocumented B_OpenFriendSafari.Visible = sav is SAV6XY; B_OpenEventFlags.Visible = sav is IEventFlag37 or SAV1 or SAV2 or SAV8BS or SAV7b; B_CGearSkin.Visible = sav.Generation == 5; diff --git a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs index c1bdca27a..09fb83ff0 100644 --- a/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs +++ b/PKHeX.WinForms/Controls/SAV Editor/SlotChangeManager.cs @@ -15,18 +15,16 @@ namespace PKHeX.WinForms.Controls; /// /// Orchestrates the movement of slots within the GUI. /// -public sealed class SlotChangeManager : IDisposable +public sealed class SlotChangeManager(SAVEditor se) : IDisposable { - public readonly SAVEditor SE; + public readonly SAVEditor SE = se; public readonly SlotTrackerImage LastSlot = new(); public readonly DragManager Drag = new(); public SaveDataEditor Env { get; set; } = null!; - public readonly List Boxes = new(); + public readonly List Boxes = []; public readonly SlotHoverHandler Hover = new(); - public SlotChangeManager(SAVEditor se) => SE = se; - public void Reset() { Drag.Initialize(); @@ -102,8 +100,7 @@ public void DragEnter(object? sender, DragEventArgs e) private static SlotViewInfo GetSlotInfo(T pb) where T : Control { var view = WinFormsUtil.FindFirstControlOfType>(pb); - if (view == null) - throw new InvalidCastException("Unable to find View Parent"); + ArgumentNullException.ThrowIfNull(view); var src = view.GetSlotData(pb); return new SlotViewInfo(src, view); } @@ -118,7 +115,7 @@ public void MouseMove(object? sender, MouseEventArgs e) if (sender is not PictureBox pb) return; - // Abort if there is no Pokemon in the given slot. + // Abort if there is no Pokémon in the given slot. if (pb.Image == null) return; bool encrypt = Control.ModifierKeys == Keys.Control; @@ -287,7 +284,7 @@ private bool TryLoadFiles(IReadOnlyList files, DragEventArgs e, bool bad var temp = FileUtil.GetSingleFromPath(path, sav); if (temp == null) { - Drag.RequestDD(this, e); // pass thru + Drag.RequestDD(this, e); // pass through return true; // treat as handled } diff --git a/PKHeX.WinForms/Controls/Slots/CryPlayer.cs b/PKHeX.WinForms/Controls/Slots/CryPlayer.cs index 75ffb1ba5..c432bdb87 100644 --- a/PKHeX.WinForms/Controls/Slots/CryPlayer.cs +++ b/PKHeX.WinForms/Controls/Slots/CryPlayer.cs @@ -47,7 +47,7 @@ private static string GetCryFileName(ISpeciesForm pk, EntityContext context) if (pk is { Species: (int)Species.Urshifu, Form: 1 }) // same sprite for both forms, but different cries return "892-1"; - // don't grab sprite of pk, no gender specific cries + // don't grab sprite of pk, no gender-specific cries var res = SpriteName.GetResourceStringSprite(pk.Species, pk.Form, 0, 0, context); // people like - instead of _ file names ;) diff --git a/PKHeX.WinForms/Controls/Slots/PokeGrid.cs b/PKHeX.WinForms/Controls/Slots/PokeGrid.cs index 628ccea73..91d4ae537 100644 --- a/PKHeX.WinForms/Controls/Slots/PokeGrid.cs +++ b/PKHeX.WinForms/Controls/Slots/PokeGrid.cs @@ -14,7 +14,7 @@ public PokeGrid() InitializeComponent(); } - public readonly List Entries = new(); + public readonly List Entries = []; public int Slots { get; private set; } private int sizeW = 68; diff --git a/PKHeX.WinForms/Controls/Slots/PokePreview.cs b/PKHeX.WinForms/Controls/Slots/PokePreview.cs index 8aa6cee37..c5c39798d 100644 --- a/PKHeX.WinForms/Controls/Slots/PokePreview.cs +++ b/PKHeX.WinForms/Controls/Slots/PokePreview.cs @@ -24,11 +24,11 @@ public PokePreview() } private static readonly Image[] GenderImages = - { + [ Properties.Resources.gender_0, Properties.Resources.gender_1, Properties.Resources.gender_2, - }; + ]; public void Populate(PKM pk) { diff --git a/PKHeX.WinForms/Controls/Slots/SlotList.cs b/PKHeX.WinForms/Controls/Slots/SlotList.cs index 4f5d67365..4310b8936 100644 --- a/PKHeX.WinForms/Controls/Slots/SlotList.cs +++ b/PKHeX.WinForms/Controls/Slots/SlotList.cs @@ -10,8 +10,8 @@ public partial class SlotList : UserControl, ISlotViewer { private static readonly string[] names = Enum.GetNames(typeof(StorageSlotType)); private readonly Label[] Labels = new Label[names.Length]; - private readonly List slots = new(); - private List SlotOffsets = new(); + private readonly List slots = []; + private List SlotOffsets = []; public int SlotCount { get; private set; } public SaveFile SAV { get; set; } = null!; public bool FlagIllegal { get; set; } diff --git a/PKHeX.WinForms/Controls/Slots/SlotUtil.cs b/PKHeX.WinForms/Controls/Slots/SlotUtil.cs index 30e40e8ab..81a33bdbd 100644 --- a/PKHeX.WinForms/Controls/Slots/SlotUtil.cs +++ b/PKHeX.WinForms/Controls/Slots/SlotUtil.cs @@ -14,7 +14,7 @@ public static class SlotUtil /// /// Gets the background image for a slot based on the provided . /// - public static Image GetTouchTypeBackground(SlotTouchType type) => type switch + public static Bitmap GetTouchTypeBackground(SlotTouchType type) => type switch { SlotTouchType.None => SpriteUtil.Spriter.Transparent, SlotTouchType.Get => SpriteUtil.Spriter.View, diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 340393d8d..729c69dd6 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -91,7 +91,7 @@ private set private readonly string[] main_langlist = Enum.GetNames(typeof(ProgramLanguage)); - private static readonly List Plugins = new(); + private static readonly List Plugins = []; #endregion #region Path Variables @@ -441,9 +441,11 @@ private void MainMenuBoxLoad(object sender, EventArgs e) WinFormsUtil.Alert(result); } + /// + /// Dumps all Entity content stored in the SaveFile's boxes to disk. + /// private void MainMenuBoxDump(object sender, EventArgs e) { - // Dump all of box content to files. string? path = null; DialogResult ld = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDatabaseExport); if (ld == DialogResult.Yes) @@ -888,7 +890,7 @@ private static bool SanityCheckSAV(ref SaveFile sav) { if (ModifierKeys == Keys.Control || s3.IsCorruptPokedexFF()) { - var g = new[] { GameVersion.R, GameVersion.S, GameVersion.E, GameVersion.FR, GameVersion.LG }; + GameVersion[] g = [GameVersion.R, GameVersion.S, GameVersion.E, GameVersion.FR, GameVersion.LG]; var games = g.Select(z => GameInfo.VersionDataSource.First(v => v.Value == (int)z)); var msg = string.Format(MsgFileLoadVersionDetect, $"3 ({s3.Version})"); using var dialog = new SAV_GameSelect(games, msg, MsgFileLoadSaveSelectVersion); diff --git a/PKHeX.WinForms/MainWindow/PluginLoader.cs b/PKHeX.WinForms/MainWindow/PluginLoader.cs index 6ac96bd72..3a4166171 100644 --- a/PKHeX.WinForms/MainWindow/PluginLoader.cs +++ b/PKHeX.WinForms/MainWindow/PluginLoader.cs @@ -13,7 +13,7 @@ public static class PluginLoader public static IEnumerable LoadPlugins(string pluginPath, PluginLoadSetting loadSetting) where T : class { var dllFileNames = !Directory.Exists(pluginPath) - ? Array.Empty() // Don't immediately return, as we may be loading plugins merged with this .exe + ? [] // Don't immediately return, as we may be loading plugins merged with this .exe : Directory.EnumerateFiles(pluginPath, "*.dll", SearchOption.AllDirectories); var assemblies = GetAssemblies(dllFileNames, loadSetting); var pluginTypes = GetPluginsOfType(assemblies); @@ -79,7 +79,7 @@ private static IEnumerable GetPluginTypes(Assembly z, Type plugin) // Handle Costura merged plugin dll's; need to Attach for them to correctly retrieve their dependencies. var assemblyLoaderType = z.GetType("Costura.AssemblyLoader", false); var attachMethod = assemblyLoaderType?.GetMethod("Attach", BindingFlags.Static | BindingFlags.Public); - attachMethod?.Invoke(null, Array.Empty()); + attachMethod?.Invoke(null, []); var types = z.GetExportedTypes(); return types.Where(type => IsTypePlugin(type, plugin)); @@ -90,14 +90,14 @@ private static IEnumerable GetPluginTypes(Assembly z, Type plugin) Debug.WriteLine($"Unable to load plugin [{plugin.FullName}]: {z.FullName}"); Debug.WriteLine(ex.Message); if (ex is not ReflectionTypeLoadException rtle) - return Array.Empty(); + return []; foreach (var le in rtle.LoaderExceptions) { if (le is not null) Debug.WriteLine(le.Message); } - return Array.Empty(); + return []; } } diff --git a/PKHeX.WinForms/Misc/ErrorWindow.cs b/PKHeX.WinForms/Misc/ErrorWindow.cs index 71cfd232c..1646defbe 100644 --- a/PKHeX.WinForms/Misc/ErrorWindow.cs +++ b/PKHeX.WinForms/Misc/ErrorWindow.cs @@ -30,7 +30,7 @@ private ErrorWindow(string lang) : this() } /// - /// Gets or sets whether or not the "Continue" button is visible. + /// Gets or sets the visibility of the "Continue" button. /// /// For UI exceptions, continuing could be safe. /// For application exceptions, continuing is not possible, so the button should not be shown. diff --git a/PKHeX.WinForms/PKHeX.WinForms.csproj b/PKHeX.WinForms/PKHeX.WinForms.csproj index bb6c25611..61bf27a7d 100644 --- a/PKHeX.WinForms/PKHeX.WinForms.csproj +++ b/PKHeX.WinForms/PKHeX.WinForms.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows win-x64 true diff --git a/PKHeX.WinForms/Program.cs b/PKHeX.WinForms/Program.cs index 38b556416..c5f1b8e36 100644 --- a/PKHeX.WinForms/Program.cs +++ b/PKHeX.WinForms/Program.cs @@ -61,7 +61,7 @@ private static ReadOnlySpan GetSaneVersionTag(ReadOnlySpan productVe #if !DEBUG private static void Error(string msg) => MessageBox.Show(msg, "PKHeX Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); - // Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution. + // Handle the UI exceptions by showing a dialog box, and asking the user if they wish to abort execution. private static void UIThreadException(object sender, ThreadExceptionEventArgs t) { DialogResult result = DialogResult.Cancel; @@ -79,8 +79,7 @@ private static void UIThreadException(object sender, ThreadExceptionEventArgs t) Application.Exit(); } - // Handle the UI exceptions by showing a dialog box, and asking the user whether - // or not they wish to abort execution. + // Handle the UI exceptions by showing a dialog box, and asking the user if they wish to abort execution. // NOTE: This exception cannot be kept from terminating the application - it can only // log the event, and inform the user about it. private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) diff --git a/PKHeX.WinForms/Properties/PKHeXSettings.cs b/PKHeX.WinForms/Properties/PKHeXSettings.cs index 38c08f2d1..2f15a84b3 100644 --- a/PKHeX.WinForms/Properties/PKHeXSettings.cs +++ b/PKHeX.WinForms/Properties/PKHeXSettings.cs @@ -14,7 +14,7 @@ namespace PKHeX.WinForms; [JsonSerializable(typeof(PKHeXSettings))] -public sealed partial class PKHeXSettingsContext : JsonSerializerContext { } +public sealed partial class PKHeXSettingsContext : JsonSerializerContext; [Serializable] [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] @@ -111,10 +111,10 @@ public sealed class BackupSettings public bool BAKPrompt { get; set; } [LocalizedDescription("List of extra locations to look for Save Files.")] - public List OtherBackupPaths { get; set; } = new(); + public List OtherBackupPaths { get; set; } = []; [LocalizedDescription("Save File file-extensions (no period) that the program should also recognize.")] - public List OtherSaveFileExtensions { get; set; } = new(); + public List OtherSaveFileExtensions { get; set; } = []; } [Serializable] @@ -252,7 +252,7 @@ public sealed class AdvancedSettings public string HideEvent8Contains { get; set; } = string.Empty; [Browsable(false)] - public string[] GetExclusionList8() => Array.ConvertAll(HideEvent8Contains.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries), z => z.Trim()); + public string[] GetExclusionList8() => Array.ConvertAll(HideEvent8Contains.Split(',', StringSplitOptions.RemoveEmptyEntries), z => z.Trim()); } [Serializable] diff --git a/PKHeX.WinForms/Properties/Resources.Designer.cs b/PKHeX.WinForms/Properties/Resources.Designer.cs index a69608579..449c9d15e 100644 --- a/PKHeX.WinForms/Properties/Resources.Designer.cs +++ b/PKHeX.WinForms/Properties/Resources.Designer.cs @@ -120,6 +120,146 @@ public class Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_balls { + get { + object obj = ResourceManager.GetObject("bag_balls", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_battle { + get { + object obj = ResourceManager.GetObject("bag_battle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_berries { + get { + object obj = ResourceManager.GetObject("bag_berries", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_candy { + get { + object obj = ResourceManager.GetObject("bag_candy", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_free { + get { + object obj = ResourceManager.GetObject("bag_free", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_ingredient { + get { + object obj = ResourceManager.GetObject("bag_ingredient", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_items { + get { + object obj = ResourceManager.GetObject("bag_items", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_key { + get { + object obj = ResourceManager.GetObject("bag_key", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_mail { + get { + object obj = ResourceManager.GetObject("bag_mail", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_medicine { + get { + object obj = ResourceManager.GetObject("bag_medicine", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_pcitems { + get { + object obj = ResourceManager.GetObject("bag_pcitems", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_tech { + get { + object obj = ResourceManager.GetObject("bag_tech", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_treasure { + get { + object obj = ResourceManager.GetObject("bag_treasure", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap bag_z { + get { + object obj = ResourceManager.GetObject("bag_z", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -214,13 +354,13 @@ public class Resources { /// Looks up a localized string similar to PKHeX - By Kaphotics ///http://projectpokemon.org/pkhex/ /// - ///23/02/27 - New Update: - /// - Added: Support for S/V 1.2.0 - /// - Added: SV style menu sprites for all species/forms. Thanks @sora10pls & @SciresM! - /// - Added: Gen5 Black/White City data can now be imported/exported, and Roamer status can be reset. Thanks @frefire! - /// - Added: Gen4/5 Geonet Location save file settings can now be viewed/changed. Thanks @abcboy101! - /// - Added: Gen4 Ranch now supports Toys from the Platinum game update. Thanks @Zazsona! - /// - Fixe [rest of string was truncated]";. + ///23/10/11 - New Update: + /// - Added support for Scarlet & Violet 2.0.2 save file sizes. + /// - Legality: + /// - - Badwords list has been updated to be more strict per latest Nintendo Switch 16.0.0 firmware. Thanks @Bl4ckSh4rk! + /// - - Gen9 Distribution Outbreaks now recognized. Thanks @Lusamine & @sora10pls! + /// - - Gen9 Crossover met location logic tweaked for better location identification in Kitakami. + /// - - Gen4 Pokéwalker IV spreads are now validated. Thanks [rest of string was truncated]";. /// public static string changelog { get { @@ -588,7 +728,7 @@ public class Resources { ///MoveShopEditor=Attacken Tutor Editor ///RibbonEditor=Band Editor ///SAV_Apricorn=Aprikoko Editor - ///SAV_BerryField=Beerenfeld Ansicht + ///SAV_BerryFieldXY=Beerenfeld Ansicht ///SAV_BlockDump8=Spielstand Block Dump ///SAV_BoxLayout=Box Layout Editor ///SAV_BoxList=PC Ansicht @@ -597,7 +737,7 @@ public class Resources { ///SAV_Database=Datenbank ///SAV_Encounters=Begegnungen ///SAV_EventFlags=Event Flag Editor - ///SAV_EventReset1 [rest of string was truncated]";. + ///SAV_EventRese [rest of string was truncated]";. /// public static string lang_de { get { @@ -615,7 +755,7 @@ public class Resources { ///MoveShopEditor=Move Shop Editor ///RibbonEditor=Ribbon Editor ///SAV_Apricorn=Apricorn Editor - ///SAV_BerryField=Berry Field Viewer + ///SAV_BerryFieldXY=Berry Field Viewer ///SAV_BlockDump8=Savedata Block Dump ///SAV_BoxLayout=Box Layout Editor ///SAV_BoxList=Storage Viewer @@ -624,7 +764,7 @@ public class Resources { ///SAV_Database=Database ///SAV_Encounters=Database ///SAV_EventFlags=Event Flag Editor - ///SAV_EventReset1=Event Re [rest of string was truncated]";. + ///SAV_EventReset1=Event [rest of string was truncated]";. /// public static string lang_en { get { @@ -642,13 +782,13 @@ public class Resources { ///MoveShopEditor=Editor de la Tienda de Movimientos ///RibbonEditor=Editor de Cintas ///SAV_Apricorn=Editor de Bonguri - ///SAV_BerryField=Visor de Campos de Bayas + ///SAV_BerryFieldXY=Visor de Campos de Bayas ///SAV_BlockDump8=Respaldo de bloques ///SAV_BoxLayout=Editor de fondos de Cajas ///SAV_BoxList=Visor de Almacenamiento ///SAV_Capture7GG=Editor de Récord de Captura ///SAV_CGearSkin=Editor de la apariencia C-Gear - ///SAV_Database=Ba [rest of string was truncated]";. + ///SAV_Database= [rest of string was truncated]";. /// public static string lang_es { get { @@ -666,7 +806,7 @@ public class Resources { ///MoveShopEditor=Éditeur de capacités ///RibbonEditor=Rubans ///SAV_Apricorn=Noigrumes - ///SAV_BerryField=Champs de Baies + ///SAV_BerryFieldXY=Champs de Baies ///SAV_BlockDump8=Sauvegarde des blocs de données ///SAV_BoxLayout=Fonds de Boîtes ///SAV_BoxList=Visualiseur de stockage @@ -674,7 +814,7 @@ public class Resources { ///SAV_CGearSkin=Fonds C-Gear ///SAV_Database=Base de Données ///SAV_Encounters=Base de données - ///SAV_EventFlags=Évé [rest of string was truncated]";. + ///SAV_EventFlags=É [rest of string was truncated]";. /// public static string lang_fr { get { @@ -692,7 +832,7 @@ public class Resources { ///MoveShopEditor=Editor Negozio Mosse ///RibbonEditor=Editor Fiocchi ///SAV_Apricorn=Editor Ghicocche - ///SAV_BerryField=Visualizzatore Campi di Bacche + ///SAV_BerryFieldXY=Visualizzatore Campi di Bacche ///SAV_BlockDump8=Dump Blocchi di Salvataggio ///SAV_BoxLayout=Editor Disposizione Box ///SAV_BoxList=Visualizzatore Storage @@ -700,7 +840,7 @@ public class Resources { ///SAV_CGearSkin=C-Gear Skin ///SAV_Database=Database ///SAV_Encounters=Database - ///SAV_Ev [rest of string was truncated]";. + ///SAV_ [rest of string was truncated]";. /// public static string lang_it { get { @@ -718,7 +858,7 @@ public class Resources { ///MoveShopEditor=Move Shop Editor ///RibbonEditor=取得リボン ///SAV_Apricorn=ぼんぐり - ///SAV_BerryField=きのみ畑 + ///SAV_BerryFieldXY=きのみ畑 ///SAV_BlockDump8=Savedata Block Dump ///SAV_BoxLayout=ボックスレイアウト ///SAV_BoxList=ボックスリスト @@ -730,7 +870,7 @@ public class Resources { ///SAV_EventReset1=イベントリセット ///SAV_EventWork=Event Flag Editor ///SAV_FlagWork8b=Event Flag Editor - ///SAV_FolderList=フォル [rest of string was truncated]";. + ///SAV_FolderList=フ [rest of string was truncated]";. /// public static string lang_ja { get { @@ -748,7 +888,7 @@ public class Resources { ///MoveShopEditor=Move Shop Editor ///RibbonEditor=리본 편집 도구 ///SAV_Apricorn=규토리 편집 도구 - ///SAV_BerryField=나무열매 밭 뷰어 + ///SAV_BerryFieldXY=나무열매 밭 뷰어 ///SAV_BlockDump8=세이브 데이터 블록 덤프 ///SAV_BoxLayout=박스 레이아웃 편집 도구 ///SAV_BoxList=소지 공간 뷰어 @@ -759,7 +899,7 @@ public class Resources { ///SAV_EventFlags=이벤트 플래그 편집 도구 ///SAV_EventReset1=이벤트 초기화 도구 ///SAV_EventWork=이벤트 플래그 편집 도구 - ///SAV_FlagWork8b=Event Flag Editor [rest of string was truncated]";. + ///SAV_FlagWork8b=Event Flag Edit [rest of string was truncated]";. /// public static string lang_ko { get { @@ -777,7 +917,7 @@ public class Resources { ///MoveShopEditor=招式商店编辑器 ///RibbonEditor=奖章 ///SAV_Apricorn=球果编辑 - ///SAV_BerryField=树果田查看器 + ///SAV_BerryFieldXY=树果田查看器 ///SAV_BlockDump8=存档转储 ///SAV_BoxLayout=盒子外观 ///SAV_BoxList=寄放系统 @@ -791,10 +931,10 @@ public class Resources { ///SAV_FlagWork8b=事件标志编辑器 ///SAV_FolderList=文件夹列表 ///SAV_GameSelect=游戏选择 + ///SAV_Geonet4=地理网编辑 ///SAV_HallOfFame=名人堂 ///SAV_HallOfFame7=名人堂 - ///SAV_HoneyTree=甜甜蜜树编辑 - ///SA [rest of string was truncated]";. + ///SAV [rest of string was truncated]";. /// public static string lang_zh { get { @@ -812,7 +952,7 @@ public class Resources { ///MoveShopEditor=招式商店編輯器 ///RibbonEditor=獎章 ///SAV_Apricorn=球果編輯 - ///SAV_BerryField=樹果田檢視器 + ///SAV_BerryFieldXY=樹果田檢視器 ///SAV_BlockDump8=存檔轉儲 ///SAV_BoxLayout=盒子外觀 ///SAV_BoxList=寄放系統 @@ -826,9 +966,9 @@ public class Resources { ///SAV_FlagWork8b=事件標誌編輯器 ///SAV_FolderList=資料夾清單 ///SAV_GameSelect=遊戲選擇 + ///SAV_Geonet4=寰宇網編輯器 ///SAV_HallOfFame=名人堂 ///SAV_HallOfFame7=名人堂 - ///SAV_HoneyTree=甜甜蜜樹編輯 /// [rest of string was truncated]";. /// public static string lang_zh2 { diff --git a/PKHeX.WinForms/Properties/Resources.resx b/PKHeX.WinForms/Properties/Resources.resx index 3adc0740f..0e442d0ef 100644 --- a/PKHeX.WinForms/Properties/Resources.resx +++ b/PKHeX.WinForms/Properties/Resources.resx @@ -397,4 +397,46 @@ ..\Resources\img\Accents\ribbon_affix_none.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\img\Bag\bag_balls.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_battle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_berries.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_candy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_free.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_ingredient.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_items.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_key.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_mail.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_medicine.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_pcitems.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_tech.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_treasure.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\img\Bag\bag_z.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/PKHeX.WinForms/Resources/img/Bag/Bag_TMHM.png b/PKHeX.WinForms/Resources/img/Bag/bag_tech.png similarity index 100% rename from PKHeX.WinForms/Resources/img/Bag/Bag_TMHM.png rename to PKHeX.WinForms/Resources/img/Bag/bag_tech.png diff --git a/PKHeX.WinForms/Subforms/KChart.cs b/PKHeX.WinForms/Subforms/KChart.cs index d01159289..8e38de7b7 100644 --- a/PKHeX.WinForms/Subforms/KChart.cs +++ b/PKHeX.WinForms/Subforms/KChart.cs @@ -30,7 +30,7 @@ public KChart(SaveFile sav) { var fc = pt[s, 0].FormCount; var formNames = fc <= 1 - ? Array.Empty() + ? [] : FormConverter.GetFormList(s, strings.Types, strings.forms, Main.GenderSymbols, SAV.Context); for (byte f = 0; f < fc; f++) @@ -87,7 +87,7 @@ private void PopEntry(ushort species, byte form, string name, IPersonalTable pt) private static bool GetIsNative(IPersonalInfo personalInfo, ushort s) => personalInfo switch { - PersonalInfo7 => s > 721 || PastGenAlolanNatives.BinarySearch(s) >= 0, + PersonalInfo7 => IsAlolanNative(s), PersonalInfo8SWSH ss => ss.IsInDex, PersonalInfo8BDSP bs => bs.IsInDex, PersonalInfo8LA bs => bs.IsPresentInGame, @@ -95,22 +95,29 @@ private void PopEntry(ushort species, byte form, string name, IPersonalTable pt) _ => true, }; - private static ReadOnlySpan PastGenAlolanNatives => new ushort[] + private static ReadOnlySpan PastGenAlolanNatives => + [ + 0x00, 0x1C, 0xF8, 0x1E, 0xF8, 0xC7, 0xFC, 0xFF, 0x1F, 0x9F, 0x47, 0x7F, 0xF3, 0x13, 0xCA, 0xEF, + 0xFF, 0xD7, 0x38, 0x00, 0xE8, 0x7F, 0x0A, 0x46, 0xFE, 0x51, 0xD6, 0xCC, 0x1A, 0xCA, 0x47, 0x00, + 0x00, 0xC0, 0xFF, 0x18, 0x00, 0xCB, 0x38, 0xC0, 0xF3, 0x67, 0xB8, 0xEA, 0xA3, 0x46, 0xFE, 0x01, + 0x00, 0x00, 0x00, 0x0F, 0xCC, 0x6E, 0xC0, 0xF9, 0x1F, 0x7F, 0xEC, 0x54, 0x00, 0x00, 0x00, 0x1C, + 0x00, 0x70, 0x08, 0x00, 0xFC, 0xE3, 0xF2, 0x17, 0xF0, 0x09, 0x05, 0x20, 0x00, 0x6C, 0x79, 0x10, + 0x00, 0x00, 0xE0, 0x28, 0x1C, 0x40, 0xD7, 0xF5, 0x3F, 0x44, + ]; + + private static bool IsAlolanNative(ushort species) { - 010, 011, 012, 019, 020, 021, 022, 023, 025, 026, 027, 028, 035, 036, 037, 038, 039, 040, 041, 042, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 072, 073, 074, - 075, 076, 079, 080, 081, 082, 086, 088, 089, 090, 091, 092, 093, 094, 096, 097, 100, 101, 102, 103, 104, 105, - 108, 113, 115, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 140, 142, 143, 147, 148, 149, 163, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 177, 179, 185, 186, - 190, 193, 194, 195, 196, 197, 198, 199, 200, 204, 206, 209, 210, 212, 214, 215, 218, 219, 222, 223, 225, 227, - 228, 233, 235, 238, 239, 240, 241, 242, 246, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 283, 284, 296, - 297, 299, 302, 303, 307, 308, 309, 318, 319, 320, 321, 324, 325, 326, 327, 328, 329, 330, 333, 334, 339, 340, - 341, 343, 345, 347, 349, 350, 351, 352, 353, 357, 359, 361, 362, 366, 369, 370, 371, 372, 373, 374, 375, 376, - 408, 409, 410, 411, 418, 419, 422, 423, 425, 426, 427, 429, 430, 438, 439, 440, 443, 444, 445, 446, 447, 448, - 449, 450, 451, 452, 456, 457, 458, 459, 460, 461, 462, 466, 467, 469, 470, 471, 474, 476, 478, 506, 507, 508, - 524, 525, 526, 531, 546, 547, 548, 549, 550, 551, 552, 553, 557, 558, 559, 561, 564, 565, 566, 567, 568, 569, - 570, 572, 580, 581, 582, 583, 584, 587, 592, 594, 605, 618, 619, 621, 622, 624, 627, 628, 629, 630, 636, 661, - 662, 663, 667, 669, 674, 675, 676, 686, 688, 689, 690, 692, 694, 695, 696, 698, 700, 701, 702, 703, 704, 705, - 706, 707, 708, 709, 714, 718, - }; + if (species > 721) + return true; + if (species == 720) + return false; + + // [0, 719]; always will be a bit in the array. + var offset = species >> 3; + var bitSet = PastGenAlolanNatives; + var bit = species & 7; + if ((bitSet[offset] & (1 << bit)) != 0) + return true; + return false; + } } diff --git a/PKHeX.WinForms/Subforms/Misc/EntitySummaryImage.cs b/PKHeX.WinForms/Subforms/Misc/EntitySummaryImage.cs index b972a87d9..6e2c9de15 100644 --- a/PKHeX.WinForms/Subforms/Misc/EntitySummaryImage.cs +++ b/PKHeX.WinForms/Subforms/Misc/EntitySummaryImage.cs @@ -9,13 +9,8 @@ namespace PKHeX.WinForms; /// Bind-able summary object that can fetch sprite and strings that summarize a . /// [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] -public sealed class EntitySummaryImage : EntitySummary +public sealed class EntitySummaryImage(PKM p, GameStrings strings, string Position) : EntitySummary(p, strings) { public Image Sprite => pk.Sprite(); - public override string Position { get; } - - public EntitySummaryImage(PKM p, GameStrings strings, string position) : base(p, strings) - { - Position = position; - } + public override string Position { get; } = Position; } diff --git a/PKHeX.WinForms/Subforms/Misc/SortableBindingList.cs b/PKHeX.WinForms/Subforms/Misc/SortableBindingList.cs index 263d63a71..dd5f4f085 100644 --- a/PKHeX.WinForms/Subforms/Misc/SortableBindingList.cs +++ b/PKHeX.WinForms/Subforms/Misc/SortableBindingList.cs @@ -4,18 +4,14 @@ namespace PKHeX.WinForms; -public abstract class SortableBindingList : BindingList where T : class +public abstract class SortableBindingList() : BindingList([]) + where T : class { - private readonly Dictionary> comparers; + private readonly Dictionary> comparers = []; private bool isSorted; private ListSortDirection listSortDirection; private PropertyDescriptor? propertyDescriptor; - protected SortableBindingList() : base(new List()) - { - comparers = new Dictionary>(); - } - protected override bool SupportsSortingCore => true; protected override bool IsSortedCore => isSorted; diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs index 182a5bc8d..9046418c6 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs @@ -15,9 +15,9 @@ public MemoryAmie(PKM pk) WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); Entity = pk; MemStrings = new MemoryStrings(GameInfo.Strings); - PrevCountries = new[] { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4 }; - PrevRegions = new[] { CB_Region0, CB_Region1, CB_Region2, CB_Region3, CB_Region4 }; - string[] arguments = L_Arguments.Text.Split(new[] { " ; " }, StringSplitOptions.None); + PrevCountries = [CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4]; + PrevRegions = [CB_Region0, CB_Region1, CB_Region2, CB_Region3, CB_Region4]; + string[] arguments = L_Arguments.Text.Split(" ; "); TextArgs = new TextMarkup(arguments); @@ -82,13 +82,13 @@ private void LoadFields() if (Entity is ITrainerMemories m) { // Load the OT Memories - CB_OTQual.SelectedIndex = Math.Max(0, m.OT_Intensity - 1); + CB_OTQual.SelectedIndex = m.OT_Intensity; CB_OTMemory.SelectedValue = (int)m.OT_Memory; CB_OTVar.SelectedValue = (int)m.OT_TextVar; CB_OTFeel.SelectedIndex = m.OT_Feeling; // Load the HT Memories - CB_CTQual.SelectedIndex = Math.Max(0, m.HT_Intensity - 1); + CB_CTQual.SelectedIndex = m.HT_Intensity; CB_CTMemory.SelectedValue = (int)m.HT_Memory; CB_CTVar.SelectedValue = (int)m.HT_TextVar; CB_CTFeel.SelectedIndex = m.HT_Feeling; @@ -118,7 +118,7 @@ private void LoadFields() GB_M_OT.Text = $"{TextArgs.PastGen} {Entity.OT_Name}: {TextArgs.OT}"; // Past Gen OT : OTNAME GB_M_CT.Text = $"{TextArgs.MemoriesWith} {Entity.HT_Name}"; // Memories with : HTNAME enable = false; - // Reset to no memory -- don't reset affection as ORAS can raise it + // Reset to no memory -- don't reset affection as OR/AS can raise it (+20 * n) via Contests CB_OTQual.SelectedIndex = CB_OTFeel.SelectedIndex = 0; CB_OTVar.SelectedValue = CB_OTMemory.SelectedValue = 0; } @@ -153,7 +153,7 @@ private void LoadFields() RTB_CT.Text = GetMemoryString(CB_CTMemory, CB_CTVar, CB_CTQual, CB_CTFeel, Entity.HT_Name); RTB_OT.Text = GetMemoryString(CB_OTMemory, CB_OTVar, CB_OTQual, CB_OTFeel, Entity.OT_Name); - // Affection no longer stored in gen8+, so only show in gen6/7. + // Affection no longer stored in Gen8+, so only show in Gen6/7. L_OT_Affection.Visible = L_CT_Affection.Visible = M_OT_Affection.Visible = M_CT_Affection.Visible = Entity.Format <= 7; L_Sociability.Visible = MT_Sociability.Visible = Entity is ISociability; } @@ -192,12 +192,12 @@ private void SaveFields() { m.OT_Memory = (byte)WinFormsUtil.GetIndex(CB_OTMemory); m.OT_TextVar = CB_OTVar.Enabled ? (ushort)WinFormsUtil.GetIndex(CB_OTVar) : (ushort)0; - m.OT_Intensity = CB_OTFeel.Enabled ? (byte)(CB_OTQual.SelectedIndex + 1) : (byte)0; + m.OT_Intensity = CB_OTFeel.Enabled ? (byte)CB_OTQual.SelectedIndex : (byte)0; m.OT_Feeling = CB_OTFeel.Enabled ? (byte)CB_OTFeel.SelectedIndex : (byte)0; m.HT_Memory = (byte)WinFormsUtil.GetIndex(CB_CTMemory); m.HT_TextVar = CB_CTVar.Enabled ? (ushort)WinFormsUtil.GetIndex(CB_CTVar) : (ushort)0; - m.HT_Intensity = CB_CTFeel.Enabled ? (byte)(CB_CTQual.SelectedIndex + 1) : (byte)0; + m.HT_Intensity = CB_CTFeel.Enabled ? (byte)CB_CTQual.SelectedIndex : (byte)0; m.HT_Feeling = CB_CTFeel.Enabled ? (byte)CB_CTFeel.SelectedIndex : (byte)0; } @@ -226,17 +226,22 @@ private void GetLangStrings() CB_CTMemory.DataSource = new BindingSource(strings.Memory, null); // Quality Chooser - foreach (var q in strings.GetMemoryQualities()) - { - CB_CTQual.Items.Add(q); - CB_OTQual.Items.Add(q); - } + AddIntensity(this, strings.Species[0].Text); // None + foreach (var q in strings.GetMemoryQualities()[1..]) + AddIntensity(this, q); // Feeling Chooser foreach (var q in strings.GetMemoryFeelings(Entity.Generation)) CB_OTFeel.Items.Add(q); foreach (var q in strings.GetMemoryFeelings(Entity.Format)) CB_CTFeel.Items.Add(q); + + // Same for each game. + static void AddIntensity(MemoryAmie f, string line) + { + f.CB_CTQual.Items.Add(line); + f.CB_OTQual.Items.Add(line); + } } private void UpdateMemoryDisplay(object sender) @@ -313,9 +318,11 @@ private void ChangeMemory(object sender, EventArgs e) private void ChangeCountryIndex(object sender, EventArgs e) { - int index = Array.IndexOf(PrevCountries, sender); - int val; - if (sender is ComboBox c && (val = WinFormsUtil.GetIndex(c)) > 0) + if (sender is not ComboBox cb) + return; + int index = Array.IndexOf(PrevCountries, cb); + int val = WinFormsUtil.GetIndex(cb); + if (val > 0) { Main.SetCountrySubRegion(PrevRegions[index], $"sr_{val:000}"); PrevRegions[index].Enabled = true; @@ -346,7 +353,7 @@ private void Update255_MTB(object sender, EventArgs e) private void ClickResetLocation(object sender, EventArgs e) { - Label[] senderarr = { L_Geo0, L_Geo1, L_Geo2, L_Geo3, L_Geo4 }; + Label[] senderarr = [L_Geo0, L_Geo1, L_Geo2, L_Geo3, L_Geo4]; int index = Array.IndexOf(senderarr, sender); PrevCountries[index].SelectedValue = 0; diff --git a/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs index 0fb0f4ff3..841a2c614 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/RibbonEditor.cs @@ -117,7 +117,7 @@ private void PopulateRibbons() style.SizeType = SizeType.AutoSize; } - private static int GetSortOrder(string name, IReadOnlyDictionary dict, List otherList) + private static int GetSortOrder(string name, Dictionary dict, List otherList) { if (name.StartsWith("RibbonMark")) return 99; diff --git a/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs index 7c6c25037..8fcd1c33e 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/SuperTrainingEditor.cs @@ -50,8 +50,8 @@ public SuperTrainingEditor(PKM pk) } } - private readonly List reglist = new(); - private readonly List distlist = new(); + private readonly List reglist = []; + private readonly List distlist = []; private readonly ISuperTrain Entity; private const string PrefixCHK = "CHK_"; diff --git a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs index 09ce2953e..a3064302b 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs @@ -10,7 +10,7 @@ public partial class TrashEditor : Form { private readonly SaveFile SAV; - public TrashEditor(TextBoxBase TB_NN, SaveFile sav) : this(TB_NN, Array.Empty(), sav) { } + public TrashEditor(TextBoxBase TB_NN, SaveFile sav) : this(TB_NN, [], sav) { } public TrashEditor(TextBoxBase TB_NN, Span raw, SaveFile sav) { @@ -28,7 +28,7 @@ public TrashEditor(TextBoxBase TB_NN, Span raw, SaveFile sav) } else { - Raw = FinalBytes = Array.Empty(); + Raw = FinalBytes = []; } var f = FontUtil.GetPKXFont(); @@ -52,7 +52,7 @@ public TrashEditor(TextBoxBase TB_NN, Span raw, SaveFile sav) CenterToParent(); } - private readonly List Bytes = new(); + private readonly List Bytes = []; public string FinalString; public byte[] FinalBytes; private readonly byte[] Raw; @@ -205,16 +205,88 @@ private static NumericUpDown GetNUD(byte min, byte max, bool hex) => new() private static ReadOnlySpan GetChars(int generation) => generation switch { + 5 => SpecialCharsGen5, 6 => SpecialCharsGen67, 7 => SpecialCharsGen67, - _ => Array.Empty(), // Undocumented + _ => [], // Undocumented }; - private static ReadOnlySpan SpecialCharsGen67 => new ushort[] - { - 0xE081, 0xE082, 0xE083, 0xE084, 0xE085, 0xE086, 0xE087, 0xE08D, - 0xE08E, 0xE08F, 0xE090, 0xE091, 0xE092, 0xE093, 0xE094, 0xE095, - 0xE096, 0xE097, 0xE098, 0xE099, 0xE09A, 0xE09B, 0xE09C, 0xE09D, - 0xE09E, 0xE09F, 0xE0A0, 0xE0A1, 0xE0A2, 0xE0A3, 0xE0A4, 0xE0A5, - }; + // Unicode codepoints for special characters, incorrectly starting at 0x2460 instead of 0xE0xx. + private static ReadOnlySpan SpecialCharsGen5 => + [ + 0x2460, // Full Neutral (Happy in Gen7) + 0x2461, // Full Happy (Angry in Gen7) + 0x2462, // Full Sad + 0x2463, // Full Angry (Neutral in Gen7) + 0x2464, // Full Right-up arrow + 0x2465, // Full Right-down arrow + 0x2466, // Full Zz + 0x2467, // × + 0x2468, // ÷ + // Skip 69-6B, can't be entered. + 0x246C, // … + 0x246D, // ♂ + 0x246E, // ♀ + 0x246F, // ♠ + 0x2470, // ♣ + 0x2471, // ♥ + 0x2472, // ♦ + 0x2473, // ★ + 0x2474, // ◎ + 0x2475, // ○ + 0x2476, // □ + 0x2477, // △ + 0x2478, // ◇ + 0x2479, // ♪ + 0x247A, // ☀ + 0x247B, // ☁ + 0x247C, // ☂ + 0x247D, // ☃ + 0x247E, // Half Neutral + 0x247F, // Half Happy + 0x2480, // Half Sad + 0x2481, // Half Angry + 0x2482, // Half Right-up arrow + 0x2483, // Half Right-down arrow + 0x2484, // Half Zz + ]; + + private static ReadOnlySpan SpecialCharsGen67 => + [ + 0xE081, // Full Neutral (Happy in Gen7) + 0xE082, // Full Happy (Angry in Gen7) + 0xE083, // Full Sad + 0xE084, // Full Angry (Neutral in Gen7) + 0xE085, // Full Right-up arrow + 0xE086, // Full Right-down arrow + 0xE087, // Full Zz + 0xE088, // × + 0xE089, // ÷ + // Skip 8A-8C, can't be entered. + 0xE08D, // … + 0xE08E, // ♂ + 0xE08F, // ♀ + 0xE090, // ♠ + 0xE091, // ♣ + 0xE092, // ♥ + 0xE093, // ♦ + 0xE094, // ★ + 0xE095, // ◎ + 0xE096, // ○ + 0xE097, // □ + 0xE098, // △ + 0xE099, // ◇ + 0xE09A, // ♪ + 0xE09B, // ☀ + 0xE09C, // ☁ + 0xE09D, // ☂ + 0xE09E, // ☃ + 0xE09F, // Half Neutral + 0xE0A0, // Half Happy + 0xE0A1, // Half Sad + 0xE0A2, // Half Angry + 0xE0A3, // Half Right-up arrow + 0xE0A4, // Half Right-down arrow + 0xE0A5, // Half Zz + ]; } diff --git a/PKHeX.WinForms/Subforms/ReportGrid.cs b/PKHeX.WinForms/Subforms/ReportGrid.cs index d1a41f6d2..9b9f86446 100644 --- a/PKHeX.WinForms/Subforms/ReportGrid.cs +++ b/PKHeX.WinForms/Subforms/ReportGrid.cs @@ -48,7 +48,7 @@ private void GetContextMenu() dgData.ContextMenuStrip = mnu; } - private sealed class PokemonList : SortableBindingList where T : class { } + private sealed class PokemonList : SortableBindingList where T : class; public void PopulateData(IList Data) { @@ -144,7 +144,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) } // Reformat datagrid clipboard content - string[] lines = data.Split(new[] { Environment.NewLine }, StringSplitOptions.None); + string[] lines = data.Split(Environment.NewLine); string[] newlines = ConvertTabbedToRedditTable(lines); WinFormsUtil.SetClipboardText(string.Join(Environment.NewLine, newlines)); return true; diff --git a/PKHeX.WinForms/Subforms/SAV_Database.cs b/PKHeX.WinForms/Subforms/SAV_Database.cs index 42aa572e8..85abb6aea 100644 --- a/PKHeX.WinForms/Subforms/SAV_Database.cs +++ b/PKHeX.WinForms/Subforms/SAV_Database.cs @@ -57,7 +57,7 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) var hdelta = newHeight - smallHeight; if (hdelta != 0) Height += hdelta; - PKXBOXES = grid.Entries.ToArray(); + PKXBOXES = [.. grid.Entries]; // Enable Scrolling when hovered over foreach (var slot in PKXBOXES) @@ -130,8 +130,8 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) private readonly PictureBox[] PKXBOXES; private readonly string DatabasePath = Main.DatabasePath; - private List Results = new(); - private List RawDB = new(); + private List Results = []; + private List RawDB = []; private int slotSelected = -1; // = null; private Image? slotColor; private const int RES_MAX = 66; @@ -291,7 +291,7 @@ private void PopulateComboBoxes() types.Insert(0, comboAny); CB_HPType.DataSource = types; - // Set the Move ComboBoxes too.. + // Set the Move ComboBoxes too. var moves = new List(GameInfo.MoveDataSource); moves.RemoveAt(0); moves.Insert(0, comboAny); @@ -348,16 +348,10 @@ private void GenerateDBReport(object sender, EventArgs e) reportGrid.PopulateData(Results); } - private sealed class SearchFolderDetail + private sealed class SearchFolderDetail(string path, bool ignoreBackupFiles) { - public string Path { get; } - public bool IgnoreBackupFiles { get; } - - public SearchFolderDetail(string path, bool ignoreBackupFiles) - { - Path = path; - IgnoreBackupFiles = ignoreBackupFiles; - } + public string Path { get; } = path; + public bool IgnoreBackupFiles { get; } = ignoreBackupFiles; } private void LoadDatabase() diff --git a/PKHeX.WinForms/Subforms/SAV_Encounters.cs b/PKHeX.WinForms/Subforms/SAV_Encounters.cs index 8dae3d046..7e5fcff60 100644 --- a/PKHeX.WinForms/Subforms/SAV_Encounters.cs +++ b/PKHeX.WinForms/Subforms/SAV_Encounters.cs @@ -55,7 +55,7 @@ public SAV_Encounters(PKMEditor f1, TrainerDatabase db) if (hdelta != 0) Height += hdelta; - PKXBOXES = grid.Entries.ToArray(); + PKXBOXES = [..grid.Entries]; // Enable Scrolling when hovered over foreach (var slot in PKXBOXES) @@ -127,7 +127,7 @@ private EncounterTypeGroup[] GetTypes() } private readonly PictureBox[] PKXBOXES; - private List Results = new(); + private List Results = []; private int slotSelected = -1; // = null; private Image? slotColor; private const int RES_MAX = 66; @@ -203,7 +203,7 @@ private void PopulateComboBoxes() var DS_Species = new List(GameInfo.SpeciesDataSource); DS_Species.RemoveAt(0); DS_Species.Insert(0, Any); CB_Species.DataSource = DS_Species; - // Set the Move ComboBoxes too.. + // Set the Move ComboBoxes too. var DS_Move = new List(GameInfo.MoveDataSource); DS_Move.RemoveAt(0); DS_Move.Insert(0, Any); { @@ -245,7 +245,7 @@ private IEnumerable SearchDatabase(CancellationToken token) // If nothing is specified, instead of just returning all possible encounters, just return nothing. if (settings is { Species: 0, Moves.Count: 0 } && Main.Settings.EncounterDb.ReturnNoneIfEmptySearch) - return Array.Empty(); + return []; var pk = SAV.BlankPKM; var moves = settings.Moves.ToArray(); diff --git a/PKHeX.WinForms/Subforms/SAV_FolderList.cs b/PKHeX.WinForms/Subforms/SAV_FolderList.cs index fb25a3ca8..f7e5cad75 100644 --- a/PKHeX.WinForms/Subforms/SAV_FolderList.cs +++ b/PKHeX.WinForms/Subforms/SAV_FolderList.cs @@ -18,7 +18,7 @@ public partial class SAV_FolderList : Form private readonly List Paths; private readonly SortableBindingList Recent; private readonly SortableBindingList Backup; - private readonly List