diff --git a/PKHeX.Core/Game/ComboItem.cs b/PKHeX.Core/Game/ComboItem.cs index 16149ed70..ffe3f939b 100644 --- a/PKHeX.Core/Game/ComboItem.cs +++ b/PKHeX.Core/Game/ComboItem.cs @@ -1,7 +1,6 @@ -namespace PKHeX.Core -{ - /// - /// Key Value pair for a displayed and underlying value. - /// - public record ComboItem(string Text, int Value); -} +namespace PKHeX.Core; + +/// +/// Key Value pair for a displayed and underlying value. +/// +public sealed record ComboItem(string Text, int Value); diff --git a/PKHeX.Core/Game/GameStrings/GeoLocation.cs b/PKHeX.Core/Game/GameStrings/GeoLocation.cs index 1d15baa22..f9e6cbea1 100644 --- a/PKHeX.Core/Game/GameStrings/GeoLocation.cs +++ b/PKHeX.Core/Game/GameStrings/GeoLocation.cs @@ -2,17 +2,20 @@ namespace PKHeX.Core { + /// + /// Geolocation Utility for Generation 6/7 (3DS) Earth location values. + /// public static class GeoLocation { private static readonly string[]?[] CountryList = GetCountryList(); internal static readonly string[] lang_geo = { "ja", "en", "fr", "de", "it", "es", "zh", "ko" }; private static readonly string[]?[]?[] RegionList = new string[CountryList.Length][][]; - public static string[]? GetCountryList(string language) - { - int index = GetLanguageIndex(language); - return CountryList[index]; - } + /// + /// Returns the index of which the is in the country/region list. + /// + public static int GetLanguageIndex(string language) => Array.IndexOf(lang_geo, language); + private static int GetLanguageIndex(LanguageID language) => GetLanguageIndex(language.GetLanguage2CharName()); private const string INVALID = nameof(INVALID); @@ -75,6 +78,15 @@ private static string GetRegionName(int country, int region, int l) return INVALID; } + /// + /// Gets an array of all country names for the requested . + /// + public static string[]? GetCountryList(string language) + { + int index = GetLanguageIndex(language); + return CountryList[index]; + } + /// /// Gets the Country string for a given Country ID /// @@ -124,8 +136,5 @@ public static (string Country, string Region) GetCountryRegionText(int country, var regionName = GetRegionName(country, region, lang); return (countryName, regionName); } - - public static int GetLanguageIndex(string language) => Array.IndexOf(lang_geo, language); - private static int GetLanguageIndex(LanguageID language) => GetLanguageIndex(language.GetLanguage2CharName()); } } diff --git a/PKHeX.Core/Legality/BulkGenerator.cs b/PKHeX.Core/Legality/BulkGenerator.cs index 4c5347fea..684686c71 100644 --- a/PKHeX.Core/Legality/BulkGenerator.cs +++ b/PKHeX.Core/Legality/BulkGenerator.cs @@ -57,9 +57,9 @@ public static List GetLivingDex(this ITrainerInfo tr, IEnumerable spec if (result == null) return null; - result.CurrentLevel = 100; result.Species = species; result.Form = form; + result.CurrentLevel = 100; result.Heal(); return result; diff --git a/PKHeX.Core/Legality/Learnset/LearnsetReader.cs b/PKHeX.Core/Legality/Learnset/LearnsetReader.cs index 77c21e29b..fd0d19e64 100644 --- a/PKHeX.Core/Legality/Learnset/LearnsetReader.cs +++ b/PKHeX.Core/Legality/Learnset/LearnsetReader.cs @@ -17,13 +17,11 @@ public static class LearnsetReader /// Highest species ID for the input game. public static Learnset[] GetArray(ReadOnlySpan input, int maxSpecies) { - var data = new Learnset[maxSpecies + 1]; - int offset = 0; - for (int s = 0; s < data.Length; s++) - data[s] = ReadLearnset8(input, ref offset); - - return data; + var result = new Learnset[maxSpecies + 1]; + for (int i = 0; i < result.Length; i++) + result[i] = ReadLearnset8(input, ref offset); + return result; } /// @@ -32,10 +30,10 @@ public static Learnset[] GetArray(ReadOnlySpan input, int maxSpecies) /// Entry data public static Learnset[] GetArray(BinLinkerAccessor entries) { - Learnset[] data = new Learnset[entries.Length]; - for (int i = 0; i < data.Length; i++) - data[i] = ReadLearnset16(entries[i]); - return data; + var result = new Learnset[entries.Length]; + for (int i = 0; i < result.Length; i++) + result[i] = ReadLearnset16(entries[i]); + return result; } /// @@ -52,16 +50,16 @@ private static Learnset ReadLearnset8(ReadOnlySpan data, ref int offset) } do { end += 2; } while (data[end] != 0); - var Count = (end - offset) / 2; - var Moves = new int[Count]; - var Levels = new int[Count]; - for (int i = 0; i < Moves.Length; i++) + var count = (end - offset) / 2; + var moves = new int[count]; + var levels = new int[count]; + for (int i = 0; i < moves.Length; i++) { - Levels[i] = data[offset++]; - Moves[i] = data[offset++]; + levels[i] = data[offset++]; + moves[i] = data[offset++]; } ++offset; - return new Learnset(Moves, Levels); + return new Learnset(moves, levels); } /// @@ -72,16 +70,16 @@ private static Learnset ReadLearnset16(ReadOnlySpan data) { if (data.Length == 0) return EMPTY; - var Count = (data.Length / 4) - 1; - var Moves = new int[Count]; - var Levels = new int[Count]; - for (int i = 0; i < Count; i++) + var count = (data.Length / 4) - 1; + var moves = new int[count]; + var levels = new int[count]; + for (int i = 0; i < count; i++) { var move = data.Slice(i * 4, 4); - Moves[i] = ReadInt16LittleEndian(move); - Levels[i] = ReadInt16LittleEndian(move[2..]); + levels[i] = ReadInt16LittleEndian(move[2..]); + moves[i] = ReadInt16LittleEndian(move); } - return new Learnset(Moves, Levels); + return new Learnset(moves, levels); } } } diff --git a/PKHeX.Core/Saves/SaveFileMetadata.cs b/PKHeX.Core/Saves/SaveFileMetadata.cs index 7002c9f2e..a80a203c1 100644 --- a/PKHeX.Core/Saves/SaveFileMetadata.cs +++ b/PKHeX.Core/Saves/SaveFileMetadata.cs @@ -9,6 +9,7 @@ namespace PKHeX.Core public sealed class SaveFileMetadata { private readonly SaveFile SAV; + public SaveFileMetadata(SaveFile sav) => SAV = sav; /// /// Full path where the originated from. @@ -36,8 +37,6 @@ public sealed class SaveFileMetadata /// public string BAKName => FileName + BAKSuffix; - public SaveFileMetadata(SaveFile sav) => SAV = sav; - public bool HasHeader => Header.Length != 0; public bool HasFooter => Footer.Length != 0; diff --git a/PKHeX.Core/Saves/SaveFileState.cs b/PKHeX.Core/Saves/SaveFileState.cs index 5c5e32cd4..ec87168d1 100644 --- a/PKHeX.Core/Saves/SaveFileState.cs +++ b/PKHeX.Core/Saves/SaveFileState.cs @@ -1,26 +1,20 @@ -namespace PKHeX.Core +namespace PKHeX.Core; + +/// +/// Tracks information about modifications made to a +/// +public sealed record SaveFileState(bool Exportable = true) { /// - /// Tracks information about modifications made to a + /// Mutable value tracking if the save file has been changed. This is set manually by modifications, and not for all modifications. /// - public sealed class SaveFileState - { - /// - /// Mutable value tracking if the save file has been changed. This is set manually by modifications, and not for all modifications. - /// - public bool Edited { get; set; } + public bool Edited { get; set; } - /// - /// Toggle determining if the save file can be exported. - /// - /// - /// This is always true, unless the save file is a "fake" save file with blank data. Blank Save Files are essentially zeroed out buffers. - /// - public readonly bool Exportable; - - public SaveFileState(bool exportable = true) - { - Exportable = exportable; - } - } + /// + /// Toggle determining if the save file can be exported. + /// + /// + /// This is always true, unless the save file is a "fake" save file with blank data. Blank Save Files are essentially zeroed out buffers. + /// + public bool Exportable { get; } = Exportable; }