Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Instruct.cs
Deukhoofd d2a82b5fe3
All checks were successful
Build / Build (push) Successful in 3m12s
Many more tests and fixes
2026-08-27 17:11:12 +02:00

29 lines
901 B
C#

using PkmnLib.Dynamic.BattleFlow;
using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "instruct")]
public class Instruct : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
if (!target.IsUsable)
return;
var battleData = move.User.BattleData;
if (battleData == null)
return;
var lastMoveChoiceByTarget = target.BattleData?.LastMoveChoice;
if (lastMoveChoiceByTarget == null || !battleData.Battle.CanUse(lastMoveChoiceByTarget) ||
!lastMoveChoiceByTarget.ChosenMove.MoveData.CanCopyMove())
{
move.GetHitData(target, hit).Fail();
return;
}
TurnRunner.ExecuteChoice(battleData.Battle, lastMoveChoiceByTarget);
}
}