2021-10-23 16:29:18 +00:00
|
|
|
namespace Gen7{
|
|
|
|
[Move effect=Assurance]
|
|
|
|
class Assurance : PkmnScript {
|
|
|
|
void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint &inout damage) override {
|
2021-10-24 09:36:43 +00:00
|
|
|
auto damageEvent = target.Battle.History.GetLastDamageOnTarget(target, 1);
|
2021-10-23 16:29:18 +00:00
|
|
|
if (damageEvent is null){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (damageEvent.TurnNumber == target.Battle.CurrentTurn){
|
|
|
|
damage *= 2;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TESTS
|
|
|
|
[Test name="Assurance: damage without damage on the same turn"]
|
|
|
|
void Assurance_DamageWithoutEvent(){
|
|
|
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
|
|
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
|
|
|
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
|
|
|
|
|
|
|
|
auto script = cast<Gen7::Assurance>(CreateMoveScript("Assurance"));
|
|
|
|
Require(script !is null);
|
|
|
|
uint damage = 100;
|
|
|
|
auto executingMove = CreateExecutingMove("Assurance", mon1, mon2);
|
|
|
|
script.OverrideDamage(executingMove, mon2, 0x0, damage);
|
|
|
|
RequireEquals(100, damage);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test name="Assurance: damage with damage on the same turn"]
|
|
|
|
void Assurance_DamageWithEvent(){
|
|
|
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
|
|
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
|
|
|
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
|
|
|
|
|
|
|
|
mon2.Damage(10, DamageSource::AttackDamage);
|
|
|
|
|
|
|
|
auto script = cast<Gen7::Assurance>(CreateMoveScript("Assurance"));
|
|
|
|
Require(script !is null);
|
|
|
|
uint damage = 100;
|
|
|
|
auto executingMove = CreateExecutingMove("Assurance", mon1, mon2);
|
|
|
|
script.OverrideDamage(executingMove, mon2, 0x0, damage);
|
|
|
|
RequireEquals(200, damage);
|
|
|
|
}
|
|
|
|
|
2021-10-23 17:10:18 +00:00
|
|
|
[Test name="Assurance: damage with damage on the other turn"]
|
|
|
|
void Assurance_DamageWithEventOnDifferentTurn(){
|
|
|
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
|
|
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
|
|
|
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
|
|
|
|
|
|
|
|
mon2.Damage(10, DamageSource::AttackDamage);
|
|
|
|
|
|
|
|
mon1.PassTurn();
|
|
|
|
mon2.PassTurn();
|
|
|
|
|
|
|
|
auto script = cast<Gen7::Assurance>(CreateMoveScript("Assurance"));
|
|
|
|
Require(script !is null);
|
|
|
|
uint damage = 100;
|
|
|
|
auto executingMove = CreateExecutingMove("Assurance", mon1, mon2);
|
|
|
|
script.OverrideDamage(executingMove, mon2, 0x0, damage);
|
|
|
|
RequireEquals(100, damage);
|
|
|
|
}
|
2021-10-23 16:29:18 +00:00
|
|
|
#endif
|