From 5b571cbb87be5ea0e63455dd9fd136714067c665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Thu, 5 Jan 2023 21:30:09 +0100 Subject: [PATCH] feat(data): add equipment and item type --- .../Enums/EquipmentSlot.cs | 35 ++++++++++++++ .../Enums/ItemType.cs | 48 +++++++++++++++++++ .../Infos/IItemInfo.cs | 9 +++- .../NosSmooth.Data.Abstractions.csproj | 6 ++- Data/NosSmooth.Data.Database/Data/ItemInfo.cs | 5 +- .../DatabaseMigrator.cs | 1 + .../NosSmooth.Data.Database.csproj | 4 +- .../NosSmooth.Data.NOSFiles.csproj | 8 ++-- .../Parsers/ItemParser.cs | 36 ++++++++++++-- 9 files changed, 139 insertions(+), 13 deletions(-) create mode 100644 Data/NosSmooth.Data.Abstractions/Enums/EquipmentSlot.cs create mode 100644 Data/NosSmooth.Data.Abstractions/Enums/ItemType.cs diff --git a/Data/NosSmooth.Data.Abstractions/Enums/EquipmentSlot.cs b/Data/NosSmooth.Data.Abstractions/Enums/EquipmentSlot.cs new file mode 100644 index 0000000000000000000000000000000000000000..51b82948dcfdfa710208102866d00dd3b7dccc15 --- /dev/null +++ b/Data/NosSmooth.Data.Abstractions/Enums/EquipmentSlot.cs @@ -0,0 +1,35 @@ +// +// EquipmentSlot.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; +#pragma warning disable CS1591 + +namespace NosSmooth.Data.Abstractions.Enums; + +/// +/// An equipment slot that wearable item goes to. +/// +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Self-explanatory.")] +public enum EquipmentSlot +{ + MainWeapon = 0, + Armor = 1, + Hat = 2, + Gloves = 3, + Boots = 4, + SecondaryWeapon = 5, + Necklace = 6, + Ring = 7, + Bracelet = 8, + Mask = 9, + Fairy = 10, + Amulet = 11, + Sp = 12, + CostumeSuit = 13, + CostumeHat = 14, + WeaponSkin = 15, + Wings = 16 +} \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Enums/ItemType.cs b/Data/NosSmooth.Data.Abstractions/Enums/ItemType.cs new file mode 100644 index 0000000000000000000000000000000000000000..4f807ab7fb3baa511190fb1cded7d6825e165d1b --- /dev/null +++ b/Data/NosSmooth.Data.Abstractions/Enums/ItemType.cs @@ -0,0 +1,48 @@ +// +// ItemType.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; +#pragma warning disable CS1591 + +namespace NosSmooth.Data.Abstractions.Enums; + +/// +/// Type of an item. +/// +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Self-explanatory.")] +public enum ItemType +{ + None = -1, + Weapon = 0, + Armor = 1, + Fashion = 2, + Jewelery = 3, + Specialist = 4, + Box = 5, + Shell = 6, + Main = 10, + Upgrade = 11, + Production = 12, + Map = 13, + Special = 14, + Potion = 15, + Event = 16, + Title = 17, + Quest1 = 18, + Sell = 20, + Food = 21, + Snack = 22, + Magical = 24, + Part = 25, + Teacher = 26, + Ammo = 27, + Quest2 = 28, + House = 30, + Garden = 31, + Minigame = 32, + Terrace = 33, + MinilandTheme = 34 +} \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Infos/IItemInfo.cs b/Data/NosSmooth.Data.Abstractions/Infos/IItemInfo.cs index 7828fbd295269cd67eb24ea4d6f7616e84719ea2..d3138c1f30955904799734ed8b396f7b9730ce2f 100644 --- a/Data/NosSmooth.Data.Abstractions/Infos/IItemInfo.cs +++ b/Data/NosSmooth.Data.Abstractions/Infos/IItemInfo.cs @@ -20,15 +20,20 @@ public interface IItemInfo : IVNumInfo TranslatableString Name { get; } /// - /// Gets the type of the item. TODO UNKNOWN. + /// Gets the type of the item. /// - int Type { get; } + ItemType Type { get; } /// /// Gets the subtype of the item. TODO UNKNOWN. /// int SubType { get; } + /// + /// Gets the equipment slot the item goes to, if any. + /// + EquipmentSlot? EquipmentSlot { get; } + /// /// Gets the bag the item belongs to. /// diff --git a/Data/NosSmooth.Data.Abstractions/NosSmooth.Data.Abstractions.csproj b/Data/NosSmooth.Data.Abstractions/NosSmooth.Data.Abstractions.csproj index cf8c6e4bf1cafe82219c96ed1cb559b99850d072..541fe716fd3c41b8985b8504a5ce27b65696f88c 100644 --- a/Data/NosSmooth.Data.Abstractions/NosSmooth.Data.Abstractions.csproj +++ b/Data/NosSmooth.Data.Abstractions/NosSmooth.Data.Abstractions.csproj @@ -7,9 +7,11 @@ 10 https://github.com/Rutherther/NosSmooth/ MIT - 2.0.0 + 2.1.0 net7.0 - Make Monster level ushort + Add item type and equipment slot enums. + 2.1.0 + 2.1.0 diff --git a/Data/NosSmooth.Data.Database/Data/ItemInfo.cs b/Data/NosSmooth.Data.Database/Data/ItemInfo.cs index 7a2c3fbe3a30129766d47a766c17da73465fde50..3af10c6f37e2b1b89a00850bd40531233ad9150d 100644 --- a/Data/NosSmooth.Data.Database/Data/ItemInfo.cs +++ b/Data/NosSmooth.Data.Database/Data/ItemInfo.cs @@ -40,11 +40,14 @@ public class ItemInfo : IItemInfo public TranslatableString Name { get; set; } /// - public int Type { get; set; } + public ItemType Type { get; set; } /// public int SubType { get; set; } + /// + public EquipmentSlot? EquipmentSlot { get; set; } + /// public BagType BagType { get; set; } diff --git a/Data/NosSmooth.Data.Database/DatabaseMigrator.cs b/Data/NosSmooth.Data.Database/DatabaseMigrator.cs index 170fe18f1a8c8c9e83156b59f812011d406cdbf7..e281aa18146a6cc2a5a22f09ded2ffb5e5c192a1 100644 --- a/Data/NosSmooth.Data.Database/DatabaseMigrator.cs +++ b/Data/NosSmooth.Data.Database/DatabaseMigrator.cs @@ -113,6 +113,7 @@ public class DatabaseMigrator { BagType = item.BagType, Data = item.Data, + EquipmentSlot = item.EquipmentSlot, NameKey = item.Name.Key, SubType = item.SubType, Type = item.Type, diff --git a/Data/NosSmooth.Data.Database/NosSmooth.Data.Database.csproj b/Data/NosSmooth.Data.Database/NosSmooth.Data.Database.csproj index c06821b71fe255a5aaa76a66a8fbf2f9666226fb..e7d4d035b85935242d0d07e92f54063c4b23b0ea 100644 --- a/Data/NosSmooth.Data.Database/NosSmooth.Data.Database.csproj +++ b/Data/NosSmooth.Data.Database/NosSmooth.Data.Database.csproj @@ -7,9 +7,11 @@ 10 https://github.com/Rutherther/NosSmooth/ MIT - 2.0.0 + 2.0.1 net7.0 Make Monster level ushort + 2.0.1 + 2.0.1 diff --git a/Data/NosSmooth.Data.NOSFiles/NosSmooth.Data.NOSFiles.csproj b/Data/NosSmooth.Data.NOSFiles/NosSmooth.Data.NOSFiles.csproj index 77deeec478f20f74e990778070edc85653002010..b92c56b01bf9025ef3349c09c02981b10bbaaf2e 100644 --- a/Data/NosSmooth.Data.NOSFiles/NosSmooth.Data.NOSFiles.csproj +++ b/Data/NosSmooth.Data.NOSFiles/NosSmooth.Data.NOSFiles.csproj @@ -7,11 +7,11 @@ 10 https://github.com/Rutherther/NosSmooth/ MIT - 2.0.2 - Correct skill mp cost position + 2.1.0 + Make correct parsing of item bag, type, equipment slot net7.0 - 2.0.2 - 2.0.2 + 2.1.0 + 2.1.0 diff --git a/Data/NosSmooth.Data.NOSFiles/Parsers/ItemParser.cs b/Data/NosSmooth.Data.NOSFiles/Parsers/ItemParser.cs index 71091af229a7cb655bcde249d96284b4a394e0b4..3a47ee2489b627a35e41980fabbfd9b11e055679 100644 --- a/Data/NosSmooth.Data.NOSFiles/Parsers/ItemParser.cs +++ b/Data/NosSmooth.Data.NOSFiles/Parsers/ItemParser.cs @@ -33,6 +33,34 @@ public class ItemParser : IInfoParser var vnum = item.GetEntry("VNUM").Read(1); var nameKey = item.GetEntry("NAME").Read(1); + + var bagTypeData = item.GetEntry("INDEX").Read(1); + var bagType = bagTypeData switch + { + 4 or 8 => BagType.Equipment, + 9 => BagType.Main, + 10 => BagType.Etc, + _ => (BagType)bagTypeData + }; + + var itemTypeData = indexEntry.Read(2); + var itemType = itemTypeData switch + { + -1 => ItemType.None, + _ => Enum.Parse($"{(int)bagType}{itemTypeData}") + }; + + var equipmentSlotData = indexEntry.Read(4); + EquipmentSlot? equipmentSlot = null; + if (bagType is BagType.Equipment && equipmentSlotData != -1) + { + equipmentSlot = (EquipmentSlot)equipmentSlotData; + } + else if (bagType is BagType.Specialist) + { + equipmentSlot = EquipmentSlot.Sp; + } + result.Add ( vnum, @@ -40,9 +68,10 @@ public class ItemParser : IInfoParser ( vnum, new TranslatableString(TranslationRoot.Item, nameKey), - indexEntry.Read(2), + itemType, indexEntry.Read(3), - (BagType)indexEntry.Read(1), + equipmentSlot, + bagType, item.GetEntry("DATA").GetValues() ) ); @@ -55,8 +84,9 @@ public class ItemParser : IInfoParser ( int VNum, TranslatableString Name, - int Type, + ItemType Type, int SubType, + EquipmentSlot? EquipmentSlot, BagType BagType, string[] Data )