19 lines
761 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Water Compaction is an ability that sharply raises Defense when hit by a Water-type move.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Compaction_(Ability)">Bulbapedia - Water Compaction</see>
/// </summary>
[Script(ScriptCategory.Ability, "water_compaction")]
public class WaterCompaction : Script, IScriptOnIncomingHit
{
/// <inheritdoc />
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
if (move.GetHitData(target, hit).Type?.Name != "water")
return;
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
target.ChangeStatBoost(Statistic.Defense, 2, true, false);
}
}