Files
mod_ff_battle/src/Actions/FFDefenceExecutor.cs
T
cthangover ad57e6e634 Line endings: LF everywhere
.gitattributes forces LF (CRLF only for .bat/.cmd), core.autocrlf is off;
files that differed only by CRLF are normalized.
2026-10-21 13:29:42 +02:00

35 lines
1.4 KiB
C#

using Cthangover.Core.Characters;
using Cthangover.Core.Utils;
namespace Cthangover.FFBattle.Actions
{
/// <summary>
/// Executes a defensive action (buff/barrier). Increases the target's
/// <see cref="CharacterAttributes.Defence"/> by the value stored in
/// the <c>"Defence"</c> property on the action (default 4).
/// Defence acts as a shield against incoming physical damage in the
/// <see cref="FFDamageExecutor"/>. Registered under ID <c>"physics/defence"</c>.
/// </summary>
public class FFDefenceExecutor : ActionBase
{
/// <summary>Hub registry key for this executor.</summary>
public override string ID => "FFDefenceExecutor";
/// <summary>Adds the action's "Defence" value (default 4) to the target's defence shield.</summary>
public override ChangedAttributes Execute(ActionCharacter action, Character user, Character target)
{
if (target == null || user == null || !CheckRequiredAndUsePoint(action, user))
return new ChangedAttributes { Result = false };
var defenceDelta = action.GetInt("Defence", 4);
target.Attributes.Defence.Value += defenceDelta;
GameLogger.Log("FF_BATTLE",
$"{user.Name} defends → +{defenceDelta} defence for {target?.Name}",
LogLevel.Debug);
return new ChangedAttributes { Result = true, Target = { Defence = defenceDelta } };
}
}
}