add unit test for hapatra vizier of poisons + fix issue #5886

This commit is contained in:
John Gray 2019-07-19 21:37:58 -04:00
parent 7ac58f9787
commit b05981020c
3 changed files with 42 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import mage.MageObjectReference;
import mage.ObjectColor;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.RestrictionEffect;
@ -888,7 +889,13 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
}
for (MarkedDamageInfo mdi : markedDamage) {
Ability source = null;
if (mdi.sourceObject instanceof Permanent) {
if (mdi.sourceObject instanceof PermanentToken) {
/* Tokens dont have a spellAbility. We must make a phony one as the source so the events in addCounters
* can trace the source back to an object/controller.
*/
source = new SpellAbility(null, ((PermanentToken) mdi.sourceObject).name);
source.setSourceId(((PermanentToken) mdi.sourceObject).objectId);
} else if (mdi.sourceObject instanceof Permanent) {
source = ((Permanent) mdi.sourceObject).getSpellAbility();
}
addCounters(mdi.counter, source, game);