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

42 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "infestation")]
public class InfestationEffect : Script, IScriptOnEndTurn, IScriptPreventSelfSwitch, IScriptPreventSelfRunAway,
IAIInfoScriptExpectedEndOfTurnDamage
{
private readonly IBattlePokemon _owner;
private int _turns;
private readonly float _bindDamage;
public InfestationEffect(IBattlePokemon owner, int turns, float bindDamage)
{
_owner = owner;
_turns = turns;
_bindDamage = bindDamage;
}
/// <inheritdoc />
public void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
/// <inheritdoc />
public void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
var damage = _owner.BoostedStats.Hp * _bindDamage;
_owner.Damage((uint)damage, DamageSource.Misc);
_turns--;
if (_turns <= 0)
{
RemoveSelf();
}
}
/// <inheritdoc />
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
{
damage += (int)(_owner.MaxHealth * _bindDamage);
}
}