More moves implemented
This commit is contained in:
29
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Instruct.cs
Normal file
29
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Instruct.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Dynamic.Models.BattleFlow;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "instruct")]
|
||||
public class Instruct : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (!target.IsUsable)
|
||||
return;
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var lastMoveChoiceByTarget = battleData.Battle.PreviousTurnChoices.SelectMany(x => x)
|
||||
.SkipWhile(x => x != move.MoveChoice).OfType<MoveChoice>().FirstOrDefault(x => x.User == target);
|
||||
|
||||
if (lastMoveChoiceByTarget == null || !battleData.Battle.CanUse(lastMoveChoiceByTarget))
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
|
||||
TurnRunner.ExecuteChoice(battleData.Battle, lastMoveChoiceByTarget);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user