This commit is contained in:
38
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/WideGuardEffect.cs
Normal file
38
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/WideGuardEffect.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "wide_guard")]
|
||||
public class WideGuardEffect : Script
|
||||
{
|
||||
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 override 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 override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user