Deukhoofd eea5697109
All checks were successful
Build / Build (push) Successful in 49s
Fixes all warnings
2025-05-19 11:50:51 +02:00

21 lines
750 B
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "spite")]
public class Spite : Script
{
/// <inheritdoc />
public override 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();
}
}
}