namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon; [Script(ScriptCategory.Pokemon, "ingrain")] public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptPreventSelfSwitch, IScriptPreventSelfRunAway, IScriptChangeTypesForIncomingMove { private readonly IPokemon _owner; public IngrainEffect(IPokemon owner) { _owner = owner; } /// public void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) { if (choice.User.Types.All(x => x.Name != TypeNames.Ghost)) prevent = true; } /// public void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) { if (choice.User.Types.All(x => x.Name != TypeNames.Ghost)) prevent = true; } /// public void OnEndTurn(IScriptSource owner, IBattle battle) { var heal = _owner.BoostedStats.Hp / 16; _owner.Heal(heal); } /// public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail) { if (move.UseMove.Name == MoveNames.Roar || move.UseMove.Name == MoveNames.Whirlwind) { fail = true; } } /// public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex, IList types) { if (executingMove.UseMove.MoveType.Name == TypeNames.Ground) { var typeLibrary = target.Library.StaticLibrary.Types; // Remove all types that are immune to ground moves types.RemoveAll(x => typeLibrary.GetSingleEffectiveness(executingMove.UseMove.MoveType, x) == 0); } } }