namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// Power Construct is an ability that allows Zygarde to change form when its HP drops below half. /// /// Bulbapedia - Power Construct /// [Script(ScriptCategory.Ability, "power_construct")] public class PowerConstruct : Script, IScriptOnEndTurn { private IBattlePokemon? _pokemon; /// public override void OnAddedToParent(IScriptSource source) { if (source is not IBattlePokemon pokemon) throw new InvalidOperationException("PowerConstruct script must be attached to a Pokemon."); _pokemon = pokemon; } /// public void OnEndTurn(IScriptSource owner, IBattle battle) { if (_pokemon?.Battle == null) return; if (_pokemon.Species.Name != SpeciesNames.Zygarde) return; if (_pokemon.CurrentHealth > _pokemon.BoostedStats.Hp / 2) return; if (_pokemon.Form.Name != FormNames._10 || _pokemon.Form.Name != FormNames._50) return; if (!_pokemon.Species.TryGetForm(FormNames.Complete, out var completeForm)) return; _pokemon.ChangeForm(completeForm); } }