TokenEffect: fix Cause Key it should be null in some cases

This commit is contained in:
Hans Mackowiak
2019-10-06 13:21:38 +00:00
parent 67ebfa4ddd
commit 6ef38fdcfd
2 changed files with 5 additions and 5 deletions

View File

@@ -225,11 +225,8 @@ public class TokenEffect extends SpellAbilityEffect {
// Cause of the Token Effect, in general it should be this // Cause of the Token Effect, in general it should be this
// but if its a Replacement Effect, it might be something else or null // but if its a Replacement Effect, it might be something else or null
SpellAbility cause = sa; SpellAbility cause = sa;
if (root.isReplacementAbility()) { if (root.isReplacementAbility() && root.hasReplacingObject(AbilityKey.Cause)) {
Object replacingObject = root.getReplacingObject(AbilityKey.Cause); cause = (SpellAbility) root.getReplacingObject(AbilityKey.Cause);
if (replacingObject != null) {
cause = (SpellAbility) replacingObject;
}
} }
final boolean remember = sa.hasParam("RememberTokens"); final boolean remember = sa.hasParam("RememberTokens");

View File

@@ -596,6 +596,9 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
public Map<AbilityKey, Object> getReplacingObjects() { public Map<AbilityKey, Object> getReplacingObjects() {
return replacingObjects; return replacingObjects;
} }
public boolean hasReplacingObject(final AbilityKey type) {
return replacingObjects.containsKey(type);
}
public Object getReplacingObject(final AbilityKey type) { public Object getReplacingObject(final AbilityKey type) {
final Object res = replacingObjects.get(type); final Object res = replacingObjects.get(type);
return res; return res;