Deukhoofd 7c270a6d52
All checks were successful
Build / Build (push) Successful in 1m1s
Finish script interface refactor
2025-07-06 10:27:56 +02:00

52 lines
1.3 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
[Script(ScriptCategory.Battle, "uproar_effect")]
public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEffect, IScriptOnEndTurn,
IScriptPreventStatusChange
{
private IPokemon? _placer;
private bool _hasUsedUproar;
private int _turns = 3;
public void SetPlacer(IPokemon placer)
{
_placer = placer;
_hasUsedUproar = true;
}
/// <inheritdoc />
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Sleep>())
{
preventStatus = true;
}
}
/// <inheritdoc />
public void OnBeforeTurnStart(ITurnChoice choice)
{
_hasUsedUproar = false;
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
if (move.User == _placer && move.UseMove.Name == "uproar")
_hasUsedUproar = true;
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (!_hasUsedUproar)
{
RemoveSelf();
}
_turns--;
if (_turns <= 0)
{
RemoveSelf();
}
}
}