using PkmnLib.Static.Moves;

namespace PkmnLib.Plugin.Gen7.Scripts.Side;

[Script(ScriptCategory.Side, "battery")]
public class BatteryAbilityEffect : Script, IScriptChangeDamageModifier
{
    private HashSet<IPokemon> _placers = new();

    public void PlacerActivated(IPokemon placer) => _placers.Add(placer);

    public void PlacerDeactivated(IPokemon placer)
    {
        _placers.Remove(placer);
        if (_placers.Count == 0)
            RemoveSelf();
    }

    /// <inheritdoc />
    public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
    {
        if (move.UseMove.Category == MoveCategory.Special)
        {
            modifier *= 5325f / 4096f; // ~1.3x
        }
    }
}