From f40377a1d3beb648f883ce6b553279711ea8f46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 29 Jan 2022 19:04:01 +0100 Subject: [PATCH] feat(data): add correct information into infos --- .../Enums/BagType.cs | 24 +++++++++ .../Enums/HitType.cs | 36 +++++++++++++ .../Enums/SkillType.cs | 43 +++++++++++++++ .../Enums/TargetType.cs | 33 ++++++++++++ .../IInfoService.cs | 17 ++---- .../Infos/ICardInfo.cs | 14 ----- .../Infos/IItemInfo.cs | 27 ++++++++++ .../Infos/IMapInfo.cs | 14 ++++- .../Infos/IMonsterInfo.cs | 11 ++++ .../Infos/ISkillInfo.cs | 54 ++++++++++++++++++- .../Infos/IVNumInfo.cs | 2 +- .../Language/LanguageKey.cs | 36 ------------- .../Files/FileArchive.cs | 25 ++++++++- 13 files changed, 270 insertions(+), 66 deletions(-) create mode 100644 Data/NosSmooth.Data.Abstractions/Enums/BagType.cs create mode 100644 Data/NosSmooth.Data.Abstractions/Enums/HitType.cs create mode 100644 Data/NosSmooth.Data.Abstractions/Enums/SkillType.cs create mode 100644 Data/NosSmooth.Data.Abstractions/Enums/TargetType.cs delete mode 100644 Data/NosSmooth.Data.Abstractions/Infos/ICardInfo.cs delete mode 100644 Data/NosSmooth.Data.Abstractions/Language/LanguageKey.cs diff --git a/Data/NosSmooth.Data.Abstractions/Enums/BagType.cs b/Data/NosSmooth.Data.Abstractions/Enums/BagType.cs new file mode 100644 index 0000000..f8729a3 --- /dev/null +++ b/Data/NosSmooth.Data.Abstractions/Enums/BagType.cs @@ -0,0 +1,24 @@ +// +// BagType.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; + +/// +/// The type of a bag the item belongs to. +/// +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Self-explanatory.")] +public enum BagType +{ + Equipment = 0, + Main = 1, + Etc = 2, + Miniland = 3, + Specialist = 6, + Costume = 7 +} \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Enums/HitType.cs b/Data/NosSmooth.Data.Abstractions/Enums/HitType.cs new file mode 100644 index 0000000..5e658d7 --- /dev/null +++ b/Data/NosSmooth.Data.Abstractions/Enums/HitType.cs @@ -0,0 +1,36 @@ +// +// HitType.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. + +namespace NosSmooth.Data.Abstractions.Enums; + +/// +/// A hit type of a skill. +/// +public enum HitType +{ + /// + /// The skill is for just one target. + /// + TargetOnly, + + /// + /// The skill will hit enemies in a zone. + /// + /// + /// Can be AOE skill or a targeted skill that targets more enemies. + /// + EnemiesInZone, + + /// + /// The skill will hit allies in a zone, this is a buff. + /// + AlliesInZone, + + /// + /// UNKNOWN TODO. + /// + SpecialArea +} \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Enums/SkillType.cs b/Data/NosSmooth.Data.Abstractions/Enums/SkillType.cs new file mode 100644 index 0000000..516d23b --- /dev/null +++ b/Data/NosSmooth.Data.Abstractions/Enums/SkillType.cs @@ -0,0 +1,43 @@ +// +// SkillType.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. + +namespace NosSmooth.Data.Abstractions.Enums; + +/// +/// A type of a skill. +/// +public enum SkillType +{ + /// + /// The skill is a passive, used automatically. + /// + Passive, + + /// + /// The skill is for players. + /// + Player, + + /// + /// UNKNOWN TODO. + /// + Upgrade, + + /// + /// Unknown TODO. + /// + Emote, + + /// + /// The skill is for monsters. + /// + Monster, + + /// + /// The skill is for partners. + /// + Partner +} \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Enums/TargetType.cs b/Data/NosSmooth.Data.Abstractions/Enums/TargetType.cs new file mode 100644 index 0000000..6424b84 --- /dev/null +++ b/Data/NosSmooth.Data.Abstractions/Enums/TargetType.cs @@ -0,0 +1,33 @@ +// +// TargetType.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. + +namespace NosSmooth.Data.Abstractions.Enums; + +/// +/// Type of a target of a skill. +/// +public enum TargetType +{ + /// + /// The skill has a (enemy) target. + /// + Target, + + /// + /// The skill can be targeted only on self. + /// + Self, + + /// + /// The skill can be targeted on self or a (enemy) target. + /// + SelfOrTarget, + + /// + /// The skill has no target. UNKNOWN TODO. + /// + NoTarget +} \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/IInfoService.cs b/Data/NosSmooth.Data.Abstractions/IInfoService.cs index 5bfe5ed..82627f3 100644 --- a/Data/NosSmooth.Data.Abstractions/IInfoService.cs +++ b/Data/NosSmooth.Data.Abstractions/IInfoService.cs @@ -19,33 +19,26 @@ public interface IInfoService /// /// The vnum identifier of the item. /// An item info or an error. - public Result GetItemInfo(long vnum); + public Result GetItemInfo(int vnum); /// /// Gets the information about a map. /// - /// The vnum identifier of the map. + /// The identifier of the map. /// A map info or an error. - public Result GetMapInfo(long vnum); + public Result GetMapInfo(int id); /// /// Gets the information about a monster. /// /// The vnum identifier of the monster. /// A monster or an error. - public Result GetMonsterInfo(long vnum); + public Result GetMonsterInfo(int vnum); /// /// Gets the information about a skill. /// /// The vnum identifier of the skill. /// A map or an error. - public Result GetSkillInfo(long vnum); - - /// - /// Gets the information about a card. - /// - /// The vnum identifier of the card. - /// A card or an error. - public Result GetCardInfo(long vnum); + public Result GetSkillInfo(int vnum); } \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Infos/ICardInfo.cs b/Data/NosSmooth.Data.Abstractions/Infos/ICardInfo.cs deleted file mode 100644 index c3bd95d..0000000 --- a/Data/NosSmooth.Data.Abstractions/Infos/ICardInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -// -// ICardInfo.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. - -namespace NosSmooth.Data.Abstractions.Infos; - -/// -/// The NosTale card information. -/// -public interface ICardInfo : IVNumInfo -{ -} \ 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 3e463a0..7828fbd 100644 --- a/Data/NosSmooth.Data.Abstractions/Infos/IItemInfo.cs +++ b/Data/NosSmooth.Data.Abstractions/Infos/IItemInfo.cs @@ -4,6 +4,9 @@ // 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 NosSmooth.Data.Abstractions.Enums; +using NosSmooth.Data.Abstractions.Language; + namespace NosSmooth.Data.Abstractions.Infos; /// @@ -11,4 +14,28 @@ namespace NosSmooth.Data.Abstractions.Infos; /// public interface IItemInfo : IVNumInfo { + /// + /// Gets the translatable name of the item. + /// + TranslatableString Name { get; } + + /// + /// Gets the type of the item. TODO UNKNOWN. + /// + int Type { get; } + + /// + /// Gets the subtype of the item. TODO UNKNOWN. + /// + int SubType { get; } + + /// + /// Gets the bag the item belongs to. + /// + BagType BagType { get; } + + /// + /// Gets the data of the item. + /// + string[] Data { get; } } \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Infos/IMapInfo.cs b/Data/NosSmooth.Data.Abstractions/Infos/IMapInfo.cs index a6265f3..203cd86 100644 --- a/Data/NosSmooth.Data.Abstractions/Infos/IMapInfo.cs +++ b/Data/NosSmooth.Data.Abstractions/Infos/IMapInfo.cs @@ -4,13 +4,25 @@ // 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 NosSmooth.Data.Abstractions.Language; + namespace NosSmooth.Data.Abstractions.Infos; /// /// The NosTale map information. /// -public interface IMapInfo : IVNumInfo +public interface IMapInfo { + /// + /// Gets the Id of the map. + /// + public int Id { get; } + + /// + /// Gets the translatable name of the map. + /// + public TranslatableString Name { get; } + /// /// Gets the width of the grid. /// diff --git a/Data/NosSmooth.Data.Abstractions/Infos/IMonsterInfo.cs b/Data/NosSmooth.Data.Abstractions/Infos/IMonsterInfo.cs index 7dd1f60..55735ab 100644 --- a/Data/NosSmooth.Data.Abstractions/Infos/IMonsterInfo.cs +++ b/Data/NosSmooth.Data.Abstractions/Infos/IMonsterInfo.cs @@ -4,6 +4,8 @@ // 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 NosSmooth.Data.Abstractions.Language; + namespace NosSmooth.Data.Abstractions.Infos; /// @@ -11,4 +13,13 @@ namespace NosSmooth.Data.Abstractions.Infos; /// public interface IMonsterInfo : IVNumInfo { + /// + /// Gets the name of the monster. + /// + TranslatableString Name { get; } + + /// + /// Gets the default level of the monster. + /// + int Level { get; } } \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Infos/ISkillInfo.cs b/Data/NosSmooth.Data.Abstractions/Infos/ISkillInfo.cs index 82ac8ae..496ea5f 100644 --- a/Data/NosSmooth.Data.Abstractions/Infos/ISkillInfo.cs +++ b/Data/NosSmooth.Data.Abstractions/Infos/ISkillInfo.cs @@ -4,11 +4,63 @@ // 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 NosSmooth.Data.Abstractions.Enums; +using NosSmooth.Data.Abstractions.Language; + namespace NosSmooth.Data.Abstractions.Infos; /// /// The NosTale skill information. /// -public interface ISkillInfo +public interface ISkillInfo : IVNumInfo { + /// + /// Gets the translatable name of the skill. + /// + TranslatableString Name { get; } + + /// + /// Gets the tile range of the skill. + /// + short Range { get; } + + /// + /// Gets the zone tiles range. + /// + short ZoneRange { get; } + + /// + /// Gets the time it takes to cast this skill. Units UNKNOWN TODO. + /// + int CastTime { get; } + + /// + /// Gets the time of the cooldown. Units UNKNOWN TODO. + /// + int Cooldown { get; } + + /// + /// Gets the type of the skill. + /// + SkillType SkillType { get; } + + /// + /// Gets the mana points the skill cast costs. + /// + int MpCost { get; } + + /// + /// Gets the cast id of the skill used in u_s, su packets. + /// + short CastId { get; } + + /// + /// Gets the type of the target. + /// + TargetType TargetType { get; } + + /// + /// Gets the hit type of the skill. + /// + HitType HitType { get; } } \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Infos/IVNumInfo.cs b/Data/NosSmooth.Data.Abstractions/Infos/IVNumInfo.cs index cddfd92..0fe0c9b 100644 --- a/Data/NosSmooth.Data.Abstractions/Infos/IVNumInfo.cs +++ b/Data/NosSmooth.Data.Abstractions/Infos/IVNumInfo.cs @@ -14,5 +14,5 @@ public interface IVNumInfo /// /// Gets the VNum of the info entry. /// - public long VNum { get; } + public int VNum { get; } } \ No newline at end of file diff --git a/Data/NosSmooth.Data.Abstractions/Language/LanguageKey.cs b/Data/NosSmooth.Data.Abstractions/Language/LanguageKey.cs deleted file mode 100644 index cc8c77e..0000000 --- a/Data/NosSmooth.Data.Abstractions/Language/LanguageKey.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// LanguageKey.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. - -namespace NosSmooth.Data.Abstractions.Language; - -/// -/// Key for language translation. -/// -public struct LanguageKey -{ - /// - /// Initializes a new instance of the struct. - /// - /// The key num. - public LanguageKey(long key) - : this($"zts{key}e") - { - } - - /// - /// Initializes a new instance of the struct. - /// - /// The key. - public LanguageKey(string key) - { - Key = key; - } - - /// - /// Gets the key. - /// - public string Key { get; } -} \ No newline at end of file diff --git a/Data/NosSmooth.Data.NOSFiles/Files/FileArchive.cs b/Data/NosSmooth.Data.NOSFiles/Files/FileArchive.cs index 4382957..58090b9 100644 --- a/Data/NosSmooth.Data.NOSFiles/Files/FileArchive.cs +++ b/Data/NosSmooth.Data.NOSFiles/Files/FileArchive.cs @@ -4,6 +4,29 @@ // 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 Remora.Results; + namespace NosSmooth.Data.NOSFiles.Files; -public record FileArchive(IReadOnlyList Files); \ No newline at end of file +/// +/// An archive of files. +/// +/// The files in the archive. +public record FileArchive(IReadOnlyList Files) +{ + /// + /// Try to find the given file. + /// + /// The name of the file. + /// A file or an error. + public Result Search(string name) + { + var foundFile = Files.OfType().FirstOrDefault(x => Path.GetFileName((RawFile)x.Path) == name, null); + if (foundFile is null) + { + return new NotFoundError(); + } + + return (RawFile)foundFile; + } +} \ No newline at end of file -- 2.49.0