32 lines
1014 B
C#
32 lines
1014 B
C#
using System.Linq;
|
|
using PkmnLib.Static;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "flower_shield")]
|
|
public class FlowerShield : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var battleData = target.BattleData;
|
|
if (battleData == null)
|
|
return;
|
|
if (!battleData.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("grass", out var grassType))
|
|
return;
|
|
|
|
var batchId = new EventBatchId();
|
|
var sides = battleData.Battle.Sides;
|
|
foreach (var side in sides)
|
|
{
|
|
foreach (var pokemon in side.Pokemon)
|
|
{
|
|
if (pokemon == null || pokemon.IsFainted)
|
|
continue;
|
|
if (!pokemon.Types.Contains(grassType))
|
|
continue;
|
|
pokemon.ChangeStatBoost(Statistic.Defense, 1, pokemon == move.User, batchId);
|
|
}
|
|
}
|
|
}
|
|
} |