Deukhoofd c795f20e54
All checks were successful
Build / Build (push) Successful in 51s
Implement highest damage AI, further work on AI runner, random fixes
2025-07-05 14:56:25 +02:00

35 lines
1.0 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "me_first")]
public class MeFirst : Script, IScriptChangeMove
{
/// <inheritdoc />
public void ChangeMove(IMoveChoice choice, ref StringKey moveName)
{
var battleData = choice.User.BattleData;
if (battleData == null)
return;
var target = battleData.Battle.Sides[choice.TargetSide].Pokemon[choice.TargetPosition];
if (target == null)
{
choice.Fail();
return;
}
if (battleData.Battle.ChoiceQueue?.FirstOrDefault(x => x.User == target) is not IMoveChoice targetMove)
{
choice.Fail();
return;
}
if (battleData.Battle.Library.MiscLibrary.IsReplacementChoice(targetMove))
{
choice.Fail();
return;
}
var targetMoveData = targetMove.ChosenMove.MoveData;
moveName = targetMoveData.Name;
choice.Volatile.Add(new MeFirstPowerBoost());
}
}