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

48 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "flower_veil")]
public class FlowerVeilEffect : Script, IScriptPreventStatBoostChange, IScriptPreventStatusChange
{
private readonly HashSet<IPokemon> _placerPokemon = [];
public void OnAdded(IPokemon placer)
{
_placerPokemon.Add(placer);
}
public void OnRemoved(IPokemon placer)
{
_placerPokemon.Remove(placer);
if (_placerPokemon.Count == 0)
{
RemoveSelf();
}
}
/// <inheritdoc />
public void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
ref bool prevent)
{
if (selfInflicted)
return;
if (amount > 0)
return;
if (target.Types.All(x => x.Name != "grass"))
return;
prevent = true;
}
/// <inheritdoc />
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (selfInflicted)
return;
if (pokemon.Types.All(x => x.Name != "grass"))
return;
preventStatus = true;
}
}