2021-03-28 18:22:46 +00:00
|
|
|
namespace Gen7 {
|
|
|
|
[Pokemon effect=HealEachEndOfTurn]
|
|
|
|
shared class HealEachEndOfTurnEffect : PkmnScript {
|
|
|
|
float _factor;
|
|
|
|
|
2021-10-30 16:45:42 +00:00
|
|
|
void OnEndTurn() override {
|
|
|
|
auto target = cast<Pokemon@>(GetOwner());
|
|
|
|
if (target is null){
|
|
|
|
throw("target was null");
|
|
|
|
}
|
|
|
|
auto healAmount = target.MaxHealth * _factor;
|
|
|
|
if (target.HasHeldItem("big_root")){
|
2021-03-28 18:22:46 +00:00
|
|
|
healAmount *= 1.3;
|
|
|
|
}
|
2021-10-30 16:45:42 +00:00
|
|
|
target.Heal(uint(healAmount));
|
2021-03-28 18:22:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetBaseHealAmount(float factor){
|
|
|
|
_factor = factor;
|
|
|
|
}
|
|
|
|
}
|
2021-10-30 16:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if TESTS
|
|
|
|
|
|
|
|
[Test name="Heal Each End Of Turn effect: Heals on end of turn"]
|
|
|
|
void HealEachEndOfTurn_HealsOnEndOfTurn(){
|
|
|
|
auto battle = CreateSimpleBattle(0, "charizard", "venusaur", 100);
|
|
|
|
auto mon = battle.GetParty(0).Party.GetAtIndex(0);
|
|
|
|
mon.Damage(100, DamageSource::AttackDamage);
|
|
|
|
auto effect = cast<Gen7::HealEachEndOfTurnEffect@>(mon.AddVolatile("HealEachEndOfTurn"));
|
|
|
|
effect.SetBaseHealAmount(0.0625);
|
|
|
|
effect.OnEndTurn();
|
|
|
|
RequireEquals(215, mon.CurrentHealth);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|