Minor clean

Handle some nullable warnings, style c#12
This commit is contained in:
Kurt 2023-12-21 12:31:00 -08:00
parent 26e7a0d937
commit c181db68ff
134 changed files with 718 additions and 839 deletions

View File

@ -9,9 +9,9 @@ namespace pkNX.Containers;
public class FolderContainer : IFileContainer
{
private readonly List<string> Paths = new();
private readonly List<byte[]?> Data = new();
private readonly List<bool> TrackModify = new();
private readonly List<string> Paths = [];
private readonly List<byte[]?> Data = [];
private readonly List<bool> TrackModify = [];
public string? FilePath { get; set; }
@ -123,7 +123,7 @@ public void CancelEdits()
}
}
public void Dump(string path, ContainerHandler handler)
public void Dump(string? path = null, ContainerHandler? handler = null)
{
SaveAll(); // there's really nothing to dump, just save any modified
}

View File

@ -11,8 +11,8 @@ public class InternalFileContainer : IFileContainer
public bool Modified { get; set; }
public int Count => 1;
public byte[] Data = Array.Empty<byte>();
private byte[] Backup = Array.Empty<byte>();
public byte[] Data = [];
private byte[] Backup = [];
public InternalFileContainer(byte[] data) => LoadData(data);
private void LoadData(byte[] data) => Backup = (byte[]) (Data = data).Clone();

View File

@ -23,7 +23,7 @@ public abstract class LargeContainer : IDisposable, IFileContainer
public string? FilePath { get; set; }
public bool Modified { get; set; }
protected byte[]?[] Files = Array.Empty<byte[]>();
protected byte[]?[] Files = [];
/// <summary>
/// Packs the <see cref="LargeContainer"/> to the specified writing stream.

View File

@ -131,7 +131,7 @@ public byte[] GetDataFileName(string name)
public byte[] GetDataFull(ulong hash)
{
var fileId = GetIndexFull(hash);
return fileId < 0 ? Array.Empty<byte>() : DecompressedFiles[fileId];
return fileId < 0 ? [] : DecompressedFiles[fileId];
}
public byte[] GetDataFullPath(string path) => GetDataFull(FnvHash.HashFnv1a_64(path));
@ -392,7 +392,7 @@ public class FileHashAbsolute
public class FileHashFolder
{
public FileHashFolderInfo Folder = new();
public FileHashIndex[] Files = Array.Empty<FileHashIndex>();
public FileHashIndex[] Files = [];
public int GetIndexFileName(ulong hash) => Array.FindIndex(Files, z => z.HashFnv1aPathFileName == hash);
public int GetIndexFileName(string name) => Array.FindIndex(Files, z => z.IsMatch(name));
}

View File

@ -139,12 +139,9 @@ public override byte[] GetEntry(int index, int subFile)
public override void Dump(string? path, ContainerHandler handler)
{
path ??= FilePath;
if (path == null)
throw new ArgumentNullException(nameof(path));
if (File.Exists(path))
path = Path.GetDirectoryName(path);
if (path == null)
throw new ArgumentNullException(nameof(path));
ArgumentNullException.ThrowIfNull(path, nameof(path));
var folder = FileName ?? Identifier;
string dir = Path.Combine(path, folder);

View File

@ -12,8 +12,8 @@ public class SingleFileContainer : IFileContainer
public bool Modified { get; set; }
public int Count => 1;
public byte[] Data = Array.Empty<byte>();
private byte[] Backup = Array.Empty<byte>();
public byte[] Data = [];
private byte[] Backup = [];
public SingleFileContainer(byte[] data) => LoadData(data);
public SingleFileContainer(BinaryReader br) => LoadData(br.ReadBytes((int) br.BaseStream.Length));
public SingleFileContainer(string path) => LoadData(FileMitm.ReadAllBytes(FilePath = path));

View File

@ -10,7 +10,7 @@ public enum DeleteMode
TopMostLayer,
TopMostWriteableLayer,
AllWritable,
All
All,
}
public interface IFileSystem : IDisposable

View File

@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
@ -71,8 +70,6 @@ public static bool IsRooted(string s)
public static FileSystemPath Parse(string s)
{
if (s == null)
throw new ArgumentNullException(nameof(s));
if (!IsRooted(s))
throw new UriFormatException($"Could not parse input \"{s}\": Path is not rooted.");
if (s.Contains(string.Concat(DirectorySeparator, DirectorySeparator)))

View File

@ -35,4 +35,3 @@ internal static IFileSystemEntity Create(IFileSystem fileSystem, FileSystemPath
return VirtualDirectory.Create(fileSystem, path);
}
}

View File

@ -18,8 +18,8 @@ public class TrainerEditor : IDataEditor
public Func<TrainerPoke[], TrainerData, byte[]> WriteTeam { get; init; } = null!;
public Func<byte[], TrainerClass> ReadClass { get; init; } = null!;
private VsTrainer?[] Cache = Array.Empty<VsTrainer>();
private TrainerClass?[] CacheClass = Array.Empty<TrainerClass>();
private VsTrainer?[] Cache = [];
private TrainerClass?[] CacheClass = [];
public int Length => Cache.Length;

View File

@ -15,7 +15,7 @@ namespace pkNX.Game;
/// </summary>
public class GameFileMapping
{
private readonly Dictionary<GameFile, IFileContainer> Cache = new();
private readonly Dictionary<GameFile, IFileContainer> Cache = [];
private readonly IReadOnlyCollection<GameFileReference> FileMap;
public readonly ContainerHandler ProgressTracker = new();

View File

@ -42,7 +42,7 @@ public static FileSystemPath GetDirectoryPath(GameFile file, GameVersion game, i
GameVersion.PLA => GetDirectoryPath_PLA(file),
GameVersion.SV => GetDirectoryPath_SV(file),
_ => throw new NotSupportedException($"The selected game ({game}) is currently not mapped")
_ => throw new NotSupportedException($"The selected game ({game}) is currently not mapped"),
};
}
@ -89,7 +89,7 @@ private static FileSystemPath GetDirectoryPath_SWSH(GameFile file)
GameFile.StoryText8 => "/romfs/bin/message/Simp_Chinese/script/",
GameFile.StoryText9 => "/romfs/bin/message/Trad_Chinese/script/",
_ => throw new NotSupportedException($"The selected file ({file}) is currently not mapped")
_ => throw new NotSupportedException($"The selected file ({file}) is currently not mapped"),
};
private static FileSystemPath GetDirectoryPath_SV(GameFile file)

View File

@ -53,7 +53,7 @@ public override void Initialize()
ItemConverter.ItemNames = GetStrings(TextName.ItemNames);
// TODO: Get these from files
AIBehaviourConverter.BehaviourNames = new HashSet<string> {
AIBehaviourConverter.BehaviourNames = [
"",
"group_leader_wild_poke_coward_lv1",
"group_leader_wild_poke_coward_lv1_fish_pm0550",
@ -179,7 +179,7 @@ public override void Initialize()
"semi_legend_poke_pm0642",
"semi_legend_poke_pm0645",
"semi_legend_poke_pm0905",
};
];
}
private void ResetData()

View File

@ -11,7 +11,7 @@ public class TextManager
private readonly TextConfig Config;
private readonly IReadOnlyCollection<TextReference> References;
private readonly Dictionary<TextName, string[]> Cache = new();
private readonly Dictionary<TextName, string[]> Cache = [];
public void ClearCache() => Cache.Clear();

View File

@ -68,7 +68,7 @@ public void Initialize(IMove[] moves, LearnSettings settings, MovesetRandSetting
Settings = settings;
moverand = new MoveRandomizer(Game, Moves, Personal);
moverand.Initialize(moverandset, bannedMoves ?? Array.Empty<int>());
moverand.Initialize(moverandset, bannedMoves ?? []);
}
public override void Execute()

View File

@ -48,7 +48,7 @@ private void RandomizeAllSpecies()
RandomizeSpecies(species);
}
private bool[] processed = Array.Empty<bool>();
private bool[] processed = [];
private void RandomizeChains()
{

View File

@ -38,11 +38,11 @@ public void Initialize(SpeciesSettings settings, params int[] banlist)
}
#region Random Species Filtering Parameters
private GenericRandomizer<int> RandSpec = new(Array.Empty<int>());
private GenericRandomizer<int> RandLegend = new(Array.Empty<int>());
private GenericRandomizer<int> RandEvent = new(Array.Empty<int>());
private int[] legends = Array.Empty<int>();
private int[] events = Array.Empty<int>();
private GenericRandomizer<int> RandSpec = new([]);
private GenericRandomizer<int> RandLegend = new([]);
private GenericRandomizer<int> RandEvent = new([]);
private int[] legends = [];
private int[] events = [];
private int loopctr;
private const int l = 10; // tweakable scalars
private const int h = 11;

View File

@ -369,9 +369,9 @@ private static int[] GetRandomMega(Dictionary<int, int[]> megas, out int species
return Legal.ImportantTrainers_SWSH.ToDictionary(z => z, index => MultiBattle_SWSH.Contains(index) ? 3 : 6);
if (GameVersion.SV.Contains(game))
return Legal.ImportantTrainers_SV.ToDictionary(z => z, index => MultiBattle_SV.Contains(index) ? 3 : 6);
return new Dictionary<int, int>();
return [];
}
private static readonly int[] CrashClasses_GG = Legal.BlacklistedClasses_GG;
private static readonly int[] CrashClasses_SWSH = Legal.BlacklistedClasses_SWSH;
private static readonly int[] CrashClasses_SV = Legal.BlacklistedClasses_SV;
@ -392,7 +392,7 @@ private static int[] GetSpecialClasses(GameVersion game)
return Legal.SpecialClasses_ORAS;
if (GameVersion.XY.Contains(game))
return Legal.SpecialClasses_XY;
return Array.Empty<int>();
return [];
}
private static int[] GetCrashClasses(GameVersion game)
@ -403,6 +403,6 @@ private static int[] GetCrashClasses(GameVersion game)
return CrashClasses_SWSH;
if (GameVersion.GG.Contains(game))
return CrashClasses_GG;
return Array.Empty<int>();
return [];
}
}

