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

36 lines
1.3 KiB
C#

using PkmnLib.Static.Libraries;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "foresight")]
public class ForesightEffect : Script, IScriptPreventStatBoostChange, IScriptChangeTypesForIncomingMove
{
private readonly TypeIdentifier _normalType;
private readonly TypeIdentifier _fightingType;
private readonly TypeIdentifier _ghostType;
public ForesightEffect(IReadOnlyTypeLibrary typeLibrary)
{
typeLibrary.TryGetTypeIdentifier(TypeNames.Normal, out _normalType);
typeLibrary.TryGetTypeIdentifier(TypeNames.Fighting, out _fightingType);
typeLibrary.TryGetTypeIdentifier(TypeNames.Ghost, out _ghostType);
}
/// <inheritdoc />
public void PreventStatBoostChange(IBattlePokemon target, Statistic stat, sbyte amount, bool selfInflicted,
ref bool prevent)
{
if (stat == Statistic.Evasion)
prevent = true;
}
/// <inheritdoc />
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
if (executingMove.UseMove.MoveType == _normalType || executingMove.UseMove.MoveType == _fightingType)
{
types.RemoveAll(x => x == _ghostType);
}
}
}