From 539fd4820f37aa54df8878091db9680d89ee027a Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 13 Sep 2025 11:06:46 -0300 Subject: pergaminho --- scripts/Entities/Actions/SpellAction.cs | 33 ++++++++++++++++++++++ scripts/Entities/Actions/SpellAction.cs.uid | 1 + scripts/Entities/Actors/Actor.cs | 3 ++ scripts/Entities/Items/ConsumableItem.cs | 2 +- scripts/Entities/Items/ScrollConsumable.cs | 25 ++++++++++++++++ scripts/Entities/Items/ScrollConsumable.cs.uid | 1 + .../Entities/Items/ScrollConsumableDefinition.cs | 11 ++++++++ .../Items/ScrollConsumableDefinition.cs.uid | 1 + 8 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 scripts/Entities/Actions/SpellAction.cs create mode 100644 scripts/Entities/Actions/SpellAction.cs.uid create mode 100644 scripts/Entities/Items/ScrollConsumable.cs create mode 100644 scripts/Entities/Items/ScrollConsumable.cs.uid create mode 100644 scripts/Entities/Items/ScrollConsumableDefinition.cs create mode 100644 scripts/Entities/Items/ScrollConsumableDefinition.cs.uid (limited to 'scripts/Entities') 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; + } +} diff --git a/scripts/Entities/Actions/SpellAction.cs.uid b/scripts/Entities/Actions/SpellAction.cs.uid new file mode 100644 index 0000000..6f85025 --- /dev/null +++ b/scripts/Entities/Actions/SpellAction.cs.uid @@ -0,0 +1 @@ +uid://b18wblvggpev0 diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs index 7e6685f..8eee4e2 100644 --- a/scripts/Entities/Actors/Actor.cs +++ b/scripts/Entities/Actors/Actor.cs @@ -1,4 +1,5 @@ using Godot; +using TheLegendOfGustav.Magic; using TheLegendOfGustav.Map; using TheLegendOfGustav.Utils; @@ -132,6 +133,8 @@ public partial class Actor : Entity get; set; } + + public SpellBook SpellBook { get; private set; } = new(); #endregion #region Methods diff --git a/scripts/Entities/Items/ConsumableItem.cs b/scripts/Entities/Items/ConsumableItem.cs index f70983a..4078bd3 100644 --- a/scripts/Entities/Items/ConsumableItem.cs +++ b/scripts/Entities/Items/ConsumableItem.cs @@ -9,7 +9,7 @@ namespace TheLegendOfGustav.Entities.Items; /// Classe para itens consumíveis. /// Itens consumíveis são itens de uso limitado. /// -public abstract partial class ConsumableItem(Vector2I initialPosition, MapData map, EntityDefinition definition) : Entity(initialPosition, map, definition) +public abstract partial class ConsumableItem(Vector2I initialPosition, MapData map, ConsumableItemDefinition definition) : Entity(initialPosition, map, definition) { /// diff --git a/scripts/Entities/Items/ScrollConsumable.cs b/scripts/Entities/Items/ScrollConsumable.cs new file mode 100644 index 0000000..d260263 --- /dev/null +++ b/scripts/Entities/Items/ScrollConsumable.cs @@ -0,0 +1,25 @@ +using Godot; +using TheLegendOfGustav.Entities.Actions; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Magic; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.Entities.Items; + +public partial class ScrollConsumable(Vector2I initialPosition, MapData map, ScrollConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition) +{ + private ScrollConsumableDefinition definition = definition; + + public SpellResource Spell { get; private set; } = definition.Spell; + + + public override bool Activate(ItemAction action) + { + Player consumer = action.Player; + + MessageLogData.Instance.AddMessage("Foste cuckado"); + ConsumedBy(consumer); + return true; + } +} \ No newline at end of file diff --git a/scripts/Entities/Items/ScrollConsumable.cs.uid b/scripts/Entities/Items/ScrollConsumable.cs.uid new file mode 100644 index 0000000..ba79f47 --- /dev/null +++ b/scripts/Entities/Items/ScrollConsumable.cs.uid @@ -0,0 +1 @@ +uid://dsp0ryh6fctv1 diff --git a/scripts/Entities/Items/ScrollConsumableDefinition.cs b/scripts/Entities/Items/ScrollConsumableDefinition.cs new file mode 100644 index 0000000..c9f50a5 --- /dev/null +++ b/scripts/Entities/Items/ScrollConsumableDefinition.cs @@ -0,0 +1,11 @@ +using Godot; +using TheLegendOfGustav.Magic; + +namespace TheLegendOfGustav.Entities.Items; + +[GlobalClass] +public partial class ScrollConsumableDefinition : ConsumableItemDefinition +{ + [Export] + public SpellResource Spell { get; set; } +} \ No newline at end of file diff --git a/scripts/Entities/Items/ScrollConsumableDefinition.cs.uid b/scripts/Entities/Items/ScrollConsumableDefinition.cs.uid new file mode 100644 index 0000000..8cadd79 --- /dev/null +++ b/scripts/Entities/Items/ScrollConsumableDefinition.cs.uid @@ -0,0 +1 @@ +uid://2lk5w2po81gy -- cgit v1.2.3