namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

[Script(ScriptCategory.Move, "power_swap")]
public class PowerSwap : Script, IScriptOnSecondaryEffect
{
    /// <inheritdoc />
    public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
    {
        var user = move.User;

        var eventBatchId = new EventBatchId();
        var userAttack = user.StatBoost.Attack;
        var targetAttack = target.StatBoost.Attack;
        var userSpecialAttack = user.StatBoost.SpecialAttack;
        var targetSpecialAttack = target.StatBoost.SpecialAttack;

        user.ChangeStatBoost(Statistic.Attack, (sbyte)(targetAttack - userAttack), true, true, eventBatchId);
        user.ChangeStatBoost(Statistic.SpecialAttack, (sbyte)(targetSpecialAttack - userSpecialAttack), true, true,
            eventBatchId);
        target.ChangeStatBoost(Statistic.Attack, (sbyte)(userAttack - targetAttack), true, true, eventBatchId);
        target.ChangeStatBoost(Statistic.SpecialAttack, (sbyte)(userSpecialAttack - targetSpecialAttack), true, true,
            eventBatchId);
    }
}