From dc9f96fb19f67bd47872affeac7ee239dc77f5d3 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Sat, 25 Nov 2023 14:23:16 +0100 Subject: [PATCH] chore: required properties --- .../CharacterStatsMappingConfiguration.cs | 10 +++++----- .../Game/Mapping/DefaultCharacterMapping.cs | 2 +- Wonderking/Game/Mapping/JobSpecificMapping.cs | 8 +++++--- Wonderking/Game/Reader/ItemReader.cs | 2 ++ .../Incoming/CharacterCreationPacket.cs | 20 +++++++++---------- .../Outgoing/CharacterDeleteResponsePacket.cs | 4 +++- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Wonderking/Game/Mapping/CharacterStatsMappingConfiguration.cs b/Wonderking/Game/Mapping/CharacterStatsMappingConfiguration.cs index 50e7aa5..1776e04 100644 --- a/Wonderking/Game/Mapping/CharacterStatsMappingConfiguration.cs +++ b/Wonderking/Game/Mapping/CharacterStatsMappingConfiguration.cs @@ -6,12 +6,12 @@ namespace Wonderking.Game.Mapping; public class CharacterStatsMappingConfiguration { - [JsonPropertyName("default")] public DefaultCharacterMapping DefaultCharacterMapping { get; set; } - [JsonPropertyName("1")] public JobSpecificMapping Swordsman { get; set; } + [JsonPropertyName("default")] public required DefaultCharacterMapping DefaultCharacterMapping { get; set; } + [JsonPropertyName("1")] public required JobSpecificMapping Swordsman { get; set; } - [JsonPropertyName("2")] public JobSpecificMapping Mage { get; set; } + [JsonPropertyName("2")] public required JobSpecificMapping Mage { get; set; } - [JsonPropertyName("3")] public JobSpecificMapping Thief { get; set; } + [JsonPropertyName("3")] public required JobSpecificMapping Thief { get; set; } - [JsonPropertyName("4")] public JobSpecificMapping Scout { get; set; } + [JsonPropertyName("4")] public required JobSpecificMapping Scout { get; set; } } diff --git a/Wonderking/Game/Mapping/DefaultCharacterMapping.cs b/Wonderking/Game/Mapping/DefaultCharacterMapping.cs index a489cf7..e1d7ca5 100644 --- a/Wonderking/Game/Mapping/DefaultCharacterMapping.cs +++ b/Wonderking/Game/Mapping/DefaultCharacterMapping.cs @@ -6,5 +6,5 @@ namespace Wonderking.Game.Mapping; public class DefaultCharacterMapping { - [JsonPropertyName("items")] public List Items { get; set; } + [JsonPropertyName("items")] public required ICollection Items { get; set; } } diff --git a/Wonderking/Game/Mapping/JobSpecificMapping.cs b/Wonderking/Game/Mapping/JobSpecificMapping.cs index 924e3c4..df54675 100644 --- a/Wonderking/Game/Mapping/JobSpecificMapping.cs +++ b/Wonderking/Game/Mapping/JobSpecificMapping.cs @@ -1,15 +1,17 @@ // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. using System.Text.Json.Serialization; +using JetBrains.Annotations; using Wonderking.Packets.Outgoing.Data; namespace Wonderking.Game.Mapping; +[UsedImplicitly] public class JobSpecificMapping { - [JsonPropertyName("items")] public ICollection Items { get; set; } + [JsonPropertyName("items")] public required ICollection Items { get; set; } - [JsonPropertyName("baseStats")] public BaseStats BaseStats { get; set; } + [JsonPropertyName("baseStats")] public required BaseStats BaseStats { get; set; } - [JsonPropertyName("dynamicStats")] public DynamicStats DynamicStats { get; set; } + [JsonPropertyName("dynamicStats")] public required DynamicStats DynamicStats { get; set; } } diff --git a/Wonderking/Game/Reader/ItemReader.cs b/Wonderking/Game/Reader/ItemReader.cs index e61d2f1..889deb5 100644 --- a/Wonderking/Game/Reader/ItemReader.cs +++ b/Wonderking/Game/Reader/ItemReader.cs @@ -14,7 +14,9 @@ public class ItemReader(string path) : DataReader(path) return (uint)((DatFileContent.Length - 9) / SizeOfEntry); } +#pragma warning disable MA0051 public override ItemObject GetEntry(uint entryId) +#pragma warning restore MA0051 { var item = new ItemObject(); var arraySegment = new ArraySegment(DatFileContent, diff --git a/Wonderking/Packets/Incoming/CharacterCreationPacket.cs b/Wonderking/Packets/Incoming/CharacterCreationPacket.cs index dc1e00d..3560539 100644 --- a/Wonderking/Packets/Incoming/CharacterCreationPacket.cs +++ b/Wonderking/Packets/Incoming/CharacterCreationPacket.cs @@ -8,17 +8,17 @@ namespace Wonderking.Packets.Incoming; [PacketId(OperationCode.CharacterCreation)] public class CharacterCreationPacket : IPacket { - public byte Slot { get; set; } - public byte Unknown { get; set; } - public ushort Id { get; set; } + public required byte Slot { get; set; } + public required byte Unknown { get; set; } + public required ushort Id { get; set; } - public string Name { get; set; } - public byte FirstJob { get; set; } - public Gender Gender { get; set; } - public byte Hair { get; set; } - public byte Eyes { get; set; } - public byte Shirt { get; set; } - public byte Pants { get; set; } + public required string Name { get; set; } + public required byte FirstJob { get; set; } + public required Gender Gender { get; set; } + public required byte Hair { get; set; } + public required byte Eyes { get; set; } + public required byte Shirt { get; set; } + public required byte Pants { get; set; } public void Deserialize(byte[] data) { diff --git a/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs b/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs index 3a1ef56..e6226d3 100644 --- a/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs +++ b/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs @@ -1,5 +1,7 @@ // Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. +using NotSupportedException = System.NotSupportedException; + namespace Wonderking.Packets.Outgoing; [PacketId(OperationCode.CharacterDeletionResponse)] @@ -9,7 +11,7 @@ public class CharacterDeleteResponsePacket : IPacket public void Deserialize(byte[] data) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public byte[] Serialize()