This commit is contained in:
@@ -3,16 +3,36 @@ namespace Gen7 {
|
||||
shared class HealEachEndOfTurnEffect : PkmnScript {
|
||||
float _factor;
|
||||
|
||||
void OnEndTurn(Pokemon@ pokemon) override {
|
||||
auto healAmount = pokemon.MaxHealth * _factor;
|
||||
if (pokemon.HasHeldItem("big_root")){
|
||||
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")){
|
||||
healAmount *= 1.3;
|
||||
}
|
||||
pokemon.Heal(uint(healAmount));
|
||||
target.Heal(uint(healAmount));
|
||||
}
|
||||
|
||||
void SetBaseHealAmount(float factor){
|
||||
_factor = factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#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
|
||||
Reference in New Issue
Block a user