Gen7Data/Scripts/Moves/Acupressure.as

55 lines
2.1 KiB
ActionScript
Raw Normal View History

2020-04-10 22:23:17 +00:00
namespace Gen7{
[Move effect=Acupressure]
class Acupressure : PkmnScript {
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
if (attack.User is target){
2021-08-26 17:25:38 +00:00
attack.GetHitData(target, hit).Fail();
2020-04-10 22:23:17 +00:00
return;
}
2021-08-26 17:25:38 +00:00
auto randStat = Statistic(target.Battle.Random.Get(1, 6));
2020-04-10 22:23:17 +00:00
target.ChangeStatBoost(randStat, 2);
};
}
2021-08-26 17:25:38 +00:00
}
#if TESTS
void TestWithRandomSeed(uint seed, Statistic stat){
auto battle = CreateSimpleBattle(seed, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
auto script = cast<Gen7::Acupressure>(CreateMoveScript("Acupressure"));
auto executingMove = CreateExecutingMove("Acupressure", mon1, mon2);
script.OnSecondaryEffect(executingMove, mon2, 0x0);
RequireEquals(2, mon2.GetStatBoost(stat));
}
[Test name="Acupressure: Random stat increases by two"]
void Acupressure_RandomStatIncreasesBy2(){
TestWithRandomSeed(684, Statistic::SpecialDefense);
TestWithRandomSeed(1037038, Statistic::SpecialDefense);
TestWithRandomSeed(3572948, Statistic::Attack);
TestWithRandomSeed(4087125, Statistic::SpecialDefense);
TestWithRandomSeed(4199056, Statistic::Speed);
TestWithRandomSeed(7291450, Statistic::Attack);
TestWithRandomSeed(8639137, Statistic::SpecialAttack);
TestWithRandomSeed(8918584, Statistic::Attack);
TestWithRandomSeed(9564376, Statistic::Defense);
TestWithRandomSeed(9859436, Statistic::SpecialDefense);
}
[Test name="Acupressure: Fails When Targets Self"]
void Acupressure_FailsOnSelfTarget(){
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto script = cast<Gen7::Acupressure>(CreateMoveScript("Acupressure"));
auto executingMove = CreateExecutingMove("Acupressure", mon1, mon1);
script.OnSecondaryEffect(executingMove, mon1, 0x0);
Require(executingMove.GetHitData(mon1, 0x0).HasFailed);
}
#endif