using System.Linq; using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile; using PkmnLib.Plugin.Gen7.Scripts.Utils; using PkmnLib.Static.Utils; namespace PkmnLib.Plugin.Gen7.Scripts.Moves; [Script(ScriptCategory.Move, "sleep_talk")] public class SleepTalk : Script { /// public override void ChangeMove(IMoveChoice choice, ref StringKey moveName) { if (!choice.User.HasStatus(ScriptUtils.ResolveName())) { choice.Fail(); return; } var battleData = choice.User.BattleData; if (battleData == null) return; var moves = choice.User.Moves.WhereNotNull().Where(x => x.MoveData.CanCopyMove()) .Where(x => x != choice.ChosenMove).OrderBy(_ => battleData.Battle.Random.GetInt()).FirstOrDefault(); if (moves == null) { choice.Fail(); return; } moveName = moves.MoveData.Name; choice.Volatile.Add(new BypassSleepVolatile()); } }