50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using PkmnLib.Static;
|
|
using PkmnLib.Static.Utils;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
[Script(ScriptCategory.Pokemon, "ingrain")]
|
|
public class IngrainEffect : Script
|
|
{
|
|
private readonly IPokemon _owner;
|
|
|
|
public IngrainEffect(IPokemon owner)
|
|
{
|
|
_owner = owner;
|
|
}
|
|
|
|
/// <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 heal = _owner.BoostedStats.Hp / 16;
|
|
_owner.Heal(heal);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
|
{
|
|
if (move.UseMove.Name == "roar" || move.UseMove.Name == "whirlwind")
|
|
{
|
|
fail = true;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
|
IList<TypeIdentifier> types)
|
|
{
|
|
if (executingMove.UseMove.MoveType.Name == "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);
|
|
}
|
|
}
|
|
} |