Deukhoofd 32aaa5150a
All checks were successful
Build / Build (push) Successful in 54s
Initial setup for testing AI performance, random fixes
2025-07-05 13:56:33 +02:00

23 lines
926 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Wonder Guard is an ability that only allows super-effective moves to hit the Pokémon.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Wonder_Guard_(Ability)">Bulbapedia - Wonder Guard</see>
/// </summary>
[Script(ScriptCategory.Ability, "wonder_guard")]
public class WonderGuard : Script, IScriptBlockIncomingHit
{
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
var type = executingMove.GetHitData(target, hitIndex).Type;
if (type is null || type.Value.Value == 0)
return;
var effectiveness = executingMove.GetHitData(target, hitIndex).Effectiveness;
if (!(effectiveness <= 1.0))
return;
executingMove.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
block = true;
}
}