namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;

[Script(ScriptCategory.Pokemon, "powder")]
public class PowderEffect : Script, IScriptBlockOutgoingHit
{
    /// <inheritdoc />
    /// <inheritdoc />
    public void BlockOutgoingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
    {
        var hit = executingMove.GetHitData(target, hitIndex);
        if (hit.Type?.Name == "fire")
        {
            executingMove.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("powder_explodes",
                new Dictionary<string, object>
                {
                    { "user", executingMove.User },
                    { "target", target },
                }));

            var health = executingMove.User.MaxHealth / 4;
            executingMove.User.Damage(health, DamageSource.Misc);

            block = true;
        }
    }
}