This commit is contained in:
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Spite.cs
Normal file
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Spite.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Linq;
|
||||
|
||||
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();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user