View File

@ -159,14 +159,9 @@ public string LocationTypeSummary
}
}
public string LocationTypeIdSummary
{
get
{
// todo lookup
return (LocationTypeID).ToString();
}
}
public string LocationTypeIdSummary =>
// todo lookup
(LocationTypeID).ToString();
// lazy init
private static IReadOnlyDictionary<ulong, string>? _locationArgMap;

View File

@ -8,7 +8,7 @@ public sealed class AreaInstance
// Area Info
private readonly ResidentArea Area;
public readonly AreaInstance? ParentArea;
private readonly List<AreaInstance> Children = new();
private readonly List<AreaInstance> Children = [];
public bool IsSubArea => ParentArea != null;
public IReadOnlyList<AreaInstance> SubAreas => Children;

View File

@ -76,7 +76,7 @@ public void LoadInfo()
Mikaruge = TryRead<PlacementMkrgTable >(Settings.Mkrg);
SearchItem = TryRead<PlacementSearchItemTable >(Settings.SearchItem);
}
public void SaveInfo()
{
TryWrite(Settings.Encounters, Encounters);

View File

@ -17,7 +17,6 @@ public partial class EncounterEligiblityTraits : IHasCondition, ISlotModifierTim
{
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class EncounterOybnTraits
{

View File

@ -21,7 +21,7 @@ public partial class EvolutionSet
public byte[] Write()
{
if (Table is null || Table.Count == 0)
return Array.Empty<byte>();
return [];
using var ms = new MemoryStream();
using var bw = new BinaryWriter(ms);

View File

@ -30,7 +30,7 @@ public partial class ByteBuffer
{
public VertexAttributeLayout? Debug_InputLayout { get; set; }
public object[][] Debug_VertexBuffer => Debug_InputLayout == null ? Array.Empty<object[]>() : FromInputLayout(Debug_InputLayout);
public ushort[] Debug_IndexBuffer => Debug_InputLayout == null ? ((ReadOnlySpan<byte>)Data.Span).GetArray(ReadUInt16LittleEndian, 2) : Array.Empty<ushort>();
public ushort[] Debug_IndexBuffer => Debug_InputLayout == null ? ((ReadOnlySpan<byte>)Data.Span).GetArray(ReadUInt16LittleEndian, 2) : [];
public VertexWrapper[][] FromInputLayout(VertexAttributeLayout inputLayout)
{
@ -52,7 +52,7 @@ public VertexWrapper[][] FromInputLayout(VertexAttributeLayout inputLayout)
InputLayoutFormat.RGB_32_FLOAT => new Vec3f(ReadSingleLittleEndian(data[offset..]), ReadSingleLittleEndian(data[(offset + 4)..]), ReadSingleLittleEndian(data[(offset + 8)..])),
InputLayoutFormat.RGBA_32_FLOAT => new Vec4f(ReadSingleLittleEndian(data[offset..]), ReadSingleLittleEndian(data[(offset + 4)..]), ReadSingleLittleEndian(data[(offset + 8)..]), ReadSingleLittleEndian(data[(offset + 12)..])),
InputLayoutFormat.NONE => throw new IndexOutOfRangeException(),
_ => throw new IndexOutOfRangeException()
_ => throw new IndexOutOfRangeException(),
});
}

View File

@ -6,7 +6,6 @@ namespace pkNX.Structures.FlatBuffers.Arceus;
// *.trmdl
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class FileReference
{
@ -33,6 +32,6 @@ public partial class Model
Meshes = Array.Empty<FileReference>(),
LODs = Array.Empty<LOD>(),
Skeleton = FileReference.Empty,
Materials = Array.Empty<string>()
Materials = Array.Empty<string>(),
};
}

View File

@ -37,6 +37,6 @@ public partial class MultiMaterialTable
{
public static MultiMaterialTable Empty => new()
{
Material = Array.Empty<MaterialTable>()
Material = Array.Empty<MaterialTable>(),
};
}

View File

@ -14,7 +14,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus;
public partial class MeshMaterialWrapper
{
[FlatBufferItem(0)] public string Name { get; set; } = string.Empty;
[FlatBufferItem(1)] public Material[] Materials { get; set; } = Array.Empty<Material>();
[FlatBufferItem(1)] public Material[] Materials { get; set; } = [];
}
[TypeConverter(typeof(ExpandableObjectConverter))]
@ -65,7 +65,7 @@ public PokemonModelArchive(GFPack sourceArchive)
Name = x.Name,
Materials = x.FileNames.Select(
fileName => FlatBufferConverter.DeserializeFrom<Material>(SourceArchive.GetDataFullPath(ModelPath + $"{fileName}"))
).ToArray()
).ToArray(),
}
).ToArray();

View File

@ -8,7 +8,6 @@ namespace pkNX.Structures.FlatBuffers.Arceus;
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class Skeleton { }
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class TransformNode { }

View File

@ -63,7 +63,7 @@ public PokeCaptureCollision AddEntry(ushort species, ushort form)
Type = "Barrier",
Field07 = string.Empty,
},
}
},
};
Table = Table.Append(entry)

View File

@ -14,7 +14,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus;
public partial class PokeDropItemArchive { }
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class PokeDropItem
public partial class PokeDropItem
{
public string Dump(string[] itemNames) => $"{Hash:X16}\t{itemNames[RegularItem]}\t{RegularItemProbability}\t{itemNames[RareItem]}\t{RareItemProbability}";
}

View File

@ -56,10 +56,10 @@ public PokeInfo AddEntry(ushort species, byte formCount)
new() {
AssetName = $"{species:0000}_{genderId:000}_{form:000}_n_00000000_fn_n",
Gender = new PokeInfoGender(),
}
}
}
}
},
},
},
},
},
new() {
IsRare = true, // Shiny form
@ -69,12 +69,12 @@ public PokeInfo AddEntry(ushort species, byte formCount)
new() {
AssetName = $"{species:0000}_{genderId:000}_{form:000}_n_00000000_fn_r",
Gender = new PokeInfoGender(),
}
}
}
}
},
},
},
},
},
}
},
};
}

View File

@ -61,7 +61,6 @@ public PokeModelConfig AddEntry(ushort species, ushort form, byte gender)
Species = species,
Form = form,
Gender = gender,
},
ModelPath = $"{basePath}/mdl/{pmStr}.trmdl",
MaterialTablePath = $"{basePath}/mdl/{pmStr}.trmmt",
@ -71,14 +70,14 @@ public PokeModelConfig AddEntry(ushort species, ushort form, byte gender)
new(){
Name = "base",
Path = $"{basePath}/anm/{pmStr}_base.tracn",
}
},
},
Effects = new FileNamePathPair[] {
new() {
Name = "eff",
Path = $"{basePath}/locators/{pmStr}_eff.trskl",
}
},
},
};

View File

@ -14,7 +14,7 @@ public record struct EncounterDetail(double Rate, double MultT, double MultW, in
for (var t = 0; t < TimeCount; t++)
{
for (var w = 0; w < WeatherCount; w++)
result[t, w] = new List<EncounterDetail>();
result[t, w] = [];
}
return result;
}

View File

@ -58,7 +58,7 @@ public List<string> Dump(IPersonalTable table)
var lines = new List<string>();
var ml = new List<string>[Moves.Count];
for (int i = 0; i < ml.Length; i++)
ml[i] = new List<string>();
ml[i] = [];
MoveSpeciesLearn = ml;
for (ushort species = 0; species <= table.MaxSpeciesID; species++)

View File

@ -1,30 +1,29 @@
using System;
namespace pkNX.Structures.FlatBuffers.SV
namespace pkNX.Structures.FlatBuffers.SV;
public partial struct FoodPokeTypeParam
{
public partial struct FoodPokeTypeParam
public int GetBoostFromIndex(int index) => index switch
{
public int GetBoostFromIndex(int index) => index switch
{
00 => Normal,
01 => Kakutou,
02 => Hikou,
03 => Doku,
04 => Jimen,
05 => Iwa,
06 => Mushi,
07 => Ghost,
08 => Hagane,
09 => Honoo,
10 => Mizu,
11 => Kusa,
12 => Denki,
13 => Esper,
14 => Koori,
15 => Dragon,
16 => Aku,
17 => Fairy,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null)
};
}
00 => Normal,
01 => Kakutou,
02 => Hikou,
03 => Doku,
04 => Jimen,
05 => Iwa,
06 => Mushi,
07 => Ghost,
08 => Hagane,
09 => Honoo,
10 => Mizu,
11 => Kusa,
12 => Denki,
13 => Esper,
14 => Koori,
15 => Dragon,
16 => Aku,
17 => Fairy,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null),
};
}

View File

@ -33,7 +33,7 @@ public List<string> Dump(PersonalTable9SV table)
var lines = new List<string>();
var ml = new List<string>[Moves.Count];
for (int i = 0; i < ml.Length; i++)
ml[i] = new List<string>();
ml[i] = [];
MoveSpeciesLearn = ml;
for (ushort species = 0; species <= table.MaxSpeciesID; species++)

View File

