40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using PkmnLib.Plugin.Gen7.Scripts.Side;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|
|
|
/// <summary>
|
|
/// Teravolt is an ability that allows moves to ignore the target's abilities if they could hinder or prevent the move.
|
|
///
|
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Teravolt_(Ability)">Bulbapedia - Teravolt</see>
|
|
/// </summary>
|
|
[Script(ScriptCategory.Ability, "teravolt")]
|
|
public class Teravolt : Script, IScriptOnBeforeMoveChoice, IScriptOnAfterMoveChoice
|
|
{
|
|
/// <inheritdoc />
|
|
public void OnBeforeMoveChoice(IMoveChoice moveChoice)
|
|
{
|
|
var battleData = moveChoice.User.BattleData;
|
|
if (battleData is null)
|
|
return;
|
|
|
|
var sides = battleData.Battle.Sides.Where(x => x != battleData.BattleSide);
|
|
foreach (var side in sides)
|
|
{
|
|
side.VolatileScripts.Add(new TeravoltEffect());
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void OnAfterMoveChoice(IMoveChoice move)
|
|
{
|
|
var battleData = move.User.BattleData;
|
|
if (battleData is null)
|
|
return;
|
|
|
|
var sides = battleData.Battle.Sides.Where(x => x != battleData.BattleSide);
|
|
foreach (var side in sides)
|
|
{
|
|
side.VolatileScripts.Remove<TeravoltEffect>();
|
|
}
|
|
}
|
|
} |