From 2043a7d79fee86f80765ba9a785c09ef5aefa62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 21 Jan 2023 09:33:48 +0100 Subject: [PATCH] docs: add missing documentation --- Core/NosSmooth.Core/Contracts/IContract.cs | 4 ++-- Core/NosSmooth.Game/Data/Dialogs/Dialog.cs | 14 ++++++++++++-- Core/NosSmooth.Game/Data/Raids/RaidProgress.cs | 13 +++++++++++++ .../Errors/WrongSkillPositionError.cs | 7 +++++++ .../NosSmooth.Game/Errors/WrongSkillTypeError.cs | 10 ++++++++++ .../Events/Raids/RaidFinishedEvent.cs | 14 ++++++++++++++ .../Events/Raids/RaidJoinedEvent.cs | 4 ++++ .../Events/Raids/RaidStateChangedEvent.cs | 6 ++++++ .../Events/Ui/DialogOpenedEvent.cs | 10 ++++++++++ .../NosSmooth.Extensions.Combat/CombatManager.cs | 1 - .../Selectors/InventoryItem.cs | 5 +++++ Packets/NosSmooth.Packets/Enums/QnamlType.cs | 1 + .../NosSmooth.Packets/Server/Battle/SuPacket.cs | 2 ++ .../Server/Character/CInfoPacket.cs | 2 +- .../NosSmooth.Packets/Server/Chat/Sayi2Packet.cs | 3 ++- .../Server/Entities/StPacket.cs | 2 ++ .../NosSmooth.Packets/Server/Mates/ScNPacket.cs | 4 ++-- .../Server/Raids/RbossPacket.cs | 1 + .../Server/Raids/RdlstfPacket.cs | 3 ++- Packets/NosSmooth.Packets/Server/UI/DlgPacket.cs | 9 +++++++++ .../NosSmooth.Packets/Server/UI/DlgiPacket.cs | 7 +++++++ Packets/NosSmooth.Packets/Server/UI/QnaPacket.cs | 10 ++++++++++ .../NosSmooth.Packets/Server/UI/QnamlPacket.cs | 11 ++++++++++- .../NosSmooth.Packets/Server/UI/Qnamli2Packet.cs | 12 ++++++++++++ .../Commands/CommandProcessorTests.cs | 16 ++++++++-------- .../Commands/Walking/WalkCommandHandlerTests.cs | 12 ++++++------ .../Contracts/ContractTests.cs | 1 + .../Fakes/Commands/FakeCommand.cs | 4 ++++ Tests/NosSmooth.Game.Tests/PacketFileClient.cs | 3 +-- 29 files changed, 164 insertions(+), 27 deletions(-) diff --git a/Core/NosSmooth.Core/Contracts/IContract.cs b/Core/NosSmooth.Core/Contracts/IContract.cs index 4e3089813b9e5698613b11e04b7d658cbb0c8340..783df7e4abb8206a2c0ad9dcb16714ddcb623483 100644 --- a/Core/NosSmooth.Core/Contracts/IContract.cs +++ b/Core/NosSmooth.Core/Contracts/IContract.cs @@ -66,7 +66,7 @@ public interface IContract /// For example, to use skill, create a contract for /// using a skill and call this method. /// If you want to wait for response from the server, - /// use instead. + /// use instead. /// That will register the contract and wait for response. /// /// The cancellation token used for cancelling the operation. @@ -81,7 +81,7 @@ public interface IContract /// Could be used for operations that may end successfully or fail /// after some time, with response from the server. /// -/// Look at for example usage. +/// Look at for example usage. /// /// The data returned by the contract in case of success. /// Type containing the states of the contract. diff --git a/Core/NosSmooth.Game/Data/Dialogs/Dialog.cs b/Core/NosSmooth.Game/Data/Dialogs/Dialog.cs index f8e3a666abc9c24cd13fb91d75e6e5bd4844d637..4ad659d6bb9e39f3350e7a36c6160570735934ac 100644 --- a/Core/NosSmooth.Game/Data/Dialogs/Dialog.cs +++ b/Core/NosSmooth.Game/Data/Dialogs/Dialog.cs @@ -4,6 +4,7 @@ // 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.Game.Apis; using NosSmooth.Packets.Enums; using OneOf; @@ -12,8 +13,17 @@ namespace NosSmooth.Game.Data.Dialogs; /// /// Represents dialog sent by the server /// -/// The accept command sent upon accept. -/// The parameters of the dialog. +/// +/// To deny a dialog with null , just ignore it. +/// +/// For answering to a dialog, use . +/// It takes care of collisions. In case the same dialog is accepted +/// and denied from elsewhere, an error will be returned. +/// +/// The accept command/packet sent upon accept. +/// The deny command/packet sent upon denying. This may be null for some dialogs. To deny a dialog with null DenyCommand, just ignore it. +/// The message of the dialog, may be a constant i18n message, or a string. +/// The parameters of the i18n message. Empty for string messages. public record Dialog ( string AcceptCommand, diff --git a/Core/NosSmooth.Game/Data/Raids/RaidProgress.cs b/Core/NosSmooth.Game/Data/Raids/RaidProgress.cs index 35d05a6552ecd05d8ef2c749047a9d48de35b866..3193eb4b1a80d2d560ae640036cd63009aa56247 100644 --- a/Core/NosSmooth.Game/Data/Raids/RaidProgress.cs +++ b/Core/NosSmooth.Game/Data/Raids/RaidProgress.cs @@ -6,6 +6,19 @@ namespace NosSmooth.Game.Data.Raids; +/// +/// A progress of a started . +/// +/// +/// Lockers are relevant before , +/// when all lockers are unlocked, the boss room is opened. +/// +/// The number of monsters to kill. +/// The number of monsters already killed. +/// The number of levers to pull. +/// The number of levers already pulled. +/// The current number of lives. +/// The maximum number of lives. public record RaidProgress ( short MonsterLockerInitial, diff --git a/Core/NosSmooth.Game/Errors/WrongSkillPositionError.cs b/Core/NosSmooth.Game/Errors/WrongSkillPositionError.cs index bbf4250d2da92261a01ab898bb189a449d0cb946..d0d6afd291ac6ca58e5b4c6a18a064af7d69b85a 100644 --- a/Core/NosSmooth.Game/Errors/WrongSkillPositionError.cs +++ b/Core/NosSmooth.Game/Errors/WrongSkillPositionError.cs @@ -9,5 +9,12 @@ using Remora.Results; namespace NosSmooth.Game.Errors; +/// +/// Dash skills have to have a position specified, +/// non-dash skills cannot have position specified. +/// In case this is not respected in the skills api, +/// this error will be returned. +/// +/// The type of the skill. public record WrongSkillPositionError(AttackType AttackType) : ResultError($"The skill with an attack type {AttackType} has to have a map position specified."); \ No newline at end of file diff --git a/Core/NosSmooth.Game/Errors/WrongSkillTypeError.cs b/Core/NosSmooth.Game/Errors/WrongSkillTypeError.cs index 2b2635ce366122219cd9c1ad11397c302c3a7baf..e5ce937fb057dd6f8c4142fa9de979d147423d10 100644 --- a/Core/NosSmooth.Game/Errors/WrongSkillTypeError.cs +++ b/Core/NosSmooth.Game/Errors/WrongSkillTypeError.cs @@ -5,9 +5,19 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using NosSmooth.Data.Abstractions.Enums; +using NosSmooth.Game.Apis.Safe; using Remora.Results; namespace NosSmooth.Game.Errors; +/// +/// Used for safe skill api when the skill type does not match the correct one. +/// +/// +/// Use one of the other methods , +/// , . +/// +/// The type that was expected. +/// The actual type of the skill. public record WrongSkillTypeError(SkillType ExpectedType, SkillType ActualType) : ResultError($"Cannot use a skill of type {ActualType}, only type {ExpectedType} is allowed."); \ No newline at end of file diff --git a/Core/NosSmooth.Game/Events/Raids/RaidFinishedEvent.cs b/Core/NosSmooth.Game/Events/Raids/RaidFinishedEvent.cs index 733edfcd42dc39eb7386b780cf55f0c8a59b490e..53cfc3349a240bc4413daf5dcaee38a9d779d7e3 100644 --- a/Core/NosSmooth.Game/Events/Raids/RaidFinishedEvent.cs +++ b/Core/NosSmooth.Game/Events/Raids/RaidFinishedEvent.cs @@ -8,4 +8,18 @@ using NosSmooth.Game.Data.Raids; namespace NosSmooth.Game.Events.Raids; +/// +/// The raid has been finished. +/// +/// +/// There are multiple possibilities: +/// 1. The character has left. +/// 2. The raid was cancelled. +/// 3. The raid has failed. (either the whole team failed or the character) +/// 4. The raid has succeeded. +/// +/// To determine which of these is the one that caused the finish +/// of the raid, look at state. +/// +/// The raid that has finished. public record RaidFinishedEvent(Raid Raid) : IGameEvent; \ No newline at end of file diff --git a/Core/NosSmooth.Game/Events/Raids/RaidJoinedEvent.cs b/Core/NosSmooth.Game/Events/Raids/RaidJoinedEvent.cs index a589413fd87855c75c840cfe18d56bc254924da2..1bd212f1de320eab36b949c2348b66257d2eee63 100644 --- a/Core/NosSmooth.Game/Events/Raids/RaidJoinedEvent.cs +++ b/Core/NosSmooth.Game/Events/Raids/RaidJoinedEvent.cs @@ -8,4 +8,8 @@ using NosSmooth.Game.Data.Raids; namespace NosSmooth.Game.Events.Raids; +/// +/// The character has joined a raid. +/// +/// The joined raid. public record RaidJoinedEvent(Raid Raid) : IGameEvent; \ No newline at end of file diff --git a/Core/NosSmooth.Game/Events/Raids/RaidStateChangedEvent.cs b/Core/NosSmooth.Game/Events/Raids/RaidStateChangedEvent.cs index e1093ceff168182c6b2dddfd549ae3f85f216c7b..e01dba405c73acbe7cb6ac33c687d668bf5e4660 100644 --- a/Core/NosSmooth.Game/Events/Raids/RaidStateChangedEvent.cs +++ b/Core/NosSmooth.Game/Events/Raids/RaidStateChangedEvent.cs @@ -8,6 +8,12 @@ using NosSmooth.Game.Data.Raids; namespace NosSmooth.Game.Events.Raids; +/// +/// A raid has changed a state from to . +/// +/// The previous state of the raid. +/// The current state of the raid. +/// The raid that has changed the state. The current raid, or the last one in case the raid was finished. public record RaidStateChangedEvent ( RaidState PreviousState, diff --git a/Core/NosSmooth.Game/Events/Ui/DialogOpenedEvent.cs b/Core/NosSmooth.Game/Events/Ui/DialogOpenedEvent.cs index e96c57adfc8409e4e62f29bd49ea6b434908b03b..82313112f8156459bed14c7ee242aa58a8a04ebe 100644 --- a/Core/NosSmooth.Game/Events/Ui/DialogOpenedEvent.cs +++ b/Core/NosSmooth.Game/Events/Ui/DialogOpenedEvent.cs @@ -4,8 +4,18 @@ // 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.Game.Apis; using NosSmooth.Game.Data.Dialogs; namespace NosSmooth.Game.Events.Ui; +/// +/// A dialog has been opened. An answer is expected. +/// +/// +/// For answering to a dialog, use . +/// It takes care of collisions. In case the same dialog is accepted +/// and denied from elsewhere, an error will be returned. +/// +/// The dialog that has been opened. public record DialogOpenedEvent(Dialog Dialog) : IGameEvent; \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/CombatManager.cs b/Extensions/NosSmooth.Extensions.Combat/CombatManager.cs index 874a26ec272ab5b3563a1eafd7dd4589cc9124f9..e3f6150302c8fa29814b32a5214f0e3bb371b9e9 100644 --- a/Extensions/NosSmooth.Extensions.Combat/CombatManager.cs +++ b/Extensions/NosSmooth.Extensions.Combat/CombatManager.cs @@ -22,7 +22,6 @@ public class CombatManager : IStatefulEntity { private readonly INostaleClient _client; private readonly Game.Game _game; - private bool _cancelling; /// /// Initializes a new instance of the class. diff --git a/Extensions/NosSmooth.Extensions.Combat/Selectors/InventoryItem.cs b/Extensions/NosSmooth.Extensions.Combat/Selectors/InventoryItem.cs index 48020062a8874bce602fbbb8525db1b57fedbcca..b85ba59040ac20a1d674196dfac2c2e7474b605b 100644 --- a/Extensions/NosSmooth.Extensions.Combat/Selectors/InventoryItem.cs +++ b/Extensions/NosSmooth.Extensions.Combat/Selectors/InventoryItem.cs @@ -10,5 +10,10 @@ using NosSmooth.Game.Data.Inventory; namespace NosSmooth.Extensions.Combat.Selectors; +/// +/// An item in an inventory, with a bag and slot specified. +/// +/// The bag of the item. +/// The slot with the item. [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "Fix")] public record struct InventoryItem(BagType Bag, InventorySlot Item); \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Enums/QnamlType.cs b/Packets/NosSmooth.Packets/Enums/QnamlType.cs index b58839bf294c96eec84993a2066e9fb804dd45ba..d501fa9dcdf90fe0d6a22d725ab8af792223ae7a 100644 --- a/Packets/NosSmooth.Packets/Enums/QnamlType.cs +++ b/Packets/NosSmooth.Packets/Enums/QnamlType.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using NosSmooth.Packets.Server.UI; +#pragma warning disable CS1591 namespace NosSmooth.Packets.Enums; diff --git a/Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs b/Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs index 428f0c5f271cc052ff37d7ff56cdae8f764cf433..e3131e33e28c98515543d5a055fa0917867c4fb1 100644 --- a/Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs @@ -29,6 +29,8 @@ namespace NosSmooth.Packets.Server.Battle; /// The damage the entity has taken. /// The hit mode. /// The skill type of the skill. +/// Current hp of the target. +/// Maximum hp of the target. [PacketHeader("su", PacketSource.Server)] [GenerateSerializer(true)] public record SuPacket diff --git a/Packets/NosSmooth.Packets/Server/Character/CInfoPacket.cs b/Packets/NosSmooth.Packets/Server/Character/CInfoPacket.cs index ced2f505585c26c5cd2e2f96ccfa4fa41d7ed223..f21d2cc97d7957d08c5ffb7397a0c17802072625 100644 --- a/Packets/NosSmooth.Packets/Server/Character/CInfoPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Character/CInfoPacket.cs @@ -20,7 +20,7 @@ namespace NosSmooth.Packets.Server.Character; /// The name of the character. /// Unknown TODO /// The id of the group the player is in, if any. -/// The id of the family the player is in, if any. +/// Information about family the player is in, if any. /// The name of the family the player is in, if any. /// The id of the character. /// The authority of the character. diff --git a/Packets/NosSmooth.Packets/Server/Chat/Sayi2Packet.cs b/Packets/NosSmooth.Packets/Server/Chat/Sayi2Packet.cs index 9a95a7dd6c1a123f1e07692c421170166df8a94f..1590197468c9698d1ebdce9ccc05ee4fac6d2413 100644 --- a/Packets/NosSmooth.Packets/Server/Chat/Sayi2Packet.cs +++ b/Packets/NosSmooth.Packets/Server/Chat/Sayi2Packet.cs @@ -18,7 +18,8 @@ namespace NosSmooth.Packets.Server.Chat; /// The id of the entity that spoke. /// The say/message color. /// The message constant. -/// The arguments of the message. +/// The number of parameters. +/// The arguments of the message. [PacketHeader("sayi2", PacketSource.Server)] [GenerateSerializer(true)] public record Sayi2Packet diff --git a/Packets/NosSmooth.Packets/Server/Entities/StPacket.cs b/Packets/NosSmooth.Packets/Server/Entities/StPacket.cs index 67da07b13055efd081f8b2156967d12595e115b2..a29ff7de136a598ec1f552a38650f9bf7ed99329 100644 --- a/Packets/NosSmooth.Packets/Server/Entities/StPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Entities/StPacket.cs @@ -21,6 +21,8 @@ namespace NosSmooth.Packets.Server.Entities; /// The current mp percentage. /// The current amount of hp. /// The current amount of mp. +/// The current amount of hp. +/// The maximum amount of mp. /// The list of the buffs the entity has. [PacketHeader("st", PacketSource.Server)] [GenerateSerializer(true)] diff --git a/Packets/NosSmooth.Packets/Server/Mates/ScNPacket.cs b/Packets/NosSmooth.Packets/Server/Mates/ScNPacket.cs index 14a69399a0d96d5385b82e024040bf3175d61ec9..421b8456717c8ee36770bf02701126932a3ad141 100644 --- a/Packets/NosSmooth.Packets/Server/Mates/ScNPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Mates/ScNPacket.cs @@ -29,7 +29,7 @@ namespace NosSmooth.Packets.Server.Mates; /// Information about partner's boots. /// Unknown TODO. /// Unknown TODO. -/// Unknown TODO. +/// Unknown TODO. /// The upgrade of attack. /// The minimum attack amount. /// The maximum attack amount. @@ -48,7 +48,7 @@ namespace NosSmooth.Packets.Server.Mates; /// The maximum hp of the partner. /// The current mp of the partner. /// The maximum mp of the partner. -/// Unknown TODO. +/// Unknown TODO. /// The maximum experience in current level of the partner. /// The name of the partner. /// The morph vnum of the partner, if any. diff --git a/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs index 1fd36f3468766c579c916650b86d277a34470a9a..a8e498c2558611e51622df627bf5c158da04cd94 100644 --- a/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs @@ -17,6 +17,7 @@ namespace NosSmooth.Packets.Server.Raids; /// /// The boss entity type. /// The boss entity id. +/// The current hp of the boss. /// The max hp of the boss. /// The vnum of the boss entity. [PacketHeader("rboss", PacketSource.Server)] diff --git a/Packets/NosSmooth.Packets/Server/Raids/RdlstfPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RdlstfPacket.cs index fa547fdfcdd375785c7262431844f84fff38dc8b..7600b2ee6b92ae7319778df5a4b59bdcad0526b6 100644 --- a/Packets/NosSmooth.Packets/Server/Raids/RdlstfPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Raids/RdlstfPacket.cs @@ -14,7 +14,8 @@ namespace NosSmooth.Packets.Server.Raids; /// /// The minimum needed level for the raid treasure. /// The maximum needed level for the raid treasure. -/// Unknown TODO. +/// Unknown TODO. +/// The raid, . /// Information about members in the raid. [PacketHeader("rdlstf", PacketSource.Server)] [GenerateSerializer(true)] diff --git a/Packets/NosSmooth.Packets/Server/UI/DlgPacket.cs b/Packets/NosSmooth.Packets/Server/UI/DlgPacket.cs index ac0b2e084c1811adfba8e2817eb90321d18bb19a..786169a3b8b886c22b66b21d5950b3de6d16ef12 100644 --- a/Packets/NosSmooth.Packets/Server/UI/DlgPacket.cs +++ b/Packets/NosSmooth.Packets/Server/UI/DlgPacket.cs @@ -8,6 +8,15 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Packets.Server.UI; +/// +/// A dialog with normal string message. +/// +/// +/// For a dialog with constant message, . +/// +/// The command/packet to send to accept the dialog. +/// The command/packet to send to deny the dialog. +/// The message of the dialog. [PacketHeader("dlg", PacketSource.Server)] [GenerateSerializer(true)] public record DlgPacket diff --git a/Packets/NosSmooth.Packets/Server/UI/DlgiPacket.cs b/Packets/NosSmooth.Packets/Server/UI/DlgiPacket.cs index 86987f0089df4f39a776fd64aabeeaa70dbb7af1..8110bf22e5cb170a16f8d7002f2d3dabf07ac0a7 100644 --- a/Packets/NosSmooth.Packets/Server/UI/DlgiPacket.cs +++ b/Packets/NosSmooth.Packets/Server/UI/DlgiPacket.cs @@ -9,6 +9,13 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Packets.Server.UI; +/// +/// A dialog with i18n message. +/// +/// The command/packet to send to accept the dialog. +/// The command/packet to send to deny the dialog. +/// The i18n message. +/// The parameters of the message. [PacketHeader("dlgi", PacketSource.Server)] [GenerateSerializer(true)] public record DlgiPacket diff --git a/Packets/NosSmooth.Packets/Server/UI/QnaPacket.cs b/Packets/NosSmooth.Packets/Server/UI/QnaPacket.cs index 9255376a0be03896c3a0733c0e63382bca2815e6..8a60fc7f8e90fd1d291a8b5d4a332bf2d9800b4a 100644 --- a/Packets/NosSmooth.Packets/Server/UI/QnaPacket.cs +++ b/Packets/NosSmooth.Packets/Server/UI/QnaPacket.cs @@ -4,10 +4,20 @@ // 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.Packets.Enums; using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Packets.Server.UI; +/// +/// Question and answer dialog that uses string message. +/// +/// +/// To deny the dialog, just ignore it. +/// This behaves as with type . +/// +/// The command/packet to send to accept the dialog. +/// The message of the dialog. [PacketHeader("qna", PacketSource.Server)] [GenerateSerializer(true)] public record QnaPacket diff --git a/Packets/NosSmooth.Packets/Server/UI/QnamlPacket.cs b/Packets/NosSmooth.Packets/Server/UI/QnamlPacket.cs index e09e1287545074fc1445073b3af78e8aa65a78c6..6742d9bce90cd280afff3c4538f956009ee7d563 100644 --- a/Packets/NosSmooth.Packets/Server/UI/QnamlPacket.cs +++ b/Packets/NosSmooth.Packets/Server/UI/QnamlPacket.cs @@ -9,7 +9,16 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Packets.Server.UI; -[PacketHeader("qnaml", PacketSource.Server)] +/// +/// Question and answer dialog that can have a location in the UI specified using . +/// Uses string message. +/// +/// +/// To deny the dialog, just ignore it. +/// +/// The ui location. +/// The command/packet to send to accept the dialog. +/// The message of the dialog. [GenerateSerializer(true)] public record QnamlPacket ( diff --git a/Packets/NosSmooth.Packets/Server/UI/Qnamli2Packet.cs b/Packets/NosSmooth.Packets/Server/UI/Qnamli2Packet.cs index ada1b22cfad53cf714564ec119d79d035126ab23..e58494f572e349b225462b8eece24fdcc5b6f88e 100644 --- a/Packets/NosSmooth.Packets/Server/UI/Qnamli2Packet.cs +++ b/Packets/NosSmooth.Packets/Server/UI/Qnamli2Packet.cs @@ -9,6 +9,18 @@ using NosSmooth.PacketSerializer.Abstractions.Attributes; namespace NosSmooth.Packets.Server.UI; +/// +/// Question and answer dialog that can have a location in the UI specified using . +/// Uses i18n message. +/// +/// +/// To deny the dialog, just ignore it. +/// +/// The ui location. +/// The command/packet to send to accept the dialog. +/// The i18n message. +/// The count of parameters for the mssage. +/// The parameters for the message. [PacketHeader("qnamli2", PacketSource.Server)] [GenerateSerializer(true)] public record Qnamli2Packet diff --git a/Tests/NosSmooth.Core.Tests/Commands/CommandProcessorTests.cs b/Tests/NosSmooth.Core.Tests/Commands/CommandProcessorTests.cs index cbf62a089ecb4b3eaf30a1c0704c1c094d0953e6..05dc80542fb27da1b1782129d60cf61602b4881f 100644 --- a/Tests/NosSmooth.Core.Tests/Commands/CommandProcessorTests.cs +++ b/Tests/NosSmooth.Core.Tests/Commands/CommandProcessorTests.cs @@ -413,9 +413,9 @@ public class CommandProcessorTests Assert.NotNull(aggregateError); if (aggregateError is not null) { - Assert.True(aggregateError.Errors.Any(x => x.Error == error1)); + Assert.Contains(aggregateError.Errors, x => (FakeError)x.Error! == error1); - Assert.True(aggregateError.Errors.Any(x => x.Error == error2)); + Assert.Contains(aggregateError.Errors, x => (FakeError)x.Error! == error2); Assert.Equal(2, aggregateError.Errors.Count); } } @@ -425,7 +425,7 @@ public class CommandProcessorTests /// /// A representing the asynchronous unit test. [Fact] - public async Task ProcessCommand_HavingExceptionInHandler_ShouldNotThrow() + public Task ProcessCommand_HavingExceptionInHandler_ShouldNotThrow() { var fakeCommand = new FakeCommand("asdf"); var provider = new ServiceCollection() @@ -447,7 +447,7 @@ public class CommandProcessorTests ) .BuildServiceProvider(); - await provider.GetRequiredService().ProcessCommand + return provider.GetRequiredService().ProcessCommand (new FakeEmptyNostaleClient(), fakeCommand); } @@ -456,7 +456,7 @@ public class CommandProcessorTests /// /// A representing the asynchronous unit test. [Fact] - public async Task ProcessCommand_HavingExceptionInPreEvent_ShouldNotThrow() + public Task ProcessCommand_HavingExceptionInPreEvent_ShouldNotThrow() { var fakeCommand = new FakeCommand("asdf"); var provider = new ServiceCollection() @@ -478,7 +478,7 @@ public class CommandProcessorTests ) .BuildServiceProvider(); - await provider.GetRequiredService().ProcessCommand + return provider.GetRequiredService().ProcessCommand (new FakeEmptyNostaleClient(), fakeCommand); } @@ -487,7 +487,7 @@ public class CommandProcessorTests /// /// A representing the asynchronous unit test. [Fact] - public async Task ProcessCommand_HavingExceptionInPostEvent_ShouldNotThrow() + public Task ProcessCommand_HavingExceptionInPostEvent_ShouldNotThrow() { var fakeCommand = new FakeCommand("asdf"); var provider = new ServiceCollection() @@ -509,7 +509,7 @@ public class CommandProcessorTests ) .BuildServiceProvider(); - await provider.GetRequiredService().ProcessCommand + return provider.GetRequiredService().ProcessCommand (new FakeEmptyNostaleClient(), fakeCommand); } } \ No newline at end of file diff --git a/Tests/NosSmooth.Core.Tests/Commands/Walking/WalkCommandHandlerTests.cs b/Tests/NosSmooth.Core.Tests/Commands/Walking/WalkCommandHandlerTests.cs index c3c0f8cf337477bd37526744ef3e7f1519eacfc1..a6fb9a954a0f0906b4aed918dac4be5ce8acc4bc 100644 --- a/Tests/NosSmooth.Core.Tests/Commands/Walking/WalkCommandHandlerTests.cs +++ b/Tests/NosSmooth.Core.Tests/Commands/Walking/WalkCommandHandlerTests.cs @@ -70,7 +70,7 @@ public class WalkCommandHandlerTests /// /// A representing the asynchronous unit test. [Fact] - public async Task Handle_PreservesTakeHandlerCommandProperties() + public Task Handle_PreservesTakeHandlerCommandProperties() { var command = new WalkCommand ( @@ -106,7 +106,7 @@ public class WalkCommandHandlerTests ) ); - await walkHandler.HandleCommand(command); + return walkHandler.HandleCommand(command); } /// @@ -114,7 +114,7 @@ public class WalkCommandHandlerTests /// /// A representing the asynchronous unit test. [Fact] - public async Task Handle_PreservesPlayerWalkPosition() + public Task Handle_PreservesPlayerWalkPosition() { var command = new WalkCommand ( @@ -143,7 +143,7 @@ public class WalkCommandHandlerTests ) ); - await walkHandler.HandleCommand(command); + return walkHandler.HandleCommand(command); } /// @@ -202,7 +202,7 @@ public class WalkCommandHandlerTests /// /// A representing the asynchronous unit test. [Fact] - public async Task Handle_WithPets_UsesNearbyPositionForPetCommands() + public Task Handle_WithPets_UsesNearbyPositionForPetCommands() { var command = new WalkCommand ( @@ -241,6 +241,6 @@ public class WalkCommandHandlerTests ) ); - await walkHandler.HandleCommand(command); + return walkHandler.HandleCommand(command); } } \ No newline at end of file diff --git a/Tests/NosSmooth.Core.Tests/Contracts/ContractTests.cs b/Tests/NosSmooth.Core.Tests/Contracts/ContractTests.cs index 1e3cd32abe3e3ba2fecafcddc17b87d021be6c73..f25b1e412b92814f6a1d64c3681530d78f5b7a31 100644 --- a/Tests/NosSmooth.Core.Tests/Contracts/ContractTests.cs +++ b/Tests/NosSmooth.Core.Tests/Contracts/ContractTests.cs @@ -11,6 +11,7 @@ using NosSmooth.Core.Contracts; using Remora.Results; using Shouldly; using Xunit; +#pragma warning disable CS4014 namespace NosSmooth.Core.Tests.Contracts; diff --git a/Tests/NosSmooth.Core.Tests/Fakes/Commands/FakeCommand.cs b/Tests/NosSmooth.Core.Tests/Fakes/Commands/FakeCommand.cs index be1a02859cf683e7cd1c6bded1ff87821fc96ab1..b65bd283a5483bba7283f8a8e4269a0bb922d894 100644 --- a/Tests/NosSmooth.Core.Tests/Fakes/Commands/FakeCommand.cs +++ b/Tests/NosSmooth.Core.Tests/Fakes/Commands/FakeCommand.cs @@ -8,4 +8,8 @@ using NosSmooth.Core.Commands; namespace NosSmooth.Core.Tests.Fakes.Commands; +/// +/// A command with arbitrary input. +/// +/// The input of the command. public record FakeCommand(string Input) : ICommand; \ No newline at end of file diff --git a/Tests/NosSmooth.Game.Tests/PacketFileClient.cs b/Tests/NosSmooth.Game.Tests/PacketFileClient.cs index 4bb07ae33a8180f810226173e4f697eef66d47e0..8c2c0d5a6c2a1cc10c7dc5cb891720ec73d55d7e 100644 --- a/Tests/NosSmooth.Game.Tests/PacketFileClient.cs +++ b/Tests/NosSmooth.Game.Tests/PacketFileClient.cs @@ -29,13 +29,12 @@ namespace NosSmooth.Game.Tests; /// /// A client used for tests. Supports loading just part of a file with packets. /// +// TODO: make this class cleaner public class PacketFileClient : BaseNostaleClient, IDisposable { private const string LineRegex = ".*\\[(Recv|Send)\\]\t(.*)"; private const string LabelRegex = "##(.*)"; - // TODO: make this class cleaner - private readonly FileStream _stream; private readonly StreamReader _reader; private readonly IPacketSerializer _packetSerializer;