@ -44,6 +44,6 @@ public partial class DeliveryRaidLotteryRewardItem
27 => RewardItem27,
28 => RewardItem28,
29 => RewardItem29,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null)
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null),
};
}

View File

@ -28,6 +28,6 @@ public partial class RaidFixedRewardItem
12 => RewardItem12,
13 => RewardItem13,
14 => RewardItem14,
_ => throw new ArgumentOutOfRangeException(nameof(index))
_ => throw new ArgumentOutOfRangeException(nameof(index)),
};
}

View File

@ -44,6 +44,6 @@ public partial class RaidLotteryRewardItem
27 => RewardItem27,
28 => RewardItem28,
29 => RewardItem29,
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null)
_ => throw new ArgumentOutOfRangeException(nameof(index), index, null),
};
}

View File

@ -27,7 +27,7 @@ public void SerializePKHeX(BinaryWriter bw, sbyte captureLv, RaidSerializationFo
byte form = species switch
{
//(ushort)Species.Vivillon or (ushort)Species.Spewpa or (ushort)Species.Scatterbug => 30,
//(ushort)Species.Minior when FormId == 0 => 31, -- nope, actually form 0
(ushort)Species.Minior when FormId < 7 => (byte)(FormId + 7),
_ => (byte)FormId,
};

View File

@ -6,7 +6,6 @@ namespace pkNX.Structures.FlatBuffers.SWSH;
// *.gfbmdl
[TypeConverter(typeof(ExpandableObjectConverter))]
public partial class LayerData
{

View File

@ -102,7 +102,7 @@ private static bool IsPermittedWeather(byte locID, SWSHEncounterType weather, by
private class DumpableLocation
{
public static readonly DumpableLocation Empty = new(new List<Slot8>(), 0, 0);
public static readonly DumpableLocation Empty = new([], 0, 0);
public readonly List<Slot8> Slots;
public readonly byte Location;

View File

@ -37,6 +37,5 @@ public Color4f(Vec4f v)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Color4f FromByteColor(Vec4i c) => new(c.X * RGBToFloat, c.Y * RGBToFloat, c.Z * RGBToFloat, c.W * RGBToFloat);
public override string ToString() => $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}";
}

View File

@ -72,7 +72,6 @@ public Unorm16(ushort fixedValue)
return lhs._value != rhs._value;
}
/// <summary>Returns true if the Unorm16 is equal to a given Unorm16, false otherwise.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Unorm16 rhs)

View File

@ -72,7 +72,6 @@ public Unorm8(byte fixedValue)
return lhs._value != rhs._value;
}
/// <summary>Returns true if the Unorm8 is equal to a given Unorm8, false otherwise.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Unorm8 rhs)

View File

