summaryrefslogtreecommitdiff
path: root/scripts/Entities/Actions/SpellAction.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-14 00:14:25 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-14 00:14:25 -0300
commit5958d9c071915ab71aea5a5c08d79e88024f6c58 (patch)
tree8ab992a1ae055ea501faa48f3fdc778061945ba0 /scripts/Entities/Actions/SpellAction.cs
parent539fd4820f37aa54df8878091db9680d89ee027a (diff)
The newer scolls: groundrim.
Diffstat (limited to 'scripts/Entities/Actions/SpellAction.cs')
-rw-r--r--scripts/Entities/Actions/SpellAction.cs34
1 files changed, 29 insertions, 5 deletions
diff --git a/scripts/Entities/Actions/SpellAction.cs b/scripts/Entities/Actions/SpellAction.cs
index 086a52a..f8819b9 100644
--- a/scripts/Entities/Actions/SpellAction.cs
+++ b/scripts/Entities/Actions/SpellAction.cs
@@ -1,23 +1,45 @@
using Godot;
using TheLegendOfGustav.Entities.Actors;
using TheLegendOfGustav.Magic;
+using TheLegendOfGustav.Utils;
namespace TheLegendOfGustav.Entities.Actions;
-public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource spell) : DirectionalAction(actor, offset)
+/// <summary>
+/// Ação para quando o jogador joga um feitiço.
+/// </summary>
+public partial class SpellAction : DirectionalAction
{
- private SpellResource spell = spell;
+ private SpellResource spell;
+
+ public SpellAction(Actor actor, Vector2I offset, SpellResource spell) : base(actor, offset)
+ {
+ this.spell = spell;
+
+ Cost = 5;
+ }
public override bool Perform()
{
- Actor target = null;
+ Actor target;
- if (GetTarget() is Actor actor)
+ if (spell.Type == SpellType.Self)
+ {
+ target = Actor;
+ }
+ else if (GetTarget() is Actor actor)
{
target = actor;
}
+ else
+ {
+ return false;
+ }
- if (spell.Type == SpellType.Ranged && target == null) return false;
+ if (Grid.Distance(Actor.GridPosition, target.GridPosition) > spell.Range)
+ {
+ return false;
+ }
if (Actor.Mp < spell.Cost)
{
@@ -28,6 +50,8 @@ public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource sp
{
effect.Apply(Actor, target);
}
+
+ Actor.Energy -= Cost;
return true;
}
}