More moves
This commit is contained in:
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/PerishSong.cs
Normal file
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/PerishSong.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
/// <summary>
|
||||
/// Implements the secondary effect of Perish Song, which causes all Pokemon on the field to faint in 3 turns.
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Move, "perish_song")]
|
||||
public class PerishSong : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (move.User.Volatile.Contains<PerishSongEffect>())
|
||||
return;
|
||||
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
// Add Perish Song volatile to all Pokémon on the field
|
||||
foreach (var pokemon in battleData.Battle.Sides.SelectMany(x => x.Pokemon).WhereNotNull())
|
||||
{
|
||||
pokemon.Volatile.Add(new PerishSongEffect(pokemon));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user