summaryrefslogtreecommitdiff
path: root/scripts/actors/actions/MeleeAction.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-08-28 17:01:53 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-08-28 17:01:53 -0300
commit358943907bc9e37d26618ee03adf1ffd97635335 (patch)
tree223b32f5631d3decb679302b489e6d7e124674c8 /scripts/actors/actions/MeleeAction.cs
parentafcd5055e98dcb7c9fefeabb072ecc56d0456bd7 (diff)
Combate corpo a corpo.
Diffstat (limited to 'scripts/actors/actions/MeleeAction.cs')
-rw-r--r--scripts/actors/actions/MeleeAction.cs18
1 files changed, 14 insertions, 4 deletions
diff --git a/scripts/actors/actions/MeleeAction.cs b/scripts/actors/actions/MeleeAction.cs
index cf40f1d..c61a803 100644
--- a/scripts/actors/actions/MeleeAction.cs
+++ b/scripts/actors/actions/MeleeAction.cs
@@ -14,14 +14,24 @@ public partial class MeleeAction : DirectionalAction
/// </summary>
public override void Perform()
{
- Vector2I destination = actor.GridPosition + Offset;
// Eu te disse que este método seria útil.
- Actor target = GetBlockingActorAtPosition(destination);
+ Actor target = GetTargetActor();
// Se não houver um ator na direção, não podemos continuar.
if (target == null) return;
- // TODO: Implementar ataque.
- GD.Print($"Você tenta socar {target.ActorName}, mas como não sobra nada para o beta, você ainda não tem um método de ataque.");
+ // não podemos ter dano negativo.
+ int damage = actor.Atk - target.Def;
+
+ string attackDesc = $"{actor.ActorName} ataca {target.ActorName}";
+
+ if (damage > 0) {
+ attackDesc += $" e remove {damage} de HP.";
+ target.Hp -= damage;
+ } else {
+ attackDesc += $" mas {target.ActorName} tem músculos de aço.";
+ }
+
+ GD.Print(attackDesc);
}
}