20 lines
733 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Power of Alchemy is an ability that copies the ability of a fainted ally.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Power_of_Alchemy_(Ability)">Bulbapedia - Power of Alchemy</see>
/// </summary>
[Script(ScriptCategory.Ability, "power_of_alchemy")]
public class PowerOfAlchemy : Script, IScriptOnAllyFaint
{
/// <inheritdoc />
public void OnAllyFaint(IPokemon ally, IPokemon faintedPokemon)
{
if (faintedPokemon.ActiveAbility?.HasFlag("cant_be_copied") != true)
return;
ally.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(ally));
ally.ChangeAbility(faintedPokemon.ActiveAbility);
}
}