Gen7Data/Scripts/Moves/ChangeAllTargetStats.as

43 lines
1.6 KiB
ActionScript
Raw Normal View History

2021-03-28 18:22:46 +00:00
namespace Gen7 {
[Move effect=ChangeAllTargetStats]
class ChangeAllTargetStats : PkmnScript{
int8 _amount;
void OnInitialize(const EffectParameter@[] &in parameters) override{
_amount = int8(parameters[0].AsInt());
}
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override{
target.ChangeStatBoost(Statistic::Attack, _amount);
target.ChangeStatBoost(Statistic::Defense, _amount);
target.ChangeStatBoost(Statistic::SpecialAttack, _amount);
target.ChangeStatBoost(Statistic::SpecialDefense, _amount);
target.ChangeStatBoost(Statistic::Speed, _amount);
}
}
2021-08-26 17:25:38 +00:00
}
#if TESTS
void TestChangeAllStats(int8 amount){
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto script = cast<Gen7::ChangeAllTargetStats>(CreateMoveScript("ChangeAllTargetStats"));
auto executingMove = CreateExecutingMove("Tackle", mon1, mon1);
script._amount = amount;
script.OnSecondaryEffect(executingMove, mon1, 0x0);
RequireEquals(amount, mon1.GetStatBoost(Statistic::Attack));
RequireEquals(amount, mon1.GetStatBoost(Statistic::Defense));
RequireEquals(amount, mon1.GetStatBoost(Statistic::SpecialAttack));
RequireEquals(amount, mon1.GetStatBoost(Statistic::SpecialDefense));
RequireEquals(amount, mon1.GetStatBoost(Statistic::Speed));
}
[Test name="ChangeAllTargetStats: Does as the name suggests"]
void ChangeAllTargetStats_Test(){
for (int8 i = -6; i <= 6; i++){
TestChangeAllStats(i);
}
}
#endif