summaryrefslogtreecommitdiff
path: root/scripts/Entities/Actions/SpellAction.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-13 11:06:46 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-13 11:06:46 -0300
commit539fd4820f37aa54df8878091db9680d89ee027a (patch)
tree41f9f5d6aa123058e3549c1baba4155fa5a85279 /scripts/Entities/Actions/SpellAction.cs
parentb8962990ddb75b874a49c83d8eeaba7b7e45c196 (diff)
pergaminho
Diffstat (limited to 'scripts/Entities/Actions/SpellAction.cs')
-rw-r--r--scripts/Entities/Actions/SpellAction.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/Entities/Actions/SpellAction.cs b/scripts/Entities/Actions/SpellAction.cs
new file mode 100644
index 0000000..086a52a
--- /dev/null
+++ b/scripts/Entities/Actions/SpellAction.cs
@@ -0,0 +1,33 @@
+using Godot;
+using TheLegendOfGustav.Entities.Actors;
+using TheLegendOfGustav.Magic;
+
+namespace TheLegendOfGustav.Entities.Actions;
+
+public partial class SpellCommand(Actor actor, Vector2I offset, SpellResource spell) : DirectionalAction(actor, offset)
+{
+ private SpellResource spell = spell;
+
+ public override bool Perform()
+ {
+ Actor target = null;
+
+ if (GetTarget() is Actor actor)
+ {
+ target = actor;
+ }
+
+ if (spell.Type == SpellType.Ranged && target == null) return false;
+
+ if (Actor.Mp < spell.Cost)
+ {
+ return false;
+ }
+
+ foreach (SpellEffect effect in spell.Effects)
+ {
+ effect.Apply(Actor, target);
+ }
+ return true;
+ }
+}