namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Sand Force is an ability that boosts the power of Rock, Ground, and Steel-type moves in a sandstorm.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Force_(Ability)">Bulbapedia - Sand Force</see>
/// </summary>
[Script(ScriptCategory.Ability, "sand_force")]
public class SandForce : Script, IScriptChangeBasePower, IScriptCustomTrigger
{
    /// <inheritdoc />
    public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
    {
        if (move.Battle.WeatherName == ScriptUtils.ResolveName<Weather.Sandstorm>())
        {
            var type = move.GetHitData(target, hit).Type;
            if (type != null &&
                (type.Value.Name == "rock" || type.Value.Name == "ground" || type.Value.Name == "steel"))
            {
                basePower = basePower.MultiplyOrMax(1.3f);
            }
        }
    }

    /// <inheritdoc />
    public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
    {
        if (eventName == CustomTriggers.BypassSandstormDamage &&
            args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
        {
            bypassArgs.Bypass = true;
        }
    }
}