2025-01-11 13:08:04 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2025-01-26 10:55:13 +00:00
|
|
|
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
2025-01-11 13:08:04 +00:00
|
|
|
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
|
|
|
|
[Script(ScriptCategory.Pokemon, "bide")]
|
|
|
|
public class BideEffect : Script
|
|
|
|
{
|
|
|
|
private readonly IPokemon? _owner;
|
|
|
|
public byte Turns;
|
|
|
|
public uint DamageTaken;
|
|
|
|
public readonly List<IPokemon> HitBy = [];
|
|
|
|
|
|
|
|
private BideEffect()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public BideEffect(IPokemon owner)
|
|
|
|
{
|
|
|
|
_owner = owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
|
|
|
{
|
|
|
|
HitBy.Add(move.User);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
|
|
|
{
|
|
|
|
DamageTaken += oldHealth - newHealth;
|
|
|
|
}
|
|
|
|
|
|
|
|
private ITurnChoice? _choice;
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
|
|
|
{
|
|
|
|
if (_owner == null)
|
|
|
|
return;
|
|
|
|
var ownerBattleData = _owner.BattleData;
|
|
|
|
if (ownerBattleData == null)
|
|
|
|
return;
|
|
|
|
if (ownerBattleData.SideIndex != sideIndex || ownerBattleData.Position != position)
|
|
|
|
return;
|
|
|
|
if (_choice != null)
|
|
|
|
{
|
|
|
|
choice = _choice;
|
|
|
|
return;
|
|
|
|
}
|
2025-01-26 10:55:13 +00:00
|
|
|
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
|
|
|
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", opposingSideIndex, position);
|
2025-01-11 13:08:04 +00:00
|
|
|
}
|
|
|
|
}
|