41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|
using PkmnLib.Static.Utils;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
[Script(ScriptCategory.Pokemon, "ice_ball")]
|
|
public class IceBallEffect : Script
|
|
{
|
|
private readonly IPokemon _owner;
|
|
private readonly StringKey _moveName;
|
|
public int TurnCount { get; set; }
|
|
|
|
public IceBallEffect(IPokemon owner, StringKey moveName)
|
|
{
|
|
_owner = owner;
|
|
_moveName = moveName;
|
|
TurnCount = 0;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
|
{
|
|
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
|
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnMoveMiss(IExecutingMove move, IPokemon target)
|
|
{
|
|
RemoveSelf();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnEndTurn(IBattle battle)
|
|
{
|
|
if (TurnCount < 5)
|
|
TurnCount++;
|
|
else
|
|
RemoveSelf();
|
|
}
|
|
} |