Deukhoofd 1b9d137bb0
All checks were successful
Build / Build (push) Successful in 50s
Surprisingly, more abilities
2025-06-14 13:37:58 +02:00

37 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Power Construct is an ability that allows Zygarde to change form when its HP drops below half.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Power_Construct_(Ability)">Bulbapedia - Power Construct</see>
/// </summary>
[Script(ScriptCategory.Ability, "power_construct")]
public class PowerConstruct : Script
{
private IPokemon? _pokemon;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
throw new InvalidOperationException("PowerConstruct script must be attached to a Pokemon.");
_pokemon = pokemon;
}
/// <inheritdoc />
public override void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (_pokemon?.BattleData?.Battle == null)
return;
if (_pokemon.Species.Name != "zygarde")
return;
if (_pokemon.CurrentHealth > _pokemon.BoostedStats.Hp / 2)
return;
if (_pokemon.Form.Name != "10" || _pokemon.Form.Name != "50")
return;
if (!_pokemon.Species.TryGetForm("complete", out var completeForm))
return;
_pokemon.ChangeForm(completeForm);
}
}