@ -16,7 +16,7 @@ public class Vec4i : IEquatable<Vec4i>
public static readonly Vec4i One = new(1, 1, 1, 1);
public Vec4i() { }
public Vec4i(int x = 0, int y = 0, int z = 0, int w = 0)
{
X = x;

View File

@ -11,8 +11,8 @@ namespace pkNX.Structures.FlatBuffers;
/// </summary>
public class FlatSchemaDump
{
public readonly List<string> GeneratedSchemas = new();
private readonly List<string> GeneratedClasses = new();
public readonly List<string> GeneratedSchemas = [];
private readonly List<string> GeneratedClasses = [];
public FlatSchemaDump(object obj) => Recurse(obj.GetType());

View File

@ -8,7 +8,7 @@ namespace pkNX.Structures;
public class AIBehaviourConverter : TypeConverter
{
public static HashSet<string> BehaviourNames = new();
public static HashSet<string> BehaviourNames { get; set; } = [];
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{

View File

@ -6,7 +6,7 @@ namespace pkNX.Structures;
public class DropTableConverter : TypeConverter
{
public static ulong[] DropTableHashes = Array.Empty<ulong>();
public static ulong[] DropTableHashes { get; set; } = [];
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{

View File

@ -6,7 +6,7 @@ namespace pkNX.Structures;
public class ItemConverter : TypeConverter
{
public static string[] ItemNames = Array.Empty<string>();
public static string[] ItemNames { get; set; } = [];
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{

View File

@ -51,7 +51,7 @@ public List<string> Dump(IPersonalTable table)
var lines = new List<string>();
var ml = new List<string>[Moves.Count];
for (int i = 0; i < ml.Length; i++)
ml[i] = new List<string>();
ml[i] = [];
MoveSpeciesLearn = ml;
for (ushort species = 0; species <= table.MaxSpeciesID; species++)

View File

@ -18,7 +18,7 @@ public static EggMoves[] GetArray(byte[] data, int count)
}
EggMoves[] entries = new EggMoves[count + 1];
entries[0] = new EggMoves2(Array.Empty<byte>());
entries[0] = new EggMoves2([]);
for (int i = 1; i < entries.Length; i++)
entries[i] = new EggMoves2(data.Skip(ptrs[i]).TakeWhile(b => b != 0xFF).ToArray());

View File

@ -4,7 +4,7 @@ namespace pkNX.Structures;
public sealed class EggMoves6 : EggMoves
{
private static readonly EggMoves6 None = new(Array.Empty<int>());
private static readonly EggMoves6 None = new([]);
private EggMoves6(int[] moves) : base(moves) { }

View File

@ -4,7 +4,7 @@ namespace pkNX.Structures;
public sealed class EggMoves7 : EggMoves
{
private static readonly EggMoves7 None = new(Array.Empty<int>());
private static readonly EggMoves7 None = new([]);
public readonly int FormTableIndex;
private EggMoves7(int[] moves, int formIndex = 0) : base(moves) => FormTableIndex = formIndex;

View File

@ -19,7 +19,7 @@ public abstract class EncounterGift
public virtual bool ShinyLock { get; set; }
public virtual bool IV3 { get; set; }
public virtual int[] RelearnMoves { get; set; } = Array.Empty<int>();
public virtual int[] RelearnMoves { get; set; } = [];
public abstract Shiny Shiny { get; set; }
public abstract int IV_HP { get; set; }

View File

@ -20,7 +20,7 @@ public abstract class EncounterStatic
public virtual bool ShinyLock { get; set; }
public virtual bool IV3 { get; set; }
public virtual int[] RelearnMoves { get; set; } = Array.Empty<int>();
public virtual int[] RelearnMoves { get; set; } = [];
public abstract Shiny Shiny { get; set; }
public virtual int IV_HP { get; set; } = -1;

View File

@ -21,7 +21,7 @@ public abstract class EncounterTrade
public virtual bool ShinyLock { get; set; }
public virtual bool IV3 { get; set; }
public virtual int[] RelearnMoves { get; set; } = Array.Empty<int>();
public virtual int[] RelearnMoves { get; set; } = [];
public abstract Shiny Shiny { get; set; }
public abstract int IV_HP { get; set; }

View File

@ -10,5 +10,5 @@ public abstract class EvolutionSet
public EvolutionMethod[] PossibleEvolutions;
public abstract byte[] Write();
protected EvolutionSet() => PossibleEvolutions = Array.Empty<EvolutionMethod>();
protected EvolutionSet() => PossibleEvolutions = [];
}

View File

@ -12,7 +12,7 @@ public class EvolutionSet6 : EvolutionSet
private const int ENTRY_SIZE = 6;
private const int ENTRY_COUNT = 8;
public const int SIZE = ENTRY_COUNT * ENTRY_SIZE;
private static readonly HashSet<int> argEvos = new() { 6, 8, 16, 17, 18, 19, 20, 21, 22, 29, 30, 32, 33, 34 };
private static readonly HashSet<int> argEvos = [6, 8, 16, 17, 18, 19, 20, 21, 22, 29, 30, 32, 33, 34];
public EvolutionSet6(byte[] data)
{

View File

@ -332,7 +332,7 @@ private static void ReadTbdy(ReadOnlySpan<byte> buffer, List<HavokTypeObject> tn
}
else
{
tna.Fields = new List<HavokField>();
tna.Fields = [];
}
if (tna.IsOptionInterfaces)
{
@ -356,7 +356,7 @@ private static void ReadTbdy(ReadOnlySpan<byte> buffer, List<HavokTypeObject> tn
}
else
{
tna.Interfaces = new List<HavokInterface>();
tna.Interfaces = [];
}
if (tna.IsOptionAttribute)
{

View File

@ -12,8 +12,8 @@ public abstract class Learnset
protected Learnset()
{
Moves = Array.Empty<int>();
Levels = Array.Empty<int>();
Moves = [];
Levels = [];
}
public abstract byte[] Write();
@ -29,13 +29,13 @@ public int[] GetMoves(int maxLevel, int minLevel = 0)
if (minLevel <= 1 && maxLevel >= 100)
return Moves;
if (minLevel > maxLevel)
return Array.Empty<int>();
return [];
int start = Array.FindIndex(Levels, z => z >= minLevel);
if (start < 0)
return Array.Empty<int>();
return [];
int end = Array.FindLastIndex(Levels, z => z <= maxLevel);
if (end < 0)
return Array.Empty<int>();
return [];
int[] result = new int[end - start + 1];
Array.Copy(Moves, start, result, 0, result.Length);
return result;

View File

@ -8,7 +8,7 @@ public class Learnset6 : Learnset
public Learnset6(byte[] data)
{
if (data.Length < 4 || data.Length % 4 != 0)
{ Count = 0; Levels = Moves = Array.Empty<int>(); return; }
{ Count = 0; Levels = Moves = []; return; }
Count = (data.Length / 4) - 1;
Moves = new int[Count];
Levels = new int[Count];

View File

@ -20,7 +20,7 @@ public Learnset8(byte[] data)
Count = count;
if (Count == 0)
{
Levels = Moves = Array.Empty<int>();
Levels = Moves = [];
return;
}

View File

@ -13,7 +13,7 @@ public class GameInfo
public int MaxSpeciesID { get; private set; }
public int MaxItemID { get; private set; }
public int MaxMoveID { get; private set; }
public ushort[] HeldItems { get; private set; } = Array.Empty<ushort>();
public ushort[] HeldItems { get; private set; } = [];
public int MaxAbilityID { get; private set; }
public bool XY { get; private set; }

View File

@ -159,7 +159,7 @@ public static int[] GetRandomItemList(GameVersion game)
public static int[] GetBannedMoves(GameVersion infoGame, int moveCount)
{
if (!GameVersion.GG.Contains(infoGame))
return Array.Empty<int>();
return [];
return Enumerable.Range(0, moveCount).Except(AllowedMovesGG).ToArray();
}
@ -172,8 +172,8 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount)
return Enumerable.Range(0, moveCount).ToArray();
}
public static readonly HashSet<int> BattleForms = new()
{
public static readonly HashSet<int> BattleForms =
[
(int)Species.Castform,
(int)Species.Cherrim,
(int)Species.Darmanitan,
@ -189,10 +189,10 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount)
(int)Species.Zamazenta,
(int)Species.Eternatus,
(int)Species.Palafin,
};
];
public static readonly HashSet<int> BattleMegas = new()
{
public static readonly HashSet<int> BattleMegas =
[
// XY
(int)Species.Venusaur, (int)Species.Charizard, (int)Species.Blastoise, (int)Species.Alakazam, (int)Species.Gengar,
(int)Species.Kangaskhan, (int)Species.Pinsir, (int)Species.Gyarados, (int)Species.Aerodactyl, (int)Species.Mewtwo,
@ -207,9 +207,9 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount)
(int)Species.Altaria, (int)Species.Glalie, (int)Species.Salamence, (int)Species.Metagross, (int)Species.Rayquaza,
(int)Species.Lopunny, (int)Species.Gallade,
(int)Species.Audino, (int)Species.Diancie,
};
];
public static readonly HashSet<int> BattlePrimals = new() { 382, 383 }; // Kyogre and Groudon
public static readonly HashSet<int> BattleFusions = new() { 646, 800, 898 }; // Kyurem, Necrozma, Calyrex
public static readonly HashSet<int> BattlePrimals = [382, 383]; // Kyogre and Groudon
public static readonly HashSet<int> BattleFusions = [646, 800, 898]; // Kyurem, Necrozma, Calyrex
public static readonly HashSet<int> BattleExclusiveForms = new(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions)));
}

View File

@ -48,13 +48,13 @@ public static bool ShouldIterateForms(ushort species, byte form, int generation,
/// <summary>
/// Species that can change between their forms and get access to form-specific moves.
/// </summary>
private static readonly HashSet<ushort> FormChangeMovesRetain = new()
{
private static readonly HashSet<ushort> FormChangeMovesRetain =
[
(int)Species.Deoxys,
(int)Species.Giratina,
(int)Species.Shaymin,
(int)Species.Hoopa,
};
];
/// <summary>
/// Species that can change between their forms and get access to form-specific moves.

View File

@ -244,8 +244,8 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm,
/// Species that can change between their forms, regardless of origin.
/// </summary>
/// <remarks>Excludes Zygarde as it has special conditions. Check separately.</remarks>
private static readonly HashSet<ushort> FormChange = new()
{
private static readonly HashSet<ushort> FormChange =
[
// Sometimes considered for wild encounters
(int)Burmy,
(int)Rotom,
@ -269,13 +269,13 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm,
(int)Necrozma,
(int)Calyrex,
(int)Enamorus,
};
];
/// <summary>
/// Species that have an alternate form that cannot exist outside of battle.
/// </summary>
private static readonly HashSet<ushort> BattleForms = new()
{
private static readonly HashSet<ushort> BattleForms =
[
(int)Castform,
(int)Cherrim,
(int)Darmanitan,
@ -297,14 +297,14 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm,
(int)Eternatus,
(int)Palafin,
};
];
/// <summary>
/// Species that have a mega form that cannot exist outside of battle.
/// </summary>
/// <remarks>Using a held item to change form during battle, via an in-battle transformation feature.</remarks>
private static readonly HashSet<ushort> BattleMegas = new()
{
private static readonly HashSet<ushort> BattleMegas =
[
// XY
(int)Venusaur, (int)Charizard, (int)Blastoise,
(int)Alakazam, (int)Gengar, (int)Kangaskhan, (int)Pinsir,
@ -330,12 +330,12 @@ public static bool IsFormChangeable(ushort species, byte oldForm, byte newForm,
// USUM
(int)Necrozma, // Ultra Necrozma
};
];
/// <summary>
/// Species that have a primal form that cannot exist outside of battle.
/// </summary>
private static readonly HashSet<ushort> BattlePrimals = new() { (int)Kyogre, (int)Groudon };
private static readonly HashSet<ushort> BattlePrimals = [(int)Kyogre, (int)Groudon];
private static readonly HashSet<ushort> BattleOnly = GetBattleFormSet();
@ -450,10 +450,10 @@ public static bool HasFormSelection(IPersonalInfo pi, ushort species, int format
/// <summary>
/// <seealso cref="IsValidOutOfBoundsForm"/>
/// </summary>
private static readonly HashSet<ushort> HasFormValuesNotIndicatedByPersonal = new()
{
private static readonly HashSet<ushort> HasFormValuesNotIndicatedByPersonal =
[
(int)Unown,
(int)Mothim, // (Burmy form is not cleared on evolution)
(int)Scatterbug, (int)Spewpa, // Vivillon pre-evos
};
];
}

View File

@ -9,8 +9,8 @@ public static partial class Legal
/// <summary>
/// Generation 3 &amp; 4 Battle Frontier Species banlist. When referencing this in context to generation 4, be sure to disallow <see cref="Pichu"/> with Form 1 (Spiky).
/// </summary>
public static readonly HashSet<ushort> BattleFrontierBanlist = new()
{
public static readonly HashSet<ushort> BattleFrontierBanlist =
[
(int)Mewtwo, (int)Mew,
(int)Lugia, (int)HoOh, (int)Celebi,
(int)Kyogre, (int)Groudon, (int)Rayquaza, (int)Jirachi, (int)Deoxys,
@ -19,13 +19,13 @@ public static partial class Legal
(int)Xerneas, (int)Yveltal, (int)Zygarde, (int)Diancie, (int)Hoopa, (int)Volcanion,
(int)Cosmog, (int)Cosmoem, (int)Solgaleo, (int)Lunala, (int)Necrozma, (int)Magearna, (int)Marshadow, (int)Zeraora,
(int)Meltan, (int)Melmetal,
};
];
/// <summary>
/// Species that are from Mythical Distributions (disallowed species for competitive rulesets)
/// </summary>
public static readonly HashSet<ushort> Mythicals = new()
{
public static readonly HashSet<ushort> Mythicals =
[
(int)Mew,
(int)Celebi,
(int)Jirachi, (int)Deoxys,
@ -35,13 +35,13 @@ public static partial class Legal
(int)Magearna, (int)Marshadow,
(int)Zeraora, (int)Meltan, (int)Melmetal,
(int)Zarude,
};
];
/// <summary>
/// Species classified as "Legend" by the game code.
/// </summary>
public static readonly HashSet<ushort> Legends = new()
{
public static readonly HashSet<ushort> Legends =
[
(int)Mewtwo, (int)Mew,
(int)Lugia, (int)HoOh, (int)Celebi,
(int)Kyogre, (int)Groudon, (int)Rayquaza, (int)Jirachi, (int)Deoxys,
@ -51,13 +51,13 @@ public static partial class Legal
(int)Cosmog, (int)Cosmoem, (int)Solgaleo, (int)Lunala, (int)Necrozma, (int)Magearna, (int)Marshadow, (int)Zeraora,
(int)Meltan, (int)Melmetal,
(int)Zacian, (int)Zamazenta, (int)Eternatus, (int)Zarude, (int)Calyrex,
};
];
/// <summary>
/// Species classified as "SubLegend" by the game code.
/// </summary>
public static readonly HashSet<ushort> SubLegends = new()
{
public static readonly HashSet<ushort> SubLegends =
[
(int)Articuno, (int)Zapdos, (int)Moltres,
(int)Raikou, (int)Entei, (int)Suicune,
(int)Regirock, (int)Regice, (int)Registeel, (int)Latias, (int)Latios,
@ -67,13 +67,13 @@ public static partial class Legal
(int)Nihilego, (int)Buzzwole, (int)Pheromosa, (int)Xurkitree, (int)Celesteela, (int)Kartana, (int)Guzzlord,
(int)Poipole, (int)Naganadel, (int)Stakataka, (int)Blacephalon,
(int)Kubfu, (int)Urshifu, (int)Regieleki, (int)Regidrago, (int)Glastrier, (int)Spectrier, (int)Enamorus,
};
];
/// <summary>
/// Species that evolve from a Bi-Gendered species into a Single-Gender.
/// </summary>
public static readonly HashSet<ushort> FixedGenderFromBiGender = new()
{
public static readonly HashSet<ushort> FixedGenderFromBiGender =
[
(int)Nincada,
(int)Shedinja, // (G)
@ -89,7 +89,7 @@ public static partial class Legal
(int)Espurr,
(int)Meowstic, // (M/F) form specific
};
];
/// <summary>
/// Gets a permit list with the permitted indexes, then un-flags the indexes that are not permitted.

View File

@ -59,18 +59,18 @@ public static partial class Legal
576, // Dream Ball
});
public static readonly HashSet<ushort> ValidMet_BW = new()
{
public static readonly HashSet<ushort> ValidMet_BW =
[
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, 054, 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, 095, 096, 097, 098, 099, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
};
];
public static readonly HashSet<ushort> ValidMet_B2W2 = new()
{
public static readonly HashSet<ushort> ValidMet_B2W2 =
[
004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020,
021, 022, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, //023 Route 10, 040->134 Victory Road
041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 055, 056, 057, 058, 060, //059 Challenger's cave
@ -79,5 +79,5 @@ public static partial class Legal
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 139, 140, //138 ---
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
};
];
}

View File

@ -50,23 +50,23 @@ public static partial class Legal
public static readonly int[] EggLocations6 = { 60002, 30002 };
public static readonly HashSet<ushort> ValidMet_XY = new()
{
public static readonly HashSet<ushort> ValidMet_XY =
[
006, 008, 009, 010, 012, 013, 014, 016, 017, 018, 020, 021, 022, 024, 026, 028, 029, 030, 032, 034, 035, 036,
038, 039, 040, 042, 043, 044, 046, 047, 048, 050, 051, 052, 054, 055, 056, 058, 060, 062, 063, 064, 066, 067,
068, 069, 070, 072, 074, 075, 076, 078, 079, 082, 084, 085, 086, 088, 089, 090, 092, 093, 094, 096, 097, 098,
100, 101, 102, 103, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 135, 136,
138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168,
};
];
public static readonly HashSet<ushort> ValidMet_AO = new()
{
public static readonly HashSet<ushort> ValidMet_AO =
[
170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198,
200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242,
244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286,
288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330,
332, 334, 336, 338, 340, 342, 344, 346, 350, 352, 354,
};
];
public static readonly int[] FriendSafari =
{
@ -489,11 +489,11 @@ public static partial class Legal
new[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Region matching
};
public static readonly HashSet<int> MemoryGeneral = new() { 1, 2, 3, 4, 19, 24, 31, 32, 33, 35, 36, 37, 38, 39, 42, 52, 59 };
public static readonly HashSet<int> MemorySpecific = new() { 6 };
public static readonly HashSet<int> MemoryMove = new() { 12, 16, 48, 49 };
public static readonly HashSet<int> MemoryItem = new() { 5, 15, 26, 34, 40, 51 };
public static readonly HashSet<int> MemorySpecies = new() { 7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60 };
public static readonly HashSet<int> MemoryGeneral = [1, 2, 3, 4, 19, 24, 31, 32, 33, 35, 36, 37, 38, 39, 42, 52, 59];
public static readonly HashSet<int> MemorySpecific = [6];
public static readonly HashSet<int> MemoryMove = [12, 16, 48, 49];
public static readonly HashSet<int> MemoryItem = [5, 15, 26, 34, 40, 51];
public static readonly HashSet<int> MemorySpecies = [7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60];
#endregion
public static readonly int[] MovePP_XY =

View File

@ -115,8 +115,8 @@ public static partial class Legal
public static readonly ushort[] HeldItems_USUM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM);
#endregion
public static readonly HashSet<ushort> AlolanOriginForms = new()
{
public static readonly HashSet<ushort> AlolanOriginForms =
[
(int)Rattata,
(int)Raticate,
(int)Sandshrew,
@ -132,20 +132,19 @@ public static partial class Legal
(int)Golem,
(int)Grimer,
(int)Muk,
};
];
public static readonly HashSet<ushort> AlolanVariantEvolutions12 = new()
{
public static readonly HashSet<ushort> AlolanVariantEvolutions12 =
[
(int)Raichu,
(int)Exeggutor,
(int)Marowak,
};
];
public static readonly HashSet<ushort> EvolveToAlolanForms = new(AlolanVariantEvolutions12.Concat(AlolanOriginForms));
public static readonly HashSet<ushort> PastGenAlolanNatives = new()
{
public static readonly HashSet<ushort> PastGenAlolanNatives =
[
010, 011, 012, 019, 020, 021, 022, 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, 088, 089, 090, 091, 092, 093, 094, 096, 097, 102, 103, 104, 105, 113, 115, 118, 119,
@ -189,17 +188,17 @@ public static partial class Legal
194, 195, // Quagsire
100, 101, // Voltorb & Electrode
};
];
public static readonly HashSet<ushort> ValidMet_SM = new()
{
public static readonly HashSet<ushort> ValidMet_SM =
[
006, 008, 010, 012, 014, 016, 018, 020, 022, 024, 026, 028, 030, 032, 034, 036, 038, 040, 042, 044, 046, 048,
050, 052, 054, 056, 058, 060, 062, 064, 068, 070, 072, 074, 076, 078, 082, 084, 086, 088, 090, 092, 094,
100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148,
150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192,
30016,
};
];
public static readonly HashSet<ushort> ValidMet_USUM = new(ValidMet_SM)
{
@ -275,22 +274,22 @@ public static partial class Legal
});
#endregion
public static readonly HashSet<ushort> Totem_Alolan = new()
{
public static readonly HashSet<ushort> Totem_Alolan =
[
(int)Raticate, // (Normal, Alolan, Totem)
(int)Marowak, // (Normal, Alolan, Totem)
(int)Mimikyu, // (Normal, Busted, Totem, Totem_Busted)
};
];
public static readonly HashSet<ushort> Totem_NoTransfer = new()
{
public static readonly HashSet<ushort> Totem_NoTransfer =
[
(int)Marowak,
(int)Araquanid,
(int)Togedemaru,
(int)Ribombee,
};
public static readonly HashSet<int> Totem_SM = new()
{
];
public static readonly HashSet<int> Totem_SM =
[
(int)Raticate,
(int)Gumshoos,
// (int)Wishiwashi,
@ -299,10 +298,10 @@ public static partial class Legal
(int)Vikavolt,
(int)Mimikyu,
(int)Kommoo,
};
];
public static readonly HashSet<ushort> Totem_USUM = new()
{
public static readonly HashSet<ushort> Totem_USUM =
[
(int)Raticate,
(int)Gumshoos,
//(int)Wishiwashi,
@ -315,7 +314,7 @@ public static partial class Legal
(int)Araquanid,
(int)Togedemaru,
(int)Ribombee,
};
];
public static readonly ushort[] HeldItemsBuy_SM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Medicine_SM);
}

View File

@ -85,8 +85,8 @@ public static partial class Legal
public static readonly int[] Met_SWSH_6 = {/* XY */ 60001, 60003, /* ORAS */ 60004 };
public static readonly HashSet<ushort> ValidMet_SWSH = new()
{
public static readonly HashSet<ushort> ValidMet_SWSH =
[
006, 008,
012, 014, 016, 018,
020, 022, 024, 028,
@ -114,7 +114,7 @@ public static partial class Legal
222, 224, 226, 228, 230,
232, 234, 236, 238, 240,
242, 244, 246,
};
];
#endregion
@ -298,7 +298,7 @@ public static partial class Legal
521, 523, 527, 534, 541, 555, 566, 577, 580, 581,
604, 678, 595, 598, 206, 403, 684, 693, 707, 784,
};
public static readonly ushort[] TR_SWSH =
{
// TR
@ -338,8 +338,8 @@ public static partial class Legal
#endregion
public static readonly HashSet<ushort> GalarOriginForms = new()
{
public static readonly HashSet<ushort> GalarOriginForms =
[
(int)Meowth,
(int)Ponyta,
(int)Rapidash,
@ -353,23 +353,23 @@ public static partial class Legal
(int)Darumaka,
(int)Darmanitan,
(int)Stunfisk,
};
];
public static readonly HashSet<ushort> GalarVariantFormEvolutions = new()
{
public static readonly HashSet<ushort> GalarVariantFormEvolutions =
[
(int)MrMime,
(int)Weezing,
};
];
public static readonly HashSet<int> GalarForm0Evolutions = new()
{
public static readonly HashSet<int> GalarForm0Evolutions =
[
(int)Obstagoon,
(int)Perrserker,
(int)Cursola,
(int)Sirfetchd,
(int)MrRime,
(int)Runerigus,
};
];
public static readonly HashSet<ushort> EvolveToGalarForms = new(GalarVariantFormEvolutions.Concat(GalarOriginForms));

View File

@ -13,7 +13,7 @@ public static partial class Legal
public const int MaxAbilityID_8a = MaxAbilityID_8_R2;
#region Inventory Pouch
public static readonly ushort[] HeldItems_LA = Array.Empty<ushort>();
public static readonly ushort[] HeldItems_LA = [];
public static readonly ushort[] Pouch_Items_LA =
{

View File

@ -6,12 +6,12 @@ public static partial class Legal
{
#region Gen 6
public static readonly ushort[] Mega_XY =
{
[
003, 006, 009, 065, 080, 115, 127, 130, 142, 150,
181, 212, 214, 229, 248,
257, 282, 303, 306, 308, 310, 354, 359, 380, 381,
445, 448, 460,
};
];
public static readonly ushort[] Mega_ORAS = Mega_XY.Concat(new ushort[]
{
@ -24,7 +24,7 @@ public static partial class Legal
}).ToArray();
public static readonly int[] SpecialClasses_XY =
{
[
#region Classes
000, // Pokémon Trainer
001, // Pokémon Trainer
@ -78,10 +78,10 @@ public static partial class Legal
176, // Successor
177, // Leader
#endregion
};
];
public static readonly int[] SpecialClasses_ORAS =
{
[
#region Classes
064, // Battle Chatelaine
065, // Battle Chatelaine
@ -129,12 +129,12 @@ public static partial class Legal
278, // Pokémon Trainer
279, // Pokémon Trainer
#endregion
};
];
#endregion
#region Gen 7
public static readonly int[] SpecialClasses_SM =
{
[
#region Classes
000, // Pokémon Trainer
001, // Pokémon Trainer
@ -208,10 +208,10 @@ public static partial class Legal
184, // Battle Legend
185, // Aether Foundation
#endregion
};
];
public static readonly int[] SpecialClasses_USUM =
{
[
#region Classes
000, // Pokémon Trainer
001, // Pokémon Trainer
@ -306,10 +306,10 @@ public static partial class Legal
221, // Pokémon Trainer
222, // Pokémon Trainer
#endregion
};
];
public static readonly int[] SpecialClasses_GG =
{
[
#region Classes
000, // Pokémon Trainer [Trace, Standard]
001, // Gym Leader [Brock]
@ -337,7 +337,7 @@ public static partial class Legal
061, // Champion [Trace]
383, // Pokémon Trainer [Trace, Champion Title Defense]
#endregion
};
];
/// <summary>
/// Unused Trainer Classes in Let's Go, Pikachu! &amp; Let's Go, Eevee!.
@ -355,7 +355,7 @@ public static partial class Legal
#region Gen 8
public static readonly int[] SpecialClasses_SWSH =
{
[
#region Classes
004, // Champion [Leon]
005, // Pokémon Trainer [Leon, Battle Tower]
@ -413,10 +413,10 @@ public static partial class Legal
252, // Gym Leader [Avery]
253, // Gym Leader [Klara]
#endregion
};
];
public static readonly int[] DoubleBattleClasses_SWSH =
{
[
#region DoubleBattleClasses
072, // Reporter
073, // Cameraman
@ -463,14 +463,14 @@ public static partial class Legal
177, // Colleagues (Displayed when Trainer Classes 175 and 176 partake in a Double Battle)
182, // Medical Team (Displayed when Trainer Classes 180 and 181 partake in a Double Battle)
#endregion
};
];
/// <summary>
/// Unused Trainer Classes in Sword &amp; Shield.
/// Consists of NPCs you can interact with but never battle.
/// </summary>
public static readonly int[] UnusedClasses_SWSH =
{
[
#region UnusedClasses
000, // Pokémon Trainer [Your Player]
001, // Pokémon Trainer [Your Player]
@ -517,14 +517,14 @@ public static partial class Legal
224, // Master Dojo [Male] -- functionally identical to 223
226, // Master Dojo [Female] -- functionally identical to 225
#endregion
};
];
/// <summary>
/// Unused Trainer Classes in Sword &amp; Shield.
/// Assigning these Trainer Classes to a Trainer crashes the game.
/// </summary>
public static readonly int[] CrashClasses_SWSH =
{
[
#region CrashClasses
019, // ベテラントレーナー
047, // Waitress
@ -556,14 +556,14 @@ public static partial class Legal
154, // はいたついん
222, // Dojo Master [Mustard] -- this is used, but crashes if assigned to any other trainers
#endregion
};
];
/// <summary>
/// Dummy Trainer Classes in Sword and Shield.
/// No names are assigned to them. Could be preserved for future DLC, or could just be leftovers.
/// </summary>
public static readonly int[] DummyClasses_SWSH =
{
[
#region DummyClasses
254, // [~ 254]
255, // [~ 255]
@ -583,59 +583,59 @@ public static partial class Legal
269, // [~ 269]
270, // [~ 270]
#endregion
};
];
public static readonly int[] BlacklistedClasses_SWSH = DoubleBattleClasses_SWSH.Concat(UnusedClasses_SWSH).Concat(CrashClasses_SWSH).Concat(DummyClasses_SWSH).ToArray();
#endregion
#region Gen 9
public static readonly int[] SpecialClasses_SV =
{
[
#region Classes
#endregion
};
];
public static readonly int[] DoubleBattleClasses_SV =
{
[
#region DoubleBattleClasses
#endregion
};
];
/// <summary>
/// Unused Trainer Classes in Scarlet &amp; Violet.
/// Consists of NPCs you can interact with but never battle.
/// </summary>
public static readonly int[] UnusedClasses_SV =
{
[
#region UnusedClasses
#endregion
};
];
/// <summary>
/// Unused Trainer Classes in Scarlet &amp; Violet.
/// Assigning these Trainer Classes to a Trainer crashes the game.
/// </summary>
public static readonly int[] CrashClasses_SV =
{
[
#region CrashClasses
#endregion
};
];
/// <summary>
/// Dummy Trainer Classes in Scarlet &amp; Violet.
/// No names are assigned to them. Could be preserved for future DLC, or could just be leftovers.
/// </summary>
public static readonly int[] DummyClasses_SV =
{
[
#region DummyClasses
#endregion
};
];
#endregion
public static readonly int[] BlacklistedClasses_SV = DoubleBattleClasses_SV.Concat(UnusedClasses_SV).Concat(CrashClasses_SV).Concat(DummyClasses_SV).ToArray();
public static readonly int[] BlacklistedClasses_SV = [.. DoubleBattleClasses_SV, .. UnusedClasses_SV, .. CrashClasses_SV, .. DummyClasses_SV];
public static readonly int[] Model_XY =
{
[
#region Models
018, // Aliana
019, // Bryony
@ -652,10 +652,10 @@ public static partial class Legal
105, // Sycamore
175, // Lysandre (Mega Ring)
#endregion
};
];
public static readonly int[] Model_AO =
{
[
#region Models
127, // Brendan
128, // May
@ -671,16 +671,16 @@ public static partial class Legal
278, // Brendan (Mega Bracelet)
279, // May (Mega Bracelet)
#endregion
};
];
public static readonly int[] Z_Moves =
{
[
622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658,
695, 696, 697, 698, 699, 700, 701, 702, 703, 719, 723, 724, 725, 726, 727, 728,
};
];
public static readonly int[] Max_Moves =
{
[
743, // Max Guard
757, // Max Flare
758, // Max Flutterby
@ -700,62 +700,62 @@ public static partial class Legal
772, // Max Darkness
773, // Max Overgrowth
774, // Max Steelspike
};
];
public static readonly int[] Taboo_Moves =
{
[
165, // Struggle
464, // Dark Void
621, // Hyperspace Fury
781, // Behemoth Blade
782, // Behemoth Bash
};
];
public static readonly int[] ImportantTrainers_XY =
{
[
006, 021, 022, 023, 024, 025, 026, 076, 130, 131, 132, 175, 184, 185, 186, 187, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 279, 303, 321, 322, 323, 324, 325, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 237, 348, 349, 350, 351, 435, 436,
437, 438, 439, 503, 504, 505, 507, 511, 512, 513, 514, 515, 519, 520, 521, 525, 526, 559, 560, 561, 562, 573, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589,
590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 604, 605, 606, 613,
};
];
public static readonly int[] ImportantTrainers_ORAS =
{
[
178, 231, 235, 236, 266, 271, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 518, 527, 528, 529, 530, 531, 532, 553, 554, 555, 556, 557, 561, 563, 567, 569, 570, 571, 572,
583, 674, 675, 676, 677, 678, 679, 680, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 713, 856, 857, 898, 906, 907, 908, 909, 910, 911,
912, 913, 942, 943, 944, 945, 946, 947,
};
];
public static readonly int[] ImportantTrainers_SM =
{
[
012, 013, 014, 023, 052, 074, 075, 076, 077, 078, 079, 089, 090, 129, 131, 132, 138, 144, 146, 149, 152, 153, 154, 155, 156, 158, 159, 160, 164, 167, 215, 216, 217, 218, 219, 220, 221,
222, 235, 236, 238, 239, 240, 241, 349, 350, 351, 352, 356, 357, 358, 359, 360, 392, 396, 398, 400, 401, 403, 405, 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, 435, 438, 439, 440,
441, 447, 448, 449, 450, 451, 452, 467, 477, 478, 479, 480, 481, 482, 483, 484,
};
];
public static readonly int[] ImportantTrainers_USUM =
{
[
012, 013, 014, 023, 052, 074, 075, 076, 077, 078, 079, 089, 090, 131, 132, 138, 144, 146, 149, 153, 154, 156, 159, 160, 215, 216, 217, 218, 219, 220, 221, 222, 235, 236, 238, 239, 240,
241, 350, 351, 352, 356, 358, 359, 396, 398, 401, 405, 409, 410, 412, 415, 416, 417, 418, 419, 438, 439, 440, 441, 447, 448, 449, 450, 451, 452, 477, 478, 479, 480, 489, 490, 494, 495,
496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 541, 542, 543, 555, 556, 557, 558, 559, 560, 561, 562, 572, 573, 578, 580, 582, 583, 623, 630, 644, 645, 647, 648, 649,
650, 651, 652,
};
];
public static readonly int[] ImportantTrainers_GG =
{
[
005, 007, 008, 009, 010, 011, 013, 014, 015, 016, 017, 018, 020, 021, 022, 023, 024, 025, 027, 028, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046,
048, 049, 050, 051, 052, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 437, 439, 597, 601,
};
];
public static readonly int[] ImportantTrainers_SWSH =
{
[
032, 036, 037, 077, 078, 107, 108, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 138, 143, 144, 145, 149, 153, 154, 155, 156, 157, 158, 175, 189, 190,
191, 192, 193, 195, 196, 197, 198, 199, 202, 203, 204, 210, 211, 212, 213, 214, 215, 216, 221, 222, 225, 226, 227, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 248, 249, 250, 251,
252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 289, 315, 316, 317, 318, 319, 320, 321, 324, 325, 326, 327, 328, 329, 330, 374, 376, 414, 415, 416,
417, 418, 419, 420, 431, 432, 433, 434,
};
];
public static readonly int[] ImportantTrainers_SV =
{
};
[
];
}

View File

@ -11,7 +11,7 @@ public class Maison6Trainer
public Maison6Trainer()
{
Choices = Array.Empty<ushort>();
Choices = [];
}
public Maison6Trainer(byte[] data)

View File

@ -9,7 +9,7 @@ namespace pkNX.Structures;
/// <remarks>They do this because the Pickup Ability no longer exists, and to ease the grind of marts.</remarks>
public class CaptureRewardTable
{
public List<CaptureRewardGroup> Table = new();
public List<CaptureRewardGroup> Table = [];
public CaptureRewardTable(byte[] data)
{

View File

@ -13,7 +13,7 @@ public sealed class PersonalInfo7GG : IPersonalInfoGG
private readonly byte[] Data;
public bool[] TMHM { get; set; }
public bool[] TypeTutors { get; set; }
public bool[] SpecialTutors { get; set; } = Array.Empty<bool>();
public bool[] SpecialTutors { get; set; } = [];
public PersonalInfo7GG(byte[] data)
{

View File

@ -70,7 +70,7 @@ public static class IBaseStatExtensions
3 => stats.SPE = value,
4 => stats.SPA = value,
5 => stats.SPD = value,
_ => throw new ArgumentOutOfRangeException(nameof(index))
_ => throw new ArgumentOutOfRangeException(nameof(index)),
};
/// <summary>

View File

@ -65,7 +65,7 @@ public static class IIEffortValueYieldExtensions
3 => stats.EV_SPE = value,
4 => stats.EV_SPA = value,
5 => stats.EV_SPD = value,
_ => throw new ArgumentOutOfRangeException(nameof(index))
_ => throw new ArgumentOutOfRangeException(nameof(index)),
};
/// <summary>

View File

@ -56,7 +56,7 @@ public static void SetAbilities(this IPersonalAbility a, Span<int> result)
0 => a.Ability1 = value,
1 => a.Ability2 = value,
2 => a.AbilityH = value,
_ => throw new ArgumentOutOfRangeException(nameof(index))
_ => throw new ArgumentOutOfRangeException(nameof(index)),
};
/// <summary>

View File

@ -52,7 +52,7 @@ public static void SetItems(this IPersonalItems a, Span<int> result)
0 => a.Item1 = value,
1 => a.Item2 = value,
2 => a.Item3 = value,
_ => throw new ArgumentOutOfRangeException(nameof(index))
_ => throw new ArgumentOutOfRangeException(nameof(index)),
};
/// <summary>

View File

@ -62,11 +62,11 @@ private static string GetFileName(string resName)
public static byte[] GetBinaryResource(string name)
{
if (!resourceNameMap.TryGetValue(name, out var resName))
return Array.Empty<byte>();
return [];
using var resource = thisAssembly.GetManifestResourceStream(resName);
if (resource is null)
return Array.Empty<byte>();
return [];
var buffer = new byte[resource.Length];
_ = resource.Read(buffer, 0, (int)resource.Length);

View File

@ -399,7 +399,7 @@ private IEnumerable<ushort> GetRubyValues(string ruby)
Convert.ToUInt16(3 + baseText1.Length + rubyText.Length),
KEY_TEXTRUBY,
Convert.ToUInt16(baseText1.Length),
Convert.ToUInt16(rubyText.Length)
Convert.ToUInt16(rubyText.Length),
};
vals.AddRange(baseText1.Select(val => Convert.ToUInt16(TryRemapChar(val))));
vals.AddRange(rubyText.Select(val => Convert.ToUInt16(TryRemapChar(val))));

View File

@ -16,7 +16,7 @@ private TextVariableCode(int code, string name)
public static TextVariableCode[] GetVariables(GameVersion game)
{
if (game == GameVersion.Any)
return Array.Empty<TextVariableCode>();
return [];
if (GameVersion.GG.Contains(game))
return GG;
@ -27,7 +27,7 @@ public static TextVariableCode[] GetVariables(GameVersion game)
if (GameVersion.SM.Contains(game) || GameVersion.USUM.Contains(game))
return SM;
return Array.Empty<TextVariableCode>();
return [];
}
private static readonly TextVariableCode[] XY =

View File

@ -30,7 +30,7 @@ public static T[] GetArray<T>(byte[][] entries, Func<byte[], T> del, int size)
public static T[] GetArray<T>(this byte[] entries, Func<byte[], int, T> del, int size)
{
if (entries.Length < size)
return Array.Empty<T>();
return [];
var data = new T[entries.Length / size];
for (int i = 0; i < entries.Length; i += size)
@ -41,7 +41,7 @@ public static T[] GetArray<T>(this byte[] entries, Func<byte[], int, T> del, int
public static T[] GetArray<T>(this byte[] entries, Func<byte[], T> del, int size)
{
if (entries == null || entries.Length < size)
return Array.Empty<T>();
return [];
var data = new T[entries.Length / size];
for (int i = 0; i < entries.Length; i += size)
@ -57,7 +57,7 @@ public static T[] GetArray<T>(this byte[] entries, Func<byte[], T> del, int size
public static T[] GetArray<T>(this ReadOnlySpan<byte> entries, FromBytesConstructor<T> constructor, int size)
{
if (entries.Length < size)
return Array.Empty<T>();
return [];
Debug.Assert(entries.Length % size == 0, "This data can't be split into equally sized entries with the provided slice size");
@ -80,7 +80,7 @@ public static T[] GetArray<T>(this Task<byte[][]> task, Func<byte[], T> del)
public static string[] GetHexLines(byte[] data, int count = 4)
{
if (data == null)
return Array.Empty<string>();
return [];
// Generates an x-byte wide space separated string array; leftovers included at the end.
string[] s = new string[(data.Length / count) + (data.Length % count > 0 ? 1 : 0)];

View File

@ -9,7 +9,7 @@ public abstract class TrData6 : TrainerData
public bool HasMoves { get => (Format & 2) == 2; set => Format = (ushort)((Format & ~2) | (value ? 2 : 0)); }
protected TrData6(byte[] trData, byte[] trPoke) : base(trData) => Team = GetTeam(trPoke);
protected TrData6(byte[] trData) : base(trData) => Team = Array.Empty<TrPoke6>();
protected TrData6(byte[] trData) : base(trData) => Team = [];
public TrPoke6[] Team { get; set; }
@ -19,7 +19,7 @@ public abstract class TrData6 : TrainerData
public static byte[] WriteTeam(TrPoke6[] team, bool HasItem, bool HasMoves)
{
if (team.Length == 0)
return Array.Empty<byte>();
return [];
var first = team[0].Write(HasItem, HasMoves);
byte[] result = new byte[first.Length * team.Length];
first.CopyTo(result, 0);

View File

@ -1,22 +1,21 @@
using System;
using Xunit;
namespace SharpFileSystem.Tests
namespace SharpFileSystem.Tests;
public static class EAssert
{
public static class EAssert
public static void Throws<T>(Action a)
where T : Exception
{
public static void Throws<T>(Action a)
where T : Exception
try
{
try
{
a();
}
catch (T)
{
return;
}
Assert.False(true, $"The exception '{typeof(T).FullName}' was not thrown.");
a();
}
catch (T)
{
return;
}
Assert.Fail($"The exception '{typeof(T).FullName}' was not thrown.");
}
}

View File

@ -63,7 +63,6 @@ public void IsRootTest()
[Fact]
public void IsFileTest()
{
Assert.True(fileA.IsFile);
Assert.False(directoryA.IsFile);
Assert.False(root.IsFile);
@ -224,7 +223,6 @@ public void GetDirectorySegmentsTest()
Files.All(f => f.GetDirectorySegments().Count() == f.ParentPath.GetDirectorySegments().Count());
}
/// <summary>
///A test for CompareTo
///</summary>

View File

@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using pkNX.Containers.VFS;
using Xunit;
@ -9,14 +8,14 @@ namespace pkNX.Tests;
public class PhysicalFSTests : IDisposable
{
string Root { get; set; }
PhysicalFileSystem FileSystem { get; set; }
private string Root { get; set; }
private PhysicalFileSystem FileSystem { get; set; }
string AbsFilePath_W { get; set; }
string AbsFilePath_R { get; set; }
private string AbsFilePath_W { get; set; }
private string AbsFilePath_R { get; set; }
FileSystemPath FilePath_W { get; }
FileSystemPath FilePath_R { get; }
private FileSystemPath FilePath_W { get; }
private FileSystemPath FilePath_R { get; }
public PhysicalFSTests()
{
@ -100,14 +99,14 @@ public void CreateFile_Exists()
[Fact]
public void CreateFile_Empty()
{
using (var stream = FileSystem.CreateFile(FilePath_W))
using (_ = FileSystem.CreateFile(FilePath_W))
{
}
Assert.Equal(Array.Empty<byte>(), File.ReadAllBytes(AbsFilePath_W));
Assert.Equal([], File.ReadAllBytes(AbsFilePath_W));
using (var stream = FileSystem.OpenFile(FilePath_W))
{
Assert.Equal(Array.Empty<byte>(), stream.ReadAllBytes());
Assert.Equal([], stream.ReadAllBytes());
}
}
@ -234,7 +233,6 @@ public void OpenFile_CreateNew_Throws()
Assert.Throws<ArgumentException>(() => { using var _ = FileSystem.OpenFile(FilePath_W, FileMode.CreateNew, FileAccess.Read); });
}
[Fact]
public void OpenFile_Create()
{

View File

@ -93,7 +93,7 @@ private void UpdateRowImage(int row)
}
private IList<EncounterSlot>? Slots;
public static string[] SpeciesNames { private get; set; } = Array.Empty<string>();
public static string[] SpeciesNames { private get; set; } = [];
public void LoadSlots(IList<EncounterSlot> slots)
{

View File

@ -9,7 +9,7 @@ namespace pkNX.WinForms;
public partial class EncounterList8 : UserControl
{
private IList<EncounterSlot>? Slots;
public static string[] SpeciesNames { private get; set; } = Array.Empty<string>();
public static string[] SpeciesNames { private get; set; } = [];
private const string FormColumn = nameof(FormColumn);
public EncounterList8() => InitializeComponent();

View File

@ -23,7 +23,7 @@ public partial class EvolutionEntry : INotifyPropertyChanged
public static readonly DependencyProperty FormProperty = DependencyProperty.Register(nameof(Form), typeof(int), typeof(EvolutionEntry), new PropertyMetadata(0, OnSpeciesChanged));
public static readonly DependencyProperty LevelProperty = DependencyProperty.Register(nameof(Level), typeof(ushort), typeof(EvolutionEntry), new PropertyMetadata((ushort)0));
public string[] MethodArgumentList { get; set; } = Array.Empty<string>();
public string[] MethodArgumentList { get; set; } = [];
public int Method
{
get => (int)GetValue(MethodProperty);

View File

@ -67,10 +67,10 @@ public void SaveEvolution()
evo.Argument = (ushort)CB_Arg.SelectedIndex;
}
public static string[] items = Array.Empty<string>();
public static string[] movelist = Array.Empty<string>();
public static string[] species = Array.Empty<string>();
public static string[] types = Array.Empty<string>();
public static string[] items = [];
public static string[] movelist = [];
public static string[] species = [];
public static string[] types = [];
private static readonly string[] EvoMethods = Enum.GetNames(typeof(EvolutionType));
private static readonly string[] Levels = Enumerable.Range(0, 100 + 1).Select(z => z.ToString()).ToArray();

View File

@ -9,10 +9,10 @@ namespace pkNX.WinForms;
public partial class EvolutionRow8a : UserControl
{
public static string[] items = Array.Empty<string>();
public static string[] movelist = Array.Empty<string>();
public static string[] species = Array.Empty<string>();
public static string[] types = Array.Empty<string>();
public static string[] items = [];
public static string[] movelist = [];
public static string[] species = [];
public static string[] types = [];
private static readonly string[] EvoMethods = Enum.GetNames(typeof(EvolutionType));
private static readonly string[] Levels = Enumerable.Range(0, 100 + 1).Select(z => z.ToString()).ToArray();

View File

@ -8,7 +8,7 @@ namespace pkNX.WinForms;
public partial class MegaEvoEntry : UserControl
{
public static string[] items = Array.Empty<string>();
public static string[] items = [];
private static readonly string[] EvoMethods = Enum.GetNames(typeof(MegaEvolutionMethod));

View File

@ -115,7 +115,7 @@ public void DumpPokeInfo()
private void DumpMoveUsers(IPersonalTable pt, Learnset lr)
{
List<string> Users = new();
List<string> Users = [];
var moves = ROM.GetStrings(TextName.MoveNames);
var spec = ROM.GetStrings(TextName.SpeciesNames);
var shop = Legal.MoveShop8_LA;
@ -128,7 +128,7 @@ private void DumpMoveUsers(IPersonalTable pt, Learnset lr)
var filtered = learn.Where(z => ((IPersonalInfoPLA)pt.GetFormEntry(z.Species, (byte)z.Form)).IsPresentInGame);
var result = filtered.Select(x => GetSpeciesMove(spec, x, move)).ToArray();
List<string> r = new() { $"{moves[move]}:" };
List<string> r = [$"{moves[move]}:"];
if (isShop)
{
var species = pt.Table.OfType<IPersonalInfoPLA>().Where(z => z.SpecialTutors[shopIndex] && z.IsPresentInGame);
@ -304,7 +304,7 @@ public void DumpLearnsetBinary()
var result = new byte[pt.Table.Length][];
var mastery = new byte[pt.Table.Length][];
for (int i = 0; i < result.Length; i++)
result[i] = mastery[i] = Array.Empty<byte>();
result[i] = mastery[i] = [];
var Dupes = new List<(int Species, int Form)>();
foreach (var e in obj.Table)
@ -349,7 +349,7 @@ public void DumpEvolutionBinary()
var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats));
var result = new byte[pt.Table.Length][];
for (int i = 0; i < result.Length; i++)
result[i] = Array.Empty<byte>();
result[i] = [];
foreach (var e in obj.Table)
{
@ -773,7 +773,7 @@ public void DumpOutbreak()
File.WriteAllText(GetPath("massOutbreak.txt"), result);
var arr = FlatBufferConverter.DeserializeFrom<MassOutbreakTable>(file!).Table;
var cache = new DataCache<MassOutbreak>(arr);
var cache = new DataCache<MassOutbreak>(arr!);
var names = Enumerable.Range(0, cache.Length).Select(z => $"{z}").ToArray();
var form = new GenericEditor<MassOutbreak>(cache, names, "Outbreak");
form.ShowDialog();
@ -799,7 +799,7 @@ private void DumpResearchTasks(PokedexResearchTable dexResearch)
var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats));
var result = new byte[pt.Table.Max(p => p.DexIndexRegional)][];
for (int i = 0; i < result.Length; i++)
result[i] = Array.Empty<byte>();
result[i] = [];
ushort GetDexIndex(ushort species)
{

View File

@ -138,8 +138,8 @@ private void RipLanguage(TextConfig textConfig, string type, string lang, string
var prefix = $"messagedat{lang}";
const string suffix = ".trpak";
var pattern = $"{prefix}*{suffix}";
List<(string File, string[] Lines)> text = new();
List<(string File, string[] Lines)> full = new();
List<(string File, string[] Lines)> text = [];
List<(string File, string[] Lines)> full = [];
var folders = Directory.EnumerateDirectories(arcPath, pattern, SearchOption.TopDirectoryOnly);
foreach (var folder in folders)
{
@ -253,7 +253,7 @@ public void DumpPersonal()
var evos = SerializeEvolutionPickle(pt);
File.WriteAllBytes(GetPath("pkhex", "evos_sv.pkl"), MiniUtil.PackMini(evos, "sv"));
List<(ushort Internal, ushort National)> map = new();
List<(ushort Internal, ushort National)> map = [];
for (ushort i = 0; i <= (ushort)DevID.DEV_MATCHA2; i++)
{
var pi = pt[i];
@ -335,7 +335,7 @@ private static byte[][] SerializeU16Pickle(PersonalTable9SV pt, Func<PersonalInf
{
var p = t[i].FB;
if (!p.IsPresentInGame)
result[i] = Array.Empty<byte>();
result[i] = [];
else
result[i] = Write(sel(p));
}
@ -362,7 +362,7 @@ private static byte[][] SerializeEvolutionPickle(PersonalTable9SV pt)
static byte[] GetPickle(PersonalInfo9SV e)
{
if (!e.IsPresentInGame)
return Array.Empty<byte>();
return [];
return Write(e.FB.Info.SpeciesNational, e.FB.Evolutions);
}

View File

@ -14,9 +14,9 @@ namespace pkNX.WinForms;
public static class MassOutbreakRipper
{
private static readonly List<PickledOutbreak> Encounters = new();
private static readonly List<PickledOutbreak> Encounters = [];
private static int EncounterIndex;
private static Dictionary<string, (string Name, int Index)> NameDict = new();
private static Dictionary<string, (string Name, int Index)> NameDict = [];
public static void DumpDeliveryOutbreaks(IFileInternal ROM, string path, string dump)
{
@ -369,7 +369,7 @@ private class CachedOutbreak
public required DeliveryOutbreakPokeData Poke { get; init; }
public byte MetBase { get; set; }
public readonly Dictionary<LevelRange, UInt128> MetInfo = new();
public readonly Dictionary<LevelRange, UInt128> MetInfo = [];
}
private static CachedOutbreak[] GetMetaEncounter(IEnumerable<DeliveryOutbreak> possibleTable, DeliveryOutbreakPokeDataArray pd)

View File

@ -94,7 +94,7 @@ public class EncounterDumperSV
}
// Fixed symbols
List<byte[]> serialized = new();
List<byte[]> serialized = [];
var fsymData = FlatBufferConverter.DeserializeFrom<FixedSymbolTableArray>(ROM.GetPackedFile("world/data/field/fixed_symbol/fixed_symbol_table/fixed_symbol_table_array.bin"));
var eventBattle = FlatBufferConverter.DeserializeFrom<EventBattlePokemonArray>(ROM.GetPackedFile("world/data/battle/eventBattlePokemon/eventBattlePokemon_array.bin"));
foreach (var (game, gamePoints) in new[] { ("sl", fsym.scarletPoints), ("vl", fsym.violetPoints) })

View File

@ -5,7 +5,7 @@ namespace pkNX.Structures.FlatBuffers;
public class LocationDatabase
{
public readonly Dictionary<int, LocationStorage> Locations = new();
public readonly Dictionary<int, LocationStorage> Locations = [];
public LocationStorage Get(int location, PaldeaFieldIndex fieldIndex, string areaName, AreaInfo areaInfo)
{

Some files were not shown because too many files have changed in this diff Show More