using System; using System.Collections.Generic; using System.Linq; using PkmnLib.Dynamic.Models; using PkmnLib.Dynamic.Models.Choices; using PkmnLib.Dynamic.ScriptHandling; using PkmnLib.Dynamic.ScriptHandling.Registry; 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 HitBy = []; private BideEffect() { } public BideEffect(IPokemon owner) { _owner = owner; } /// public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit) { HitBy.Add(move.User); } /// public override void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth) { DamageTaken += oldHealth - newHealth; } private ITurnChoice? _choice; /// 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; } var bideMove = _owner.Moves.FirstOrDefault(x => x?.MoveData.Name == "bide"); if (bideMove == null) { if (!_owner.Library.StaticLibrary.Moves.TryGet("bide", out var moveData)) throw new Exception("Move 'bide' not found in move library."); bideMove = new LearnedMoveImpl(moveData, MoveLearnMethod.Unknown); } choice = _choice = new MoveChoice(_owner, bideMove, sideIndex, position); } }