namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;

/// <summary>
/// Protean is an ability that changes the Pokémon's type to the type of the move it is about to use.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Protean_(Ability)">Bulbapedia - Protean</see>
/// </summary>
[Script(ScriptCategory.Ability, "protean")]
public class Protean : Script, IScriptOnBeforeMove
{
    /// <inheritdoc />
    public void OnBeforeMove(IExecutingMove move)
    {
        if (move.User.Types.Count == 1 && move.User.Types[0] == move.UseMove.MoveType)
            return;
        move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
        move.User.SetTypes([move.UseMove.MoveType]);
    }
}