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