namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;

[Script(ScriptCategory.Pokemon, "perish_song")]
public class PerishSongEffect : Script, IScriptOnEndTurn
{
    internal int Turns { get; private set; }
    private IPokemon _owner;

    public PerishSongEffect(IPokemon owner, int turns = 3)
    {
        _owner = owner;
        Turns = turns;
    }

    /// <inheritdoc />
    public void OnEndTurn(IScriptSource owner, IBattle battle)
    {
        Turns--;
        if (Turns <= 0)
        {
            RemoveSelf();
            _owner.Faint(DamageSource.Misc);
        }
    }
}