using PkmnLib.Plugin.Gen7.Scripts.Pokemon;

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Flash Fire is an ability that makes the Pokémon immune to Fire-type moves.
/// When hit by a Fire-type move, the ability activates and increases the power of the Pokémon's Fire-type moves by 50%.
/// This ability is commonly associated with Ninetales and Arcanine.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Flash_Fire_(Ability)">Bulbapedia - Flash Fire</see>
/// </summary>
[Script(ScriptCategory.Ability, "flash_fire")]
public class FlashFire : Script, IScriptChangeIncomingEffectiveness
{
    /// <inheritdoc />
    public void ChangeIncomingEffectiveness(IExecutingMove executingMove, IPokemon target, byte hitIndex,
        ref float effectiveness)
    {
        if (executingMove.GetHitData(target, hitIndex).Type?.Name != "fire")
            return;
        effectiveness = 0f;

        if (target.Volatile.Contains<FlashFireEffect>())
            return;
        target.Volatile.Add(new FlashFireEffect());
        executingMove.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
    }
}