21 lines
767 B
C#
21 lines
767 B
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "spite")]
|
|
public class Spite : Script, IScriptOnSecondaryEffect
|
|
{
|
|
/// <inheritdoc />
|
|
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var lastMoveChoiceByTarget = move.Battle.PreviousTurnChoices.SelectMany(x => x).Reverse()
|
|
.SkipWhile(x => x != move.MoveChoice).OfType<MoveChoice>().FirstOrDefault(x => x.User == target);
|
|
if (lastMoveChoiceByTarget == null || lastMoveChoiceByTarget.HasFailed)
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
if (!lastMoveChoiceByTarget.ChosenMove.ReduceUses(4))
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
}
|
|
}
|
|
} |