using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Models.Choices;
///
/// The choice of a Pokémon to use a move.
///
public interface IMoveChoice : ITurnChoice
{
///
/// The move that is used.
///
ILearnedMove ChosenMove { get; }
///
/// The side the move is targeted at.
///
byte TargetSide { get; }
///
/// The position the move is targeted at.
///
byte TargetPosition { get; }
///
/// The priority of the move.
///
sbyte Priority { get; set; }
///
/// The underlying script of the move.
///
ScriptContainer Script { get; set; }
Dictionary? AdditionalData { get; }
}
///
public class MoveChoice : TurnChoice, IMoveChoice
{
///
public MoveChoice(IPokemon user, ILearnedMove usedMove, byte targetSide, byte targetPosition) : base(user)
{
ChosenMove = usedMove;
TargetSide = targetSide;
TargetPosition = targetPosition;
var secondaryEffect = usedMove.MoveData.SecondaryEffect;
if (secondaryEffect != null)
{
if (user.Library.ScriptResolver.TryResolve(ScriptCategory.Move, secondaryEffect.Name,
secondaryEffect.Parameters, out var script))
{
Script.Set(script);
}
}
}
///
public ILearnedMove ChosenMove { get; }
///
public byte TargetSide { get; }
///
public byte TargetPosition { get; }
///
public sbyte Priority { get; set; }
///
public ScriptContainer Script { get; set; } = new();
///
public Dictionary? AdditionalData { get; }
///
public override int ScriptCount => 1 + User.ScriptCount;
///
public override void GetOwnScripts(List> scripts) => scripts.Add(Script);
///
public override void CollectScripts(List> scripts)
{
GetOwnScripts(scripts);
User.CollectScripts(scripts);
}
}