namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

/// <summary>
/// Implements the secondary effect of Payback, which doubles the move's power if the user moves after the target.
/// </summary>
[Script(ScriptCategory.Move, "payback")]
public class Payback : Script, IScriptChangeBasePower
{
    /// <inheritdoc />
    public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
    {
        var battleData = move.User.BattleData;

        // Check if the target has already moved this turn
        if (battleData?.Battle.ChoiceQueue?.FirstOrDefault(x => x.User == target) != null)
        {
            basePower = basePower.MultiplyOrMax(2);
        }
    }
}