Deukhoofd 7727f92f4e
All checks were successful
continuous-integration/drone/push Build is passing
Even more moves
2025-05-05 16:58:03 +02:00

28 lines
1.1 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "power_split")]
public class PowerSplit : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var user = move.User;
var userStats = user.FlatStats;
var targetStats = target.FlatStats;
var userAttack = userStats.GetStatistic(Statistic.Attack);
var targetAttack = targetStats.GetStatistic(Statistic.Attack);
var userSpecialAttack = userStats.GetStatistic(Statistic.SpecialAttack);
var targetSpecialAttack = targetStats.GetStatistic(Statistic.SpecialAttack);
var newAttack = (userAttack + targetAttack) / 2;
var newSpecialAttack = (userSpecialAttack + targetSpecialAttack) / 2;
userStats.SetStatistic(Statistic.Attack, newAttack);
userStats.SetStatistic(Statistic.SpecialAttack, newSpecialAttack);
targetStats.SetStatistic(Statistic.Attack, newAttack);
targetStats.SetStatistic(Statistic.SpecialAttack, newSpecialAttack);
user.RecalculateBoostedStats();
target.RecalculateBoostedStats();
}
}