25 lines
729 B
C#
25 lines
729 B
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "recycle")]
|
|
public class Recycle : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
if (move.User.HeldItem is not null)
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
var battleData = move.User.BattleData;
|
|
if (battleData is null)
|
|
return;
|
|
var lastItem = battleData.BattleSide.GetLastConsumedItem(battleData.Position);
|
|
if (lastItem is null)
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
_ = move.User.SetHeldItem(lastItem);
|
|
}
|
|
} |