summaryrefslogtreecommitdiff
path: root/scripts/entities/items/HealingConsumable.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-04 18:31:40 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-04 18:31:40 -0300
commit1e248d3dd18f7c6bfaf8066c4662facbbb89e8f9 (patch)
tree8250335d5ad8176da05f7243052b9af85802c7ed /scripts/entities/items/HealingConsumable.cs
parent147bb12b5d48c5432aa1bd1cbe60b8435294445b (diff)
Itens na masmorra
Diffstat (limited to 'scripts/entities/items/HealingConsumable.cs')
-rw-r--r--scripts/entities/items/HealingConsumable.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/entities/items/HealingConsumable.cs b/scripts/entities/items/HealingConsumable.cs
new file mode 100644
index 0000000..3d8df51
--- /dev/null
+++ b/scripts/entities/items/HealingConsumable.cs
@@ -0,0 +1,27 @@
+using Godot;
+
+public partial class HealingConsumable : ConsumableItem
+{
+ private HealingConsumableDefinition definition;
+ public float HealingPercentage { get; private set; }
+ public HealingConsumable(Vector2I initialPosition, MapData map, HealingConsumableDefinition definition) : base(initialPosition, map, definition)
+ {
+ this.definition = definition;
+ HealingPercentage = definition.healingPercentage;
+ }
+
+ public override bool Activate(ItemAction action)
+ {
+ Actor consumer = action.ThisActor;
+ int intendedAmount = (int)(HealingPercentage / 100 * consumer.MaxHp);
+ int recovered = consumer.Heal(intendedAmount);
+
+ // Se não tinha o que curar, a ativação falhou.
+ if (recovered == 0) {
+ MessageLogData.Instance.AddMessage("Você já está saudável.");
+ return false;
+ }
+ MessageLogData.Instance.AddMessage($"Você consome {DisplayName} e recupera {recovered} de HP");
+ return true;
+ }
+} \ No newline at end of file