25 lines
811 B
C#
25 lines
811 B
C#
using System.Linq;
|
|
using PkmnLib.Static.Utils;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "core_enforcer")]
|
|
public class CoreEnforcer : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var battleData = target.BattleData;
|
|
if (battleData == null)
|
|
return;
|
|
var turnChoices = battleData.Battle.PreviousTurnChoices.Last();
|
|
var currentChoiceIndex = turnChoices.IndexOf(move.MoveChoice);
|
|
if (currentChoiceIndex == -1 ||
|
|
!turnChoices.Take(currentChoiceIndex).Any(choice => choice is IMoveChoice or IItemChoice))
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
target.SuppressAbility();
|
|
}
|
|
} |