From c1dde0d5bb8a58eaa2e168c6648a41da4ad353ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 19 Feb 2022 09:16:30 +0100 Subject: [PATCH] docs(combat): add missing documentation --- .../Techniques/ICombatTechnique.cs | 23 +++++++++++++++++++ .../Techniques/SimpleAttackTechnique.cs | 21 ++++++++++------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Extensions/NosSmooth.Extensions.Combat/Techniques/ICombatTechnique.cs b/Extensions/NosSmooth.Extensions.Combat/Techniques/ICombatTechnique.cs index a7732dea075f889fa04794315fb9bde446f4604e..3aa71ad5ff2a36a28b74eb522ce4d5343f3e72c5 100644 --- a/Extensions/NosSmooth.Extensions.Combat/Techniques/ICombatTechnique.cs +++ b/Extensions/NosSmooth.Extensions.Combat/Techniques/ICombatTechnique.cs @@ -18,9 +18,32 @@ namespace NosSmooth.Extensions.Combat.Techniques; /// public interface ICombatTechnique { + /// + /// Should check whether the technique should process more steps or quit the combat. + /// + /// The combat state. + /// Whether to continue with steps. public bool ShouldContinue(ICombatState state); + /// + /// Handle one step that should enqueue an operation. + /// + /// + /// If error is returned, the combat will be cancelled. + /// + /// The combat state. + /// A result that may or may not succeed. public Result HandleCombatStep(ICombatState state); + /// + /// Handles an error from . + /// + /// + /// If an error is returned, the combat will be cancelled. + /// + /// The combat state. + /// The combat operation that returned an error. + /// The errorful result. + /// A result that may or may not succeed. public Result HandleError(ICombatState state, ICombatOperation operation, Result result); } \ No newline at end of file diff --git a/Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs b/Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs index c0b273f8cadb0624fe16c5d395860adef8cfc720..d754379fe80cf0beb94df8a6caee1b02caca984b 100644 --- a/Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs +++ b/Extensions/NosSmooth.Extensions.Combat/Techniques/SimpleAttackTechnique.cs @@ -29,12 +29,12 @@ public class SimpleAttackTechnique : ICombatTechnique private ILivingEntity? _target; /// - /// + /// Initializes a new instance of the class. /// - /// - /// - /// - /// + /// The target entity id. + /// The walk manager. + /// The skill selector. + /// The item selector. public SimpleAttackTechnique ( int targetId, @@ -59,7 +59,7 @@ public class SimpleAttackTechnique : ICombatTechnique } var entity = map.Entities.GetEntity(_targetId); - return !(entity is null || entity.Hp is not null && (entity.Hp.Amount <= 0 || entity.Hp.Percentage <= 0)); + return !(entity is null || (entity.Hp is not null && (entity.Hp.Amount <= 0 || entity.Hp.Percentage <= 0))); } /// @@ -122,9 +122,14 @@ public class SimpleAttackTechnique : ICombatTechnique return new MissingInfoError("skill", currentSkill.SkillVNum); } - if (character.Position is null || _target.Position is null) + if (character.Position is null) { - return new; + return new CharacterNotInitializedError("Position"); + } + + if (_target.Position is null) + { + return new EntityNotFoundError(); } if (!character.Position.Value.IsInRange(_target.Position.Value, _currentSkill.Info.Range))