PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Copycat.cs

22 lines
667 B
C#
Raw Normal View History

2025-01-27 11:18:48 +00:00
using System.Linq;
using PkmnLib.Plugin.Gen7.Scripts.Utils;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "copycat")]
public class Copycat : Script
{
/// <inheritdoc />
public override void ChangeMove(IMoveChoice choice, ref StringKey moveName)
{
2025-03-02 16:19:57 +00:00
var lastMove = choice.User.BattleData?.Battle.PreviousTurnChoices.SelectMany(x => x).OfType<IMoveChoice>()
2025-01-27 11:18:48 +00:00
.LastOrDefault();
if (lastMove == null || !lastMove.ChosenMove.MoveData.CanCopyMove())
{
choice.Fail();
return;
}
moveName = lastMove.ChosenMove.MoveData.Name;
}
}