diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
| commit | c6bbb834f7758027c0df338f1520f34fad3befea (patch) | |
| tree | 1818cd23c24be16fbe19b16dd0a510874d440d83 /scripts/Entities/Items/HealingConsumable.cs | |
| parent | f1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff) | |
Organização
Diffstat (limited to 'scripts/Entities/Items/HealingConsumable.cs')
| -rw-r--r-- | scripts/Entities/Items/HealingConsumable.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/Entities/Items/HealingConsumable.cs b/scripts/Entities/Items/HealingConsumable.cs new file mode 100644 index 0000000..32f76a6 --- /dev/null +++ b/scripts/Entities/Items/HealingConsumable.cs @@ -0,0 +1,30 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Utils; +using TheLegendOfGustav.Entities.Actions; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Items; + +public partial class HealingConsumable(Vector2I initialPosition, MapData map, HealingConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition) +{ + private HealingConsumableDefinition Definition { get; set; } = definition; + public float HealingPercentage { get; private set; } = definition.healingPercentage; + + public override bool Activate(ItemAction action) + { + Player consumer = action.Player; + 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"); + ConsumedBy(consumer); + return true; + } +}
\ No newline at end of file |
