namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Battery is an ability that increases the power of allies' Special moves by 30%.
/// This effect only applies to allies on the same side of the field.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Battery_(Ability)">Bulbapedia - Battery</see>
/// </summary>
[Script(ScriptCategory.Ability, "battery")]
public class Battery : Script, IScriptOnSwitchIn, IScriptOnSwitchOut
{
    /// <inheritdoc />
    public void OnSwitchIn(IPokemon pokemon, byte position)
    {
        var side = pokemon.BattleData?.BattleSide;
        var effect = side?.VolatileScripts.Add(new Side.BatteryAbilityEffect())?.Script as Side.BatteryAbilityEffect;
        effect?.PlacerActivated(pokemon);
    }

    /// <inheritdoc />
    public void OnSwitchOut(IPokemon oldPokemon, byte position)
    {
        var side = oldPokemon.BattleData?.BattleSide;
        var effect = side?.VolatileScripts.Get<Side.BatteryAbilityEffect>();
        effect?.PlacerDeactivated(oldPokemon);
    }
}