From 5c40f7e3e7416379f5f5240dfe980e8cfea14bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sun, 13 Feb 2022 09:38:28 +0100 Subject: [PATCH] feat(core): add walk command error --- .../Errors/WalkNotFinishedError.cs | 18 ++++++++++ .../Errors/WalkUnfinishedReason.cs | 36 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Core/NosSmooth.Core/Errors/WalkNotFinishedError.cs create mode 100644 Core/NosSmooth.Core/Errors/WalkUnfinishedReason.cs diff --git a/Core/NosSmooth.Core/Errors/WalkNotFinishedError.cs b/Core/NosSmooth.Core/Errors/WalkNotFinishedError.cs new file mode 100644 index 0000000000000000000000000000000000000000..622362426a2da025b77350f4feea209460681adf --- /dev/null +++ b/Core/NosSmooth.Core/Errors/WalkNotFinishedError.cs @@ -0,0 +1,18 @@ +// +// WalkNotFinishedError.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 Remora.Results; + +namespace NosSmooth.Core.Errors; + +/// +/// Represents an error that can be returned from walk command handler. +/// +/// The x coordinate where the player is. (if known) +/// The y coordinate where the player is. (if known) +/// +public record WalkNotFinishedError(int? X, int? Y, WalkUnfinishedReason Reason) + : ResultError($"Could not finish the walk to {X} {Y}, because {Reason}"); \ No newline at end of file diff --git a/Core/NosSmooth.Core/Errors/WalkUnfinishedReason.cs b/Core/NosSmooth.Core/Errors/WalkUnfinishedReason.cs new file mode 100644 index 0000000000000000000000000000000000000000..4e08c8effe9b1761f6bf0033621ae09faa34e926 --- /dev/null +++ b/Core/NosSmooth.Core/Errors/WalkUnfinishedReason.cs @@ -0,0 +1,36 @@ +// +// WalkUnfinishedReason.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.Core.Errors; + +/// +/// Reason for not finishing a walk. +/// +public enum WalkUnfinishedReason +{ + /// + /// There was an unknown unfinished reason. + /// + Unknown, + + /// + /// The client could not find path to the given location. + /// + /// + /// The user walked just some part of the path. + /// + PathNotFound, + + /// + /// The user has took an action that has cancelled the walk. + /// + UserAction, + + /// + /// There was another walk action that cancelled this one. + /// + AnotherTask +} \ No newline at end of file