From 1b78257b6b32ace8a2a8afdf36be8a2f33f10ba7 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 18 Feb 2022 23:31:39 +0100 Subject: [PATCH] feat(combat): add errors --- .../Errors/CharacterNotInitializedError.cs | 15 +++++++++++++++ .../Errors/EntityNotFoundError.cs | 14 ++++++++++++++ .../Errors/ItemNotFoundError.cs | 14 ++++++++++++++ .../Errors/MapNotInitializedError.cs | 15 +++++++++++++++ .../Errors/MissingInfoError.cs | 16 ++++++++++++++++ .../Errors/SkillNotFoundError.cs | 14 ++++++++++++++ .../Errors/TargetNotSetError.cs | 11 +++++++++++ .../Errors/UnusableOperationError.cs | 17 +++++++++++++++++ 8 files changed, 116 insertions(+) create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/CharacterNotInitializedError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/EntityNotFoundError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/ItemNotFoundError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/MapNotInitializedError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/MissingInfoError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/SkillNotFoundError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/TargetNotSetError.cs create mode 100644 Extensions/NosSmooth.Extensions.Combat/Errors/UnusableOperationError.cs diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/CharacterNotInitializedError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/CharacterNotInitializedError.cs new file mode 100644 index 0000000000000000000000000000000000000000..e5c5208cea8a1f6c4c2b200a8bdb81c0fd5e6aa1 --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/CharacterNotInitializedError.cs @@ -0,0 +1,15 @@ +// +// CharacterNotInitializedError.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.Extensions.Combat.Errors; + +/// +/// The character is not initialized. +/// +public record CharacterNotInitializedError(string Field = "") + : ResultError($"The character {Field} is not yet initialized."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/EntityNotFoundError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/EntityNotFoundError.cs new file mode 100644 index 0000000000000000000000000000000000000000..adc676a5521864e33783b7b190c531a0201165ee --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/EntityNotFoundError.cs @@ -0,0 +1,14 @@ +// +// EntityNotFoundError.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.Extensions.Combat.Errors; + +/// +/// Matching entity not found error. +/// +public record EntityNotFoundError() : ResultError("Could not find an entity that matches the conditions."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/ItemNotFoundError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/ItemNotFoundError.cs new file mode 100644 index 0000000000000000000000000000000000000000..f7bffbf5d51c0a8b579f15972491dbdb380e8747 --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/ItemNotFoundError.cs @@ -0,0 +1,14 @@ +// +// ItemNotFoundError.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.Extensions.Combat.Errors; + +/// +/// Matchin item not found error. +/// +public record ItemNotFoundError() : ResultError("Could not find an item that matches the conditions."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/MapNotInitializedError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/MapNotInitializedError.cs new file mode 100644 index 0000000000000000000000000000000000000000..54bad72f8e4b823e1cd83fd96b3d35bd0abc2ec3 --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/MapNotInitializedError.cs @@ -0,0 +1,15 @@ +// +// MapNotInitializedError.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.Extensions.Combat.Errors; + +/// +/// The map is not initialized. +/// +public record MapNotInitializedError() + : ResultError("The map is not yet initialized."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/MissingInfoError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/MissingInfoError.cs new file mode 100644 index 0000000000000000000000000000000000000000..1fcb4f8eec07c1115ca3e74a6e2199e11b885d4c --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/MissingInfoError.cs @@ -0,0 +1,16 @@ +// +// MissingInfoError.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.Extensions.Combat.Errors; + +/// +/// Missing info of a specified type and id.. +/// +/// The type. +/// The id. +public record MissingInfoError(string Type, long Id) : ResultError($"Cannot find info of {{Type}} with id {Id}."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/SkillNotFoundError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/SkillNotFoundError.cs new file mode 100644 index 0000000000000000000000000000000000000000..132cab004910afd8a2d6cbf4b103f0dc7127f14d --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/SkillNotFoundError.cs @@ -0,0 +1,14 @@ +// +// SkillNotFoundError.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.Extensions.Combat.Errors; + +/// +/// Matchin skill not found. +/// +public record SkillNotFoundError() : ResultError("Could not find a skill that matches the conditions."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/TargetNotSetError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/TargetNotSetError.cs new file mode 100644 index 0000000000000000000000000000000000000000..e59243ba053e842611492e156b1ccf528b598f04 --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/TargetNotSetError.cs @@ -0,0 +1,11 @@ +// +// TargetNotSetError.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.Extensions.Combat.Errors; + +public record TargetNotSetError() : ResultError("The current target is not set, the operation cannot complete."); \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Errors/UnusableOperationError.cs b/Extensions/NosSmooth.Extensions.Combat/Errors/UnusableOperationError.cs new file mode 100644 index 0000000000000000000000000000000000000000..729aaa1d9ba504e544cd8ca3be2f6f701e8e024d --- /dev/null +++ b/Extensions/NosSmooth.Extensions.Combat/Errors/UnusableOperationError.cs @@ -0,0 +1,17 @@ +// +// UnusableOperationError.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 NosSmooth.Extensions.Combat.Operations; +using Remora.Results; + +namespace NosSmooth.Extensions.Combat.Errors; + +/// +/// An error that tells the operation was unusable. +/// +/// The operation. +public record UnusableOperationError(ICombatOperation Operation) + : ResultError("A given operation {Operation} responded that it won't be usable ever and thus there is an unrecoverable state."); \ No newline at end of file