Deukhoofd 1feb27e826
All checks were successful
Build / Build (push) Successful in 50s
More work on refactor to interfaces
2025-06-29 12:03:51 +02:00

34 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Solar Power is an ability that boosts Special Attack in harsh sunlight but causes the Pokémon to lose HP each turn.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Solar_Power_(Ability)">Bulbapedia - Solar Power</see>
/// </summary>
[Script(ScriptCategory.Ability, "solar_power")]
public class SolarPower : Script, IScriptChangeOffensiveStatValue, IScriptOnEndTurn
{
/// <inheritdoc />
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
{
if ((stat == Statistic.SpecialAttack &&
move.Battle.WeatherName == ScriptUtils.ResolveName<Weather.HarshSunlight>()) ||
move.Battle.WeatherName == ScriptUtils.ResolveName<Weather.DesolateLands>())
{
value = value.MultiplyOrMax(1.5f);
}
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
if (owner is not IPokemon pokemon)
return;
if (!pokemon.IsUsable)
return;
pokemon.Damage(pokemon.MaxHealth / 8, DamageSource.Weather);
}
}