PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/InfestationEffect.cs

33 lines
845 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "infestation")]
public class InfestationEffect : Script
{
private readonly IPokemon _owner;
private int _turns;
public InfestationEffect(IPokemon owner, int turns)
{
_owner = owner;
_turns = turns;
}
/// <inheritdoc />
public override void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
/// <inheritdoc />
public override void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
/// <inheritdoc />
public override void OnEndTurn(IBattle battle)
{
var damage = _owner.BoostedStats.Hp / 8;
_owner.Damage(damage, DamageSource.Misc);
_turns--;
if (_turns <= 0)
{
RemoveSelf();
}
}
}