summaryrefslogtreecommitdiff
path: root/scripts/Magic/DamageEffect.cs
blob: 1263ab69cdb8e2ddd4e082037b34bce6fc75020f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Godot;
using TheLegendOfGustav.Entities.Actors;
using TheLegendOfGustav.Utils;

namespace TheLegendOfGustav.Magic;

[GlobalClass]
public partial class DamageEffect : SpellEffect
{
	[Export]
	public int Damage { get; set; }

	public override void Apply(Actor caster, Actor target)
	{
		int damageDealt = Damage - target.Men;

		if (damageDealt < 0)
		{
			damageDealt = 0;
		}

		if (damageDealt <= 0) {
			MessageLogData.Instance.AddMessage($"{target.DisplayName} resiste o ataque mágico de {caster.DisplayName}");
		}
		else {
			MessageLogData.Instance.AddMessage($"{caster.DisplayName} aplica {damageDealt} de dano mágico em {target.DisplayName}");
		}

		target.Hp -= damageDealt;
	}
}