namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;

[Script(ScriptCategory.Pokemon, "destiny_bond")]
public class DestinyBondEffect : Script, IScriptOnBeforeMove, IScriptOnFaint
{
    /// <inheritdoc />
    public void OnFaint(IPokemon pokemon, DamageSource source)
    {
        if (source == DamageSource.MoveDamage)
        {
            if (pokemon.BattleData?.Battle.ChoiceQueue?.LastRanChoice is not IMoveChoice lastChoice)
                return;
            lastChoice.User.Damage(lastChoice.User.BoostedStats.Hp * 10, DamageSource.Misc, forceDamage: true);
        }
    }

    /// <inheritdoc />
    public void OnBeforeMove(IExecutingMove move)
    {
        RemoveSelf();
    }
}