Deukhoofd 1feb27e826
All checks were successful
Build / Build (push) Successful in 50s
More work on refactor to interfaces
2025-06-29 12:03:51 +02:00

38 lines
953 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "wide_guard")]
public class WideGuardEffect : Script, IScriptChangeTargets, IScriptOnEndTurn
{
private IBattleSide? _side;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is IBattleSide side)
{
_side = side;
}
else
{
throw new InvalidOperationException("WideGuard can only be added to a battle side.");
}
}
/// <inheritdoc />
public void ChangeTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
if (_side == null)
return;
if (targets.Count > 1)
{
targets = targets.Where(x => x?.BattleData?.BattleSide != _side).ToList();
}
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
RemoveSelf();
}
}